CvUnit::CanFoundReligion(const CvPlot *) const
- Defined in
- CvUnit.cpp, line 8171
- Class
- CvUnit
- Hook name
CivHooks::CvUnit_CanFoundReligion- Lua events
GameEvents.PlayerCanFoundReligion
Hooks
static bool BeforeCvUnit_CanFoundReligion(const CvUnit* self, const CvPlot* pPlot, bool& result);static void AfterCvUnit_CanFoundReligion(const CvUnit* self, const CvPlot* pPlot, bool& result);static bool ReplaceCvUnit_CanFoundReligion(bool (*original)(const CvUnit*, const CvPlot*), const CvUnit* self, const CvPlot* pPlot);CivRegisterBefore<CivHooks::CvUnit_CanFoundReligion>(host, &BeforeCvUnit_CanFoundReligion);CivRegisterAfter<CivHooks::CvUnit_CanFoundReligion>(host, &AfterCvUnit_CanFoundReligion);CivRegisterReplace<CivHooks::CvUnit_CanFoundReligion>(host, &ReplaceCvUnit_CanFoundReligion);
Code
8171bool CvUnit::CanFoundReligion(const CvPlot* pPlot) const8172{8173 VALIDATE_OBJECT8174 CvCity* pCity;8175 CvGameReligions* pReligions = GC.getGame().GetGameReligions();81768177 pCity = pPlot->getPlotCity();81788179 if(!m_pUnitInfo->IsFoundReligion())8180 {8181 return false;8182 }81838184 if(pCity == NULL)8185 {8186 return false;8187 }81888189 if(GET_PLAYER(getOwner()).GetReligions()->IsFoundingReligion())8190 {8191 return false;8192 }81938194 if(getTeam() != pCity->getTeam())8195 {8196 return false;8197 }81988199 if(GET_TEAM(getTeam()).isMinorCiv())8200 {8201 return false;8202 }82038204 if(isDelayedDeath())8205 {8206 return false;8207 }82088209 if(pReligions->GetNumReligionsStillToFound() <= 0)8210 {8211 return false;8212 }82138214 if(pReligions->HasCreatedReligion(getOwner()))8215 {8216 return false;8217 }82188219#if defined(MOD_EVENTS_FOUND_RELIGION)8220 if (MOD_EVENTS_FOUND_RELIGION ) {8221 if (GAMEEVENTINVOKE_TESTALL(GAMEEVENT_PlayerCanFoundReligion, getOwner(), pCity->GetID()) == GAMEEVENTRETURN_FALSE) {8222 return false;8223 }8224 } else {8225#endif8226 ICvEngineScriptSystem1* pkScriptSystem = gDLL->GetScriptSystem();8227 if (pkScriptSystem) 8228 {8229 CvLuaArgsHandle args;8230 args->Push(getOwner());8231 args->Push(pCity->GetID());82328233 // Attempt to execute the game events.8234 // Will return false if there are no registered listeners.8235 bool bResult = false;8236 if (LuaSupport::CallTestAll(pkScriptSystem, "PlayerCanFoundReligion", args.get(), bResult))8237 {8238 if (bResult == false) 8239 {8240 return false;8241 }8242 }8243 }8244#if defined(MOD_EVENTS_FOUND_RELIGION)8245 }8246#endif82478248#if defined(MOD_EVENTS_ACQUIRE_BELIEFS)8249 if (pReligions->GetAvailableFounderBeliefs(getOwner(), NO_RELIGION).size() < 1 || pReligions->GetAvailableFollowerBeliefs(getOwner(), NO_RELIGION).size() < 1)8250#else8251 if (pReligions->GetAvailableFounderBeliefs().size() < 1 || pReligions->GetAvailableFollowerBeliefs().size() < 1)8252#endif8253 {8254 return false;8255 }82568257 return true;8258}
Calls
- CustomMods::eventTestAll(const char *, const char *, ...)
- CustomMods::isEVENTS_FOUND_RELIGION()
- CvCity::GetID() const
- CvCity::getTeam() const
- CvGame::GetGameReligions()
- CvGameReligions::GetAvailableFollowerBeliefs(PlayerTypes, ReligionTypes)
- CvGameReligions::GetAvailableFounderBeliefs(PlayerTypes, ReligionTypes)
- CvGameReligions::GetNumReligionsStillToFound(bool) const
- CvGameReligions::HasCreatedReligion(PlayerTypes, bool) const
- CvGlobals::getDLLIFace()
- CvGlobals::getGame()
- CvLuaArgsHandle::CvLuaArgsHandle()
- CvLuaArgsHandle::get() const
- CvLuaArgsHandle::operator->() const
- CvPlayer::GetReligions() const
- CvPlayerAI::getPlayer(PlayerTypes)
- CvPlayerReligions::IsFoundingReligion() const
- CvPlot::getPlotCity() const
- CvTeam::getTeam(TeamTypes)
- CvTeam::isMinorCiv() const
- CvUnit::getOwner() const
- CvUnit::getTeam() const
- CvUnit::isDelayedDeath() const
- CvUnitEntry::IsFoundReligion() const
ICvEngineScriptSystemArgs1::PushICvEngineUtility1::GetScriptSystem- LuaSupport::CallTestAll(ICvEngineScriptSystem1 *, const char *, ICvEngineScriptSystemArgs1 *, bool &)
std::vector::size