Hooks
static bool BeforeCvGameReligions_FoundPantheon(CvGameReligions* self, PlayerTypes ePlayer, BeliefTypes eBelief);static void AfterCvGameReligions_FoundPantheon(CvGameReligions* self, PlayerTypes ePlayer, BeliefTypes eBelief);static void ReplaceCvGameReligions_FoundPantheon(void (*original)(CvGameReligions*, PlayerTypes, BeliefTypes), CvGameReligions* self, PlayerTypes ePlayer, BeliefTypes eBelief);CivRegisterBefore<CivHooks::CvGameReligions_FoundPantheon>(host, &BeforeCvGameReligions_FoundPantheon);CivRegisterAfter<CivHooks::CvGameReligions_FoundPantheon>(host, &AfterCvGameReligions_FoundPantheon);CivRegisterReplace<CivHooks::CvGameReligions_FoundPantheon>(host, &ReplaceCvGameReligions_FoundPantheon);
Code
899/// Tell the game a new pantheon has been created900void CvGameReligions::FoundPantheon(PlayerTypes ePlayer, BeliefTypes eBelief)901{902 CvGame& kGame = GC.getGame();903 CvPlayer& kPlayer = GET_PLAYER(ePlayer);904905 CvReligion newReligion(RELIGION_PANTHEON, ePlayer, NULL, true);906 newReligion.m_Beliefs.AddBelief(eBelief);907908 // Found it909 m_CurrentReligions.push_back(newReligion);910911#if defined(MOD_TRAITS_OTHER_PREREQS)912 if (MOD_TRAITS_OTHER_PREREQS) {913 // Update our traits (some may have become obsolete)914 kPlayer.GetPlayerTraits()->Reset();915 kPlayer.GetPlayerTraits()->InitPlayerTraits();916 kPlayer.recomputePolicyCostModifier();917 }918#endif919920 // Update game systems921 kPlayer.UpdateReligion();922 kPlayer.ChangeFaith(-GetMinimumFaithNextPantheon());923924 int iIncrement = GC.getRELIGION_GAME_FAITH_DELTA_NEXT_PANTHEON();925 iIncrement *= GC.getGame().getGameSpeedInfo().getTrainPercent();926 iIncrement /= 100;927 SetMinimumFaithNextPantheon(GetMinimumFaithNextPantheon() + iIncrement);928929#if defined(MOD_EVENTS_FOUND_RELIGION)930 if (MOD_EVENTS_FOUND_RELIGION) {931 GAMEEVENTINVOKE_HOOK(GAMEEVENT_PantheonFounded, ePlayer, GET_PLAYER(ePlayer).getCapitalCity()->GetID(), RELIGION_PANTHEON, eBelief);932 } else {933#endif934 ICvEngineScriptSystem1* pkScriptSystem = gDLL->GetScriptSystem();935 if(pkScriptSystem) 936 {937 CvLuaArgsHandle args;938 args->Push(ePlayer);939 args->Push(GET_PLAYER(ePlayer).getCapitalCity()->GetID());940 args->Push(RELIGION_PANTHEON);941 args->Push(eBelief);942943 bool bResult;944 LuaSupport::CallHook(pkScriptSystem, "PantheonFounded", args.get(), bResult);945 }946#if defined(MOD_EVENTS_FOUND_RELIGION)947 }948#endif949950 // Spread the pantheon into each of their cities951 int iLoop;952 CvCity* pLoopCity;953 for(pLoopCity = kPlayer.firstCity(&iLoop); pLoopCity != NULL; pLoopCity = kPlayer.nextCity(&iLoop))954 {955 // Add enough pressure to make this the likely majority religion956 pLoopCity->GetCityReligions()->AddReligiousPressure(FOLLOWER_CHANGE_PANTHEON_FOUNDED, newReligion.m_eReligion, GC.getRELIGION_ATHEISM_PRESSURE_PER_POP() * pLoopCity->getPopulation() * 2);957 }958959 // Send out messaging960 CvReligionEntry* pEntry = GC.getReligionInfo(newReligion.m_eReligion);961 CvBeliefEntry* pBelief = GC.getBeliefInfo(eBelief);962 if(pEntry && pBelief)963 {964 //Add replay message.965 Localization::String strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_PANTHEON_FOUNDED_S");966 Localization::String replayText = Localization::Lookup("TXT_KEY_NOTIFICATION_PANTHEON_FOUNDED");967 replayText << kPlayer.getCivilizationShortDescriptionKey() << pBelief->getShortDescription() << pBelief->GetDescriptionKey();968969 kGame.addReplayMessage(REPLAY_MESSAGE_PANTHEON_FOUNDED, newReligion.m_eFounder, replayText.toUTF8());970971 for(int iNotifyLoop = 0; iNotifyLoop < MAX_MAJOR_CIVS; ++iNotifyLoop){972 PlayerTypes eNotifyPlayer = (PlayerTypes) iNotifyLoop;973 CvPlayerAI& kCurNotifyPlayer = GET_PLAYER(eNotifyPlayer);974 CvNotifications* pNotifications = kCurNotifyPlayer.GetNotifications();975 if(pNotifications){976 // Message slightly different for founder player977 if(newReligion.m_eFounder == eNotifyPlayer)978 {979 Localization::String localizedText = GetLocalizedText("TXT_KEY_NOTIFICATION_PANTHEON_FOUNDED_ACTIVE_PLAYER");980 localizedText << pBelief->getShortDescription() << pBelief->GetDescriptionKey();981982#if defined(MOD_API_EXTENSIONS)983 pNotifications->Add(NOTIFICATION_PANTHEON_FOUNDED_ACTIVE_PLAYER, localizedText.toUTF8(), strSummary.toUTF8(), -1, -1, RELIGION_PANTHEON, -1);984#else985 pNotifications->Add(NOTIFICATION_PANTHEON_FOUNDED_ACTIVE_PLAYER, localizedText.toUTF8(), strSummary.toUTF8(), -1, -1, -1);986#endif987 }988 else989 {990 //If the notify player has not met this civ yet, display a more ambiguous notification.991 CvTeam& kTeam = GET_TEAM(kCurNotifyPlayer.getTeam());992 if(kTeam.isHasMet(kPlayer.getTeam()))993 {994#if defined(MOD_API_EXTENSIONS)995 pNotifications->Add(NOTIFICATION_PANTHEON_FOUNDED, replayText.toUTF8(), strSummary.toUTF8(), -1, -1, RELIGION_PANTHEON, -1);996#else997 pNotifications->Add(NOTIFICATION_PANTHEON_FOUNDED, replayText.toUTF8(), strSummary.toUTF8(), -1, -1, -1);998#endif999 }1000 else1001 {1002 Localization::String unknownFoundedText = Localization::Lookup("TXT_KEY_NOTIFICATION_PANTHEON_FOUNDED_UNKNOWN");1003 unknownFoundedText << pBelief->getShortDescription() << pBelief->GetDescriptionKey();10041005#if defined(MOD_API_EXTENSIONS)1006 pNotifications->Add(NOTIFICATION_PANTHEON_FOUNDED, unknownFoundedText.toUTF8(), strSummary.toUTF8(), -1, -1, RELIGION_PANTHEON, -1);1007#else1008 pNotifications->Add(NOTIFICATION_PANTHEON_FOUNDED, unknownFoundedText.toUTF8(), strSummary.toUTF8(), -1, -1, -1);1009#endif1010 }1011 }1012 }1013 }10141015 // Logging1016 if(GC.getLogging())1017 {1018 CvString strLogMsg;1019 strLogMsg = kPlayer.getCivilizationShortDescription();1020 strLogMsg += ", PANTHEON FOUNDED, ";1021 strLogMsg += pEntry->GetDescription();1022 LogReligionMessage(strLogMsg);1023 }10241025#if !defined(NO_ACHIEVEMENTS)1026 //Achievements!1027 if(ePlayer == GC.getGame().getActivePlayer())1028 {1029 gDLL->UnlockAchievement(ACHIEVEMENT_XP1_10);1030 }1031#endif1032 }10331034 GC.GetEngineUserInterface()->setDirty(CityInfo_DIRTY_BIT, true);1035}