# Extensions: Frequency

These extensions add extra utility to the Trigger Key it's attached to by allowing you to alter when they may trigger, and/or how often. These extensions can be combined with the extensions listed in the "Extensions: User" subsection to add an extra layer of customization to each key. However, not every key is compatible with these extensions, although most are. Since these extensions are used to alter the frequency of a key triggering, any keys that can only ever be triggered once per battle are not compatible with these extensions.&#x20;

For example, the <mark style="background-color:purple;">"BeforeItemUse"</mark> key is compatible with these extensions since it's possible that multiple items may be used in a battle, so it makes sense that you would want to add extensions to repeat or randomize when this key may be triggered. However, the <mark style="background-color:purple;">"BattleEnd"</mark> key is not compatible with these extensions, since each battle obviously only ends once, so it makes no sense to randomize or repeat when that key could trigger.

As a rule of thumb, all of the keys in the subsections "Triggers: End of Battle" and "Triggers: Choices" are not compatible with these extensions.

With all of that out of the way, here are all of the possible frequency extensions that can be used:

<details>

<summary><mark style="background-color:orange;"><strong>"_repeat"</strong></mark></summary>

Add this extension to a key so that it will continuously repeat indefinitely. Normally, each trigger in a midbattle hash will only trigger once. With this extension however, it will continuously trigger for the entire battle. For example, <mark style="background-color:purple;">"TargetTookDamage\_foe"</mark> would only trigger the first time an opponent's Pokemon took damage from an attack, and then never again for that battle. While <mark style="background-color:purple;">"TargetTookDamage\_foe\_repeat"</mark> would continuously trigger each time any of the opponent's Pokemon took damage during this battle.

</details>

<details>

<summary><mark style="background-color:orange;"><strong>"_random"</strong></mark></summary>

Add this extension to a key so that it will randomly trigger instead of being guaranteed to trigger. For example, <mark style="background-color:purple;">"UserDealtDamage\_player"</mark> is guaranteed to trigger upon one of the player's Pokemon dealing damage to a target with an attack, but <mark style="background-color:purple;">"UserDealtDamage\_player\_random"</mark> would only randomly have a chance to trigger when one of the player's Pokemon deals damage. You can extend this even further by adding another underscore followed by a number to specify the odds of this occurring. For example, <mark style="background-color:purple;">"UserDealtDamage\_player\_random\_25"</mark> would have a 25% chance to randomly trigger when the player's Pokemon deals damage. If no number is added to this extension, this rate defaults to 50%.

</details>

<details>

<summary><mark style="background-color:orange;"><strong>"_repeat_random"</strong></mark></summary>

This extension is a combo of both the <mark style="background-color:orange;">"\_repeat"</mark> and <mark style="background-color:orange;">"\_random"</mark> extensions above. Add this extension to a key so that it will continuously repeat, but at randomized intervals. For example, <mark style="background-color:purple;">"TurnEnd\_player\_repeat"</mark> would continuously trigger at the end of every turn for the player's Pokemon, while <mark style="background-color:purple;">"TurnEnd\_player\_random"</mark> would randomly trigger once at the end of their turn. However, <mark style="background-color:purple;">"TurnEnd\_player\_repeat\_random"</mark> would continuously trigger at the end of their every turn, but it would only have a random chance of triggering each time. Like with the regular <mark style="background-color:orange;">"\_random"</mark> extension, you can specify the rate at which this random chance occurs by attaching an additional underscore, followed by a number. For example, <mark style="background-color:purple;">"TurnEnd\_player\_repeat\_random\_75"</mark> would continuously trigger at the end of their every turn with a 75% success rate. If no number is added to this extension, this rate defaults to 50%.

</details>

***

<mark style="background-color:yellow;">**Turn Count Extensions**</mark>\
These frequency extensions are special in that they can only apply to the keys listed in the "Triggers: Round Phases", "Triggers: Battler Turns" and "Triggers: Variable" subsections. This is because these extensions determine when they trigger based on the number value that a Trigger Key keeps track of, such as the battle turn count, an individual battler's turn count, or the value of a variable.

<details>

<summary><mark style="background-color:orange;"><strong>"_repeat_odd"</strong></mark></summary>

Add this extension to a key so that it will continuously repeat in battle, but only when the value that the key is tracking is an odd number. For example, <mark style="background-color:purple;">"RoundStartCommand\_foe\_repeat"</mark> would trigger at the start of the Command Phase of every turn, while <mark style="background-color:purple;">"RoundStartCommand\_foe\_repeat\_odd"</mark> would repeatedly trigger only on odd-numbered turns.

</details>

<details>

<summary><mark style="background-color:orange;"><strong>"_repeat_even"</strong></mark></summary>

Add this extension to a key so that it will continuously repeat in battle, but only when the value that the key is tracking is an even number. For example, <mark style="background-color:purple;">"VariableUp"</mark> would trigger whenever the midbattle variable is increased, while <mark style="background-color:purple;">"VariableUp\_repeat\_even"</mark> would repeatedly trigger only when the value of the variable is increased to an even number.

</details>

<details>

<summary><mark style="background-color:orange;"><strong>"_repeat_every_#"</strong></mark></summary>

Add this extension to a key so that it will continuously repeat in battle, but only when the value that the key is tracking is divisible by the number entered where <mark style="background-color:orange;">#</mark> is. For example, <mark style="background-color:purple;">"RoundEnd\_player\_repeat"</mark> would trigger at the end of each round, while <mark style="background-color:purple;">"RoundEnd\_player\_repeat\_every\_3"</mark> would repeatedly trigger only on turns that are divisible by 3. This means turns 3, 6, 9, etc. will trigger this key, while all other turns will not.

</details>


---

# 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://lucidious89-tutorials.gitbook.io/deluxe-battle-kit-tutorial/deluxe-battle-kit-for-v21.1/mid-battle-scripting/trigger-keys/triggers-extensions/extensions-frequency.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.
