Bazaar developer reference

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

Defined in
CvAIOperation.cpp, line 5519
Class
CvAIOperationNukeAttack
Hook name
CivHooks::CvAIOperationNukeAttack_Init
Overrides
CvAIOperation::Init(int, PlayerTypes, PlayerTypes, int, CvCity *, CvCity *)

Hooks

static bool BeforeCvAIOperationNukeAttack_Init(CvAIOperationNukeAttack* self, int iID, PlayerTypes eOwner, PlayerTypes eEnemy, int arg3, CvCity* arg4, CvCity* arg5);static void AfterCvAIOperationNukeAttack_Init(CvAIOperationNukeAttack* self, int iID, PlayerTypes eOwner, PlayerTypes eEnemy, int arg3, CvCity* arg4, CvCity* arg5);static void ReplaceCvAIOperationNukeAttack_Init(void (*original)(CvAIOperationNukeAttack*, int, PlayerTypes, PlayerTypes, int, CvCity*, CvCity*), CvAIOperationNukeAttack* self, int iID, PlayerTypes eOwner, PlayerTypes eEnemy, int arg3, CvCity* arg4, CvCity* arg5);CivRegisterBefore<CivHooks::CvAIOperationNukeAttack_Init>(host, &BeforeCvAIOperationNukeAttack_Init);CivRegisterAfter<CivHooks::CvAIOperationNukeAttack_Init>(host, &AfterCvAIOperationNukeAttack_Init);CivRegisterReplace<CivHooks::CvAIOperationNukeAttack_Init>(host, &ReplaceCvAIOperationNukeAttack_Init);

Code

5519void CvAIOperationNukeAttack::Init(int iID, PlayerTypes eOwner, PlayerTypes eEnemy, int , CvCity* /*pTarget*/, CvCity* /*pMuster*/)5520{5521	Reset();5522	m_eMoveType = AI_OPERATION_MOVETYPE_STATIC; // this operation will only work when the units are already in place5523	m_iID = iID;5524	m_eOwner = eOwner;5525	m_eEnemy = eEnemy;55265527	if(iID != -1)5528	{5529		// create the armies that are needed and set the state to ARMYAISTATE_WAITING_FOR_UNITS_TO_REINFORCE5530		CvPlayer& kPlayer = GET_PLAYER(m_eOwner);5531		CvArmyAI* pArmyAI = kPlayer.addArmyAI();5532		if(pArmyAI)5533		{5534			m_viArmyIDs.push_back(pArmyAI->GetID());5535			pArmyAI->Init(pArmyAI->GetID(), m_eOwner, m_iID);5536			pArmyAI->SetArmyAIState(ARMYAISTATE_WAITING_FOR_UNITS_TO_REINFORCE);5537			pArmyAI->SetFormationIndex(GetFormation());55385539			// Figure out the target spot5540			CvPlot* pTargetPlot = FindBestTarget();5541			if(pTargetPlot != NULL)5542			{5543				SetTargetPlot(pTargetPlot);5544				pArmyAI->SetGoalPlot(pTargetPlot);5545				// Find the list of units we need to build before starting this operation in earnest5546				BuildListOfUnitsWeStillNeedToBuild();5547				// try to get as many units as possible from existing units that are waiting around5548				if(GrabUnitsFromTheReserves(GC.getMap().plotCheckInvalid(m_iMusterX, m_iMusterY), pTargetPlot))5549				{5550					pArmyAI->SetArmyAIState(ARMYAISTATE_AT_DESTINATION);5551					m_eCurrentState = AI_OPERATION_STATE_AT_TARGET;5552					LogOperationStart();5553					ArmyInPosition(pArmyAI);5554				}5555				else5556				{5557					// No nukes, abort5558					m_eCurrentState = AI_OPERATION_STATE_ABORTED;5559					m_eAbortReason = AI_ABORT_NO_NUKES;5560				}5561			}55625563			else5564			{5565				// No target, abort5566				m_eCurrentState = AI_OPERATION_STATE_ABORTED;5567				m_eAbortReason = AI_ABORT_LOST_TARGET;5568			}5569		}5570	}5571}

Calls