> 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

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="/files/yDou2VE7L9OD1R84OJLs" 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="/files/G0JH346X8J6r8KLEZoaO" 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 %}
