Hooks
static bool BeforeCvTacticalAI_PlotPillageMoves(CvTacticalAI* self, AITacticalTargetType eTarget, bool bFirstPass);static void AfterCvTacticalAI_PlotPillageMoves(CvTacticalAI* self, AITacticalTargetType eTarget, bool bFirstPass);static void ReplaceCvTacticalAI_PlotPillageMoves(void (*original)(CvTacticalAI*, AITacticalTargetType, bool), CvTacticalAI* self, AITacticalTargetType eTarget, bool bFirstPass);CivRegisterBefore<CivHooks::CvTacticalAI_PlotPillageMoves>(host, &BeforeCvTacticalAI_PlotPillageMoves);CivRegisterAfter<CivHooks::CvTacticalAI_PlotPillageMoves>(host, &AfterCvTacticalAI_PlotPillageMoves);CivRegisterReplace<CivHooks::CvTacticalAI_PlotPillageMoves>(host, &ReplaceCvTacticalAI_PlotPillageMoves);
Code
2736/// Assigns units to pillage enemy improvements2737void CvTacticalAI::PlotPillageMoves(AITacticalTargetType eTarget, bool bFirstPass)2738{2739 int iPillageHeal = GC.getPILLAGE_HEAL_AMOUNT();27402741 CvString szTargetName = "";2742 if(GC.getLogging() && GC.getAILogging())2743 {2744 if (eTarget == AI_TACTICAL_TARGET_CITADEL)2745 {2746 szTargetName = "Citadel";2747 }2748 else if (eTarget == AI_TACTICAL_TARGET_IMPROVEMENT_RESOURCE)2749 {2750 szTargetName = "Improved Resource";2751 }2752 else2753 {2754 szTargetName = "Improvement";2755 }2756 }27572758 CvTacticalTarget* pTarget;2759 pTarget = GetFirstZoneTarget(eTarget);2760 while(pTarget != NULL)2761 {2762 // See what units we have who can reach target this turn2763 CvPlot* pPlot = GC.getMap().plot(pTarget->GetTargetX(), pTarget->GetTargetY());27642765 // try paratroopers first, not because they are more effective, just because it looks cooler...2766 if (bFirstPass && FindParatroopersWithinStrikingDistance(pPlot))2767 {2768 // Queue best one up to capture it2769 ExecuteParadropPillage(pPlot);27702771 if(GC.getLogging() && GC.getAILogging())2772 {2773 CvString strLogString;2774 strLogString.Format("Paratrooping in to pillage %s, X: %d, Y: %d", szTargetName.GetCString(), pTarget->GetTargetX(), pTarget->GetTargetY());2775 LogTacticalMessage(strLogString);2776 }27772778 }27792780 else if (bFirstPass && FindUnitsWithinStrikingDistance(pPlot, 0, iPillageHeal, false /* bNoRangedUnits */, false /*bNavalOnly*/, true /*bMustMoveThrough*/, false /*bIncludeBlockedUnits*/, true /*bWillPillage*/))2781 {2782 // Queue best one up to capture it2783 ExecutePillage(pPlot);27842785 if(GC.getLogging() && GC.getAILogging())2786 {2787 CvString strLogString;2788 strLogString.Format("Pillaging %s, X: %d, Y: %d", szTargetName.GetCString(), pTarget->GetTargetX(), pTarget->GetTargetY());2789 LogTacticalMessage(strLogString);2790 }2791 }27922793 // No one can reach it this turn, what about next turn?2794 else if(!bFirstPass && FindUnitsWithinStrikingDistance(pPlot, 2, iPillageHeal, false /* bNoRangedUnits */, false /*bNavalOnly*/, false /*bMustMoveThrough*/, false /*bIncludeBlockedUnits*/, true /*bWillPillage*/))2795 {2796 ExecuteMoveToTarget(pPlot);27972798 if(GC.getLogging() && GC.getAILogging())2799 {2800 CvString strLogString;2801 strLogString.Format("Moving toward %s for pillage, X: %d, Y: %d", szTargetName.GetCString(), pTarget->GetTargetX(), pTarget->GetTargetY());2802 LogTacticalMessage(strLogString);2803 }2804 }28052806 pTarget = GetNextZoneTarget();2807 }2808}