diff --git a/AI/Nullkiller/Analyzers/ArmyManager.cpp b/AI/Nullkiller/Analyzers/ArmyManager.cpp index a8eb72c34..6179b562c 100644 --- a/AI/Nullkiller/Analyzers/ArmyManager.cpp +++ b/AI/Nullkiller/Analyzers/ArmyManager.cpp @@ -382,6 +382,7 @@ std::vector ArmyManager::getArmyAvailableToBuy( if (shouldDisband) { disbandMalus = leastValuableStackValue / ci.creID.toCreature()->getFullRecruitCost(); + logAi->info("Should disband %d %s at %s worth: %d", hero->getStack(leastValuableSlot).count, hero->getStack(leastValuableSlot).getCreatureID().toCreature()->getNamePluralTranslated(), town->getNameTranslated(), leastValuableStackValue.marketValue()); alreadyDisbanded.insert(leastValuableSlot); } diff --git a/AI/Nullkiller/Goals/BuyArmy.cpp b/AI/Nullkiller/Goals/BuyArmy.cpp index 1e1b96b14..b66b42ec7 100644 --- a/AI/Nullkiller/Goals/BuyArmy.cpp +++ b/AI/Nullkiller/Goals/BuyArmy.cpp @@ -58,7 +58,7 @@ void BuyArmy::accept(AIGateway * ai) if(ci.count) { - if (town->stacksCount() == GameConstants::ARMY_SIZE) + if (town->getUpperArmy()->stacksCount() == GameConstants::ARMY_SIZE) { SlotID lowestValueSlot; int lowestValue = std::numeric_limits::max(); @@ -70,10 +70,14 @@ void BuyArmy::accept(AIGateway * ai) slot.second->getCreatureID().toCreature()->getFullRecruitCost().marketValue() * slot.second->getCount(); if (slot.second->getCreatureID().toCreature()->getFactionID() == town->getFactionID()) + { + logAi->info("Skipped Dismissing %s due to same faction", slot.second->getCreatureID().toCreature()->getNamePluralTranslated()); continue; + } if (currentStackMarketValue < lowestValue) { + logAi->info("Marked %s for dismissal.", slot.second->getCreatureID().toCreature()->getNamePluralTranslated()); lowestValue = currentStackMarketValue; lowestValueSlot = slot.first; } @@ -81,10 +85,15 @@ void BuyArmy::accept(AIGateway * ai) } if (lowestValueSlot.validSlot()) { + logAi->info("Dismiss %d %s at %s slot: %d", town->getUpperArmy()->getStackCount(lowestValueSlot), town->getUpperArmy()->getStack(lowestValueSlot).getCreatureID().toCreature()->getNamePluralTranslated(), town->getNameTranslated(), lowestValueSlot.getNum()); cb->dismissCreature(town->getUpperArmy(), lowestValueSlot); } } - cb->recruitCreatures(town, town->getUpperArmy(), ci.creID, ci.count, ci.level); + if (town->getUpperArmy()->stacksCount() < GameConstants::ARMY_SIZE || town->getUpperArmy()->getSlotFor(ci.creID).validSlot()) //It is possible we don't scrap despite we wanted to due to not scrapping stacks that fit our faction + { + logAi->info("Buy %d %s at %s", ci.count, ci.creID.toCreature()->getNamePluralTranslated(), town->getNameTranslated()); + cb->recruitCreatures(town, town->getUpperArmy(), ci.creID, ci.count, ci.level); + } valueBought += ci.count * ci.creID.toCreature()->getAIValue(); } }