# Quests

Quests are database entries that define tasks for the player to complete. Each quest has objectives to track progress, requirements to gate acceptance, and rewards granted on turn-in.

## Creating a Quest Entry

Open the Spark Editor, go to **Quests > Quests** and click **Create New**.

Each quest entry defines:

| Field                   | Description                                                                                                    |
| ----------------------- | -------------------------------------------------------------------------------------------------------------- |
| Display Name            | Quest name shown in the journal and UI.                                                                        |
| Description             | Quest text describing what the player needs to do.                                                             |
| Icon                    | Sprite for the quest in UI.                                                                                    |
| Quest Category          | The category this quest belongs to (see [Categories](/documentation/user-guide/plugins/quests/categories.md)). |
| Quest Journal Turn In   | If enabled, the player can turn in this quest directly from the Quest Journal without returning to an NPC.     |
| Accept Requirements     | List of requirement groups that must be met before the player can accept this quest.                           |
| Objectives              | List of objectives the player must complete (see below).                                                       |
| Rewards To Select Count | How many rewards the player can choose from the selectable rewards list.                                       |
| Selectable Rewards      | Rewards the player can choose from — they pick a number of these equal to Rewards To Select Count.             |
| Guaranteed Rewards      | Rewards that are always given when the quest is turned in, regardless of selection.                            |

## Quest States

A quest progresses through these states:

| State            | Description                                                    |
| ---------------- | -------------------------------------------------------------- |
| Not Started      | Quest has not been accepted yet.                               |
| Active           | Quest has been accepted and objectives are in progress.        |
| Ready To Turn In | All objectives are complete. The player can turn in the quest. |
| Completed        | Quest has been turned in and rewards granted.                  |
| Abandoned        | Quest was abandoned by the player.                             |

## Objectives

Each objective tracks a specific task. Objectives use a type system — different objective types track different things.

| Field           | Description                                                           |
| --------------- | --------------------------------------------------------------------- |
| Objective Type  | The type of task to track (ScriptableObject dropdown).                |
| Description     | Short description shown in the quest journal (e.g., "Kill 5 wolves"). |
| Amount Required | How many times this objective must be completed (default: 1).         |

**Built-in objective types include:**

| Objective Type       | What it tracks                                                             |
| -------------------- | -------------------------------------------------------------------------- |
| Enter Scene          | Player enters a specific scene.                                            |
| Craft Recipe         | Player crafts a specific recipe (or any recipe). Requires Crafting plugin. |
| Unlock Recipe        | Player unlocks a specific crafting recipe. Requires Crafting plugin.       |
| Gain Currency        | Player gains a specific amount of currency. Requires Currency plugin.      |
| Reach Currency Total | Player's total currency reaches a target amount. Requires Currency plugin. |

Objective types from other plugins become available when those plugins are installed. Custom objective types can be created by developers.

## Rewards

Rewards are granted when the quest is turned in.

**Guaranteed rewards** are always given. **Selectable rewards** let the player choose — they pick a number equal to **Rewards To Select Count**.

| Field       | Description                                     |
| ----------- | ----------------------------------------------- |
| Reward Type | The type of reward (ScriptableObject dropdown). |
| Reward Data | Type-specific configuration.                    |

**Built-in reward types include:**

| Reward Type   | What it grants                                                                                                          |
| ------------- | ----------------------------------------------------------------------------------------------------------------------- |
| Trigger       | Executes a trigger entry when claimed. Use this to grant items, currency, experience, or anything else triggers can do. |
| Unlock Recipe | Unlocks a crafting recipe. Requires Crafting plugin.                                                                    |
| Gain Currency | Grants a currency amount. Requires Currency plugin.                                                                     |

## Quest-Related Triggers

| Trigger                  | Description                                                                                                                            |
| ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------- |
| Add Quest                | Adds a quest to the player's quest list (or removes it if the remove option is enabled). Configure the quest entry and optional delay. |
| Complete Quest Objective | Completes a specific objective by index, or fully completes all objectives if the "fully complete" option is enabled.                  |

## Quest-Related Requirements

| Requirement  | Description                                                                                                |
| ------------ | ---------------------------------------------------------------------------------------------------------- |
| Quest Status | Checks if a quest is in a specific state (Not Started, Active, Ready To Turn In, Completed, or Abandoned). |

## NPC Integration

When both the Quests and NPCs plugins are installed, NPC interaction types for quests become available:

| Interaction Type | Description                                                                                                                                                                                                        |
| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Give Quest       | Offers a quest to the player. The NPC shows the quest details and the player can accept or decline. Only available if the player hasn't already accepted or completed the quest and meets the accept requirements. |
| Turn In Quest    | Allows the player to turn in a completed quest at this NPC. Only available if the quest is Active or Ready To Turn In.                                                                                             |

NPCs with quest interactions display quest state indicators above their heads:

| Indicator         | Meaning                                       |
| ----------------- | --------------------------------------------- |
| Quest Available   | This NPC has a quest the player can accept.   |
| Quest In Progress | The player has an active quest from this NPC. |
| Quest Completed   | The player can turn in a quest at this NPC.   |

The quest state indicator component can be configured with:

| Field                 | Description                                               |
| --------------------- | --------------------------------------------------------- |
| Quest State UI Prefab | Prefab to instantiate for the quest state display.        |
| Position Offset       | Local position offset above the NPC (default: 0, 2.5, 0). |
| Update Interval       | How often to check quest state in seconds (default: 0.5). |

## Persistence

Quest progress is automatically saved and loaded through Spark's save system. What is saved per quest includes the quest state, objective progress (current count and completion status for each objective), selected reward indices, and timestamps for when the quest was accepted and completed.


---

# 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://docs.sparkframework.dev/documentation/user-guide/plugins/quests/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.
