Skip to content

[Modding] Advanced quest events and features

Steve edited this page Oct 13, 2023 · 6 revisions

The following methods can be used in your missions init.c to fire custom-coded events in different quest event scenarios:

class CustomMission: MissionServer
{
#ifdef EXPANSIONMODQUESTS
	//! Event called when a player connects/reconnects to the server and the quest system and his quests are initialized for the player.
	override void Expansion_OnQuestPlayerInit(ExpansionQuestPersistentData playerQuestData, PlayerIdentity identity) {}

	//! Condition check method if given player identity can start the quest with the given configuration.
	override bool Expansion_CanStartQuest(ExpansionQuestConfig questConfig, PlayerIdentity identity)
	{
		bool condition = super.Expansion_CanStartQuest(questConfig, identity);
		return condition;
	}

	//! Condition check method if given player identity can complete the given quest instance.
	override bool Expansion_CanCompleteQuest(ExpansionQuest quest, PlayerIdentity identity) {}

	//! Event method that gets called when a quest is started.
	override void Expansion_OnQuestStart(ExpansionQuest quest) {}
	
	//! Event method that gets called when a quest is continued.
	override void Expansion_OnQuestContinue(ExpansionQuest quest) {}
	
	//! Event method that gets called when a quest objective timer runs out.
	override void Expansion_OnObjectiveTimeLimitReached(ExpansionQuestObjectiveEventBase objectiveEventBase) {}
	
	//! Event method that gets called when a quest gets cancled by the player or quest system.
	override void Expansion_OnQuestCancel(ExpansionQuest quest) {}
	
	//! Event method that gets called when all quest objectives of a quest are completed.
	override void Expansion_OnQuestObjectivesComplete(ExpansionQuest quest) {}
	
	//! Event method that gets called when one quest objective of a quest gets incompleted and all quest objective where completed once.
	override void Expansion_OnQuestObjectivesIncomplete(ExpansionQuest quest) {}
	
	//! Event method called when a quest is completed (turned-in).
	override void Expansion_OnQuestCompletion(ExpansionQuest quest)
	{
		super.Expansion_OnQuestCompletion(quest);
	}
#endif
};

Create/delete and check temporary quest NPCs:

//! Create new temporary quest NPC data
//! ID, NPC class name, NPC name, and default quest menu text that is shown to the player.
ExpansionTempQuestHolder questHolder = new ExpansionTempQuestHolder(4000, "ExpansionQuestNPCAIFrida", "Marina Sidorova", "There is nothing to do here for you...");
if (!questHolder)
	return;

questHolder.SetNPCEmoteID(EmoteConstants.ID_EMOTE_SITA); //! Emote ID of the NPC if it is an AI. 
questHolder.SetLoadoutName("SurvivorLoadout"); //! Loadout file name that gets applied to the NPC if it is a normal or AI NPC.
ExpansionTempQuestHolderPosition questHolderPos = new ExpansionTempQuestHolderPosition("9029.09 9.36924 10112.8", "55.5735 0 -0"); //! World position and orientation of the NPC when spawned.
ExpansionQuestModule.GetModuleInstance().SpawnQuestHolder(questHolder, questHolderPos); //! Spawn the temporary quest NPC.
//! Delete an existing temporary quest NPC if it exists.
//! Need the temporary quest NPC ID and NPC type integer to find and delete the entity.
ExpansionQuestModule.GetModuleInstance().DeleteQuestHolder(4000, ExpansionQuestNPCType.AI);
//! Check if a temporary quest NPC with the given ID has already been spawned.
ExpansionQuestModule.GetModuleInstance().TempQuestHolderExists(4000)

Advanced useful quest methods:

ExpansionQuest quest;
//! Condition check if any other quest with the given quests ID is active for other players.
//! Returns true if an other active quest instance with the same quest ID is found.
ExpansionQuestModule.GetModuleInstance().IsOtherQuestInstanceActive(quest);
Clone this wiki locally