Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Commit

Permalink
Fix bug where damage could be stacked
Browse files Browse the repository at this point in the history
  • Loading branch information
Pluviolithic committed Nov 24, 2023
1 parent d036096 commit 6ca70a4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/server/Combat/Enemies/ApplyDamageToEnemy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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,
Expand All @@ -55,4 +56,8 @@ return function(player, enemy, info, janitor)
janitor:Destroy()
end
end)

janitor:Add(function()
enabled = false
end, true)
end

0 comments on commit 6ca70a4

Please sign in to comment.