Hooks
static bool BeforeCvAIEnemyTerritoryOperation_SelectInitialMusterPoint(CvAIEnemyTerritoryOperation* self, CvArmyAI* pThisArmy, CvPlot*& result);static void AfterCvAIEnemyTerritoryOperation_SelectInitialMusterPoint(CvAIEnemyTerritoryOperation* self, CvArmyAI* pThisArmy, CvPlot*& result);static CvPlot* ReplaceCvAIEnemyTerritoryOperation_SelectInitialMusterPoint(CvPlot* (*original)(CvAIEnemyTerritoryOperation*, CvArmyAI*), CvAIEnemyTerritoryOperation* self, CvArmyAI* pThisArmy);CivRegisterBefore<CivHooks::CvAIEnemyTerritoryOperation_SelectInitialMusterPoint>(host, &BeforeCvAIEnemyTerritoryOperation_SelectInitialMusterPoint);CivRegisterAfter<CivHooks::CvAIEnemyTerritoryOperation_SelectInitialMusterPoint>(host, &AfterCvAIEnemyTerritoryOperation_SelectInitialMusterPoint);CivRegisterReplace<CivHooks::CvAIEnemyTerritoryOperation_SelectInitialMusterPoint>(host, &ReplaceCvAIEnemyTerritoryOperation_SelectInitialMusterPoint);
Code
1964/// Figure out the initial rally point1965CvPlot* CvAIEnemyTerritoryOperation::SelectInitialMusterPoint(CvArmyAI* pThisArmy)1966{1967 CvPlot* pMusterPt = NULL;1968 CvPlot* pStartCityPlot;1969 CvCity* pStartCity;1970 CvPlot* pCurrentPlot;1971 int iSpacesFromTarget = 0;1972 CvPlot* pDeployPlot = NULL;1973 int iDangerousPlots = 0;19741975 pStartCity = GetOperationStartCity();1976 if(pStartCity)1977 {1978 pStartCityPlot = pStartCity->plot();19791980 if(pStartCityPlot != NULL)1981 {1982 // Different areas? If so, just muster at start city1983 if (pStartCityPlot->getArea() != pThisArmy->GetGoalPlot()->getArea())1984 {1985 SetMusterPlot(pStartCityPlot);1986 return pStartCityPlot;1987 }19881989 CvAStarNode* pNode;19901991 // Generate path1992 GC.getStepFinder().SetData(&m_eEnemy);1993 if(GC.getStepFinder().GeneratePath(pStartCityPlot->getX(), pStartCityPlot->getY(), pThisArmy->GetGoalPlot()->getX(), pThisArmy->GetGoalPlot()->getY(), m_eOwner, false))1994 {1995 pNode = GC.getStepFinder().GetLastNode();19961997 // Starting at the end, loop until we find a plot from this owner1998 while(pNode != NULL)1999 {2000 pCurrentPlot = GC.getMap().plotCheckInvalid(pNode->m_iX, pNode->m_iY);20012002 // Is this the deploy point?2003 if(iSpacesFromTarget == GetDeployRange())2004 {2005 pDeployPlot = pCurrentPlot;2006 }20072008 // Check and see if this plot has the right owner2009 if(pCurrentPlot->getOwner() == GetOwner())2010 {2011 pMusterPt = pCurrentPlot;2012 break;2013 }20142015 else2016 {2017 // Is this a dangerous plot?2018 if(GET_PLAYER(m_eOwner).GetPlotDanger(*pCurrentPlot) > 0)2019 {2020 iDangerousPlots++;2021 }2022 }20232024 // Move to the previous plot on the path2025 iSpacesFromTarget++;2026 pNode = pNode->m_pParent;2027 }20282029 // Is the path safe? If so, let's just muster at the deploy point2030 if(iSpacesFromTarget > 0 && (iDangerousPlots * 100 / iSpacesFromTarget) < GC.getAI_OPERATIONAL_PERCENT_DANGER_FOR_FORWARD_MUSTER())2031 {2032 if(pDeployPlot)2033 {2034 pMusterPt = pDeployPlot;2035 }2036 }2037 }2038 }2039 }20402041 if(pMusterPt != NULL)2042 {2043 SetMusterPlot(pMusterPt);2044 }2045 else2046 {2047 if(GC.getLogging() && GC.getAILogging())2048 {2049 CvString szMsg;2050 szMsg.Format("No muster point found, Operation aborting, Target was, X: %d, Y: %d", pThisArmy->GetGoalPlot()->getX(), pThisArmy->GetGoalPlot()->getY());2051 LogOperationSpecialMessage(szMsg);2052 }2053 }20542055 return pMusterPt;2056}