# Triggers

A **Trigger** is a configurable action that happens in response to something. "Give the player 100 gold", "Start a quest", "Play a sound", "Load a scene", and "Add an item" are all examples of triggers.

Triggers are used throughout Spark: in quest rewards, NPC interactions, interactable objects, level-up rewards, and more. You configure them in the Spark Editor by picking a trigger type and filling in its parameters.

## Trigger Entries

In the Spark Editor under the **Triggers** tab, each trigger entry has:

| Field                     | Description                                            |
| ------------------------- | ------------------------------------------------------ |
| `triggerType`             | Which type of action to perform                        |
| `triggerTypeData`         | Configuration specific to that trigger type            |
| `executionDelay`          | Optional delay before the trigger fires (0-10 seconds) |
| `allowMultipleExecutions` | If false, the trigger only fires once per entity       |

## Trigger Instances

When triggers are referenced from other entries (quest rewards, NPC interactions, etc.), they are wrapped in a **TriggerInstance** which can optionally override the delay defined on the trigger entry.

## All Trigger Types

### Core Triggers

| Trigger Type                         | Plugin   | Description                                                              |
| ------------------------------------ | -------- | ------------------------------------------------------------------------ |
| **AnimatorTriggerType**              | Triggers | Sets a parameter on an Animator component (trigger, bool, int, or float) |
| **ComponentMethodTriggerType**       | Triggers | Calls a method on a specified MonoBehaviour component                    |
| **DestroySelfTriggerType**           | Triggers | Destroys the source GameObject                                           |
| **InstantiateGameObjectTriggerType** | Triggers | Instantiates a prefab at a position                                      |
| **ToggleUIPanelTriggerType**         | Triggers | Opens or closes a UI panel                                               |
| **TriggerSaveTriggerType**           | Save     | Triggers a save operation                                                |
| **LoadSceneTriggerType**             | Scenes   | Loads a scene by its SceneEntry                                          |

### Plugin Triggers

| Trigger Type                          | Plugin      | Description                               |
| ------------------------------------- | ----------- | ----------------------------------------- |
| **AddItemTriggerType**                | Items       | Adds an item to the player's inventory    |
| **RollLootTableTriggerType**          | Items       | Rolls a loot table and gives the results  |
| **GainCurrencyTriggerType**           | Currency    | Adds currency to the player's wallet      |
| **GainExperienceTriggerType**         | Progression | Awards experience points to a progression |
| **LearnRecipeTriggerType**            | Crafting    | Unlocks a crafting recipe                 |
| **UnlearnRecipeTriggerType**          | Crafting    | Locks a crafting recipe                   |
| **AddQuestTriggerType**               | Quests      | Gives a quest to the player               |
| **CompleteQuestObjectiveTriggerType** | Quests      | Completes a specific quest objective      |
| **AddSecondaryClassTriggerType**      | Classes     | Adds a secondary class to the entity      |
| **AddProfessionTriggerType**          | Professions | Grants a profession to the entity         |
| **LearnProfessionTriggerType**        | Professions | Teaches a profession to the entity        |
| **AddSpellbookTriggerType**           | Spellbooks  | Grants or removes a spellbook             |
| **ApplyEffectTriggerType**            | Combat      | Applies a combat effect to the target     |

## Where Triggers Are Used

Triggers appear in many places across Spark:

* **Quest rewards**: Triggers fire when a quest is turned in
* **NPC interactions**: Triggers fire when the player interacts with an NPC
* **Interactable objects**: Triggers fire when the player interacts with an object
* **Level-up rewards**: Triggers fire when a progression reaches a specific level
* **Rule effects**: Triggers can be configured as effects in the Rules system


---

# 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/core-systems/triggers.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.
