Bazaar developer reference

CvHomelandAI::ExecuteArchaeologistMoves()

Defined in
CvHomelandAI.cpp, line 5213
Class
CvHomelandAI
Hook name
CivHooks::CvHomelandAI_ExecuteArchaeologistMoves

Hooks

static bool BeforeCvHomelandAI_ExecuteArchaeologistMoves(CvHomelandAI* self);static void AfterCvHomelandAI_ExecuteArchaeologistMoves(CvHomelandAI* self);static void ReplaceCvHomelandAI_ExecuteArchaeologistMoves(void (*original)(CvHomelandAI*), CvHomelandAI* self);CivRegisterBefore<CivHooks::CvHomelandAI_ExecuteArchaeologistMoves>(host, &BeforeCvHomelandAI_ExecuteArchaeologistMoves);CivRegisterAfter<CivHooks::CvHomelandAI_ExecuteArchaeologistMoves>(host, &AfterCvHomelandAI_ExecuteArchaeologistMoves);CivRegisterReplace<CivHooks::CvHomelandAI_ExecuteArchaeologistMoves>(host, &ReplaceCvHomelandAI_ExecuteArchaeologistMoves);

Code

5212// Get an archaeologist and send it to an antiquity site5213void CvHomelandAI::ExecuteArchaeologistMoves()5214{5215#if defined(MOD_AI_SMART_V3)5216	int iUnassignedArchaeologists = 0;5217#endif52185219	FStaticVector< CvHomelandUnit, 64, true, c_eCiv5GameplayDLL >::iterator it;5220	for(it = m_CurrentMoveUnits.begin(); it != m_CurrentMoveUnits.end(); ++it)5221	{5222		CvUnit* pUnit = m_pPlayer->getUnit(it->GetID());5223		if(!pUnit)5224		{5225			continue;5226		}52275228		CvPlot* pTarget = FindArchaeologistTarget(pUnit);5229		if (pTarget)5230		{5231			BuildTypes eBuild = (BuildTypes)GC.getInfoTypeForString("BUILD_ARCHAEOLOGY_DIG");5232			if(pUnit->UnitPathTo(pTarget->getX(), pTarget->getY(), 0) > 0)5233			{5234				pUnit->PushMission(CvTypes::getMISSION_MOVE_TO(), pTarget->getX(), pTarget->getY());5235				if(GC.getLogging() && GC.getAILogging())5236				{5237					CvString strLogString;5238					strLogString.Format("Archaeologist moving to site at, X: %d, Y: %d", pTarget->getX(), pTarget->getY());5239					LogHomelandMessage(strLogString);5240				}52415242				if(pUnit->plot() == pTarget)5243				{5244					pUnit->PushMission(CvTypes::getMISSION_BUILD(), eBuild, -1, 0, (pUnit->GetLengthMissionQueue() > 0), false, MISSIONAI_BUILD, pTarget);5245					if(GC.getLogging() && GC.getAILogging())5246					{5247						CvString strLogString;5248						strLogString.Format("Archaeologist creating dig at, X: %d, Y: %d", pTarget->getX(), pTarget->getY());5249						LogHomelandMessage(strLogString);5250					}5251				}5252				else5253				{5254					pUnit->finishMoves();5255				}5256			}5257			// Delete this unit from those we have to move5258			UnitProcessed(pUnit->GetID());5259		}5260#if defined(MOD_AI_SMART_V3)5261		else if (MOD_AI_SMART_V3)5262		{5263			iUnassignedArchaeologists++;5264			pUnit->finishMoves();5265			UnitProcessed(pUnit->GetID());5266		}5267#endif5268	}52695270#if defined(MOD_AI_SMART_V3)5271	// Unassigned archaeologists due to no valid targets, check against the possible targets left and scrap one if there are too many.5272	if (MOD_AI_SMART_V3 && iUnassignedArchaeologists > 0)5273	{5274		int iPossibleSites = ((m_TargetedAntiquitySites.size() / 5) + 1);52755276		if (iUnassignedArchaeologists > iPossibleSites)5277		{5278			CvUnit* pUnit = m_pPlayer->getUnit(m_CurrentMoveUnits.end()->GetID());52795280			if (pUnit)5281			{5282				if(GC.getLogging() && GC.getAILogging())5283				{5284					CvString strLogString;5285					strLogString.Format("Idle Archaeologist scrapped at, X: %d, Y: %d", pUnit->getX(), pUnit->getY());5286					LogHomelandMessage(strLogString);5287				}52885289				pUnit->scrap();5290			}5291		}5292	}5293#endif5294}

Calls

Called by