1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

#2018 - fix shipyard usage for NKAI, allied shipyard should work now

This commit is contained in:
Andrii Danylchenko 2023-04-22 18:37:27 +03:00 committed by Andrii Danylchenko
parent d347db4c16
commit fbc9a32ad8
5 changed files with 12 additions and 13 deletions

View File

@ -209,7 +209,7 @@ Goals::TGoalVec CaptureObjectsBehavior::decompose() const
{
captureObjects(ai->nullkiller->objectClusterizer->getNearbyObjects());
if(tasks.empty())
if(tasks.empty() || ai->nullkiller->getScanDepth() == ScanDepth::FULL)
captureObjects(ai->nullkiller->objectClusterizer->getFarObjects());
}

View File

@ -58,13 +58,6 @@ void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInsta
auto treatNode = ai->nullkiller->dangerHitMap->getObjectTreat(town);
auto treats = { treatNode.maximumDanger, treatNode.fastestDanger };
if(!treatNode.fastestDanger.hero)
{
logAi->trace("No treat found for town %s", town->getNameTranslated());
return;
}
int dayOfWeek = cb->getDate(Date::DAY_OF_WEEK);
if(town->garrisonHero)
@ -91,6 +84,13 @@ void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInsta
return;
}
if(!treatNode.fastestDanger.hero)
{
logAi->trace("No treat found for town %s", town->getNameTranslated());
return;
}
uint64_t reinforcement = ai->nullkiller->armyManager->howManyReinforcementsCanBuy(town->getUpperArmy(), town);

View File

@ -117,7 +117,7 @@ Goals::TTask Nullkiller::choseBestTask(Goals::TSubgoal behavior, int decompositi
void Nullkiller::resetAiState()
{
lockedResources = TResources();
scanDepth = ScanDepth::SMALL;
scanDepth = ScanDepth::FULL;
playerID = ai->playerID;
lockedHeroes.clear();
dangerHitMap->reset();

View File

@ -88,6 +88,7 @@ public:
int32_t getFreeGold() const { return getFreeResources()[EGameResID::GOLD]; }
void lockResources(const TResources & res);
const TResources & getLockedResources() const { return lockedResources; }
ScanDepth getScanDepth() const { return scanDepth; }
private:
void resetAiState();

View File

@ -53,15 +53,13 @@ namespace AIPathfinding
for(const CGTownInstance * t : cb->getTownsInfo())
{
// do not allow ally shipyards because of bug
if(t->hasBuilt(BuildingID::SHIPYARD) && t->getOwner() == ai->playerID)
if(t->hasBuilt(BuildingID::SHIPYARD))
shipyards.push_back(t);
}
for(const CGObjectInstance * obj : ai->memory->visitableObjs)
{
// do not allow ally shipyards because of bug
if(obj->ID != Obj::TOWN && obj->getOwner() == ai->playerID) //towns were handled in the previous loop
if(obj->ID != Obj::TOWN) //towns were handled in the previous loop
{
if(const IShipyard * shipyard = IShipyard::castFrom(obj))
shipyards.push_back(shipyard);