Documentation

__ Modular Quests

Documentation

__ Modular Quests

Implementation

1 - Initialization

1.1 - Call init function

Firstly, call "Init Modular Quest System" function from the default subsystem (you can also create your Own Subsystem), at the begin play for exemple, but you'll need to give a reference to your save, so make sure to init save before. Returns true if system has been initialized properly.

1.2 - Be careful

⚠️You'll need to use the same subsystem as the one you initialized.


2 - Use your own savegame object

2.1 - Add Interface

Add Interface "ModularQuestsInterface" to your savegame object.

2.2 - Override save function

Double click on "Save Quest" function to implement it (this is a function from the BPI).

2.3 - Promote to variable

Right click on SaveData -> "Promote to Variable" (this is the variable where quests data will be stored).

2.4 - Override load function

Double click on "Load Quests" function to implement it.

2.5 - Use quest's variable

Use the promoted variable of quest saves as return value.

 

Quests

1 - How to create a quest

1.1 - Create a Primary Quest

Right click in content browser, select Modular Quests -> Primary Quest.

1.2 - Select quest class

Choose your base class for this quest. You can create your Own Quest Type or use basic one.

1.3 - Quest Name & Description

Optional, can be used for widget or something else.

 

1.4 - Quest steps

Each Steps of your quest. You can use default one or create yours if you need more accessibility (like doing something on step initialization, on tick, ...).

4 Events available:

  • Initialize: Called when step starts.
  • Tick: Called each "TickInterval" (or each tick if TickInterval <= 0). Not Called if disabled.
  • Success: Called when step succeeded.
  • Reset: Called when FailAction ResetStep is used.

1.5 - Quest rewards

Each Rewards of you quest. Given when whole quest in completed.

1 Event available:

  • Handle Reward: Called when reward should be given. Write your own logic here.

2 - Unlock Quest & Events

2.1 - Unlock Quest

Returns true if unlocked, false otherwiser. Fails if quest is already unlocked.

2.2 - On Quest Unlocked

Triggers when a new quest is unlocked. Returns quest's Data Asset reference.

2.3 - On Quest Fail

Triggers when FailQuest (Fail Action) is called, or when Fail Quest is called. Returns quest's Data Asset reference.

 

2.4 - On Quest Step Finished

Triggers when a step has been validated (with validation objective or with auto validation). Returns quest's Data Asset reference and the index of the validated step.

2.5 - On Quest Finished

Triggers when all steps of the quest are validated. Returns quest's Data Asset reference.


3 - Functions

3.1 - Getters

Getter functions used to get quest infos entered in the Quest.

3.2 - Helpers

"Get Step at Index" is basically a get array from getter "Get Quest Steps", but it's more... compact.

Quest Type

How to create your own Quest Type

1 - Create a Quest Type

Right click in content browser, select Modular Quests -> Quest Type.

2 - Do your stuff

You can now implement your logic. Event Initialize is called when quest is unlocked.

3 - Your Quest Type as Primary Quest Class

You can now select your new Quest Type as Primary Quest Class!

 

Steps

1 - How to create & use a quest step

1.1 - Create Step

Right click in content browser, select Modular Quests -> Step.

1.2 - Do your stuff

You can now implement your logic.

  • Initialize: Called when step starts.
  • Tick: Called each "TickInterval" (or each tick if TickInterval <= 0). Not Called if disabled.
  • Success: Called when step succeeded.
  • Reset: Called when FailAction ResetStep is used.

1.3 - Select Step Type

By default, Modular Quests Step is selected. You can use it if you don't need custom logic inside step.

1.4 - Custom variables

Any variable you created inside your custom Step Type will be displayed here. You can override its defaults on each steps.

1.5 - Step Name & Description

Optional, can be used for widget or something else.

1.6 - Tick interval

If checked, Event Tick will triggers each "Tick Interval" or each tick if Tick Interval <= 0.

If unchecked, Tick will not triggers.

1.7 - Step Objectives

Each Objectives of your quest.

Required Objectives Count to Validate Step:

  • If enabled, the step will validate as soon as the required objectives and at least 'count' objectives are completed (any objectives, including required ones).
  • If disabled, the step will validate only when all required objectives are completed (Optional objectives can be done too, but this is not necessary).

4 Events available:

  • Initialize: Called when step starts.
  • Tick: Called each "TickInterval" (or each tick if TickInterval <= 0). Not Called if disabled.
  • Success: Called when objective succeeded (when SetIsSuccess is called to true).
  • Cancel: Only used for Validation Objective. Will not triggers in Step Objectives.

 

