Bazaar developer reference

CvTacticalAI::PlotPlunderTradeUnitMoves(DomainTypes)

Defined in
CvTacticalAI.cpp, line 2879
Class
CvTacticalAI
Hook name
CivHooks::CvTacticalAI_PlotPlunderTradeUnitMoves

Hooks

static bool BeforeCvTacticalAI_PlotPlunderTradeUnitMoves(CvTacticalAI* self, DomainTypes eDomain);static void AfterCvTacticalAI_PlotPlunderTradeUnitMoves(CvTacticalAI* self, DomainTypes eDomain);static void ReplaceCvTacticalAI_PlotPlunderTradeUnitMoves(void (*original)(CvTacticalAI*, DomainTypes), CvTacticalAI* self, DomainTypes eDomain);CivRegisterBefore<CivHooks::CvTacticalAI_PlotPlunderTradeUnitMoves>(host, &BeforeCvTacticalAI_PlotPlunderTradeUnitMoves);CivRegisterAfter<CivHooks::CvTacticalAI_PlotPlunderTradeUnitMoves>(host, &AfterCvTacticalAI_PlotPlunderTradeUnitMoves);CivRegisterReplace<CivHooks::CvTacticalAI_PlotPlunderTradeUnitMoves>(host, &ReplaceCvTacticalAI_PlotPlunderTradeUnitMoves);

Code

2878/// Assigns units to plunder trade units it sees 2879void CvTacticalAI::PlotPlunderTradeUnitMoves (DomainTypes eDomain)2880{2881	AITacticalTargetType eTargetType = AI_TACTICAL_TARGET_NONE;2882	bool bNavalOnly = false;2883	if (eDomain == DOMAIN_LAND)2884	{2885		eTargetType = AI_TACTICAL_TARGET_TRADE_UNIT_LAND;2886	}2887	else if (eDomain == DOMAIN_SEA)2888	{2889		eTargetType = AI_TACTICAL_TARGET_TRADE_UNIT_SEA;2890		bNavalOnly = true;2891	}28922893	CvAssertMsg(eTargetType != AI_TACTICAL_TARGET_NONE, "Undefined domain type for target");2894	if (eTargetType == AI_TACTICAL_TARGET_NONE)2895	{2896		return;2897	}28982899	CvTacticalTarget* pTarget;2900	pTarget = GetFirstZoneTarget(eTargetType);2901	while(pTarget != NULL)2902	{2903		// See what units we have who can reach target this turn2904		CvPlot* pPlot = GC.getMap().plot(pTarget->GetTargetX(), pTarget->GetTargetY());29052906		if (FindUnitsWithinStrikingDistance(pPlot, 0, 0, false /* bNoRangedUnits */, bNavalOnly, true /*bMustMoveThrough*/, false /*bIncludeBlockedUnits*/, false /*bWillPillage*/))2907		{2908			// Queue best one up to capture it2909			ExecutePlunderTradeUnit(pPlot);29102911			if(GC.getLogging() && GC.getAILogging())2912			{2913				CvString strLogString;2914				strLogString.Format("Plundering trade unit, X: %d, Y: %d", pTarget->GetTargetX(), pTarget->GetTargetY());2915				LogTacticalMessage(strLogString);2916			}2917		}29182919		pTarget = GetNextZoneTarget();2920	}2921}

Calls

Called by