# 02 Events

An **Event** is a callback that fires when an AI interacts with a node or path. Use them to trigger gameplay (sound, dialog, spawn, quest update).

## Timing options

| Timing         | Fires when                                |
| -------------- | ----------------------------------------- |
| **OnEnter**    | AI enters a node radius / starts a path.  |
| **OnExit**     | AI exits a node radius / finishes a path. |
| **OnTraverse** | AI fully traverses a path (start to end). |
| **OnMidpoint** | AI reaches the midpoint of a path.        |

## Adding an event

1. Select an OWP Node or Path.
2. In the **Details** panel, expand **OWP > Gameplay > Events**.
3. Click **+** and pick an event class (or your own custom subclass).
4. Set **Timing** and any class-specific properties.

## Properties

| Property         | What it does                                             |
| ---------------- | -------------------------------------------------------- |
| **Display Name** | Label in the editor.                                     |
| **Timing**       | When to fire (see above).                                |
| **Repeatable**   | If off, the event fires at most once per actor lifetime. |

## Custom event (Blueprint)

1. Content Browser → Add → Blueprint Class → Parent: **OWP Event**.
2. Override **Execute** in the event graph.
   * Inputs: **Traveler** (struct with the AI's actor, tags, etc.) and **OWP Element** (the node or path).
   * Add your gameplay logic.
3. Optionally override **Should Trigger** for runtime gates.
4. Add your event to a node or path.

## Examples

| Goal                       | Setup                                                              |
| -------------------------- | ------------------------------------------------------------------ |
| Play sound at intersection | OnEnter on the node, custom event plays sound at element location. |
| Spawn ambush at bridge     | OnMidpoint on the bridge path, custom event spawns enemies.        |
| Award XP after a path      | OnTraverse on the path, custom event awards XP to Traveler.Actor.  |
| One-shot tutorial step     | OnEnter, **Repeatable = false**, custom event advances tutorial.   |

## Tips

{% hint style="warning" %}
Don't modify the network from inside Execute. Spawning/deleting nodes mid-traversal can break the AI's current path. Defer with a timer if you must.
{% endhint %}

{% hint style="info" %}
Keep Execute cheap. It runs during the AI's move tick.
{% endhint %}

{% hint style="info" %}
Same event instance fires for every traveler. Don't store per-traveler state on the event — read it from the Traveler input.
{% 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://onesteppack.gitbook.io/openworldnavigation-doc/05-gameplay/02-events.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.
