---
description: v4.0
---

# Create a Custom Quest Condition

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.

{% content-ref url="create-a-custom-quest-condition/your-quest-condition" %}
[your-quest-condition](create-a-custom-quest-condition/your-quest-condition)
{% endcontent-ref %}

{% content-ref url="create-a-custom-quest-condition/your-quest-condition-editor" %}
[your-quest-condition-editor](create-a-custom-quest-condition/your-quest-condition-editor)
{% endcontent-ref %}

{% content-ref url="create-a-custom-quest-condition/your-quest-condition-drawer" %}
[your-quest-condition-drawer](create-a-custom-quest-condition/your-quest-condition-drawer)
{% endcontent-ref %}

## Anatomy of a Quest Condition Inspector

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.

<figure><img src="https://2431624982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MY3N_li2jPq7az6mYfq%2Fuploads%2F2omnXCeKCEUkGyLdmrpf%2FScreenshot%202023-06-25%20at%2010.07.57%20AM.png?alt=media&#x26;token=f2134663-5d08-4dff-ab32-2bfcd94df5a8" alt=""><figcaption></figcaption></figure>

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.

{% hint style="info" %}
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.
{% endhint %}

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.

### Class which inherits from QuestCondition

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()`.

```csharp
// Each derived class is required to have this method
public abstract bool ConditionMet(BlackboardNote blackboardNote);

// These can be overridden
public virtual bool ConditionMet<T>(QuestStep questStep, T obj)
public virtual void SaveCurrentValue(GameQuest gameQuest, QuestStep questStep)
public virtual float TrueValue()
public virtual void CompleteQuest()
```

### Editor Class

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.

```csharp
protected override QuestConditionDrawer CreateDrawer()
{
    questConditionDrawer = ScriptableObject.CreateInstance<BlackboardValueNumberDrawer>();
    return questConditionDrawer;
}
```

### Drawer Class

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.

<pre class="language-csharp"><code class="lang-csharp">public override bool CanHandle(QuestCondition questCondition) 
<strong>    => questCondition is BlackboardValueNumber;
</strong>        
protected override void ShowSpecificData(QuestCondition questCondition) 
    => ShowData(questCondition as BlackboardValueNumber);
{
<strong>    // Draw Stuff....
</strong>}
</code></pre>
