Bazaar developer reference

CvUnitCombat::AttackNuclear(CvUnit &, int, int, ATTACK_OPTION)

Defined in
CvUnitCombat.cpp, line 3695
Class
CvUnitCombat
Hook name
CivHooks::CvUnitCombat_AttackNuclear

Hooks

static bool BeforeCvUnitCombat_AttackNuclear(CvUnit& kAttacker, int iX, int iY, ATTACK_OPTION arg3, CvUnitCombat::ATTACK_RESULT& result);static void AfterCvUnitCombat_AttackNuclear(CvUnit& kAttacker, int iX, int iY, ATTACK_OPTION arg3, CvUnitCombat::ATTACK_RESULT& result);static CvUnitCombat::ATTACK_RESULT ReplaceCvUnitCombat_AttackNuclear(CvUnitCombat::ATTACK_RESULT (*original)(CvUnit&, int, int, ATTACK_OPTION), CvUnit& kAttacker, int iX, int iY, ATTACK_OPTION arg3);// CivHooks.h gives this hook point no types, so nothing checks these hooks' parameters.host->RegisterHook(host->pluginIndex, CivHooks::CvUnitCombat_AttackNuclear::ID, CIV_HOOK_BEFORE, (void*)&BeforeCvUnitCombat_AttackNuclear);host->RegisterHook(host->pluginIndex, CivHooks::CvUnitCombat_AttackNuclear::ID, CIV_HOOK_AFTER, (void*)&AfterCvUnitCombat_AttackNuclear);host->RegisterHook(host->pluginIndex, CivHooks::CvUnitCombat_AttackNuclear::ID, CIV_HOOK_REPLACE, (void*)&ReplaceCvUnitCombat_AttackNuclear);

Code

3695CvUnitCombat::ATTACK_RESULT CvUnitCombat::AttackNuclear(CvUnit& kAttacker, int iX, int iY, ATTACK_OPTION /* eOption */)3696{3697	ATTACK_RESULT eResult = ATTACK_ABORTED;36983699	CvPlot* pPlot = GC.getMap().plot(iX, iY);3700	if(NULL == pPlot)3701		return eResult;37023703	bool bDoImmediate = CvPreGame::quickCombat();3704	CvCombatInfo kCombatInfo;3705	CvUnitCombat::GenerateNuclearCombatInfo(kAttacker, *pPlot, &kCombatInfo);3706	CvAssertMsg(!kAttacker.isDelayedDeath(), "Trying to battle and the attacker is already dead!");3707	kAttacker.setMadeAttack(true);3708	uint uiParentEventID = 0;3709	if(!bDoImmediate)3710	{3711		// Nuclear attacks are different in that you can target a plot you can't see, so check to see if the active player3712		// is involved in the combat3713		TeamTypes eActiveTeam = GC.getGame().getActiveTeam();37143715		bool isTargetVisibleToActivePlayer = pPlot->isActiveVisible(false);3716		if(!isTargetVisibleToActivePlayer)3717		{3718			// Is the attacker part of the local team?3719			isTargetVisibleToActivePlayer = (kAttacker.getTeam() != NO_TEAM && eActiveTeam == kAttacker.getTeam());37203721			if(!isTargetVisibleToActivePlayer)3722			{3723				// Are any of the teams effected by the blast in the local team?3724				for(int i = 0; i < MAX_TEAMS && !isTargetVisibleToActivePlayer; ++i)3725				{3726					if(kAttacker.isNukeVictim(pPlot, ((TeamTypes)i)))3727					{3728						isTargetVisibleToActivePlayer = eActiveTeam == ((TeamTypes)i);3729					}3730				}3731			}3732		}37333734		if(isTargetVisibleToActivePlayer)3735		{3736			auto_ptr<ICvPlot1> pDllPlot = GC.WrapPlotPointer(pPlot);3737			GC.GetEngineUserInterface()->lookAt(pDllPlot.get(), CAMERALOOKAT_NORMAL);3738		}3739		kCombatInfo.setVisualizeCombat(isTargetVisibleToActivePlayer);37403741		// Set a combat unit/city.  Not really needed for the combat since we are killing everyone, but it is currently the only way a unit is marked that it is 'in-combat'3742		if(pPlot->getPlotCity())3743			kAttacker.setCombatCity(pPlot->getPlotCity());3744		else3745		{3746			if(pPlot->getNumUnits())3747				kAttacker.setCombatUnit(pPlot->getUnitByIndex(0), true);3748			else3749				kAttacker.setAttackPlot(pPlot, false);3750		}37513752		auto_ptr<ICvCombatInfo1> pDllCombatInfo(new CvDllCombatInfo(&kCombatInfo));3753		uiParentEventID = gDLL->GameplayUnitCombat(pDllCombatInfo.get());37543755		eResult = ATTACK_QUEUED;3756	}3757	else3758	{3759		eResult = ATTACK_COMPLETED;3760		// Set the plot, just so the unit is marked as 'in-combat'3761		kAttacker.setAttackPlot(pPlot, false);3762	}37633764	ResolveCombat(kCombatInfo,  uiParentEventID);37653766	return eResult;3767}

Calls

Called by