Bazaar developer reference

CvTacticalAI::PlotCampDefenseMoves()

Defined in
CvTacticalAI.cpp, line 3084
Class
CvTacticalAI
Hook name
CivHooks::CvTacticalAI_PlotCampDefenseMoves

Hooks

static bool BeforeCvTacticalAI_PlotCampDefenseMoves(CvTacticalAI* self);static void AfterCvTacticalAI_PlotCampDefenseMoves(CvTacticalAI* self);static void ReplaceCvTacticalAI_PlotCampDefenseMoves(void (*original)(CvTacticalAI*), CvTacticalAI* self);CivRegisterBefore<CivHooks::CvTacticalAI_PlotCampDefenseMoves>(host, &BeforeCvTacticalAI_PlotCampDefenseMoves);CivRegisterAfter<CivHooks::CvTacticalAI_PlotCampDefenseMoves>(host, &AfterCvTacticalAI_PlotCampDefenseMoves);CivRegisterReplace<CivHooks::CvTacticalAI_PlotCampDefenseMoves>(host, &ReplaceCvTacticalAI_PlotCampDefenseMoves);

Code

3083/// Assigns a barbarian to go protect an undefended camp3084void CvTacticalAI::PlotCampDefenseMoves()3085{3086	CvTacticalTarget* pTarget;3087	pTarget = GetFirstZoneTarget(AI_TACTICAL_TARGET_BARBARIAN_CAMP);3088	while(pTarget != NULL)3089	{3090		CvPlot* pPlot = GC.getMap().plot(pTarget->GetTargetX(), pTarget->GetTargetY());3091		if(FindUnitsWithinStrikingDistance(pPlot, 1, 0, true /* bNoRangedUnits */, false /*bNavalOnly*/, false /*bMustMoveThrough*/))3092		{3093			ExecuteMoveToPlot(pPlot);30943095			if(GC.getLogging() && GC.getAILogging())3096			{3097				CvString strLogString;3098				strLogString.Format("Moving to protect camp, X: %d, Y: %d", pTarget->GetTargetX(), pTarget->GetTargetY());3099				LogTacticalMessage(strLogString);3100			}3101		}3102		pTarget = GetNextZoneTarget();3103	}3104}

Calls

Called by