Jump to content

Help with ability's


Recommended Posts

Put this in your character lua file:

local function sane (inst)
    if inst.components.temperature.current <= 0 then
    inst.components.sanity:DoDelta(1,1) --change it to your values (value1 is the amount restored, value2 when to do this every x seconds)

  --else if inst.components.temperature.current >= 70 then --optional if you want to get hurt in the summer this will do the trick

 --inst.components.health:DoDelta(-1,1)

--end
    end
end

local master_postinit = function(inst)

    -- Stats of the character
    inst.components.health:SetMaxHealth(185) --just reference don't put this its just reference
    inst.components.hunger:SetMax(185)
    inst.components.sanity:SetMax(200)


    inst.components.temperature.hurtrate = 0 --well you'll be immune to freezing damage but what about overheating damage?
 
    inst:DoPeriodicTask(1, sane, nil, inst) -- put this in the master_postinit
    
    inst.OnLoad = onload
    inst.OnNewSpawn = onload
end

Edited by K1NGT1GER609
it was 70 when you die from overheating
Link to comment
Share on other sites

would this work for freezing?

 

AddPrefabPostInit("CHARACTER", function(inst)

    if inst.components.freezable then

        inst:RemoveComponent("freezable")

    end

end)

possibly this?

 

inst.components.temperature.hurtrate = 0
else if inst.components.temperature.current >= 75 then
inst.componets.temperture.hurtrate = 30

Link to comment
Share on other sites

Its a bit simpler than that, you can put this in the master_postinit:

inst:RemoveComponent("freezable")

I don't use addprefabpostinit as I don't know how to use it or it gave me more of an headache so I didn't bother with it. as for the last part of the code you could put the hurtrate at one and it'll be fine, putting it to 30 will most likely kill your character in seconds. Plus there's a certain limit on how high you can go on those rates and cause a crash since the value was way too high for the game to run.

Link to comment
Share on other sites

He wants to freeze, and instead of taking damage, gain sanity. So in winter, when he reaches 0, he will take "sanity freezing" effects. Correct me if I'm wrong

,

I thought your earlier post made sense... didn't test it, but looked like it was on the right track to stop damage but not stop freezing

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