Jump to content

Help with scripts


Recommended Posts

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

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 by ksaab
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
 Share

×
  • Create New...