Browse Source

Merge pull request #2572 from vcmi/nkai-fix-heroes-not-recruiting

Nkai fix heroes not recruiting
Andrii Danylchenko 2 năm trước cách đây
mục cha
commit
6c025fd768

+ 1 - 1
AI/Nullkiller/Behaviors/RecruitHeroBehavior.cpp

@@ -84,7 +84,7 @@ Goals::TGoalVec RecruitHeroBehavior::decompose() const
 				}
 				}
 			}
 			}
 
 
-			if(treasureSourcesCount < 5)
+			if(treasureSourcesCount < 5 && (town->garrisonHero || town->getUpperArmy()->getArmyStrength() < 10000))
 				continue;
 				continue;
 
 
 			if(cb->getHeroesInfo().size() < cb->getTownsInfo().size() + 1
 			if(cb->getHeroesInfo().size() < cb->getTownsInfo().size() + 1

+ 4 - 0
lib/battle/CBattleInfoCallback.cpp

@@ -1732,6 +1732,10 @@ SpellID CBattleInfoCallback::getRandomCastedSpell(CRandomGenerator & rand,const
 	TConstBonusListPtr bl = caster->getBonuses(Selector::type()(BonusType::SPELLCASTER));
 	TConstBonusListPtr bl = caster->getBonuses(Selector::type()(BonusType::SPELLCASTER));
 	if (!bl->size())
 	if (!bl->size())
 		return SpellID::NONE;
 		return SpellID::NONE;
+
+	if(bl->size() == 1)
+		return SpellID(bl->front()->subtype);
+
 	int totalWeight = 0;
 	int totalWeight = 0;
 	for(const auto & b : *bl)
 	for(const auto & b : *bl)
 	{
 	{