Bazaar developer reference

CvAIEscortedOperation::RetargetCivilian(CvUnit *, CvArmyAI *)

Defined in
CvAIOperation.cpp, line 2946
Class
CvAIEscortedOperation
Hook name
CivHooks::CvAIEscortedOperation_RetargetCivilian

Hooks

static bool BeforeCvAIEscortedOperation_RetargetCivilian(CvAIEscortedOperation* self, CvUnit* pCivilian, CvArmyAI* pArmy, bool& result);static void AfterCvAIEscortedOperation_RetargetCivilian(CvAIEscortedOperation* self, CvUnit* pCivilian, CvArmyAI* pArmy, bool& result);static bool ReplaceCvAIEscortedOperation_RetargetCivilian(bool (*original)(CvAIEscortedOperation*, CvUnit*, CvArmyAI*), CvAIEscortedOperation* self, CvUnit* pCivilian, CvArmyAI* pArmy);CivRegisterBefore<CivHooks::CvAIEscortedOperation_RetargetCivilian>(host, &BeforeCvAIEscortedOperation_RetargetCivilian);CivRegisterAfter<CivHooks::CvAIEscortedOperation_RetargetCivilian>(host, &AfterCvAIEscortedOperation_RetargetCivilian);CivRegisterReplace<CivHooks::CvAIEscortedOperation_RetargetCivilian>(host, &ReplaceCvAIEscortedOperation_RetargetCivilian);

Code

2945/// Start the civilian off to a new target plot2946bool CvAIEscortedOperation::RetargetCivilian(CvUnit* pCivilian, CvArmyAI* pArmy)2947{2948	CvPlot* pBetterTarget;29492950	// Find best city site (taking into account whether or not we are escorted)2951	pBetterTarget = FindBestTarget(pCivilian, !m_bEscorted);29522953	// No targets at all!  Abort2954	if(pBetterTarget == NULL)2955	{2956		m_eCurrentState = AI_OPERATION_STATE_ABORTED;2957		m_eAbortReason = AI_ABORT_NO_TARGET;2958		return false;2959	}2960	// If this is a new target, switch to it2961	else if(pBetterTarget != GetTargetPlot())2962	{2963		SetTargetPlot(pBetterTarget);2964		pArmy->SetGoalPlot(pBetterTarget);2965	}2966	else2967	{2968		SetToAbort(AI_ABORT_REPEAT_TARGET);2969		return false;2970	}29712972	pArmy->SetArmyAIState(ARMYAISTATE_MOVING_TO_DESTINATION);2973	m_eCurrentState = AI_OPERATION_STATE_MOVING_TO_TARGET;29742975	return true;2976}

Calls

Called by