Problem: safes don't carry modded items as loot


Recommended Posts

The long story of this vexing problem:

I want to reduce the cooldowns of Stim 1 and 2 to 8 and 6 turns respectively, to make them less of trash compared to Stim 3.  I did so, and playtested a few missions with Rush and Olivia.  Things were looking as they should: Rush's starting Stim 1 had an 8-turn cooldown and marked with my mod icon, as was everything else from itemdefs.  Nanofabs, guard loot, starting items, all marked with my icon.  Then I pick a Stim 1 out of a safe.  It has a 9-turn cooldown.  It does not have my mod icon.  But it sells for the amount it should at the nanofab (200 CR).

Now this weirdness isn't much of a problem.  Loot from safes is rare, anyways.  The real issue I have is that any items looted from safes that my agents are still carrying disappear at the end of the mission.  Poof, gone.  Like they never existed.  It's true that I was going to sell them to Monst3r anyway, but I don't appreciate a second trip to the nanofab during every mission.

In tracking down a solution to this issue, I went through store.lua, worldgen.lua, procgen.lua, finding nothing relevant, until I got to procgen_context.lua, where I found this loot table right at the top:

local LOOT_TABLES =
{
	lab_safe =
	{
		{ unitdefs.tool_templates.item_icebreaker, 2 },
		{ unitdefs.tool_templates.item_portabledrive, 1 },
		{ unitdefs.tool_templates.item_paralyzer, 2 },
		{ unitdefs.tool_templates.item_adrenaline, 3 },
		{ unitdefs.tool_templates.item_cloakingrig_1, 1 },		
		{ unitdefs.tool_templates.item_clip, 2 },
		{ unitdefs.tool_templates.item_stim, 3 },
		{ unitdefs.tool_templates.item_emp_pack, 2 },
		{ 50, 3 },
		{ 150, 3 },
		{ 400, 3 },
		{ nil, 40 }, -- cash out the rest of the value in credits
	},  	
}

I'm not 100% sure if this is all I need, but in any case, I can't figure out how to make the safe-spawning scripts reference my mod's itemdefs.lua instead of the base game's itemdefs.lua

Link to comment
Share on other sites

*sigh,

I tried a myriad of ways to get lib_modApiFix.lua to work for me.  Kept running into failures.  I don't think it's intended to fix my problem, anyway.  I read through its code and nowhere did I find mention of safe, safes, lab_safe, LOOT_TABLES, or anything else related to the loot of safes.  The closest thing I found was the guards' droptables.  In my opinion, Klei already fixed their addItemDef before I began modding last week, using Lemonymous's library as reference.

I tried to code the changes I wanted directly into modinit.lua, using the technique I found from NewItemsAndAugments:

-- load will be refreshed and run each time a new campaign is started.
local function load( modApi, options )
	local scriptPath = modApi:getScriptPath()

	if options["itemgen"].enabled then
		local itemdefs = include( scriptPath .. "/itemdefs_changes" )
		for name, itemDef in pairs(itemdefs) do
			modApi:addItemDef( "item_clip_steelcrow", itemDef )
			modApi:addItemDef( name, itemDef )
		end
		
		local procgen_context = include( "sim/procgen_context" )
		local unitdefs = include( "sim/unitdefs" )
		local itemdefs_changes = include( scriptPath .. "/itemdefs_changes" )
		
		
		procgen_context.lab_safe = 
	{
		{ itemdefs_changes.item_icebreaker, 2 },
		{ itemdefs_changes.item_portabledrive, 1 },
		{ itemdefs_changes.item_paralyzer, 2 },
		{ itemdefs_changes.item_adrenaline, 3 },
		{ itemdefs_changes.item_cloakingrig_1, 1 },		
		{ itemdefs_changes.item_clip, 2 },
		{ itemdefs_changes.item_stim, 3 },
		{ itemdefs_changes.item_emp_pack, 2 },
		{ 50, 3 },
		{ 150, 3 },
		{ 400, 3 },
		{ nil, 40 }, -- cash out the rest of the value in credits
	}
	else
		procgen_context.lab_safe = 
	{
		{ unitdefs.tool_templates.item_icebreaker, 2 },
		{ unitdefs.tool_templates.item_portabledrive, 1 },
		{ unitdefs.tool_templates.item_paralyzer, 2 },
		{ unitdefs.tool_templates.item_adrenaline, 3 },
		{ unitdefs.tool_templates.item_cloakingrig_1, 1 },		
		{ unitdefs.tool_templates.item_clip, 2 },
		{ unitdefs.tool_templates.item_stim, 3 },
		{ unitdefs.tool_templates.item_emp_pack, 2 },
		{ 50, 3 },
		{ 150, 3 },
		{ 400, 3 },
		{ nil, 40 }, -- cash out the rest of the value in credits
	}
	end
end

But still with no success.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.