Random_kin Posted August 8, 2022 Share Posted August 8, 2022 I've been having trouble implementing this function in my code. I'm kind of a novice when it come to programming so I don't know in what part of the code to pu it. Here's the function and the code itself. inst:ListenForEvent("sanitydelta", function(inst, data) if inst.components.sanity.current >= 100 then inst.components.combat.damagemultiplier = 1.5 elseif inst.components.sanity.current <= 100 then inst.components.combat.damagemultiplier = 2.5 end ) end end custom character.txt Link to comment https://forums.kleientertainment.com/forums/topic/142477-trouble-implementing-a-damage-boost-after-going-below-50-sanity/ Share on other sites More sharing options...
HarryPPP Posted August 8, 2022 Share Posted August 8, 2022 (edited) First of all, you gotta put this anywhere inside the "master_postinit" function: inst:ListenForEvent("sanitydelta", OnSanityDelta) It can be anywhere, but I suggest putting it above the "inst.OnLoad" variable. Then you put this anywhere above the "master_postinit", outside of it. local function OnSanityDelta(inst, data) if inst.components.sanity:GetPercent() > 0.5 then inst.components.combat.damagemultiplier = 1.5 elseif inst.components.sanity:GetPercent() <= 0.5 then inst.components.combat.damagemultiplier = 2.5 end end Edited August 8, 2022 by HarryPPP 1 Link to comment https://forums.kleientertainment.com/forums/topic/142477-trouble-implementing-a-damage-boost-after-going-below-50-sanity/#findComment-1593150 Share on other sites More sharing options...
Nosidda Posted August 9, 2022 Share Posted August 9, 2022 5 hours ago, HarryPPP said: First of all, you gotta put this anywhere inside the "master_postinit" function: inst:ListenForEvent("sanitydelta", OnSanityDelta) It can be anywhere, but I suggest putting it above the "inst.OnLoad" variable. Then you put this anywhere above the "master_postinit", outside of it. local function OnSanityDelta(inst, data) if inst.components.sanity:GetPercent() > 0.5 then inst.components.combat.damagemultiplier = 1.5 elseif inst.components.sanity:GetPercent() <= 0.5 then inst.components.combat.damagemultiplier = 2.5 end end does this work for vanilla survivors? Link to comment https://forums.kleientertainment.com/forums/topic/142477-trouble-implementing-a-damage-boost-after-going-below-50-sanity/#findComment-1593203 Share on other sites More sharing options...
CarlZalph Posted August 9, 2022 Share Posted August 9, 2022 Just now, AngryBeeQueen said: does this work for vanilla survivors? AddPrefabPostInit + TheWorld.ismastersim check + this ListenForEvent will. Listening for an event doesn't is a non-blocking operation and is more of a notification listener rather than an event chain resolver. 1 Link to comment https://forums.kleientertainment.com/forums/topic/142477-trouble-implementing-a-damage-boost-after-going-below-50-sanity/#findComment-1593204 Share on other sites More sharing options...
Nosidda Posted August 9, 2022 Share Posted August 9, 2022 3 minutes ago, CarlZalph said: AddPrefabPostInit + TheWorld.ismastersim check + this ListenForEvent will. Listening for an event doesn't is a non-blocking operation and is more of a notification listener rather than an event chain resolver. can you explain like im five ._. Link to comment https://forums.kleientertainment.com/forums/topic/142477-trouble-implementing-a-damage-boost-after-going-below-50-sanity/#findComment-1593206 Share on other sites More sharing options...
CarlZalph Posted August 9, 2022 Share Posted August 9, 2022 16 minutes ago, AngryBeeQueen said: can you explain like im five ._. No but I can write up an example, it'd be quicker. local function someeventcallback(inst, data) -- Do stuff. end local function OnPostInit_wilson(inst) if not GLOBAL.TheWorld.ismastersim then return end inst:ListenForEvent("someevent", someeventcallback) end AddPrefabPostInit("wilson", OnPostInit_wilson) 1 Link to comment https://forums.kleientertainment.com/forums/topic/142477-trouble-implementing-a-damage-boost-after-going-below-50-sanity/#findComment-1593208 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now