Bazaar developer reference

CvTacticalAnalysisMap::SetTargetFlankBonusCells(CvPlot *)

Defined in
CvTacticalAnalysisMap.cpp, line 432
Class
CvTacticalAnalysisMap
Hook name
CivHooks::CvTacticalAnalysisMap_SetTargetFlankBonusCells

Hooks

static bool BeforeCvTacticalAnalysisMap_SetTargetFlankBonusCells(CvTacticalAnalysisMap* self, CvPlot* pTarget);static void AfterCvTacticalAnalysisMap_SetTargetFlankBonusCells(CvTacticalAnalysisMap* self, CvPlot* pTarget);static void ReplaceCvTacticalAnalysisMap_SetTargetFlankBonusCells(void (*original)(CvTacticalAnalysisMap*, CvPlot*), CvTacticalAnalysisMap* self, CvPlot* pTarget);CivRegisterBefore<CivHooks::CvTacticalAnalysisMap_SetTargetFlankBonusCells>(host, &BeforeCvTacticalAnalysisMap_SetTargetFlankBonusCells);CivRegisterAfter<CivHooks::CvTacticalAnalysisMap_SetTargetFlankBonusCells>(host, &AfterCvTacticalAnalysisMap_SetTargetFlankBonusCells);CivRegisterReplace<CivHooks::CvTacticalAnalysisMap_SetTargetFlankBonusCells>(host, &ReplaceCvTacticalAnalysisMap_SetTargetFlankBonusCells);

Code

431// Mark cells we can use to bomb a specific target432void CvTacticalAnalysisMap::SetTargetFlankBonusCells(CvPlot* pTarget)433{434	CvPlot* pLoopPlot;435	int iPlotIndex;436437	// No flank attacks on units at sea (where all combat is bombards)438	if(pTarget->isWater())439	{440		return;441	}442443	for(int iI = 0; iI < NUM_DIRECTION_TYPES; iI++)444	{445		pLoopPlot = plotDirection(pTarget->getX(), pTarget->getY(), ((DirectionTypes)iI));446		if(pLoopPlot != NULL)447		{448			iPlotIndex = GC.getMap().plotNum(pLoopPlot->getX(), pLoopPlot->getY());449			if(m_pPlots[iPlotIndex].IsRevealed() && !m_pPlots[iPlotIndex].IsImpassableTerrain() && !m_pPlots[iPlotIndex].IsImpassableTerritory())450			{451				if(!m_pPlots[iPlotIndex].IsFriendlyCity() && !m_pPlots[iPlotIndex].IsEnemyCity() && !m_pPlots[iPlotIndex].IsNeutralCity())452				{453					if(!m_pPlots[iPlotIndex].IsFriendlyTurnEndTile() && m_pPlots[iPlotIndex].GetEnemyMilitaryUnit() == NULL)454					{455						m_pPlots[iPlotIndex].SetHelpsProvidesFlankBonus(true);456					}457				}458			}459		}460	}461}

Calls

Called by