Hooks
static bool BeforeCvUnit_GetDeclareWarMove(const CvUnit* self, const CvPlot& plot, TeamTypes& result);static void AfterCvUnit_GetDeclareWarMove(const CvUnit* self, const CvPlot& plot, TeamTypes& result);static TeamTypes ReplaceCvUnit_GetDeclareWarMove(TeamTypes (*original)(const CvUnit*, const CvPlot&), const CvUnit* self, const CvPlot& plot);CivRegisterBefore<CivHooks::CvUnit_GetDeclareWarMove>(host, &BeforeCvUnit_GetDeclareWarMove);CivRegisterAfter<CivHooks::CvUnit_GetDeclareWarMove>(host, &AfterCvUnit_GetDeclareWarMove);CivRegisterReplace<CivHooks::CvUnit_GetDeclareWarMove>(host, &ReplaceCvUnit_GetDeclareWarMove);
Code
2922/// Returns the ID of the team to declare war against2923TeamTypes CvUnit::GetDeclareWarMove(const CvPlot& plot) const2924{2925 VALIDATE_OBJECT2926 const CvUnit* pUnit;2927 TeamTypes eRevealedTeam;29282929 CvAssert(isHuman());29302931 if(getDomainType() != DOMAIN_AIR)2932 {2933 eRevealedTeam = plot.getRevealedTeam(getTeam(), false);29342935 if(eRevealedTeam != NO_TEAM)2936 {2937 if(!GET_TEAM(eRevealedTeam).isMinorCiv() || plot.isCity())2938 {2939 if(!canEnterTerritory(eRevealedTeam, false /*bIgnoreRightOfPassage*/, plot.isCity(), true))2940 {2941#if defined(MOD_EVENTS_WAR_AND_PEACE)2942 if(GET_TEAM(getTeam()).canDeclareWar(plot.getTeam(), getOwner()))2943#else2944 if(GET_TEAM(getTeam()).canDeclareWar(plot.getTeam()))2945#endif2946 {2947 return eRevealedTeam;2948 }2949 }2950 }2951 }29522953 if(plot.isActiveVisible(false))2954 {2955 if(canMoveInto(plot, MOVEFLAG_ATTACK | MOVEFLAG_DECLARE_WAR | MOVEFLAG_PRETEND_CORRECT_EMBARK_STATE))2956 {2957 pUnit = plot.plotCheck(PUF_canDeclareWar, getOwner(), isAlwaysHostile(plot), NO_PLAYER, NO_TEAM, PUF_isVisible, getOwner());29582959 if(pUnit != NULL)2960 {2961 return pUnit->getTeam();2962 }2963 }2964 }2965 }29662967 return NO_TEAM;2968}