Quest Steps
v4.0
Quest Steps, at runtime, will live on GameQuest
objects: GameQuest.questSteps
While they can be set up to run automatically, in many cases, you may wish to manually process the status, or otherwise make use of the QuestStep.cs
class.
Check For Completion
The CheckForCompletion()
method will return true
(and do nothing else) if the QuestStep
has already been completed (success or failure), and can not revert.
Otherwise, it will first run the CheckForSuccess()
method. If that returns true
, meaning we just now marked the QuestStep
successful, then the method will also return true
.
Otherwise, it will then run the CheckForFailure()
method. Again, if that returns true
, meaning we just now marked the QuestStep
as failed, then the method will return true
.
Otherwise, it will return false
.
Example
The code below first calls CheckForCompletion()
only if the quest is currently "In Progress", which will actively try to complete the quest based on the Quest Conditions. If it does, we call one method if the status is now "Succeeded", and another if it is not. (i.e. "Failed").
Set Succeeded and Set Failed
Both SetSucceeded()
and SetFailed()
will return
(not do anything) if the status is already set to successful or failed.
Otherwise, they will set the status appropriately, bypassing any QuestConditions
. Each method also has an optional bool
parameter forceCanNotRevert
, which is false
by default. If true, the QuestStep
value for canRevert
will be set false
, meaning that it will not revert back to a previous status. (Unless you manually do that, of course).
These are great methods to use if you'd like to skip the QuestStep
to a finished state, bypassing all of the conditions that are otherwise required.
Set Succeeded or Failed if Not Completed
The SetFailedIfNotCompleted()
and SetSucceededIfNotCompleted()
methods first check if the opposite status is already set, and if the status can't revert, then it will return and do no actions.
If the status can revert, or if the status has not yet been marked as successful / failed, it will CheckForSuccess()
or CheckForFailure()
.
If that check returns false, then SetFailed()
or SetSucceeded()
will be called, failing or succeeding the QuestStep
immediately.
Set Can Revert
Defaulting to true
, you can set the canRevert
value to true
or false
.
Add Custom Rewards
Using AddCustomRewardSuccess()
or AddCustomRewardFailure()
methods, you can pass in a QuestReward
value to be added to the respective custom reward lists. This is a great way to customize quests, perhaps providing specific rewards based on in-game actions or other data.
We use a CustomQuestReward
object in these lists. QuestRewards
can not be serialized, so the CustomQuestReward
, which can be serialized, will store the Uid()
of the rewards, and auto-populate at runtime.
Whenever SetSucceeded()
or SetFailed()
change the status of the quest, the rewards will be given. The QuestStep
will call the GiveQuestStepRewards()
method on the parent GameQuest
object, passing in the lists of rewards and custom rewards.
If canRevert
is true
, the rewards for success or failure may be given multiple times!
Remove Custom Rewards
You can remove rewards from the custom rewards lists with RemoveCustomRewardSuccess()
and RemoveCustomRewardFailure()
and passing in a QuestReward
.
Add Success or Failure Conditions
You can pass a QuestCondition
into AddSuccessCondition()
or AddFailureCondition()
to add those to the respective lists. They will not be added if the condition already exists in the list.
Remove Condition
Passing in a QuestCondition
to RemoveCondition()
will remove it from successConditions
and failureConditions
. Generally it would only be present in one, but the method will attempt to remove it from both lists.
If you'd like to specify which list the QuestCondition
should be removed from, call RemoveSuccessCondition()
or RemoveFailureCondition()
.
Last updated