mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-23 21:29:13 +02:00
NKAI: fix error message can not take away last stack
This commit is contained in:
parent
f1a9ae99ee
commit
ec0596f3dd
AI/Nullkiller
@ -867,6 +867,19 @@ void AIGateway::pickBestCreatures(const CArmedInstance * destinationArmy, const
|
|||||||
|
|
||||||
auto bestArmy = nullkiller->armyManager->getBestArmy(destinationArmy, destinationArmy, source);
|
auto bestArmy = nullkiller->armyManager->getBestArmy(destinationArmy, destinationArmy, source);
|
||||||
|
|
||||||
|
for(auto army : armies)
|
||||||
|
{
|
||||||
|
// move first stack at first slot if empty to avoid can not take away last creature
|
||||||
|
if(!army->hasStackAtSlot(SlotID(0)) && army->stacksCount() > 0)
|
||||||
|
{
|
||||||
|
cb->mergeOrSwapStacks(
|
||||||
|
army,
|
||||||
|
army,
|
||||||
|
SlotID(0),
|
||||||
|
army->Slots().begin()->first);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//foreach best type -> iterate over slots in both armies and if it's the appropriate type, send it to the slot where it belongs
|
//foreach best type -> iterate over slots in both armies and if it's the appropriate type, send it to the slot where it belongs
|
||||||
for(SlotID i = SlotID(0); i.validSlot(); i.advance(1)) //i-th strongest creature type will go to i-th slot
|
for(SlotID i = SlotID(0); i.validSlot(); i.advance(1)) //i-th strongest creature type will go to i-th slot
|
||||||
{
|
{
|
||||||
|
@ -236,7 +236,7 @@ const CGHeroInstance * HeroManager::findWeakHeroToDismiss(uint64_t armyLimit) co
|
|||||||
|
|
||||||
for(auto existingHero : myHeroes)
|
for(auto existingHero : myHeroes)
|
||||||
{
|
{
|
||||||
if(ai->isHeroLocked(existingHero) && ai->getHeroLockedReason(existingHero) == HeroLockedReason::DEFENCE
|
if(ai->getHeroLockedReason(existingHero) == HeroLockedReason::DEFENCE
|
||||||
|| existingHero->getArmyStrength() >armyLimit
|
|| existingHero->getArmyStrength() >armyLimit
|
||||||
|| getHeroRole(existingHero) == HeroRole::MAIN
|
|| getHeroRole(existingHero) == HeroRole::MAIN
|
||||||
|| existingHero->movementPointsRemaining()
|
|| existingHero->movementPointsRemaining()
|
||||||
|
@ -119,10 +119,11 @@ Goals::TGoalVec GatherArmyBehavior::deliverArmyToHero(const CGHeroInstance * her
|
|||||||
|
|
||||||
HeroExchange heroExchange(hero, path);
|
HeroExchange heroExchange(hero, path);
|
||||||
|
|
||||||
float armyValue = (float)heroExchange.getReinforcementArmyStrength() / hero->getArmyStrength();
|
uint64_t armyValue = heroExchange.getReinforcementArmyStrength();
|
||||||
|
float armyRatio = (float)armyValue / hero->getArmyStrength();
|
||||||
|
|
||||||
// avoid transferring very small amount of army
|
// avoid transferring very small amount of army
|
||||||
if(armyValue < 0.1f && armyValue < 20000)
|
if((armyRatio < 0.1f && armyValue < 20000) || armyValue < 500)
|
||||||
{
|
{
|
||||||
#if NKAI_TRACE_LEVEL >= 2
|
#if NKAI_TRACE_LEVEL >= 2
|
||||||
logAi->trace("Army value is too small.");
|
logAi->trace("Army value is too small.");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user