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:
parent
d347db4c16
commit
fbc9a32ad8
@ -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());
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
@ -92,6 +85,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);
|
||||
|
||||
if(reinforcement)
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user