Jump to content

[Need Help] Increase Cold injuries

Recommended Posts

Hi Mod makers and Developers!


I'm trying to do a mod character that has more injuries while he's freezing, but i'm not the best programer and later looking for too much code in other mods and games files... I'm in deadlock...


Some one can tell me what's wrong in this code? 

local function allergic(inst)inst.components.talker:Say(GetString(inst.prefab, "ANNOUNCE_COLD2"))inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 0.5)inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1)inst.components.combat.damagemultiplier = 0.5inst.components.temperature.hurtrate = 1.3endinst:ListenForEvent( "startfreezing", function() allergic(inst) end , GetWorld())

I already tried to change the listened event fboy other like "isWinter", "self.temp <= 0", "coldness" ... but still not working :(


I really appreciate any kind help :p

Link to comment
Share on other sites

local function allergic(inst)    if TheWorld.ismastersim then        inst.components.combat.damagemultiplier = 0.5        inst.components.temperature.hurtrate = 1.3    end    inst.components.talker:Say(GetString(inst.prefab, "ANNOUNCE_COLD2"))    inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 0.5)    inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1)end-- Here a function stopallergy similar to allergic with opposite values to turn character back to normallocal function common_postinit(inst)    -- Your code    inst:ListenForEvent("startfreezing", allergic)    inst:ListenForEvent("stopfreezing", stopallergy)end

common_postinit is for host and client code.

Clients need the locomotor changes or you would rubberband.

Clients have the talker component so you can share it.

Clients don't need the multiplier or the hurtrate.


You don't change the runspeed, so, it's kinda moot.

Modifying damagemultiplier makes your character deal less damage, not receive it.

I would say for you to look into the RoG characters mod to check out how Wigfrid modifies receiving damage.

Link to comment
Share on other sites

Thanks you so much @DarkXero, this code works perfectly  :joyous:


I've done what you told me (adding the function stopallergy also) and changed the runspeed's value (same as walkspeed's value), I thought walkspeed means the move speed of character, and runspeed is only when he's moving on a road... I don't know the difference for now... 
Besides I want to explain my intention decreasing damagemultiplier it's makes my character deal less damage because he's feeling very sick when its cold, so that's correct, maybe 0.5 it's so hard and I'll increase it a bit


Finally I deleted "inst.components.talker:Say(GetString(inst.prefab, "ANNOUNCE_COLD2"))" because it overlaps with "ANNOUNCE_COLD"


One step closer to finish the mod  :mrgreen:  

Link to comment
Share on other sites

I assumed that "has more injuries while he's freezing" meant that he would receive extra damage, Much00Msh00.


The player only runs, other creatures though have walk and run speeds and use both.


To avoid the overlap, may I introduce you to:

inst:DoTaskInTime(2, function(inst)   inst.components.talker:Say(GetString(inst.prefab, "ANNOUNCE_COLD2"))end)

Which will execute the function after 2 seconds.

Edited by DarkXero
Link to comment
Share on other sites

May I had to put in the title "injuries and annoyances", because the runspeed and damage decreased aren't physical injuries at all, although they are related...
Anyway inst.components.temperature.hurtrate = 1.3 increase the damage of coldness, right? but.. thats affects fire damage too? I hope no,  I saw too many others mods with temperarture.hurtrate = 0 to be immunity to cold in winter, so I inverted it, for adding more damage.
The winters in this game are complicated but with this character will be hardest as hell
Your help is very usefull, I'll not forget you in the credits of this mod ^^


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

  • Create New...