Create a Custom Quest Condition
v4.0
Last updated
v4.0
Last updated
It is not difficult to create custom Quest Condition scripts. Often your game will have unique mechanics, and you may wish to include those in condition comparisons.
Read on to learn more about the anatomy of a Quest Condition Inspector, or visit the pages below to create the required scripts, and then code your first custom Quest Condition.
Each Quest Condition may have a different inspector. I've created custom Inspectors for each of the Quest Conditions that ship with Game Modules, however custom Inspectors are not required -- they're just a convenience and look prettier.
We will be looking at the BlackboardValueNumber
condition.
This is a "BlackBoardValueNumber
" QuestCondition
, which I've named "Gold is 100 or More". The top portion is the custom Inspector, while the bottom portion is the default Inspector. Both accomplish the same thing, and have the same fields exposed.
If you create custom Quest Conditions, you can create custom Inspectors, or not -- entirely up to you. If you do choose to create custom Inspectors, you can follow the same pattern explained here.
There are three scripts that make up a fully formed Quest Condition which can be viewed in the Editor with a custom Inspector. See full details about creating your own on the pages nested in this section.
The BlackboardValueNumber
class inherits from QuestCondition
. This is the class which performs the actual comparison evaluation. The derived class has the opportunity to override a number of methods on the base class, and are required to have their own version of ConditionMet()
.
The BlackboardValueNumberEditor
class inherits from QuestConditionEditor
, and is the script which tells Unity to draw a custom Inspector when the BlackboardValueNumber
object is being viewed.
It overrides the CreateDrawer()
method, and nothing else. While it does not seem like much, it is required for displaying the custom Inspector.
Finally the BlackboardValueNumberDrawer
class inherits from QuestConditionDrawer
. This is the class which does the actual drawing of the custom Inspector.
This is using the static class InfinityPBR.InfinityEditor
, which you can also use to make your own custom Inspectors.