Bazaar developer reference

CvTacticalAI::ScoreHedgehogPlots(CvPlot *)

Defined in
CvTacticalAI.cpp, line 11279
Class
CvTacticalAI
Hook name
CivHooks::CvTacticalAI_ScoreHedgehogPlots

Hooks

static bool BeforeCvTacticalAI_ScoreHedgehogPlots(CvTacticalAI* self, CvPlot* pTarget);static void AfterCvTacticalAI_ScoreHedgehogPlots(CvTacticalAI* self, CvPlot* pTarget);static void ReplaceCvTacticalAI_ScoreHedgehogPlots(void (*original)(CvTacticalAI*, CvPlot*), CvTacticalAI* self, CvPlot* pTarget);CivRegisterBefore<CivHooks::CvTacticalAI_ScoreHedgehogPlots>(host, &BeforeCvTacticalAI_ScoreHedgehogPlots);CivRegisterAfter<CivHooks::CvTacticalAI_ScoreHedgehogPlots>(host, &AfterCvTacticalAI_ScoreHedgehogPlots);CivRegisterReplace<CivHooks::CvTacticalAI_ScoreHedgehogPlots>(host, &ReplaceCvTacticalAI_ScoreHedgehogPlots);

Code

11278/// Pick best hexes for defending a friendly city. Returns false if insufficient free plots.11279void CvTacticalAI::ScoreHedgehogPlots(CvPlot* pTarget)11280{11281	int iScore;11282	CvPlot* pPlot;11283	CvTacticalAnalysisCell* pCell;11284	bool bChoiceBombardSpot;11285	bool bSafeFromAttack;11286	CvTacticalTarget target;1128711288	// We'll store the hexes we've found here11289	m_TempTargets.clear();1129011291#if defined(MOD_GLOBAL_CITY_WORKING)11292	for(int jJ = 0; jJ < AVG_CITY_PLOTS; jJ++)11293#else11294	for(int jJ = 0; jJ < NUM_CITY_PLOTS; jJ++)11295#endif11296	{11297		pPlot = plotCity(pTarget->getX(), pTarget->getY(), jJ);1129811299		if(pPlot != NULL)11300		{11301			bChoiceBombardSpot = false;11302			bSafeFromAttack = true;1130311304			int iPlotDistance = plotDistance(pPlot->getX(), pPlot->getY(), pTarget->getX(), pTarget->getY());11305			int iPlotIndex = GC.getMap().plotNum(pPlot->getX(), pPlot->getY());11306			pCell = m_pMap->GetCell(iPlotIndex);1130711308			if(pCell->CanUseForOperationGatheringCheckWater(false /*bWater*/))11309			{11310				iScore = 600 - (iPlotDistance * 150);1131111312				if(pCell->IsSubjectToAttack())11313				{11314					iScore += 100;11315					bSafeFromAttack = false;11316				}11317				if(pCell->IsEnemyCanMovePast())11318				{11319					iScore += 50;11320				}11321				if(pPlot->isCity() && pPlot->getOwner() == m_pPlayer->GetID())11322				{11323					iScore += 100;11324				}11325				else11326				{11327					iScore += pCell->GetDefenseModifier() * 4;11328				}1132911330				pCell->SetSafeForDeployment(bSafeFromAttack);11331				pCell->SetDeploymentScore(iScore);1133211333				// Save this in our list of potential targets11334				target.SetTargetX(pPlot->getX());11335				target.SetTargetY(pPlot->getY());11336				target.SetAuxIntData(iScore);1133711338				// A bit of a hack -- use high priority targets to indicate good plots for ranged units11339				if(bSafeFromAttack)11340				{11341					target.SetTargetType(AI_TACTICAL_TARGET_HIGH_PRIORITY_UNIT);11342				}11343				else11344				{11345					target.SetTargetType(AI_TACTICAL_TARGET_LOW_PRIORITY_UNIT);11346				}1134711348				m_TempTargets.push_back(target);11349			}11350		}11351	}11352}

Calls

Called by