> For the complete documentation index, see [llms.txt](https://infinitypbr.gitbook.io/magic-pig-games/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://infinitypbr.gitbook.io/magic-pig-games/game-modules-4/module-documentation/conditions/expiration-condition-handler.md).

# Expiration Condition Handler

v4.0.6

By default if an **Expiration Condition** is populated, it will be given when the **GameCondition** expires. To customize the handling of this, you can use an `ExpirationConditionHandler`. This is a Scriptable Object which utilizes a custom script, so you can fully cusomize how to handle Expiration Conditions.

This is similar to how the [QuestRewards](/magic-pig-games/game-modules-4/module-documentation/quests/quest-rewards.md) are created.

## Creating a New Object

Once a Expiration Condition Handler has been scripted, right click in the project and select `Game Modules/Expiration Condition Handler/[Name of Handler]`

<figure><img src="https://2431624982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MY3N_li2jPq7az6mYfq%2Fuploads%2FWptZMf68GQYle7zismn6%2FScreenshot%202023-09-02%20at%2012.08.53%20PM.png?alt=media&amp;token=7606bdf9-7eb4-4c09-b417-6a31e0496eb4" alt=""><figcaption></figcaption></figure>

The new Scriptable Object will be created. Name it appropriately, and then customize the values, if any are customizable.

{% hint style="success" %}
The object is a `ModulesScriptableObject` which means it has an exposed `string uid` and [Dictionaries](/magic-pig-games/game-modules-4/module-documentation/dictionaries.md) as well. In most cases, you likely will not use these, and they can be ignored in the `Inspector`.
{% endhint %}

## Scripting a new Expiration Condition Handler

It may be easiest to copy the `PercentChance` script. Search for it and copy it, then rename it as you'd like. Update the code appropriately, adding in the custom logic for your situation.

<figure><img src="https://2431624982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MY3N_li2jPq7az6mYfq%2Fuploads%2FSGg1uXo5FLjGcFGL6Hqf%2FScreenshot%202023-09-03%20at%209.52.04%20AM.png?alt=media&amp;token=7cba7584-f036-4bbd-8730-e3575c2eed17" alt=""><figcaption></figcaption></figure>

Be sure to update the `CreateAssetMenu` `fileName` and `menuName`. This will allow you to create the object using the instructions above.

Finally, be sure to attach the handler you'd like to use to any [Condition](/magic-pig-games/game-modules-4/module-documentation/conditions/condition.cs.md) object.

{% hint style="success" %}
You can do *ANYTHING* in the `HandleExpiration` method. Here, we check for the random result, and then add the condition. The yellow highlighted area is a public float which appears in the Inspector. You can add additional content to your class exposed to the Inspector, allowing for virtually any logic you'd like in the `HandleExpiration` method.
{% endhint %}
