From d629ce3df3cad87d6956f3e0c0787a679ba0e2c4 Mon Sep 17 00:00:00 2001 From: Eric Robinson Date: Sat, 27 Dec 2025 13:13:34 -0500 Subject: [PATCH 1/3] Fix DamageArmor --- Source/player.cpp | 48 ++++++++++++++++++----------------------------- 1 file changed, 18 insertions(+), 30 deletions(-) diff --git a/Source/player.cpp b/Source/player.cpp index 894b8335d..5aa9e0ba4 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -961,45 +961,33 @@ bool DoBlock(Player &player) return false; } -void DamageArmor(Player &player) +void DamageArmor(Player &player, int numDurLost) { - if (&player != MyPlayer) { + if (&player != MyPlayer) return; - } - if (player.InvBody[INVLOC_CHEST].isEmpty() && player.InvBody[INVLOC_HEAD].isEmpty()) { + Item &armor = player.InvBody[INVLOC_CHEST]; + Item &helmet = player.InvBody[INVLOC_HEAD]; + + if (armor.isEmpty() && helmet.isEmpty()) return; - } - bool targetHead = FlipCoin(3); - if (!player.InvBody[INVLOC_CHEST].isEmpty() && player.InvBody[INVLOC_HEAD].isEmpty()) { - targetHead = false; - } - if (player.InvBody[INVLOC_CHEST].isEmpty() && !player.InvBody[INVLOC_HEAD].isEmpty()) { - targetHead = true; - } + const bool targetHelmet = + armor.isEmpty() ? true : + helmet.isEmpty() ? false : + FlipCoin(3); + int slot = targetHelmet ? INVLOC_HEAD : INVLOC_CHEST; + Item &item = player.InvBody[slot]; - Item *pi; - if (targetHead) { - pi = &player.InvBody[INVLOC_HEAD]; - } else { - pi = &player.InvBody[INVLOC_CHEST]; - } - if (pi->_iDurability == DUR_INDESTRUCTIBLE) { + if (item._iMaxDur == DUR_INDESTRUCTIBLE) return; - } - pi->_iDurability--; - if (pi->_iDurability != 0) { - return; - } + item._iDurability -= numDurLost; - if (targetHead) { - RemoveEquipment(player, INVLOC_HEAD, true); - } else { - RemoveEquipment(player, INVLOC_CHEST, true); + if (item._iDurability <= 0) { + RemoveEquipment(player, static_cast(slot), true); + CalcPlrInv(player, true); } - CalcPlrInv(player, true); } bool DoSpell(Player &player) @@ -1032,7 +1020,7 @@ bool DoGotHit(Player &player) StartStand(player, player._pdir); ClearStateVariables(player); if (!FlipCoin(4)) { - DamageArmor(player); + DamageArmor(player, 1); } return true; From 706f7d1174a9f74519c2fb590507147dcf727db6 Mon Sep 17 00:00:00 2001 From: Eric Robinson Date: Sat, 27 Dec 2025 13:22:46 -0500 Subject: [PATCH 2/3] Update player.cpp --- Source/player.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Source/player.cpp b/Source/player.cpp index 5aa9e0ba4..51013a015 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -972,10 +972,8 @@ void DamageArmor(Player &player, int numDurLost) if (armor.isEmpty() && helmet.isEmpty()) return; - const bool targetHelmet = - armor.isEmpty() ? true : - helmet.isEmpty() ? false : - FlipCoin(3); + const bool targetHelmet = armor.isEmpty() ? true : helmet.isEmpty() ? false + : FlipCoin(3); int slot = targetHelmet ? INVLOC_HEAD : INVLOC_CHEST; Item &item = player.InvBody[slot]; From 9e1544c87dfcd9b74e478f60bc4e273646e3b60e Mon Sep 17 00:00:00 2001 From: Eric Robinson Date: Sat, 27 Dec 2025 13:32:55 -0500 Subject: [PATCH 3/3] Fix timedemo --- Source/player.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/player.cpp b/Source/player.cpp index 51013a015..af18d53af 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -972,8 +972,9 @@ void DamageArmor(Player &player, int numDurLost) if (armor.isEmpty() && helmet.isEmpty()) return; + const bool coin = FlipCoin(3); const bool targetHelmet = armor.isEmpty() ? true : helmet.isEmpty() ? false - : FlipCoin(3); + : coin; int slot = targetHelmet ? INVLOC_HEAD : INVLOC_CHEST; Item &item = player.InvBody[slot];