Bazaar developer reference

CvTacticalAI::QueueAttack(void *, CvTacticalTarget *, bool, bool)

Defined in
CvTacticalAI.cpp, line 538
Class
CvTacticalAI
Hook name
CivHooks::CvTacticalAI_QueueAttack

Hooks

static bool BeforeCvTacticalAI_QueueAttack(CvTacticalAI* self, void* pAttacker, CvTacticalTarget* pTarget, bool bRanged, bool bCityAttack, bool& result);static void AfterCvTacticalAI_QueueAttack(CvTacticalAI* self, void* pAttacker, CvTacticalTarget* pTarget, bool bRanged, bool bCityAttack, bool& result);static bool ReplaceCvTacticalAI_QueueAttack(bool (*original)(CvTacticalAI*, void*, CvTacticalTarget*, bool, bool), CvTacticalAI* self, void* pAttacker, CvTacticalTarget* pTarget, bool bRanged, bool bCityAttack);CivRegisterBefore<CivHooks::CvTacticalAI_QueueAttack>(host, &BeforeCvTacticalAI_QueueAttack);CivRegisterAfter<CivHooks::CvTacticalAI_QueueAttack>(host, &AfterCvTacticalAI_QueueAttack);CivRegisterReplace<CivHooks::CvTacticalAI_QueueAttack>(host, &ReplaceCvTacticalAI_QueueAttack);

Code

537/// Queue up the attack - return TRUE if first attack on this target538bool CvTacticalAI::QueueAttack(void* pAttacker, CvTacticalTarget* pTarget, bool bRanged, bool bCityAttack)539{540	bool bRtnValue = true;541	CvQueuedAttack attack;542	int iSeriesID;543	CvPlot* pTargetPlot = GC.getMap().plot(pTarget->GetTargetX(), pTarget->GetTargetY());544	CvPlot* pFromPlot;545546	// Can we find this target in the queue, if so what is its series ID547	int iTempSeriesID = PlotAlreadyTargeted(pTargetPlot);548549	if(iTempSeriesID == -1)550	{551		m_iCurrentSeriesID++;552		iSeriesID = m_iCurrentSeriesID;553	}554	else555	{556		iSeriesID = iTempSeriesID;557		bRtnValue = false;558	}559560	attack.SetAttacker(pAttacker);561	attack.SetTarget(pTarget);562	attack.SetSeriesID(iSeriesID);563	attack.SetRanged(bRanged);564	attack.SetCityAttack(bCityAttack);565	m_QueuedAttacks.push_back(attack);566567	if(GC.getLogging() && GC.getAILogging())568	{569		CvString strMsg;570		CvString strTemp;571		if(bCityAttack)572		{573			strTemp = ((CvCity*)pAttacker)->getName();574			pFromPlot = ((CvCity*)pAttacker)->plot();575		}576		else577		{578			CvUnit* pkAttackingUnit = static_cast<CvUnit*>(pAttacker);579			strTemp = pkAttackingUnit->getUnitInfo().GetDescription();580			pFromPlot = ((CvUnit*)pAttacker)->plot();581		}582		strMsg.Format("Queued attack with %s, To X: %d, To Y: %d, From X: %d, From Y: %d", strTemp.GetCString(), pTarget->GetTargetX(), pTarget->GetTargetY(), pFromPlot->getX(), pFromPlot->getY());583		LogTacticalMessage(strMsg);584	}585586	return bRtnValue;587}

Calls

Called by