CvTeam::canDeclareWar(TeamTypes, PlayerTypes) const
- Defined in
- CvTeam.cpp, line 1025
- Class
- CvTeam
- Hook name
CivHooks::CvTeam_canDeclareWar- Lua events
GameEvents.IsAbleToDeclareWar,GameEvents.PlayerCanDeclareWar,GameEvents.CanDeclareWar
Hooks
static bool BeforeCvTeam_canDeclareWar(const CvTeam* self, TeamTypes eTeam, PlayerTypes eOriginatingPlayer, bool& result);static void AfterCvTeam_canDeclareWar(const CvTeam* self, TeamTypes eTeam, PlayerTypes eOriginatingPlayer, bool& result);static bool ReplaceCvTeam_canDeclareWar(bool (*original)(const CvTeam*, TeamTypes, PlayerTypes), const CvTeam* self, TeamTypes eTeam, PlayerTypes eOriginatingPlayer);CivRegisterBefore<CivHooks::CvTeam_canDeclareWar>(host, &BeforeCvTeam_canDeclareWar);CivRegisterAfter<CivHooks::CvTeam_canDeclareWar>(host, &AfterCvTeam_canDeclareWar);CivRegisterReplace<CivHooks::CvTeam_canDeclareWar>(host, &ReplaceCvTeam_canDeclareWar);
Code
1024#if defined(MOD_EVENTS_WAR_AND_PEACE)1025bool CvTeam::canDeclareWar(TeamTypes eTeam, PlayerTypes eOriginatingPlayer) const1026#else1027bool CvTeam::canDeclareWar(TeamTypes eTeam) const1028#endif1029{1030 if(eTeam == GetID())1031 {1032 return false;1033 }10341035 if(!(isAlive()) || !(GET_TEAM(eTeam).isAlive()))1036 {1037 return false;1038 }10391040 if(isAtWar(eTeam))1041 {1042 return false;1043 }10441045 if(!isHasMet(eTeam))1046 {1047 return false;1048 }10491050 if(isForcePeace(eTeam))1051 {1052 return false;1053 }10541055 if(!canChangeWarPeace(eTeam))1056 {1057 return false;1058 }10591060 if(GC.getGame().isOption(GAMEOPTION_ALWAYS_PEACE))1061 {1062 return false;1063 }10641065#if defined(MOD_EVENTS_WAR_AND_PEACE)1066 if (MOD_EVENTS_WAR_AND_PEACE) {1067 if (GAMEEVENTINVOKE_TESTALL(GAMEEVENT_IsAbleToDeclareWar, eOriginatingPlayer, eTeam) == GAMEEVENTRETURN_FALSE) {1068 return false;1069 }10701071 if (GAMEEVENTINVOKE_TESTALL(GAMEEVENT_PlayerCanDeclareWar, eOriginatingPlayer, eTeam) == GAMEEVENTRETURN_FALSE) {1072 return false;1073 }1074 }1075#endif10761077 // First, obtain the Lua script system.1078 ICvEngineScriptSystem1* pkScriptSystem = gDLL->GetScriptSystem();1079 if(pkScriptSystem)1080 {1081 // Construct and push in some event arguments.1082 CvLuaArgsHandle args(2);1083 args->Push(GetID());1084 args->Push(eTeam);10851086 // Attempt to execute the game events.1087 // Will return false if there are no registered listeners.1088 bool bResult = false;1089 if(LuaSupport::CallTestAll(pkScriptSystem, "CanDeclareWar", args.get(), bResult))1090 {1091 // Check the result.1092 if(bResult == false)1093 {1094 return false;1095 }1096 }1097 }10981099 return true;1100}
Calls
- CustomMods::eventTestAll(const char *, const char *, ...)
- CustomMods::isEVENTS_WAR_AND_PEACE()
- CvGame::isOption(GameOptionTypes) const
- CvGlobals::getDLLIFace()
- CvGlobals::getGame()
- CvLuaArgsHandle::CvLuaArgsHandle(uint)
- CvLuaArgsHandle::get() const
- CvLuaArgsHandle::operator->() const
- CvTeam::canChangeWarPeace(TeamTypes) const
- CvTeam::GetID() const
- CvTeam::getTeam(TeamTypes)
- CvTeam::isAlive() const
- CvTeam::isAtWar(TeamTypes) const
- CvTeam::isForcePeace(TeamTypes) const
- CvTeam::isHasMet(TeamTypes) const
ICvEngineScriptSystemArgs1::PushICvEngineUtility1::GetScriptSystem- LuaSupport::CallTestAll(ICvEngineScriptSystem1 *, const char *, ICvEngineScriptSystemArgs1 *, bool &)
Called by
- CvDeal::IsPossibleToTradeItem(PlayerTypes, PlayerTypes, TradeableItems, int, int, int, bool, bool, bool)
- CvDiplomacyAI::DoAggressiveMilitaryStatement(PlayerTypes, DiploStatementTypes &)
- CvDiplomacyAI::DoMakeWarOnPlayer(PlayerTypes)
- CvDiplomacyAI::DoStartDemandProcess(PlayerTypes)
- CvDiplomacyAI::DoUpdateOnePlayerExpansionAggressivePosture(PlayerTypes)
- CvDiplomacyAI::GetBestApproachTowardsMajorCiv(PlayerTypes, int &, bool, bool, WarFaceTypes &)
- CvDiplomacyAI::GetBestApproachTowardsMinorCiv(PlayerTypes, int &, bool, bool)
- CvDiplomacyAI::GetCoopWarScore(PlayerTypes, PlayerTypes, bool)
- PUF_canDeclareWar(const CvUnit *, int, int)
- CvUnit::GetDeclareWarMove(const CvPlot &) const
- CvUnit::GetDeclareWarRangeStrike(const CvPlot &) const
- CvUnit::canMoveInto(const CvPlot &, byte) const
- CvUnit::canNukeAt(const CvPlot *, int, int) const
- CvUnit::canRangeStrikeAt(int, int, bool, bool) const
- CvLuaTeam::lCanDeclareWar(lua_State *)