Jump to content

Making stats change based on temperature?


Recommended Posts

I have a snow/cold based character, and I want their stats to be affected by the temperature around the, their temperature, season, moon phase, and if it's snowing.  For now though I'm focusing on changing their stats based on temperature and the full moon (since I'm not sure how to detect any other phase of the moon.)

I know there's a way to check the deltatemp and self.temp, but my code doesn't seem to work.  It doesn't break, but the stat changes simply never activate.  This is in my character.lau file, but above the "local master_postinit = function(inst)", which I assume is where it need to go.

------------------------------------------------------------------------------------------

local function ontemperaturechange(inst,data)  --Doesn't appear to be working-
    if inst.components.temperature.current <= 20 then
        inst.components.temperature.inherentinsulation = 150
        inst.components.locomotor.walkspeed =  15  -- 5.5
        inst.components.locomotor.runspeed = 15  -- 6.5
        inst.components.sanity.night_drain_mult = -10  -- -1
        
        --Need to test these values
        
    elseif inst.components.temperature.current <= 20 and OnIsFullmoon(inst, isfullmoon) then
        inst.components.temperature.inherentinsulation = 200
        inst.components.locomotor.walkspeed =  6.5
        inst.components.locomotor.runspeed = 7.5
        inst.components.sanity.night_drain_mult = -4
    elseif inst.components.temperature.current > 20 and inst.components.temperature.current <= 52 then
        inst.components.temperature.inherentinsulation = 100
        inst.components.locomotor.walkspeed =  5
        inst.components.locomotor.runspeed = 6
        inst.components.sanity.night_drain_mult = 0.9
    elseif inst.components.temperature.current > 20 and inst.components.temperature.current <= 52 and OnIsFullmoon(inst, isfullmoon) then
        inst.components.temperature.inherentinsulation = 150
        inst.components.locomotor.walkspeed =  6
        inst.components.locomotor.runspeed = 7
        inst.components.sanity.night_drain_mult = -.5
    elseif inst.components.temperature.current > 52 then
        inst.components.temperature.inherentinsulation = 50
        inst.components.locomotor.walkspeed =  4.5
        inst.components.locomotor.runspeed = 5.5
        inst.components.sanity.night_drain_mult = 1.2
    elseif inst.components.temperature.current > 52 and OnIsFullmoon(inst, isfullmoon) then
        inst.components.temperature.inherentinsulation = 100
        inst.components.locomotor.walkspeed =  5.5
        inst.components.locomotor.runspeed = 6.5
        inst.components.sanity.night_drain_mult = 0.5
--Likely to remove this code    
    --if  inst.components.temperature.current <= 25 then
    --  inst.components.temperature:SetTemperature(26)
    --end
    
    --else
    --    self.burning = true  --(Not working)
    end
end

 

furryeskimo.lua

Link to comment
Share on other sites

Oh, lol.  So I'm defining a function, sure, but never telling it to run.  XD

Do I call it inside the "local master_postinit = function(inst)"?  I'm a little unsure what part of this is just defining properties, and what runs repeatedly.

Link to comment
Share on other sites

17 hours ago, FurryEskimo said:

I have a snow/cold based character, and I want their stats to be affected by the temperature around the, their temperature, season, moon phase, and if it's snowing.  For now though I'm focusing on changing their stats based on temperature and the full moon (since I'm not sure how to detect any other phase of the moon.)

I know there's a way to check the deltatemp and self.temp, but my code doesn't seem to work.  It doesn't break, but the stat changes simply never activate.  This is in my character.lau file, but above the "local master_postinit = function(inst)", which I assume is where it need to go.

Didn't you ask this question before?

Here, you made a post about changing the stats with the temperature:

I replied to that post so check it out if you haven't. And if you're struggling tell me what do you need more help with.

  • Like 1
Link to comment
Share on other sites

I was suggested to make multiple threads, each asking about a specific aspect of the code, in order to make it easier for people to respond to my questions.  There was an original post which did not do this, but I think I deleted that one.

currently most of the code is working, and my expertise in math allowed me to write a few rather intuitive formulas to change the player stats.  What I needed help with was converting them into functional code.

the player is now rather complex, with multiple stats changing depending on their temp.  This results in the player prioritizing endothermic fires, but ironically having no way to cook food.  It’s somewhat odd, but a fun change in pace compared to how most characters play.

My AC broke last night, so I’m busy fixing that today, but my hope is to eventually code a unique weapon (Boomerang) and armor piece (good in winter, bad in summer) for the character.  I’m going to look for a guide and search these forums for help, before I can ask any specific questions here.

The main issue I still have with the character is a lack of a ghost animation.  The game also crashed once upon my character’s death, and I want to make sure player stat changes while dead aren’t occurring.

Oh, and yeah, this thread was about detecting temperature, and that one was about detecting snow.  I still don’t know how to do that, but presumably it’s just detecting rain, when it’s cold?  If that thread got a response I simply haven’t seen it yet, so it’s not in my character’s new code yet.

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...