Bazaar developer reference

CvMinorCivAI::DoTestStartPersonalQuest(PlayerTypes)

Defined in
CvMinorCivAI.cpp, line 3689
Class
CvMinorCivAI
Hook name
CivHooks::CvMinorCivAI_DoTestStartPersonalQuest

Hooks

static bool BeforeCvMinorCivAI_DoTestStartPersonalQuest(CvMinorCivAI* self, PlayerTypes ePlayer);static void AfterCvMinorCivAI_DoTestStartPersonalQuest(CvMinorCivAI* self, PlayerTypes ePlayer);static void ReplaceCvMinorCivAI_DoTestStartPersonalQuest(void (*original)(CvMinorCivAI*, PlayerTypes), CvMinorCivAI* self, PlayerTypes ePlayer);CivRegisterBefore<CivHooks::CvMinorCivAI_DoTestStartPersonalQuest>(host, &BeforeCvMinorCivAI_DoTestStartPersonalQuest);CivRegisterAfter<CivHooks::CvMinorCivAI_DoTestStartPersonalQuest>(host, &AfterCvMinorCivAI_DoTestStartPersonalQuest);CivRegisterReplace<CivHooks::CvMinorCivAI_DoTestStartPersonalQuest>(host, &ReplaceCvMinorCivAI_DoTestStartPersonalQuest);

Code

3688/// See if it is time to start a personal quest for this player3689void CvMinorCivAI::DoTestStartPersonalQuest(PlayerTypes ePlayer)3690{3691	CvAssertMsg(ePlayer >= 0, "ePlayer is expected to be non-negative (invalid Index)");3692	CvAssertMsg(ePlayer < MAX_MAJOR_CIVS, "ePlayer is expected to be within maximum bounds (invalid Index)");36933694	// Can't start a new quest too quickly after an old one has ended3695	if(GetQuestCountdownForPlayer(ePlayer) > 0)3696	{3697		return;3698	}36993700	// Can't start a new quest if we already have several active ones3701	if(GetNumActivePersonalQuestsForPlayer(ePlayer) >= GetMaxActivePersonalQuestsForPlayer())3702	{3703		return;3704	}37053706#if defined(MOD_EVENTS_QUESTS)3707	FStaticVector<MinorCivQuestTypes, NUM_MINOR_CIV_QUEST_TYPES, false, c_eCiv5GameplayDLL, 0> veValidQuests; // will grow size if needed3708#else3709	FStaticVector<MinorCivQuestTypes, NUM_MINOR_CIV_QUEST_TYPES, true, c_eCiv5GameplayDLL, 0> veValidQuests;3710#endif37113712	int iCount, iCountLoop;37133714	MinorCivQuestTypes eQuest;3715#if defined(MOD_EVENTS_QUESTS)3716	for(int iQuestLoop = 0; iQuestLoop < GC.getNumQuestInfos(); iQuestLoop++)3717#else3718	for(int iQuestLoop = 0; iQuestLoop < NUM_MINOR_CIV_QUEST_TYPES; iQuestLoop++)3719#endif3720	{3721		eQuest = (MinorCivQuestTypes) iQuestLoop;37223723		if(IsValidQuestForPlayer(ePlayer, eQuest) && IsPersonalQuest(eQuest))3724		{3725			// What is the bias for this player wanting this particular quest? Queue up multiple copies (default is 10)3726			iCount = GetPersonalityQuestBias(eQuest);37273728			for(iCountLoop = 0; iCountLoop < iCount; iCountLoop++)3729			{3730				veValidQuests.push_back(eQuest);3731			}3732		}3733	}37343735	// No valid Quests3736	if(veValidQuests.size() == 0)3737	{3738		return;3739	}37403741	int iRandIndex = GC.getGame().getJonRandNum(veValidQuests.size(), "Picking random quest for Minor to give to a player.");3742	eQuest = veValidQuests[iRandIndex];37433744	AddQuestForPlayer(ePlayer, eQuest, GC.getGame().getGameTurn());37453746	// Check if we need to seed the countdown timer to allow for another quest3747	DoTestSeedQuestCountdownForPlayer(ePlayer);3748}

Calls

Called by