mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-14 02:33:51 +02:00
Disable building from army goals, re-fix building capitol prereqs
This commit is contained in:
parent
8c763253d2
commit
12e1e5b315
@ -158,6 +158,8 @@ bool BuildingManager::getBuildingOptions(const CGTownInstance * t)
|
|||||||
//TODO: build resource silo, defences when needed
|
//TODO: build resource silo, defences when needed
|
||||||
//Possible - allow "locking" on specific building (build prerequisites and then building itself)
|
//Possible - allow "locking" on specific building (build prerequisites and then building itself)
|
||||||
|
|
||||||
|
//TODO: There is some disabled building code in GatherTroops and GatherArmy - take it into account when enhancing building. For now AI works best with building only via Build goal.
|
||||||
|
|
||||||
immediateBuildings.clear();
|
immediateBuildings.clear();
|
||||||
expensiveBuildings.clear();
|
expensiveBuildings.clear();
|
||||||
|
|
||||||
@ -169,6 +171,18 @@ bool BuildingManager::getBuildingOptions(const CGTownInstance * t)
|
|||||||
if (tryBuildAnyStructure(t, std::vector<BuildingID>(essential, essential + ARRAY_COUNT(essential))))
|
if (tryBuildAnyStructure(t, std::vector<BuildingID>(essential, essential + ARRAY_COUNT(essential))))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
//workaround for mantis #2696 - build fort and citadel - building castle prerequisite when trying to build capitol will be then handled without bug
|
||||||
|
if(vstd::contains(t->builtBuildings, BuildingID::CITY_HALL) &&
|
||||||
|
cb->canBuildStructure(t, BuildingID::CAPITOL) != EBuildingState::HAVE_CAPITAL)
|
||||||
|
{
|
||||||
|
if(cb->canBuildStructure(t, BuildingID::CAPITOL) != EBuildingState::FORBIDDEN)
|
||||||
|
{
|
||||||
|
if(tryBuildNextStructure(t, std::vector<BuildingID>(capitolRequirements,
|
||||||
|
capitolRequirements + ARRAY_COUNT(capitolRequirements))))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//the more gold the better and less problems later //TODO: what about building mage guild / marketplace etc. with city hall disabled in editor?
|
//the more gold the better and less problems later //TODO: what about building mage guild / marketplace etc. with city hall disabled in editor?
|
||||||
if (tryBuildNextStructure(t, std::vector<BuildingID>(goldSource, goldSource + ARRAY_COUNT(goldSource))))
|
if (tryBuildNextStructure(t, std::vector<BuildingID>(goldSource, goldSource + ARRAY_COUNT(goldSource))))
|
||||||
return true;
|
return true;
|
||||||
@ -177,18 +191,6 @@ bool BuildingManager::getBuildingOptions(const CGTownInstance * t)
|
|||||||
if(tryBuildThisStructure(t, BuildingID::FORT))
|
if(tryBuildThisStructure(t, BuildingID::FORT))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
//workaround for mantis #2696 - build fort and citadel - building castle will be handled without bug //RECHECK THIS CODE BLOCK - its logic predates building manager
|
|
||||||
if (vstd::contains(t->builtBuildings, BuildingID::CITY_HALL) &&
|
|
||||||
cb->canBuildStructure(t, BuildingID::CAPITOL) != EBuildingState::HAVE_CAPITAL)
|
|
||||||
{
|
|
||||||
if (cb->canBuildStructure(t, BuildingID::CAPITOL) != EBuildingState::FORBIDDEN)
|
|
||||||
{
|
|
||||||
if (tryBuildNextStructure(t, std::vector<BuildingID>(capitolRequirements,
|
|
||||||
capitolRequirements + ARRAY_COUNT(capitolRequirements))))
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO: save money for capitol or city hall if capitol unavailable
|
//TODO: save money for capitol or city hall if capitol unavailable
|
||||||
//do not build other things (unless gold source buildings are disabled in map editor)
|
//do not build other things (unless gold source buildings are disabled in map editor)
|
||||||
|
|
||||||
|
@ -1227,10 +1227,10 @@ TSubgoal GatherTroops::whatToDoToAchieve()
|
|||||||
{
|
{
|
||||||
dwellings.push_back(t);
|
dwellings.push_back(t);
|
||||||
}
|
}
|
||||||
else
|
/*else //disable random building requests for now - this code needs to know a lot of town/resource context to do more good than harm
|
||||||
{
|
{
|
||||||
return sptr(Goals::BuildThis(bid, t).setpriority(priority));
|
return sptr(Goals::BuildThis(bid, t).setpriority(priority));
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(auto obj : ai->visitableObjs)
|
for(auto obj : ai->visitableObjs)
|
||||||
@ -1459,7 +1459,9 @@ TGoalVec GatherArmy::getAllPossibleSubgoals()
|
|||||||
//build dwelling
|
//build dwelling
|
||||||
//TODO: plan building over multiple turns?
|
//TODO: plan building over multiple turns?
|
||||||
//auto bid = ah->canBuildAnyStructure(t, std::vector<BuildingID>(unitsSource, unitsSource + ARRAY_COUNT(unitsSource)), 8 - cb->getDate(Date::DAY_OF_WEEK));
|
//auto bid = ah->canBuildAnyStructure(t, std::vector<BuildingID>(unitsSource, unitsSource + ARRAY_COUNT(unitsSource)), 8 - cb->getDate(Date::DAY_OF_WEEK));
|
||||||
auto bid = ai->ah->canBuildAnyStructure(t, std::vector<BuildingID>(unitsSource, unitsSource + ARRAY_COUNT(unitsSource)), 1);
|
|
||||||
|
//Do not use below code for now, rely on generic Build. Code below needs to know a lot of town/resource context to do more good than harm
|
||||||
|
/*auto bid = ai->ah->canBuildAnyStructure(t, std::vector<BuildingID>(unitsSource, unitsSource + ARRAY_COUNT(unitsSource)), 1);
|
||||||
if (bid.is_initialized())
|
if (bid.is_initialized())
|
||||||
{
|
{
|
||||||
auto goal = sptr(BuildThis(bid.get(), t).setpriority(priority));
|
auto goal = sptr(BuildThis(bid.get(), t).setpriority(priority));
|
||||||
@ -1467,7 +1469,7 @@ TGoalVec GatherArmy::getAllPossibleSubgoals()
|
|||||||
ret.push_back(goal);
|
ret.push_back(goal);
|
||||||
else
|
else
|
||||||
logAi->debug("Can not build a structure, because of ai->ah->containsObjective");
|
logAi->debug("Can not build a structure, because of ai->ah->containsObjective");
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user