Bazaar developer reference

CvTacticalAI::ExecuteMoveToPlot(UnitHandle, CvPlot *, bool)

Defined in
CvTacticalAI.cpp, line 7481
Class
CvTacticalAI
Hook name
CivHooks::CvTacticalAI_ExecuteMoveToPlot_with_UnitHandle_CvPlot_bool

Hooks

static bool BeforeCvTacticalAI_ExecuteMoveToPlot_with_UnitHandle_CvPlot_bool(CvTacticalAI* self, UnitHandle pUnit, CvPlot* pTarget, bool bSaveMoves);static void AfterCvTacticalAI_ExecuteMoveToPlot_with_UnitHandle_CvPlot_bool(CvTacticalAI* self, UnitHandle pUnit, CvPlot* pTarget, bool bSaveMoves);static void ReplaceCvTacticalAI_ExecuteMoveToPlot_with_UnitHandle_CvPlot_bool(void (*original)(CvTacticalAI*, UnitHandle, CvPlot*, bool), CvTacticalAI* self, UnitHandle pUnit, CvPlot* pTarget, bool bSaveMoves);CivRegisterBefore<CivHooks::CvTacticalAI_ExecuteMoveToPlot_with_UnitHandle_CvPlot_bool>(host, &BeforeCvTacticalAI_ExecuteMoveToPlot_with_UnitHandle_CvPlot_bool);CivRegisterAfter<CivHooks::CvTacticalAI_ExecuteMoveToPlot_with_UnitHandle_CvPlot_bool>(host, &AfterCvTacticalAI_ExecuteMoveToPlot_with_UnitHandle_CvPlot_bool);CivRegisterReplace<CivHooks::CvTacticalAI_ExecuteMoveToPlot_with_UnitHandle_CvPlot_bool>(host, &ReplaceCvTacticalAI_ExecuteMoveToPlot_with_UnitHandle_CvPlot_bool);

Code

7480/// Move unit to protect a specific tile (retrieve unit from first entry in m_CurrentMoveUnits)7481void CvTacticalAI::ExecuteMoveToPlot(UnitHandle pUnit, CvPlot* pTarget, bool bSaveMoves)7482{7483	// Unit already at target plot?7484	if(pTarget == pUnit->plot())7485	{7486		// Fortify if possible7487		if(pUnit->canFortify(pUnit->plot()))7488		{7489			pUnit->PushMission(CvTypes::getMISSION_FORTIFY());7490			pUnit->SetFortifiedThisTurn(true);7491		}7492		else7493		{7494			pUnit->PushMission(CvTypes::getMISSION_SKIP());7495			if(!bSaveMoves)7496			{7497				pUnit->finishMoves();7498			}7499		}7500	}75017502	else7503	{7504		pUnit->PushMission(CvTypes::getMISSION_MOVE_TO(), pTarget->getX(), pTarget->getY(), MOVE_UNITS_IGNORE_DANGER);7505		if(!bSaveMoves)7506		{7507			pUnit->finishMoves();7508		}7509	}75107511#if defined(MOD_AI_SMART_V3)7512	if (!MOD_AI_SMART_V3 || !bSaveMoves)7513#endif7514	UnitProcessed(pUnit->GetID(), pUnit->IsCombatUnit());7515}

Calls

Called by