Bazaar developer reference

CvMinorCivAI::IsValidQuestCopyForPlayer(PlayerTypes, CvMinorCivQuest *)

Defined in
CvMinorCivAI.cpp, line 4506
Class
CvMinorCivAI
Hook name
CivHooks::CvMinorCivAI_IsValidQuestCopyForPlayer
Lua events
GameEvents.QuestIsAvailable

Hooks

static bool BeforeCvMinorCivAI_IsValidQuestCopyForPlayer(CvMinorCivAI* self, PlayerTypes ePlayer, CvMinorCivQuest* pQuest, bool& result);static void AfterCvMinorCivAI_IsValidQuestCopyForPlayer(CvMinorCivAI* self, PlayerTypes ePlayer, CvMinorCivQuest* pQuest, bool& result);static bool ReplaceCvMinorCivAI_IsValidQuestCopyForPlayer(bool (*original)(CvMinorCivAI*, PlayerTypes, CvMinorCivQuest*), CvMinorCivAI* self, PlayerTypes ePlayer, CvMinorCivQuest* pQuest);CivRegisterBefore<CivHooks::CvMinorCivAI_IsValidQuestCopyForPlayer>(host, &BeforeCvMinorCivAI_IsValidQuestCopyForPlayer);CivRegisterAfter<CivHooks::CvMinorCivAI_IsValidQuestCopyForPlayer>(host, &AfterCvMinorCivAI_IsValidQuestCopyForPlayer);CivRegisterReplace<CivHooks::CvMinorCivAI_IsValidQuestCopyForPlayer>(host, &ReplaceCvMinorCivAI_IsValidQuestCopyForPlayer);

Code

4505/// Can we give a copy of pQuest to ePlayer (ie. late join to global quest)?4506bool CvMinorCivAI::IsValidQuestCopyForPlayer(PlayerTypes ePlayer, CvMinorCivQuest* pQuest)4507{4508	if(!pQuest)4509	{4510		CvAssertMsg(false, "Checking validity of copying an existing quest, but pQuest is NULL. Please send Anton your save file and version.");4511		return false;4512	}45134514	MinorCivQuestTypes eQuestType = pQuest->GetType();45154516	// The quest type must be enabled4517	if(!IsEnabledQuest(eQuestType))4518		return false;45194520	// Somebody's dead, that's no good4521	if(!GET_PLAYER(ePlayer).isAlive() || !GetPlayer()->isAlive())4522		return false;45234524	// No quests are valid if we are at war4525	if(IsAtWarWithPlayersTeam(ePlayer))4526		return false;45274528	// antonjs: todo: dehackify4529	if(!IsHasMetPlayer(ePlayer) && !GET_TEAM(GET_PLAYER(ePlayer).getTeam()).isHasMet(GET_TEAM(GetPlayer()->getTeam()).GetID()))4530		return false;45314532	// This player cannot already have an active quest of the same type4533	if(IsActiveQuestForPlayer(ePlayer, eQuestType))4534		return false;45354536	// Both players must have a capital4537	CvCity* pMinorsCapital = GetPlayer()->getCapitalCity();4538	CvCity* pMajorsCapital = GET_PLAYER(ePlayer).getCapitalCity();4539	if(pMinorsCapital == NULL || pMajorsCapital == NULL)4540		return false;45414542#if defined(MOD_EVENTS_QUESTS)4543	if (pQuest->UseEvents() && !pQuest->IsInternal()) {4544		if (GAMEEVENTINVOKE_TESTANY(GAMEEVENT_QuestIsAvailable, ePlayer, GetPlayer()->GetID(), eQuestType, false, pQuest->GetPrimaryData(), pQuest->GetSecondaryData()) == GAMEEVENTRETURN_TRUE) {4545			return true;4546		}4547		4548		return false;4549	} else {4550#endif4551	// KILL A CAMP - Is the camp in the existing quest still around?4552	if(eQuestType == MINOR_CIV_QUEST_KILL_CAMP)4553	{4554		int iCampX = pQuest->GetPrimaryData();4555		int iCampY = pQuest->GetSecondaryData();4556		CvPlot* pPlot = GC.getMap().plot(iCampX, iCampY);4557		if(!pPlot)4558			return false;4559		if(pPlot->getImprovementType() != GC.getBARBARIAN_CAMP_IMPROVEMENT())4560			return false;4561	}4562	// CONTEST CULTURE4563	else if(eQuestType == MINOR_CIV_QUEST_CONTEST_CULTURE)4564	{4565	}4566	// CONTEST FAITH4567	else if(eQuestType == MINOR_CIV_QUEST_CONTEST_FAITH)4568	{4569	}4570	// CONTEST TECHS4571	else if(eQuestType == MINOR_CIV_QUEST_CONTEST_TECHS)4572	{4573	}4574	// Invest4575	else if(eQuestType == MINOR_CIV_QUEST_INVEST)4576	{4577		// This player must not have bullied us recently4578		if(IsRecentlyBulliedByMajor(ePlayer))4579			return false;4580	}4581	// Personal quests - This should not be done, just create a new quest from scratch!!4582	else4583	{4584		CvAssertMsg(false, "Checking validity of copying a personal quest using existing quest data.  This should not be done.  Please send Anton your save file and version.");4585		return IsValidQuestForPlayer(ePlayer, eQuestType);4586	}4587#if defined(MOD_EVENTS_QUESTS)4588	}4589#endif45904591	return true;4592}

Calls

Called by