diff --git a/lib/gameState/CGameState.cpp b/lib/gameState/CGameState.cpp index c0718d852..ddfa5a89b 100644 --- a/lib/gameState/CGameState.cpp +++ b/lib/gameState/CGameState.cpp @@ -1242,17 +1242,20 @@ bool CGameState::checkForVictory(const PlayerColor & player, const EventConditio case EventCondition::HAVE_CREATURES: { //check if in players armies there is enough creatures - int total = 0; //creature counter - for(auto ai : map->getObjects()) - { - if(ai->getOwner() == player) - { - for(const auto & elem : ai->Slots()) //iterate through army - if(elem.second->getId() == condition.objectType.as()) //it's searched creature - total += elem.second->getCount(); - } - } - return total >= condition.value; + // NOTE: only heroes & towns are checked, in line with H3. + // Garrisons, mines, and guards of owned dwellings(!) are excluded + int totalCreatures = 0; + for (const auto & hero : p->getHeroes()) + for(const auto & elem : hero->Slots()) //iterate through army + if(elem.second->getId() == condition.objectType.as()) //it's searched creature + totalCreatures += elem.second->getCount(); + + for (const auto & town : p->getTowns()) + for(const auto & elem : town->Slots()) //iterate through army + if(elem.second->getId() == condition.objectType.as()) //it's searched creature + totalCreatures += elem.second->getCount(); + + return totalCreatures >= condition.value; } case EventCondition::HAVE_RESOURCES: {