1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-24 08:32:34 +02:00

VCAI: do not attempt artefact and army exchange with ally hero

While visits of ally heroes supposedly occur accidentally It's still nice to handle it's gracefully.
No reason to prevent visits completely as they useful if hero have skill like Scholar.
This commit is contained in:
Arseniy Shestakov 2016-09-14 13:34:22 +03:00
parent 7ec9601acd
commit ca0fe8fdc4

View File

@ -321,7 +321,7 @@ void VCAI::heroExchangeStarted(ObjectInstanceID hero1, ObjectInstanceID hero2, Q
auto firstHero = cb->getHero(hero1);
auto secondHero = cb->getHero(hero2);
status.addQuery(query, boost::str(boost::format("Exchange between heroes %s and %s") % firstHero->name % secondHero->name));
status.addQuery(query, boost::str(boost::format("Exchange between heroes %s (%d) and %s (%d)") % firstHero->name % firstHero->tempOwner % secondHero->name % secondHero->tempOwner));
requestActionASAP([=]()
{
@ -340,9 +340,13 @@ void VCAI::heroExchangeStarted(ObjectInstanceID hero1, ObjectInstanceID hero2, Q
this->pickBestArtifacts(h1, h2);
};
if (goalpriority1 > goalpriority2)
//Do not attempt army or artifacts exchange if we visited ally player
//Visits can still be useful if hero have skills like Scholar
if(firstHero->tempOwner != secondHero->tempOwner)
logAi->debug("Heroes owned by different players. Do not exchange army or artifacts.");
else if(goalpriority1 > goalpriority2)
transferFrom2to1 (firstHero, secondHero);
else if (goalpriority1 < goalpriority2)
else if(goalpriority1 < goalpriority2)
transferFrom2to1 (secondHero, firstHero);
else //regular criteria
{