Bazaar developer reference

CvAIOperationRapidResponse::Init(int, PlayerTypes, PlayerTypes, int, CvCity *, CvCity *)

Defined in
CvAIOperation.cpp, line 4848
Class
CvAIOperationRapidResponse
Hook name
CivHooks::CvAIOperationRapidResponse_Init
Overrides
CvAIOperation::Init(int, PlayerTypes, PlayerTypes, int, CvCity *, CvCity *)

Hooks

static bool BeforeCvAIOperationRapidResponse_Init(CvAIOperationRapidResponse* self, int iID, PlayerTypes eOwner, PlayerTypes eEnemy, int arg3, CvCity* arg4, CvCity* arg5);static void AfterCvAIOperationRapidResponse_Init(CvAIOperationRapidResponse* self, int iID, PlayerTypes eOwner, PlayerTypes eEnemy, int arg3, CvCity* arg4, CvCity* arg5);static void ReplaceCvAIOperationRapidResponse_Init(void (*original)(CvAIOperationRapidResponse*, int, PlayerTypes, PlayerTypes, int, CvCity*, CvCity*), CvAIOperationRapidResponse* self, int iID, PlayerTypes eOwner, PlayerTypes eEnemy, int arg3, CvCity* arg4, CvCity* arg5);CivRegisterBefore<CivHooks::CvAIOperationRapidResponse_Init>(host, &BeforeCvAIOperationRapidResponse_Init);CivRegisterAfter<CivHooks::CvAIOperationRapidResponse_Init>(host, &AfterCvAIOperationRapidResponse_Init);CivRegisterReplace<CivHooks::CvAIOperationRapidResponse_Init>(host, &ReplaceCvAIOperationRapidResponse_Init);

Code

4847/// Kick off this operation4848void CvAIOperationRapidResponse::Init(int iID, PlayerTypes eOwner, PlayerTypes eEnemy, int /*iDefaultArea*/, CvCity* /*pTarget*/, CvCity* /*pMuster*/)4849{4850	Reset();4851	m_iID = iID;4852	m_eOwner = eOwner;4853	m_eEnemy = eEnemy;48544855	if(iID != -1)4856	{4857		// create the armies that are needed and set the state to ARMYAISTATE_WAITING_FOR_UNITS_TO_REINFORCE4858		CvArmyAI* pArmyAI = GET_PLAYER(m_eOwner).addArmyAI();4859		if(pArmyAI)4860		{4861			m_viArmyIDs.push_back(pArmyAI->GetID());4862			pArmyAI->Init(pArmyAI->GetID(),m_eOwner,m_iID);4863			pArmyAI->SetArmyAIState(ARMYAISTATE_WAITING_FOR_UNITS_TO_REINFORCE);4864			pArmyAI->SetFormationIndex(GetFormation());48654866			CvPlot* pTargetPlot = FindBestTarget();4867			if(pTargetPlot != NULL)4868			{4869				SetTargetPlot(pTargetPlot);4870				pArmyAI->SetGoalPlot(pTargetPlot);4871				SetMusterPlot(pTargetPlot);  // Gather directly at the point we're trying to defend4872				pArmyAI->SetXY(GetMusterPlot()->getX(), GetMusterPlot()->getY());4873				SetDefaultArea(GetMusterPlot()->getArea());48744875				// Find the list of units we need to build before starting this operation in earnest4876				BuildListOfUnitsWeStillNeedToBuild();48774878				// Try to get as many units as possible from existing units that are waiting around4879				if(GrabUnitsFromTheReserves(GetMusterPlot(), NULL))4880				{4881					pArmyAI->SetArmyAIState(ARMYAISTATE_WAITING_FOR_UNITS_TO_CATCH_UP);4882					m_eCurrentState = AI_OPERATION_STATE_GATHERING_FORCES;4883				}4884				else4885				{4886					m_eCurrentState = AI_OPERATION_STATE_RECRUITING_UNITS;4887				}48884889				LogOperationStart();4890			}4891		}4892	}4893}

Calls