Jump to content

Help - heat and cold resistances


Recommended Posts

I want my char have 20% resistance against heat status and cold status (I mean, have 20% resistance until take damage from cold and heat, or their temperature takes 20% more time to up or down, etc).

My full idea is, in times to times, change this value: sometimes get 20% resistance, sometimes get -20% resistance.

I try read other mods and search in forum, but I get confused. I find this codes:

inst.components.temperature.inherentinsulation = 100 -- How much insulation from cold, default is 0
inst.components.temperature.inherentsummerinsulation = 100 -- How much insulation from heat, default is 0

But I have no idea of how it work or how much it affect. So, can someone help me in this? (and if possible, explain or give a good link to understand how to work with temperatures)

(sorry for my bad english)

Link to comment
Share on other sites

AddPrefabPostInit("your_character",function(inst)

	inst.temperature_bonus = 0.2  -- Means +20%

	local save_ignore_temp
	inst:ListenForEvent("temperaturedelta",function(inst,data)
		if save_ignore_temp then
			save_ignore_temp = false --Skip this event.
		else
			local delta = data.new - data.last
			local bonus_delta = delta * inst.temperature_bonus
			if bonus_delta ~= 0 then
				save_ignore_temp = true
				--Will cause the event again, we should skip it.
				inst.components.temperature:DoDelta(bonus_delta)
			end
		end
	end)
	
end)
Link to comment
Share on other sites

On 22/10/2016 at 8:46 PM, Maris said:

AddPrefabPostInit("your_character",function(inst)

	inst.temperature_bonus = 0.2  -- Means +20%

	local save_ignore_temp
	inst:ListenForEvent("temperaturedelta",function(inst,data)
		if save_ignore_temp then
			save_ignore_temp = false --Skip this event.
		else
			local delta = data.new - data.last
			local bonus_delta = delta * inst.temperature_bonus
			if bonus_delta ~= 0 then
				save_ignore_temp = true
				--Will cause the event again, we should skip it.
				inst.components.temperature:DoDelta(bonus_delta)
			end
		end
	end)
	
end)

A complete code, thanks so much!

But, +20% really is 0.2, or 1.2? Because in the line:

local bonus_delta = delta * inst.temperature_bonus

I think to multiply a number for 1.2 is add 20%, or is 0.2?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...