From 6ca70a440e3d68c3fa92413f89e56e78320f3c68 Mon Sep 17 00:00:00 2001 From: pluviolithic Date: Fri, 24 Nov 2023 03:29:14 -0500 Subject: [PATCH] Fix bug where damage could be stacked --- src/server/Combat/Enemies/ApplyDamageToEnemy.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/server/Combat/Enemies/ApplyDamageToEnemy.lua b/src/server/Combat/Enemies/ApplyDamageToEnemy.lua index f213b98..aa2ed84 100644 --- a/src/server/Combat/Enemies/ApplyDamageToEnemy.lua +++ b/src/server/Combat/Enemies/ApplyDamageToEnemy.lua @@ -24,6 +24,7 @@ local function canAttack(player, enemy, info) end return function(player, enemy, info, janitor) + local enabled = true local weaponName = selectors.getEquippedWeapon(store:getState(), player.Name) local damageMultiplier = if weaponName == "Fists" then 1 else weapons[weaponName].Damage.Value @@ -36,7 +37,7 @@ return function(player, enemy, info, janitor) end task.spawn(function() - while canAttack(player, enemy, info) do + while canAttack(player, enemy, info) and enabled do local damageToDeal = math.clamp( selectors.getStat(store:getState(), player.Name, "Strength") * damageMultiplier, 0, @@ -55,4 +56,8 @@ return function(player, enemy, info, janitor) janitor:Destroy() end end) + + janitor:Add(function() + enabled = false + end, true) end