1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-13 19:54:17 +02:00

Fix AI recruitment

This commit is contained in:
Ivan Savenko
2023-10-04 17:38:38 +03:00
parent 39a92cdde3
commit 46e4d862a5
2 changed files with 10 additions and 9 deletions

View File

@@ -330,7 +330,11 @@ void AIGateway::showRecruitmentDialog(const CGDwelling * dwelling, const CArmedI
NET_EVENT_HANDLER;
status.addQuery(queryID, "RecruitmentDialog");
requestActionASAP([=](){ answerQuery(queryID, 0); });
requestActionASAP([=](){
recruitCreatures(dwelling, dst);
answerQuery(queryID, 0);
});
}
void AIGateway::heroMovePointsChanged(const CGHeroInstance * hero)
@@ -845,9 +849,6 @@ void AIGateway::performObjectInteraction(const CGObjectInstance * obj, HeroPtr h
LOG_TRACE_PARAMS(logAi, "Hero %s and object %s at %s", h->getNameTranslated() % obj->getObjectName() % obj->pos.toString());
switch(obj->ID)
{
case Obj::CREATURE_GENERATOR1:
recruitCreatures(dynamic_cast<const CGDwelling *>(obj), h.get());
break;
case Obj::TOWN:
if(h->visitedTown) //we are inside, not just attacking
{

View File

@@ -366,7 +366,11 @@ void VCAI::showRecruitmentDialog(const CGDwelling * dwelling, const CArmedInstan
NET_EVENT_HANDLER;
status.addQuery(queryID, "RecruitmentDialog");
requestActionASAP([=](){ answerQuery(queryID, 0); });
requestActionASAP([=](){
recruitCreatures(dwelling, dst);
checkHeroArmy(dynamic_cast<const CGHeroInstance*>(dst));
answerQuery(queryID, 0);
});
}
void VCAI::heroMovePointsChanged(const CGHeroInstance * hero)
@@ -1056,10 +1060,6 @@ void VCAI::performObjectInteraction(const CGObjectInstance * obj, HeroPtr h)
LOG_TRACE_PARAMS(logAi, "Hero %s and object %s at %s", h->getNameTranslated() % obj->getObjectName() % obj->pos.toString());
switch(obj->ID)
{
case Obj::CREATURE_GENERATOR1:
recruitCreatures(dynamic_cast<const CGDwelling *>(obj), h.get());
checkHeroArmy(h);
break;
case Obj::TOWN:
moveCreaturesToHero(dynamic_cast<const CGTownInstance *>(obj));
if(h->visitedTown) //we are inside, not just attacking