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());
|
captureObjects(ai->nullkiller->objectClusterizer->getNearbyObjects());
|
||||||
|
|
||||||
if(tasks.empty())
|
if(tasks.empty() || ai->nullkiller->getScanDepth() == ScanDepth::FULL)
|
||||||
captureObjects(ai->nullkiller->objectClusterizer->getFarObjects());
|
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 treatNode = ai->nullkiller->dangerHitMap->getObjectTreat(town);
|
||||||
auto treats = { treatNode.maximumDanger, treatNode.fastestDanger };
|
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);
|
int dayOfWeek = cb->getDate(Date::DAY_OF_WEEK);
|
||||||
|
|
||||||
if(town->garrisonHero)
|
if(town->garrisonHero)
|
||||||
@ -92,6 +85,13 @@ void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInsta
|
|||||||
return;
|
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);
|
uint64_t reinforcement = ai->nullkiller->armyManager->howManyReinforcementsCanBuy(town->getUpperArmy(), town);
|
||||||
|
|
||||||
if(reinforcement)
|
if(reinforcement)
|
||||||
|
@ -117,7 +117,7 @@ Goals::TTask Nullkiller::choseBestTask(Goals::TSubgoal behavior, int decompositi
|
|||||||
void Nullkiller::resetAiState()
|
void Nullkiller::resetAiState()
|
||||||
{
|
{
|
||||||
lockedResources = TResources();
|
lockedResources = TResources();
|
||||||
scanDepth = ScanDepth::SMALL;
|
scanDepth = ScanDepth::FULL;
|
||||||
playerID = ai->playerID;
|
playerID = ai->playerID;
|
||||||
lockedHeroes.clear();
|
lockedHeroes.clear();
|
||||||
dangerHitMap->reset();
|
dangerHitMap->reset();
|
||||||
|
@ -88,6 +88,7 @@ public:
|
|||||||
int32_t getFreeGold() const { return getFreeResources()[EGameResID::GOLD]; }
|
int32_t getFreeGold() const { return getFreeResources()[EGameResID::GOLD]; }
|
||||||
void lockResources(const TResources & res);
|
void lockResources(const TResources & res);
|
||||||
const TResources & getLockedResources() const { return lockedResources; }
|
const TResources & getLockedResources() const { return lockedResources; }
|
||||||
|
ScanDepth getScanDepth() const { return scanDepth; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void resetAiState();
|
void resetAiState();
|
||||||
|
@ -53,15 +53,13 @@ namespace AIPathfinding
|
|||||||
|
|
||||||
for(const CGTownInstance * t : cb->getTownsInfo())
|
for(const CGTownInstance * t : cb->getTownsInfo())
|
||||||
{
|
{
|
||||||
// do not allow ally shipyards because of bug
|
if(t->hasBuilt(BuildingID::SHIPYARD))
|
||||||
if(t->hasBuilt(BuildingID::SHIPYARD) && t->getOwner() == ai->playerID)
|
|
||||||
shipyards.push_back(t);
|
shipyards.push_back(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(const CGObjectInstance * obj : ai->memory->visitableObjs)
|
for(const CGObjectInstance * obj : ai->memory->visitableObjs)
|
||||||
{
|
{
|
||||||
// do not allow ally shipyards because of bug
|
if(obj->ID != Obj::TOWN) //towns were handled in the previous loop
|
||||||
if(obj->ID != Obj::TOWN && obj->getOwner() == ai->playerID) //towns were handled in the previous loop
|
|
||||||
{
|
{
|
||||||
if(const IShipyard * shipyard = IShipyard::castFrom(obj))
|
if(const IShipyard * shipyard = IShipyard::castFrom(obj))
|
||||||
shipyards.push_back(shipyard);
|
shipyards.push_back(shipyard);
|
||||||
|
Loading…
Reference in New Issue
Block a user