CvUnit::GetReverseGreatGeneralModifier() const
- Defined in
- CvUnit.cpp, line 18781
- Class
- CvUnit
- Hook name
CivHooks::CvUnit_GetReverseGreatGeneralModifier
Hooks
static bool BeforeCvUnit_GetReverseGreatGeneralModifier(const CvUnit* self, int& result);static void AfterCvUnit_GetReverseGreatGeneralModifier(const CvUnit* self, int& result);static int ReplaceCvUnit_GetReverseGreatGeneralModifier(int (*original)(const CvUnit*), const CvUnit* self);CivRegisterBefore<CivHooks::CvUnit_GetReverseGreatGeneralModifier>(host, &BeforeCvUnit_GetReverseGreatGeneralModifier);CivRegisterAfter<CivHooks::CvUnit_GetReverseGreatGeneralModifier>(host, &AfterCvUnit_GetReverseGreatGeneralModifier);CivRegisterReplace<CivHooks::CvUnit_GetReverseGreatGeneralModifier>(host, &ReplaceCvUnit_GetReverseGreatGeneralModifier);
Code
18781int CvUnit::GetReverseGreatGeneralModifier()const18782{18783 VALIDATE_OBJECT1878418785#if defined(MOD_PROMOTIONS_AURA_CHANGE)18786 int iGreatGeneralRange = /*2*/ GC.getGREAT_GENERAL_MAX_RANGE();18787#else18788 int iGreatGeneralRange = /*2*/ GC.getGREAT_GENERAL_RANGE();18789#endif1879018791 CvPlot* pLoopPlot;18792 IDInfo* pUnitNode;18793 CvUnit* pLoopUnit;18794 18795#if defined(MOD_BUGFIX_MINOR)18796 int iMaxMod = 0;18797#endif1879818799 // Look around this Unit to see if there's a Great General nearby18800 for(int iX = -iGreatGeneralRange; iX <= iGreatGeneralRange; iX++)18801 {18802 for(int iY = -iGreatGeneralRange; iY <= iGreatGeneralRange; iY++)18803 {18804 pLoopPlot = plotXYWithRangeCheck(getX(), getY(), iX, iY, iGreatGeneralRange);1880518806 if(pLoopPlot != NULL)18807 {18808 // If there are Units here, loop through them18809 if(pLoopPlot->getNumUnits() > 0)18810 {18811 pUnitNode = pLoopPlot->headUnitNode();1881218813 while(pUnitNode != NULL)18814 {18815 pLoopUnit = ::getUnit(*pUnitNode);18816 pUnitNode = pLoopPlot->nextUnitNode(pUnitNode);1881718818 // Owned by an enemy18819 if(pLoopUnit && GET_TEAM(getTeam()).isAtWar(pLoopUnit->getTeam()))18820 {18821 // Unit with a combat modifier against the enemy18822 int iMod = pLoopUnit->getNearbyEnemyCombatMod();18823 if(iMod != 0)18824 {18825 // Same domain18826 if(pLoopUnit->getDomainType() == getDomainType())18827 {18828 // Within range?18829 int iRange = pLoopUnit->getNearbyEnemyCombatRange();18830 if(plotDistance(getX(), getY(), pLoopPlot->getX(), pLoopPlot->getY()) <= iRange)18831 {18832#if defined(MOD_BUGFIX_MINOR)18833 // Don't assume the first one found is the worst!18834 // Combat modifiers are negative, as applied against the defender (and not for the attacker)18835 if (iMod < iMaxMod) {18836 iMaxMod = iMod;18837 }18838#else18839 return iMod;18840#endif18841 }18842 }18843 }18844 }18845 }18846 }18847 }18848 }18849 }1885018851#if defined(MOD_BUGFIX_MINOR)18852 return iMaxMod;18853#else18854 return 0;18855#endif18856}
Calls
- CvGlobals::getGREAT_GENERAL_MAX_RANGE()
- CvPlot::getNumUnits() const
- CvPlot::getX() const
- CvPlot::getY() const
- CvPlot::headUnitNode()
- CvPlot::nextUnitNode(IDInfo *)
- CvTeam::getTeam(TeamTypes)
- CvTeam::isAtWar(TeamTypes) const
- CvUnit::getDomainType() const
- CvUnit::getNearbyEnemyCombatMod() const
- CvUnit::getNearbyEnemyCombatRange() const
- CvUnit::getTeam() const
- CvUnit::getX() const
- CvUnit::getY() const
- getUnit(const IDInfo &)
- plotDistance(int, int, int, int)
- plotXYWithRangeCheck(int, int, int, int, int)