From 545d5c75738654134d94baec299241ed43af420b Mon Sep 17 00:00:00 2001 From: ZioPao Date: Sat, 17 Aug 2024 18:26:13 +0200 Subject: [PATCH] Implemented random limb side for Zombie Amputations --- .../client/TOC/Zombies/ZombiesAmputation.lua | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/media/lua/client/TOC/Zombies/ZombiesAmputation.lua b/media/lua/client/TOC/Zombies/ZombiesAmputation.lua index 56adbd4..0a7a01c 100644 --- a/media/lua/client/TOC/Zombies/ZombiesAmputation.lua +++ b/media/lua/client/TOC/Zombies/ZombiesAmputation.lua @@ -61,8 +61,6 @@ end ------------------------------- - - local bloodAmount = 10 @@ -84,13 +82,22 @@ local function HandleZombiesAmputations(player, zombie, handWeapon, damage) if (damage > SandboxVars.TOC.ZombieAmputationDamageThreshold and randomChance) or isCrit then TOC_DEBUG.print("Amputating zombie limbs - damage: " .. tostring(damage)) local zombieInv = zombie:getInventory() + -- Check left or right - if not zombieInv:containsEval(PredicateAmputationItemLeft) then - SpawnAmputation(zombie, "L") - elseif not zombieInv:containsEval(PredicateAmputationItemRight) then - SpawnAmputation(zombie, "R") + local randSide = ZombRand(2) -- Random side + local preferredSide = randSide == 0 and "L" or "R" + local alternateSide = preferredSide == "L" and "R" or "L" + + local predicatePreferred = preferredSide == "L" and PredicateAmputationItemLeft or PredicateAmputationItemRight + local predicateAlternate = alternateSide == "L" and PredicateAmputationItemLeft or PredicateAmputationItemRight + + if not zombieInv:containsEval(predicatePreferred) then + SpawnAmputation(zombie, preferredSide) + elseif not zombieInv:containsEval(predicateAlternate) then + SpawnAmputation(zombie, alternateSide) end + TOC_DEBUG.print("Amputating zombie limbs - damage: " .. tostring(damage) .. ", preferred limb side: " .. preferredSide) -- add blood splat every couple of seconds for a while addBloodSplat(getCell():getGridSquare(zombie:getX(), zombie:getY(), zombie:getZ()), bloodAmount)