# Raid: Mid-Battle Scripting

This plugin adds various new keys to be used by the Deluxe Battle Kit's mid-battle scripting functionality.

***

<mark style="background-color:orange;">**Trigger Keys**</mark>

These are keys which trigger at various points of a raid battle, or when cheer commands are used.

* <mark style="background-color:purple;">**"BeforeCheer"**</mark>\
  Triggers before a trainer uses a cheer.
* <mark style="background-color:purple;">**"AfterCheer"**</mark>\
  Triggers after a trainer successfully used a cheer.
* <mark style="background-color:purple;">**"FailedCheer"**</mark>\
  Triggers after a trainer's cheer failed.

{% hint style="info" %}
Trigger Extensions: You may extend these triggers with a cheer ID or species ID to specify that they should only trigger when a specific cheer was selected, or when the turn of a specific battler's species is used for the selected cheer. For example, <mark style="background-color:purple;">"BeforeCheer\_Healing"</mark> would trigger only when the <mark style="background-color:red;">"Heal up!"</mark> cheer was selected, where <mark style="background-color:purple;">"AfterCheer\_PIKACHU"</mark> would only trigger after a cheer was used on a Pikachu's turn.
{% endhint %}

* <mark style="background-color:purple;">**"CheerLevel"**</mark>\
  Triggers whenever a trainer's cheer level increases.

{% hint style="info" %}
Trigger Extensions: You may extend this trigger with a number to specify that this should trigger only when a trainer's cheer level increases to a certain level. For example, <mark style="background-color:purple;">"CheerLevel\_3"</mark> would only trigger when a trainer's cheer level reaches level 3.
{% endhint %}

* <mark style="background-color:purple;">**"RaidShieldStart"**</mark>\
  Triggers whenever the raid Pokemon summons a raid shield.
* <mark style="background-color:purple;">**"RaidShieldDamaged"**</mark>\
  Triggers whenever the raid Pokemon's raid shield takes damage without breaking.
* <mark style="background-color:purple;">**"RaidShieldBroken"**</mark>\
  Triggers whenever the raid Pokemon's raid shield is broken.

{% hint style="danger" %}
Trigger Extensions: Since these keys can only ever trigger for the opponent, these are not compatible with "user" extensions, such as <mark style="background-color:orange;">"\_player</mark>*<mark style="background-color:orange;">"</mark> or <mark style="background-color:orange;">"\_</mark>*<mark style="background-color:orange;">foe"</mark>.
{% endhint %}

***

<mark style="background-color:orange;">**Command Keys**</mark>

These are keys which trigger certain actions related to raid battles, such as forcing a trainer to use a cheer, or changing certain raid elements such raid shields and counters.

<details>

<summary><mark style="background-color:blue;"><strong>"setCheerLv"</strong></mark><strong> ⇒ </strong><mark style="background-color:yellow;"><strong>Integer</strong></mark></summary>

Changes a trainer's cheer level to a desired value. This is set as an integer ranging from 0-3. If this is set on the same turn that a trainer has selected to use a cheer (but prior to that cheer being used), the effects of their selected cheer will reflect their new cheer level.

</details>

<details>

<summary><mark style="background-color:blue;"><strong>"useCheer"</strong></mark><strong> ⇒ </strong><mark style="background-color:yellow;"><strong>Symbol</strong></mark></summary>

Forces a battler's turn to be used by their trainer to use a particular cheer instead. This will override whatever the normally selected commands for that battler's turn would have otherwise been. This won't work if the battler has already moved on the turn this has been triggered, or before any commands have been selected.

This is entered as a particular cheer ID. For example, setting this to `:Offense` will register the <mark style="background-color:red;">"Go all-out!"</mark> cheer to be used.&#x20;

If you enter an ID for a cheer that is not usable in this cheer mode, then the cheer for the current mode that shares the same command index will be used instead. For example, both the `:MaxRaid` and `:TeraRaid` cheers share the same cheer menu index (3), but are only usable in cheer modes 3 and 4, respectively. This means that if you try to set this command to `:TeraRaid` while in cheer mode 3 (a Max Raid battle), the trainer will not try to use the <mark style="background-color:red;">"Let's Terastallize!"</mark> cheer, but will instead try to use the <mark style="background-color:red;">"Let's Dynamax!"</mark> cheer.

</details>

<details>

<summary><mark style="background-color:blue;"><strong>"raidCounter"</strong></mark><strong> ⇒ </strong><mark style="background-color:yellow;"><strong>Array</strong></mark></summary>

Changes the current value of one of the raid counters. This is set as an array, where the first value is either symbols `:turn_count` or `:ko_count`, depending on which counter you're attempting to change. The second value must be a positive or negative integer, depending on whether you want to add or subtract from the values of these respective counters.

</details>

<details>

<summary><mark style="background-color:blue;"><strong>"raidAction"</strong></mark><strong> ⇒ </strong><mark style="background-color:yellow;"><strong>Symbol</strong></mark></summary>

Forces a raid Pokemon to perform a special raid action. This must be entered as one of the following symbols:

* `:reset_drops`\
  Forces the raid Pokemon to unleash a wave of energy that negates any of its own stat drops, as well as curing any status conditions it may have.<br>
* `:reset_boosts`\
  Forces the raid Pokemon to unleash a wave of energy that suppresses the Abilities and negates any stat boosts for the Pokemon on your side of the field.<br>
* `:drain_cheer`\
  Forces the raid Pokemon to unleash a wave of energy that reduces the cheer level of all trainers by one.

Forcing one of these extra actions in this way will not consume the raid Pokemon's natural "once-per-battle" usage of these mechanics. So, they may still naturally use these at the appropriate times regardless of how many times you force them to occur through this manner.

</details>

<details>

<summary><mark style="background-color:blue;"><strong>"raidShield"</strong></mark><strong> ⇒ </strong><mark style="background-color:yellow;"><strong>Integer</strong></mark></summary>

This can be used to give an opposing Pokemon a raid shield, or to alter the state of an existing one. Note that this can be done on any opponent, not just Raid Pokemon. So normal wild Pokemon or opposing trainer's Pokemon may be compatible with this.

When set to a positive number:

* Opponent doesn't have a shield: Grants a Raid shield with a number of bars equal to the inputted amount.
* Opponent already has a shield: Increases the amount of bars the shield has by the inputted amount.

When set to a negative number:

* Opponent doesn't have a shield: Nothing happens.
* Opponent already has a shield: Reduces the amount of bars the shield has by the inputted amount.

</details>
