mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	Disable building from army goals, re-fix building capitol prereqs
This commit is contained in:
		| @@ -157,6 +157,8 @@ bool BuildingManager::getBuildingOptions(const CGTownInstance * t) | ||||
| 	//TODO: faction-specific development: use special buildings, build dwellings in better order, etc | ||||
| 	//TODO: build resource silo, defences when needed | ||||
| 	//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(); | ||||
| 	expensiveBuildings.clear(); | ||||
| @@ -169,6 +171,18 @@ bool BuildingManager::getBuildingOptions(const CGTownInstance * t) | ||||
| 	if (tryBuildAnyStructure(t, std::vector<BuildingID>(essential, essential + ARRAY_COUNT(essential)))) | ||||
| 		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? | ||||
| 	if (tryBuildNextStructure(t, std::vector<BuildingID>(goldSource, goldSource + ARRAY_COUNT(goldSource)))) | ||||
| 		return true; | ||||
| @@ -177,18 +191,6 @@ bool BuildingManager::getBuildingOptions(const CGTownInstance * t) | ||||
| 		if(tryBuildThisStructure(t, BuildingID::FORT)) | ||||
| 			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 | ||||
| 	//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); | ||||
| 			} | ||||
| 			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)); | ||||
| 			} | ||||
| 			}*/ | ||||
| 		} | ||||
| 	} | ||||
| 	for(auto obj : ai->visitableObjs) | ||||
| @@ -1459,7 +1459,9 @@ TGoalVec GatherArmy::getAllPossibleSubgoals() | ||||
| 			//build dwelling | ||||
| 			//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 = 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()) | ||||
| 			{ | ||||
| 				auto goal = sptr(BuildThis(bid.get(), t).setpriority(priority)); | ||||
| @@ -1467,7 +1469,7 @@ TGoalVec GatherArmy::getAllPossibleSubgoals() | ||||
| 					ret.push_back(goal); | ||||
| 				else | ||||
| 					logAi->debug("Can not build a structure, because of ai->ah->containsObjective"); | ||||
| 			} | ||||
| 			}*/ | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user