160 lines
4.6 KiB
Plaintext
160 lines
4.6 KiB
Plaintext
get_data = item_exo_device.get_data
|
|
set_data = item_exo_device.set_data
|
|
init_data = item_exo_device.init_data
|
|
get_config = exo_mcm.get_config
|
|
local trade_table = {
|
|
{ -- not quality
|
|
["supplies_3"] = {
|
|
["batteries_exo"] = 1
|
|
},
|
|
["supplies_4"] = {
|
|
["batteries_exo"] = 2,
|
|
["exo_power_supply"] = 1
|
|
},
|
|
["supplies_5"] = {
|
|
["batteries_exo"] = 4,
|
|
["exo_power_supply_military"] = 1
|
|
},
|
|
},
|
|
{ -- quality (mercs, military, eco, etc)
|
|
["supplies_3"] = {
|
|
["batteries_exo"] = 3,
|
|
["exo_power_supply"] = 1
|
|
},
|
|
["supplies_4"] = {
|
|
["batteries_exo"] = 5,
|
|
["exo_power_supply_military"] = 1
|
|
},
|
|
["supplies_5"] = {
|
|
["batteries_exo"] = 7,
|
|
["exo_power_supply_military"] = 1
|
|
},
|
|
}
|
|
}
|
|
|
|
local quality_community = {
|
|
["killer"] = true,
|
|
["army"] = true,
|
|
["ecolog"] = true,
|
|
["isg"] = true,
|
|
["monolith"] = true,
|
|
}
|
|
|
|
|
|
local furniture = {
|
|
["esc_m_trader"] = true,
|
|
["red_m_lesnik"] = true
|
|
}
|
|
|
|
local blacklisted_comms = {
|
|
["trader"] = true,
|
|
["monster"] = true
|
|
}
|
|
|
|
function get_real_community(npc)
|
|
|
|
if furniture[npc:name()] then
|
|
return "stalker"
|
|
end
|
|
local community = character_community(npc)
|
|
if not blacklisted_comms[community] then
|
|
return community
|
|
end
|
|
local squad_community = get_object_squad(npc):get_squad_community()
|
|
if not blacklisted_comms[squad_community] then
|
|
return squad_community
|
|
else
|
|
return default
|
|
end
|
|
end
|
|
|
|
function spawn_psus(npc)
|
|
local is_trader = trader_autoinject.get_trader_type(npc) == trader_autoinject.SUPPLIER
|
|
if not is_trader then return end
|
|
|
|
local community = get_real_community(npc)
|
|
local loot_table = quality_community[community] and dup_table(trade_table[2]) or dup_table(trade_table[1])
|
|
local supply_level = trader_autoinject.supply_level(npc)
|
|
local supply_level_num = trader_autoinject.supply_level(npc, true)
|
|
if loot_table[supply_level] then
|
|
if supply_level_num > 2 and quality_community[community] then
|
|
loot_table[supply_level]["recipe_exo_"..math.random(1, 3)] = 1
|
|
end
|
|
trader_autoinject.spawn_items(npc, loot_table[supply_level], true)
|
|
end
|
|
end
|
|
|
|
-- add exo craft recipes
|
|
function add_recipes()
|
|
workshop_autoinject.add_new_recipe(2, "exo_power_supply", "1, recipe_basic_3, itm_backpack,1,batteries_exo,1,prt_i_copper,4,prt_i_scrap,4")
|
|
workshop_autoinject.add_new_recipe(2, "exo_power_supply_proto", "1, recipe_exo_1, exo_power_supply_military,1,af_surge,1,af_dummy_battery_af_aam,1,prt_i_transistors,4")
|
|
workshop_autoinject.add_new_recipe(2, "exo_power_supply_tank", "1, recipe_exo_2, exo_power_supply_military,1,af_surge,1,af_full_empty_af_aam,1,prt_i_resistors,4")
|
|
workshop_autoinject.add_new_recipe(2, "exo_power_supply_sprint", "1, recipe_exo_3, exo_power_supply_military,1,af_cooler,1, af_electra_flash_af_aam,1,prt_i_capacitors,4")
|
|
end
|
|
|
|
SpawnCosmetics = death_manager.spawn_cosmetics
|
|
|
|
function death_manager.spawn_cosmetics(npc, npc_id, npc_comm, npc_rank, visual, rand_condition)
|
|
SpawnCosmetics(npc, npc_id, npc_comm, npc_rank, visual, rand_condition)
|
|
|
|
local visual = visual or npc:get_visual_name()
|
|
local tbl = death_manager.get_outfit_by_npc_visual(visual)
|
|
local outfit_section = tbl and tbl[1]
|
|
spawn_gear(npc, outfit_section)
|
|
end
|
|
|
|
-- dead man gear spawning
|
|
|
|
local psu_chance = 0.2
|
|
|
|
function spawn_gear(npc, outfit_section)
|
|
|
|
-- spawn PSU and milbatts --
|
|
if outfit_section and SYS_GetParam(0, outfit_section, "repair_type") == "outfit_exo" then
|
|
-- two dice rolls to spawn battery and PSU
|
|
local loot_roll = math.random()
|
|
local battery_chance = get_config("battery_chance") or 0.7
|
|
local milpsu_chance = quality_community[npc:character_community()] and 0.1 or 0.03
|
|
|
|
if (loot_roll < battery_chance) then
|
|
death_manager.spawn_with_condition(npc, "batteries_exo", math.random(20,80)/100)
|
|
end
|
|
if (loot_roll < battery_chance / 3) then
|
|
death_manager.spawn_with_condition(npc, "batteries_exo", math.random(20,80)/100)
|
|
end
|
|
|
|
local psu_roll = math.random()
|
|
-- spawn milpsu first, if no then spawn crappy psu
|
|
if (psu_roll < milpsu_chance) then
|
|
alife_create_item( "exo_power_supply_military", npc)
|
|
elseif (psu_roll < psu_chance) then
|
|
alife_create_item("exo_power_supply", npc)
|
|
end
|
|
end
|
|
end
|
|
|
|
bar_tele = xr_effects.bar_arena_teleport
|
|
function xr_effects.bar_arena_teleport()
|
|
bar_tele()
|
|
if has_alife_info("bar_arena_fight_8") then
|
|
CreateTimeEvent("barfight", "free power", 0, free_power)
|
|
end
|
|
end
|
|
|
|
function free_power()
|
|
function itr(temp, item)
|
|
if item:section() == "exo_outfit" then
|
|
local id = item:id()
|
|
local data = init_data(id)
|
|
data.power = 100
|
|
set_data(id, data)
|
|
end
|
|
end
|
|
db.actor:iterate_inventory(itr)
|
|
return true
|
|
end
|
|
|
|
function on_game_start()
|
|
add_recipes()
|
|
RegisterScriptCallback("trader_on_restock", spawn_psus)
|
|
end |