# Terastal: 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 upon a battler utilizing Terastallization or its mechanics.

* <mark style="background-color:purple;">**"BeforeTerastallize"**</mark>\
  Triggers when a battler is going to Terastallize this turn, but before that Pokemon actually Terastallizes.<br>
* <mark style="background-color:purple;">**"AfterTerastallize"**</mark>\
  Triggers after a battler successfully Terastallizes.<br>
* <mark style="background-color:purple;">**"BeforeTeraMove"**</mark>\
  Triggers right before a battler's selected move boosted by Terastallization is about to be executed.

{% hint style="info" %}
Trigger Extensions 1: You may extend these keys with a species ID or a type ID to specify that they should only trigger when Terastallizing a specific species, or species with a specific Tera Type. For example, <mark style="background-color:purple;">"BeforeTerastallize\_OGERPON"</mark> would trigger only when an Ogerpon is about to Terastallize, where <mark style="background-color:purple;">"AfterTerastallize\_STELLAR"</mark> would trigger only after a Pokemon has Terastallized into the Stellar-type.
{% endhint %}

{% hint style="info" %}
Trigger Extensions 2: For the <mark style="background-color:purple;">"BeforeTeraMove"</mark> key specifically, you can also use a move ID to specify a specific move. For example, <mark style="background-color:purple;">"BeforeTeraMove\_TERABLAST"</mark> would only trigger before the move Tera Blast is used, but only if the move is being boosted by Terastallization.
{% endhint %}

***

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

These are keys which trigger certain actions related to Terastallization to take place during battle, such as forcing a trainer to Terastallize, or disabling its use.

<details>

<summary><mark style="background-color:blue;"><strong>"terastallize"</strong></mark><strong> => </strong><mark style="background-color:yellow;"><strong>Boolean or String</strong></mark></summary>

Forces the battler to Terastallize when set to `true`, as long as they are able to. If set to a string instead, you can customize a message that will display upon this Terastallization triggering. Note that this can even be used to force a wild Pokemon to Terastallize, as long as they are capable of it.\
\
Unlike natural Terastallization, you can use this to force Terastallization to happen at any point in battle, even at the end of the turn or after the battler has already attacked. This cannot happen if a different action with this battler has been chosen however, such as switching it out or using an item.

</details>

<details>

<summary><mark style="background-color:blue;"><strong>"disableTera"</strong></mark><strong> => </strong><mark style="background-color:yellow;"><strong>Boolean</strong></mark></summary>

Toggles the availability of Terastallization for the owner of the battler. If set to `true`, Terastallization will be disabled for this trainer. If set to `false`, Terastallization will no longer be disabled, allowing this trainer to use it again even if they've already used Terastallization prior in this battle.

</details>

<details>

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

Changes the Tera type of a battler. This must be set to a valid type ID, such as `:FIRE`. This won't do anything if the battler already has the entered Tera type, or if the entered type ID is flagged as a pseudo-type, such as `:QMARKS`. Pokemon who are locked into a specific Tera type (such as Ogerpon and Terapagos) will not have their Tera types changed.

Note that this change in Tera type is permanent, and will persist outside of battle for player-owned Pokemon.

</details>

***

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

Here's a list of methods and/or properties that you might want to reference when hardcoding a midbattle script, since this plugin adds a lot of new custom content which you may need to call on to make certain things happen:

<details>

<summary>Battle Class</summary>

* `pbHasTeraOrb?(idxBattler)`\
  Returns true if the trainer who owns the battler at index `idxBattler` has an item in their inventory that allows for Terastallization.<br>
* `pbGetTeraOrbName(idxBattler)`\
  Returns the name of the specific item in a trainer's inventory that allows for Terastallization. The specific trainer's inventory checked for is the one who owns the battler at index `idxBattler`.
* `pbCanTerastallize?(idxBattler)`\
  Returns true if the battler at index `idxBattler` is capable of Terastallizing.<br>
* `pbTerastallize(idxBattler)`\
  Begins the Terastallization process for the battler at index `idxBattler`.

</details>

<details>

<summary>Battle::Battler Class</summary>

* `tera?`\
  Returns true if this battler is Terastallized.<br>
* `tera_form?`\
  Returns true if this battler is Terastallized into a unique Tera Form.<br>
* `hasTera?`\
  Returns true if this battler is capable of using Terastallization.<br>
* `unTera(break)`\
  Forces a battler's Terastallization state to end. If the `break` argument is set to true, the battler's Terastallization will end with a dramatic Tera Break animation, instead of simply fading away.&#x20;

</details>