1.8 - Validation Objective

Same as Objectives. If checked, selected Validation Objective will be used for step validation. Auto validates instead.

4 Events available:

  • Initialize: Called when validation starts.
  • Tick: Called each "TickInterval" (or each tick if TickInterval <= 0). Not Called if disabled.
  • Success: Called when SetIsSuccess is called to true.
  • Cancel: Called only in Validation Objective when one of base objectives is set to "false Success" while running.

 

1.9 - Step Rewards

Each Rewards of this step. Given when this step in completed.

1 Event available:

  • Handle Reward: Called when reward should be given. Write your own logic here.

 

1.10 - Fail Actions

Each Fail Actions of this step. Triggered when this step fails (when FailStep is called).

1 Event available:

  • Handle Fail Action: Called when step fails. Write your own logic here.

2 - Functions

2.1 - Getters

Getter functions used to get step infos entered in the Quest.

2.2 - Helpers

Returns the size of corresponding array.

Objectives

1 - How to create & use a step objective

1.1 - Create Step

Right click in content browser, select Modular Quests -> Step.

1.2 - Do your stuff

You can now implement your logic. Call SetIsSuccess to update objective success state.

  • Initialize: Called when objective starts (or when validation starts for Validation Objective).
  • Tick: Called each "TickInterval" (or each tick if TickInterval <= 0). Not Called if disabled.
  • Success: Called when objective succeeded (when SetIsSuccess is called to true).
  • Cancel: Only used for Validation Objective. Called when one of base objectives is set to "false Success" while running.

1.3 - System functions

Main function is SetIsSuccess. You must call it so the system can handle step validation.

  • Set Is Success: Sets the objective state to Succeeded. When all objectives are succeeded, step will handle step validation.
  • Fail Step: Fails Current Step Immediately.
  • Set Progress Count: Updates ProgressCount variable (optional, but this count is saved in SaveGameObject).
  • Add Progress Count: Adds "Count" value to ProgressCount.

 💡For exemple, you can test on the tick if GetPlayerCharacter->GetActorLocation is nearly equal to a custom vector variable with an interval specified on a custom float variable. Call SetIsSuccess to the value of this test. Inside Primary Quest, you can use this objective module multiple times in differents steps (and/or different quests) with different values!

And tadaa! This objective will succeeded when your player reach specified position!

1.4 - Select Objective Type

You can use your objectives Types in Step Objectives aswell as Validation Objective.


1.5 - Custom variables

Any variable you created inside your Objective Type will be displayed here. You can override its defaults on each objectives.


1.6 - Objective Name & Description

Optional, can be used for widget or something else.

 


1.7 - Tick interval

If checked, Event Tick will triggers each "Tick Interval" or each tick if Tick Interval <= 0.

If unchecked, Tick will not triggers.


2 - Getters

Getter functions used to get objective infos entered in the Primary Quest or get the current objective progress count.

Rewards

1 - How to create & use a quest reward

1.1 - Create Reward

Right click in content browser, select Modular Quests -> Reward.

1.2 - Do your stuff

You can now implement your logic.

  • Event Handle Reward: Called when Quest or Step is succeeded (dependent of where this reward is used).

1.3 - Select Reward Type

Can be used for Quest rewards as well as Step rewards.

1.4 - Custom variables

Any variable you created inside your custom Reward Type will be displayed here. You can override its defaults on each rewards.

Fail Actions

1 - How to create & use a quest Fail Action

1.1 - Create Reward

Right click in content browser, select Modular Quests -> Fail Action.

1.2 - Do your stuff

You can now implement your logic.

  • Event Handle Fail Action: Called when step fails. Write your own logic here.

1.3 - Select Reward Type

Action called when step fails. There are 2 pre-created fail actions:

  • Reset Step: The step will restart from 0 (objectives are reset).
  • Fail Quest: The entire quest is failed, it is removed from the ActiveQuests and you'll have to unlock it again.

1.4 - Custom variables

Any variable you created inside your custom Fail Action Type will be displayed here. You can override its defaults on each fail action.

Quest Subsystem

How to create your own Quest Subsystem

1 - Create a Quest Subsystem

Right click in content browser, select Modular Quests -> Quest Subsystem.

2 - Events

You have many events that will help you realize your desires.

3 - Accessibility

You can now access the subsystem from anywhere.

4 - Function

You can also get your subsystem by class like so. Output pin type will autmatically match input class pin.