Skip to content

Commit

Permalink
Solider has 30 percent chance to not die if he has an armor and is hi…
Browse files Browse the repository at this point in the history
…t by a catapult (losing his armor)
  • Loading branch information
ottml committed Jan 22, 2025
1 parent f2d225c commit 2a59a2f
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions libs/s25main/buildings/nobMilitary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1444,12 +1444,18 @@ void nobMilitary::HitOfCatapultStone()
// Ein Soldat weniger, falls es noch welche gibt
if(!troops.empty())
{
std::unique_ptr<nofPassiveSoldier> soldier = std::move(*troops.begin());
helpers::pop_front(troops);
// Shortcut for Die(): No need to remove from world as it is inside and we can delete it right away
soldier->RemoveFromInventory();
soldier->LeftBuilding();
soldier->Destroy();
// 30 percent chance to not die if the soldier has an armor
bool die = !(*troops.begin())->HasArmor() || (RANDOM_RAND(99) < 70);
if(die)
{
std::unique_ptr<nofPassiveSoldier> soldier = std::move(*troops.begin());
helpers::pop_front(troops);
// Shortcut for Die(): No need to remove from world as it is inside and we can delete it right away
soldier->RemoveFromInventory();
soldier->LeftBuilding();
soldier->Destroy();
} else
(*troops.begin())->SetArmor(false);
}

// If there are troops left, order some more, else this will be destroyed
Expand Down

0 comments on commit 2a59a2f

Please sign in to comment.