Palyndol Posted April 19, 2018 Share Posted April 19, 2018 Hi there, I am making two characters for my friend and I and I was wondering about a few scripts. I need one character to gain health every time he gets a kill, and another character to get stronger and stronger as he deals damage. Is there a way I could achieve this? Link to comment Share on other sites More sharing options...
ksaab Posted April 19, 2018 Share Posted April 19, 2018 (edited) You need to add listeners for certain events. Selfheal on kills: inst:ListenForEvent("killed", function(inst) inst.components.health:DoDelta(heal_amount) end) Damage boost on attacks: inst:ListenForEvent("onhitother", function(inst) inst.components.combat.damagemultiplier = math.min(inst.components.combat.damagemultiplier + damageBonusDelta, maxBonusDamage) --reset bonus if inst.components.timer:TimerExists("resetdamagebonus") then inst.components.timer:SetTimeLeft("resetdamagebonus", bonusResetDelay) --update timer else inst.components.timer:StartTimer("resetdamagebonus", bonusResetDelay) --create timer end end) --reset bonus inst:ListenForEvent("timerdone", function(inst, data) if data.name == "resetdamagebonus" then inst.components.combat.damagemultiplier = defaultDamage end end) Not sure the code is 100% correct, but that's the idea. Edited April 19, 2018 by ksaab 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