# Quests

### Quest Object Hierarchy

With Game Modules, the `Quest` is a Scriptable Object which holds all the data about the quest, while the `GameQuest` is the runtime variant that can be serialized, and tracked throughout your game.

Each **Quest** has at least one **Quest Step**, and can have more than one. Each Quest Step has at least one Success **Quest Condition**, but can have more, and can also have one or more Failure **Quest Condition**, though this is optional.

{% hint style="info" %}
Technically, a Quest Step does not need a Success Condition. In that case, you would need to manually mark the Quest Step as complete in your code. This is demonstrated in the "Rescue the Puppy" quest in the **Party Based RPG demo game**.
{% endhint %}

<figure><img src="/files/hHiDOv0R5IsTZFBGvqqu" alt=""><figcaption><p>While one Quest Step is required, each Quest can have multiple steps. Each Quest Step requires one Success Condition, but can have any number, and can have any number of optional Failure Conditions</p></figcaption></figure>

{% content-ref url="/pages/UHi2102Ci6fmTOHPaBVW" %}
[Quest](/magic-pig-games/game-modules-4/module-documentation/quests/quest.md)
{% endcontent-ref %}

### Quest Events

Quest Events can be sent automatically, allowing other objects to listen and react to changes.

{% content-ref url="/pages/e9qv8080gXZA0mGBJ2Sa" %}
[Quest Events](/magic-pig-games/game-modules-4/module-documentation/quests/quest-events.md)
{% endcontent-ref %}

### Success and Failure

A Quest is deemed **successful** when *all* [**Quest Steps**](/magic-pig-games/game-modules-4/module-documentation/quests/quest-steps.md) are successful. Quest Steps are successful when each [**Quest Condition**](/magic-pig-games/game-modules-4/module-documentation/quests/quest-conditions.md) in the success column has been fulfilled.

A Quest is deemed a **failure** when *at least one* Quest Step has failed. A Quest Step has failed when at least one Quest Condition in the failure column has been fulfilled. *Failure is optional* -- Quests do not have to have any failure conditions.

[**Quest Rewards**](/magic-pig-games/game-modules-4/module-documentation/quests/quest-rewards.md) can be given for success/failure of individual Quest Steps, and the entire Quest itself.

{% content-ref url="/pages/YRuKbCJroWFzAlLsjfsl" %}
[Quest Steps](/magic-pig-games/game-modules-4/module-documentation/quests/quest-steps.md)
{% endcontent-ref %}

{% content-ref url="/pages/Iy2PEjtbwyrmSeFvAtaF" %}
[Quest Conditions](/magic-pig-games/game-modules-4/module-documentation/quests/quest-conditions.md)
{% endcontent-ref %}

{% content-ref url="/pages/rSFhOpONsLgqhXLgbRcQ" %}
[Quest Rewards](/magic-pig-games/game-modules-4/module-documentation/quests/quest-rewards.md)
{% endcontent-ref %}

### Additional Options

Quests are very flexible. They can be automatically marked as success or failure, or checked manually through your code. They can have only a single step, with a single condition, or many steps, with many conditions. Steps can be required to be completed in order, or can be set to be completed in any order.

And it's easy to get the data you need to create UI for your players, so they can easily see the status of quests that you choose to expose.

{% hint style="success" %}
The **Party Based RPG demo game** has three different quests, each with slightly different setups and operations, including how the quests are checked for success / failure, and what happens afterward.

The "Rescue the Puppy" quest, for example, can be completed successfully or as a failure, while the other two can only be completed successfully, and simply continue as an active quest until they are completed.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://infinitypbr.gitbook.io/magic-pig-games/game-modules-4/module-documentation/quests.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
