🏋️Token Handlers

Token Handlers are objects that react to token changes inside the ODK wallet. They live on the wallet component of the Morpheus player character and define what happens when a token is added, removed, or updated — such as triggering a quest, showing some UI, or playing a VFX.

The system is modular, data-driven, and highly extendable via Blueprints.


🔩 Where Token Handlers Live

Token Handlers are configured on the player's wallet component: 📍 BPMC_ODK_WalletComponent Found on: BPM_ODK_PlayerCharacterBase or your project’s subclass.

Inside the component, you’ll find a map:

Map<string, BP_ODKFilterSet>

Each entry defines a filter set with an arbitrary name and the handler that should respond if a token passes that filter.


Example Use Case:

  • Filters for tokens with type == "quest"

  • Handler: BP_ODKTokenHandler_Quest - Shows Quest UI information


🧪 How Filtering Works

Each filter in the filter set must implement the function:

IsRelevantToken(TokenData) → bool

This function inspects the token metadata and determines if it matches your logic.

If ALL of the filters return true, the assigned Token Handler is activated.


🧰 Built-in Example Filters

You can find reusable example filters in the plugin:

🧾 BP_ODKTokenFilter_TokenType

  • Checks the type field in token metadata

  • Accepts a whitelist of strings

  • Example: match type == "quest" or type == "achievement"


🧮 BP_ODKTokenConditionGroup

  • Used to group filters together in more advanced logic

  • Contains:

    • Filters[]: array of AND'd filters - All filters must pass

    • OR Filter: a single filter that acts as an OR condition.

    The OR filter is a single filter because it allows nesting of ConditionGroups, allowing complex condition trees

Example:

( TokenType == "quest" ) 
  OR 
( ConditionGroup
    (TokenType == "achievement")
            AND
    (ChainID == "33139")
)

🛠 Creating Your Own Filters

To create custom filters:

  1. Inherit from BP_ODKTokenFilterBase

  2. Implement IsRelevantToken

  3. Add any parameters you want to expose (e.g. tags, substrings, reward keys)

Custom filters give you full control over how tokens are routed, enabling:

  • Campaign-specific logic

  • Filtering by metadata fields like XP, group, or even token balance


🎯 Creating Your Own Token Handlers

Handlers inherit from BP_ODKTokenHandlerBase and define what happens when a relevant token event occurs.

Each handler receives the TokenUpdate function containing the filtered token and the update type (Add, Update, Remove etc)

Token handlers allow for custom logic for a filtered token, for example:

For all tokens with "type" "quest"

  • Fire off UI or sound

  • Trigger Task Flows

For all tokens with "type" "badge"

  • Start cinematics

  • Queue unlocks

  • Animate overlays


✅ Best Practices

  • Use meaningful filter set names ("quest notifications", "achievement unlocked")

  • Reuse modular filters (e.g. shared TokenType filters)

  • Keep filters lightweight — heavy logic should live in handlers

  • Avoid putting too much logic inside IsRelevantToken — keep it as a pass/fail gate


🧵 Summary Flow

1. Token is added/removed/updated
2. Each Filter Set checks if the token matches its filter(s)
3. If matched → corresponding Token Handler is triggered

Last updated