Hooks
static bool BeforeCvTacticalAI_PlotGarrisonMoves(CvTacticalAI* self, int iNumTurnsAway, bool bMustAllowRangedAttack);static void AfterCvTacticalAI_PlotGarrisonMoves(CvTacticalAI* self, int iNumTurnsAway, bool bMustAllowRangedAttack);static void ReplaceCvTacticalAI_PlotGarrisonMoves(void (*original)(CvTacticalAI*, int, bool), CvTacticalAI* self, int iNumTurnsAway, bool bMustAllowRangedAttack);CivRegisterBefore<CivHooks::CvTacticalAI_PlotGarrisonMoves>(host, &BeforeCvTacticalAI_PlotGarrisonMoves);CivRegisterAfter<CivHooks::CvTacticalAI_PlotGarrisonMoves>(host, &AfterCvTacticalAI_PlotGarrisonMoves);CivRegisterReplace<CivHooks::CvTacticalAI_PlotGarrisonMoves>(host, &ReplaceCvTacticalAI_PlotGarrisonMoves);
Code
3106/// Make a defensive move to garrison a city3107void CvTacticalAI::PlotGarrisonMoves(int iNumTurnsAway, bool bMustAllowRangedAttack)3108{3109 CvTacticalTarget* pTarget;3110 pTarget = GetFirstZoneTarget(AI_TACTICAL_TARGET_CITY_TO_DEFEND);3111 while(pTarget != NULL)3112 {3113 CvPlot* pPlot = GC.getMap().plot(pTarget->GetTargetX(), pTarget->GetTargetY());3114 CvCity* pCity = pPlot->getPlotCity();31153116 if(pCity && pCity->GetLastTurnGarrisonAssigned() < GC.getGame().getGameTurn())3117 {3118 // Grab units that make sense for this move type3119 FindUnitsForThisMove((TacticalAIMoveTypes)m_CachedInfoTypes[eTACTICAL_GARRISON_ALREADY_THERE], pPlot, iNumTurnsAway, bMustAllowRangedAttack);31203121 if(m_CurrentMoveHighPriorityUnits.size() + m_CurrentMoveUnits.size() > 0)3122 {3123 ExecuteMoveToTarget(pPlot);3124 if(GC.getLogging() && GC.getAILogging())3125 {3126 CvString strLogString;3127 strLogString.Format("Garrison, X: %d, Y: %d, Priority: %d, Turns Away: %d", pTarget->GetTargetX(), pTarget->GetTargetY(), pTarget->GetAuxIntData(), iNumTurnsAway);3128 if(bMustAllowRangedAttack)3129 {3130 strLogString += ", Allows bombard";3131 }3132 LogTacticalMessage(strLogString);3133 }3134 pCity->SetLastTurnGarrisonAssigned(GC.getGame().getGameTurn());3135 }3136 }3137 pTarget = GetNextZoneTarget();3138 }3139}