Jump to content

How to reduce the cold resistance of a character?


Recommended Posts

Hello every curious and every mod creators, I make my first mod for don't starve and I try to reduce the cold resistance, like a weakness of the character but I don't find how to code it. I tried, taken the code from the own scripts of the game, and even taken codes from another mods but nothing change. If somebody can tell me how to do it, it will be very nice!

 

btw I try to increase the damage multiplier to hit more strongly when the character is insane. And I tried to invert the sanity drain, make the day draining the sanity and not the night but I didn't made it, just found how to stop the drain of the night....

Link to comment
Share on other sites

Quote

    inst.components.freezable:SetResistance(1)

reduces likelihood of getting frozen solid (higher values reduce risk)

 

 

Quote

    inst.components.temperature.inherentinsulation = 1

higher values reduce loss of body heat

 

you could, in theory change the freeze temp to a negative number, but this would require recoding the temperature component, which might cause other problems, so I'd suggest sticking to the first two as you get the hang of coding. the two lines of code I gave you go under the master_postinit section

Link to comment
Share on other sites

I've tried that

Quote

    inst.components.freezable:SetResistance(-10)

And it didn't change the cold resistance, still be the same, start freezing at 5° and loose health by freezing at 0°

 

I don't understand why, I've putted this code in the master_postinit section and still don't work.

Link to comment
Share on other sites

12 hours ago, Draukel said:

I've tried that

And it didn't change the cold resistance, still be the same, start freezing at 5° and loose health by freezing at 0°

 

I don't understand why, I've putted this code in the master_postinit section and still don't work.

That's what I was trying to tell you, if you want to change the freeze temperature instead of cold resistance. if you copy-pasted the exact code I gave you, nothing would happen because 1 is the default. You would have to put a larger number. if you want to change the freeze temp, you will have to make a modded version of the temperature.lua file in the components folder and recode one of the functions. This won't be difficult, per-se, but you run the risk of breaking your mod if a DST update changes how temperature works.

 

Edit: I made a modded version of the temperature.lua file for you. If you make a components folder in the scripts folder of you mod and put this file there, it will allow you to change the freeze temp

temperature.lua

 

then go to the master_postinit and paste this line of code:

inst.components.temperature.freezetemp = 0   (replace zero with the number you want, use - for negative)

 

 

Edited by mf99k
wrong file
Link to comment
Share on other sites

Quote
12 hours ago, Draukel said:

I've tried that

And it didn't change the cold resistance, still be the same, start freezing at 5° and loose health by freezing at 0°

 

I don't understand why, I've putted this code in the master_postinit section and still don't work.

That's what I was trying to tell you, if you want to change the freeze temperature instead of cold resistance. if you copy-pasted the exact code I gave you, nothing would happen because 1 is the default. You would have to put a larger number. if you want to change the freeze temp, you will have to make a modded version of the temperature.lua file in the components folder and recode one of the functions. This won't be difficult, per-se, but you run the risk of breaking your mod if a DST update changes how temperature works.

 

Edit: I made a modded version of the temperature.lua file for you. If you make a components folder in the scripts folder of you mod and put this file there, it will allow you to change the freeze temp

temperature.lua

 

then go to the master_postinit and paste this line of code:

inst.components.temperature.freezetemp = 0   (replace zero with the number you want, use - for negative)

 

 

Hmmm the link don't work, but i'll try to see in the game files for the temperature. Even if I'm not a pro I can maybe do it.

 

Thank for this tip, and you can help for others one?

Link to comment
Share on other sites

Just now, Draukel said:

 

 

Hmmm the link don't work, but i'll try to see in the game files for the temperature. Even if I'm not a pro I can maybe do it.

 

Thank for this tip, and you can help for others one?

as in, you have another mod you need help with? It would depend on what you're trying to do

Link to comment
Share on other sites

Well like I've sayd, I want to increase the damage, to hit stronger when the character is insane.

 

And invert the sanity drain by dusk and night, like make it drained bu the day and not the night

 

The first can be possible but for the second...Not sure

Edited by Draukel
Link to comment
Share on other sites

I think something is wrong you forgot to write "then" for every "if" and for "else if" I think it's "elseif" I've modified it and now it work (i think)

Quote

    local function OnPhaseChanged(inst)
        if TheWorld.state.isday then
            inst.components.sanity.rate = -1
        elseif TheWorld.state.isdusk then
            inst.components.sanity.rate = -0.5
        elseif TheWorld.state.isnight then
            inst.components.sanity.rate = 1
        end
    end

 

Now I'll try it

Edited by Draukel
Correction and mistake, sorry
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...