Divergent/mods/Tommy Gun Drop/gamedata/scripts/m1a1_autoinject.script

56 lines
1.3 KiB
Plaintext
Raw Normal View History

2024-03-17 20:18:03 -04:00
-- supply tables
local trade_table = {
{ -- freedom, sid, skadovsk, freedom jupiter, bandit olivius
[1] = {
["wpn_thompson_m1a1"] = 1,
},
[2] = {
["wpn_thompson_1921"] = 1,
},
},
}
-- spawning guns
local traders = {
["mar_base_owl_stalker_trader"] = { chance = 80, idx = 1 },
["esc_main_base_trader_mlr"] = { chance = 80, idx = 1 },
["jup_a6_freedom_trader_ashot"] = { chance = 80, idx = 1 },
["zat_b30_owl_stalker_trader"] = { chance = 80, idx = 1 },
["val_smart_terrain_7_4_bandit_trader_stalker"] = { chance = 80, idx = 1 },
["dasc_trade_mlr19703"] = { chance = 80, idx = 1 },
["m_trader"] = { chance = 55, idx = 1 }
}
function m1a1_trade_spawn(npc)
local trader = npc:section()
if (not traders[trader]) then
return
end
local loot_table = traders[trader].chance >= math.random(100) and trade_table[traders[trader].idx]
if (not loot_table) then
return
end
local supply_level = clamp(trader_autoinject.supply_level(npc, true) or 0, 0, 5)
for k,v in pairs(loot_table) do
if supply_level >= k then
trader_autoinject.spawn_items(npc, loot_table[k], true)
end
end
end
TraderAuto = trader_autoinject.update
function trader_autoinject.update(npc)
TraderAuto(npc)
m1a1_trade_spawn(npc)
end