DonMatio Posted April 29, 2018 Share Posted April 29, 2018 (edited) As the title says, i want to create a perk that focuses on sanity during combat, it goes like this - This character has 250 sanity (Already coded). Whenever this character is attacked, this character loses 10 sanity points, This effect also applies to everyone else in the server, but everyone else loses 3 sanity points instead. When this character dies, everyone loses 90 sanity points. When this character is revived, their sanity score will start at 20. Can someone help or at least hint me through on how i'm able to do this? I would be very grateful! Edited April 29, 2018 by DonMatio Link to comment https://forums.kleientertainment.com/forums/topic/90330-how-can-i-create-a-sanity-special-perk-for-my-character/ Share on other sites More sharing options...
ksaab Posted April 30, 2018 Share Posted April 30, 2018 Try this local function DoSanityDeltaOnAttacked(inst) for _, v in pairs(AllPlayers) do if v.components.sanity ~= nil and not v:HasTag("playerghost") if v == inst then v.components.sanity:DoDelta(-10) else v.components.sanity:DoDelta(-3) end end end end local function DoSanityDeltaOnDeath() for _, v in pairs(AllPlayers) do if v.components.sanity ~= nil and not v:HasTag("playerghost") v.components.sanity:DoDelta(-90) end end end local function SetSanityOnRevive(inst) inst:DoTaskInTime(0, function(inst) v.components.sanity.current = 20 end) end inst:ListenForEvent("attacked", DoSanityDeltaOnAttacked) inst:ListenForEvent("ms_becameghost", DoSanityDeltaOnDeath) inst:ListenForEvent("ms_respawnedfromghost", SetSanityOnRevive) Link to comment https://forums.kleientertainment.com/forums/topic/90330-how-can-i-create-a-sanity-special-perk-for-my-character/#findComment-1031356 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