Browse Source

Merge 9e1544c87d into 5a08031caf

pull/8386/merge
Eric Robinson 4 days ago committed by GitHub
parent
commit
1b31f56cee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 47
      Source/player.cpp

47
Source/player.cpp

@ -961,45 +961,32 @@ bool DoBlock(Player &player)
return false; return false;
} }
void DamageArmor(Player &player) void DamageArmor(Player &player, int numDurLost)
{ {
if (&player != MyPlayer) { if (&player != MyPlayer)
return; 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; return;
}
bool targetHead = FlipCoin(3); const bool coin = FlipCoin(3);
if (!player.InvBody[INVLOC_CHEST].isEmpty() && player.InvBody[INVLOC_HEAD].isEmpty()) { const bool targetHelmet = armor.isEmpty() ? true : helmet.isEmpty() ? false
targetHead = false; : coin;
} int slot = targetHelmet ? INVLOC_HEAD : INVLOC_CHEST;
if (player.InvBody[INVLOC_CHEST].isEmpty() && !player.InvBody[INVLOC_HEAD].isEmpty()) { Item &item = player.InvBody[slot];
targetHead = true;
}
Item *pi; if (item._iMaxDur == DUR_INDESTRUCTIBLE)
if (targetHead) {
pi = &player.InvBody[INVLOC_HEAD];
} else {
pi = &player.InvBody[INVLOC_CHEST];
}
if (pi->_iDurability == DUR_INDESTRUCTIBLE) {
return; return;
}
pi->_iDurability--; item._iDurability -= numDurLost;
if (pi->_iDurability != 0) {
return;
}
if (targetHead) { if (item._iDurability <= 0) {
RemoveEquipment(player, INVLOC_HEAD, true); RemoveEquipment(player, static_cast<inv_body_loc>(slot), true);
} else { CalcPlrInv(player, true);
RemoveEquipment(player, INVLOC_CHEST, true);
} }
CalcPlrInv(player, true);
} }
bool DoSpell(Player &player) bool DoSpell(Player &player)
@ -1032,7 +1019,7 @@ bool DoGotHit(Player &player)
StartStand(player, player._pdir); StartStand(player, player._pdir);
ClearStateVariables(player); ClearStateVariables(player);
if (!FlipCoin(4)) { if (!FlipCoin(4)) {
DamageArmor(player); DamageArmor(player, 1);
} }
return true; return true;

Loading…
Cancel
Save