Divergent/mods/Arrival/gamedata/scripts/drx_da_main_traders.script

79 lines
1.8 KiB
Plaintext

get_param = utils_item.SYS_GetParam
utils_item.SYS_GetParam = function(typ, sec, param, def)
if sec == "detector_anomaly" and param == "can_trade" then
return true
else
return get_param and get_param(typ, sec, param, def) or SYS_GetParam(typ, sec, param, def)
end
end
-------------------------- trader artiinject -------------------------
trade_table = {
["ecolog"] = {
[1] = {
["detector_anomaly"] = 1,
},
},
["csky"] = {
[1] = {
["detector_anomaly"] = 1,
},
},
["isg"] = {
[1] = {
["detector_anomaly"] = 1,
},
},
}
trade_table.yan_stalker_sakharov = trade_table.ecolog
trade_table.jup_b6_scientist_nuclear_physicist = trade_table.ecolog
trade_table.jup_b6_scientist_biochemist = trade_table.ecolog
trade_table.mar_base_owl_stalker_trader = trade_table.csky
trade_table.baraholka_trader_night = trade_table.csky
trade_table.jup_depo_isg_tech = trade_table.ecolog
trade_table.ds_domik_isg_leader = trade_table.ecolog
spawn_chance = 1
function trade_add(npc)
local is_trader = trader_autoinject.get_trader_type(npc) == trader_autoinject.SUPPLIER
if not is_trader then return end
local community = npc:character_community() or "stalker"
local sec = npc:section()
local trader_table = trade_table[community] or trade_table[sec]
if not trader_table then return end
local supply_level = clamp(trader_autoinject.supply_level(npc, true) or 1, 1, 5)
for i = supply_level, 1, -1 do
if trader_table[i] then
local t = dup_table(trader_table[i])
for k, v in pairs(t) do
local s = 0
for i = 1, v do
if math.random() <= spawn_chance then
s = s + 1
end
end
t[k] = s
end
trader_autoinject.spawn_items(npc, t, true)
break
end
end
end
TraderAuto = trader_autoinject.update
function trader_autoinject.update(npc)
TraderAuto(npc)
trade_add(npc)
end