Digidragon Posted May 8, 2016 Share Posted May 8, 2016 Hello, currently I am trying to create a mechanic for a character that, the more insane the character the more damage, and past a certain level of sanity will start emitting an insanity aura. local function getstrength(inst) local dmgmult = 0.5 if currentsanity <= 50 then dmgmult = 4 elseif currentsanity <= 100 then dmgmult = 2.5 elseif currentsanity <= 175 then dmgmult = 1.5 elseif currentsanity <= 225 then dmgmult = 1 end [--] end local sanityaura_radius = 10 local function sanityaura(inst) if current <= 50 then inst:AddComponent("sanityaura") inst.components.sanityaura.aura = -TUNING.SANITYAURA_LARGE elseif current <= 100 then inst:AddComponent("sanityaura") inst.components.sanityaura.aura = -TUNING.SANITYAURA_MED elseif current <= 175 then inst:AddComponent("sanityaura") inst.components.sanityaura.aura = -TUNING.SANITYAURA_SMALL elseif sanity <= 225 then inst.RemoveComponent("sanityaura") end end While I am not sure about the sanity aura functioning or not yet (haven't tested it with friends) the code for the damage multiplier doesn't seem to work. Can anyone point out why? I've tried "sanity" "current" "currentsanity" but none of them work Link to comment Share on other sites More sharing options...
Aquaterion Posted May 8, 2016 Share Posted May 8, 2016 (edited) should be inst.components.sanity.current, or is that not what ur looknig for? under local dmgmult = 0.5 do local currentsanity = inst.components.sanity.current also, I reworked ur sanityaura function to check for things local function sanityaura(inst) local auratuning = 0 local currentsanity = inst.components.sanity.current local hasaura = inst.components.sanityaura if currentsanity <= 50 then auratuning = -TUNING.SANITYAURA_LARGE elseif currentsanity <= 100 then auratuning = -TUNING.SANITYAURA_MED elseif currentsanity <= 175 then auratuning = -TUNING.SANITYAURA_SMALL elseif currentsanity <= 225 then auratuning = 0 end if auratuning ~= 0 then if not hasaura then inst:AddComponent("sanityaura") end inst.components.sanityaura.aura = auratuning elseif hasaura then inst:RemoveComponent("sanityaura") end end Edited May 8, 2016 by Aquaterion Link to comment Share on other sites More sharing options...
Digidragon Posted May 8, 2016 Author Share Posted May 8, 2016 I tested out the local function getstrength(inst) local dmgmult = 0.5 local currentsanity = inst.components.sanity.current if currentsanity <= 50 then dmgmult = 4 elseif currentsanity <= 100 then dmgmult = 2.5 elseif currentsanity <= 175 then dmgmult = 1.5 elseif currentsanity <= 225 then dmgmult = 1 end inst.components.combat.damagemultiplier = dmgmult by using a killer bee and a spear, at no matter at what level of sanity it took 6 hits to kill the bee. Link to comment Share on other sites More sharing options...
Aquaterion Posted May 8, 2016 Share Posted May 8, 2016 1 minute ago, Digidragon said: I tested out the local function getstrength(inst) local dmgmult = 0.5 local currentsanity = inst.components.sanity.current if currentsanity <= 50 then dmgmult = 4 elseif currentsanity <= 100 then dmgmult = 2.5 elseif currentsanity <= 175 then dmgmult = 1.5 elseif currentsanity <= 225 then dmgmult = 1 end inst.components.combat.damagemultiplier = dmgmult by using a killer bee and a spear, at no matter at what level of sanity it took 6 hits to kill the bee. where are u calling the getstrength function? Link to comment Share on other sites More sharing options...
Digidragon Posted May 8, 2016 Author Share Posted May 8, 2016 I found the problem, inst.components.combat.damagemultiplier = dmgmult was missing. Thanks for your help Link to comment 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