Code
3610/// See if it is time to start a global (multiple player) quest3611void CvMinorCivAI::DoTestStartGlobalQuest()3612{3613 if(GetGlobalQuestCountdown() > 0)3614 {3615 return;3616 }36173618 if(GetNumActiveGlobalQuests() >= GetMaxActiveGlobalQuests())3619 {3620 return;3621 }36223623 // Pick a valid quest3624#if defined(MOD_EVENTS_QUESTS)3625 FStaticVector<MinorCivQuestTypes, NUM_MINOR_CIV_QUEST_TYPES, false, c_eCiv5GameplayDLL, 0> veValidQuests; // will grow size if needed3626#else3627 FStaticVector<MinorCivQuestTypes, NUM_MINOR_CIV_QUEST_TYPES, true, c_eCiv5GameplayDLL, 0> veValidQuests;3628#endif3629 MinorCivQuestTypes eQuest;3630 PlayerTypes ePlayer;3631#if defined(MOD_EVENTS_QUESTS)3632 for(int iQuestLoop = 0; iQuestLoop < GC.getNumQuestInfos(); iQuestLoop++)3633#else3634 for(int iQuestLoop = 0; iQuestLoop < NUM_MINOR_CIV_QUEST_TYPES; iQuestLoop++)3635#endif3636 {3637 eQuest = (MinorCivQuestTypes) iQuestLoop;3638 if(IsEnabledQuest(eQuest))3639 {3640 if(IsGlobalQuest(eQuest))3641 {3642 // Are there enough players for this quest to be given out?3643 int iNumValidPlayers = 0;3644 for(int iPlayerLoop = 0; iPlayerLoop < MAX_MAJOR_CIVS; iPlayerLoop++)3645 {3646 ePlayer = (PlayerTypes) iPlayerLoop;3647 if(IsValidQuestForPlayer(ePlayer, eQuest))3648 iNumValidPlayers++;3649 }3650 if(iNumValidPlayers < GetMinPlayersNeededForQuest(eQuest))3651 continue;36523653 // What is the bias for this minor favoring this particular quest? Queue up multiple copies (default is 10)3654 int iCount = GetPersonalityQuestBias(eQuest);3655 for(int iCountLoop = 0; iCountLoop < iCount; iCountLoop++)3656 {3657 veValidQuests.push_back(eQuest);3658 }3659 }3660 }3661 }36623663 // No valid quests3664 if(veValidQuests.size() == 0)3665 {3666 return;3667 }36683669 // There are valid quests, so pick one at random3670 int iRandIndex = GC.getGame().getJonRandNum(veValidQuests.size(), "Picking random global quest for Minor to give to players.");3671 eQuest = veValidQuests[iRandIndex];36723673 // Give out the quest3674 for(int iPlayerLoop = 0; iPlayerLoop < MAX_MAJOR_CIVS; iPlayerLoop++)3675 {3676 ePlayer = (PlayerTypes) iPlayerLoop;3677 if(IsValidQuestForPlayer(ePlayer, eQuest))3678 {3679 // Since we are adding each instance of the quest separately, global quests should not rely on random choice of data3680 AddQuestForPlayer(ePlayer, eQuest, GC.getGame().getGameTurn());3681 }3682 }36833684 // Check if we need to seed the countdown timer to allow for another quest3685 DoTestSeedGlobalQuestCountdown();3686}