# Dynamax: 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 Dynamax.

* <mark style="background-color:purple;">**"BeforeDynamax"**</mark>\
  Triggers when a battler is going to Dynamax this turn, but before that Pokemon actually Dynamaxes.<br>
* <mark style="background-color:purple;">**"BeforeGigantamax"**</mark>\
  Triggers when a battler is going to Gigantamax this turn, but before that Pokemon actually Gigantamaxes.<br>
* <mark style="background-color:purple;">**"AfterDynamax"**</mark>\
  Triggers after a battler successfully Dynamaxes.<br>
* <mark style="background-color:purple;">**"AfterGigantamax"**</mark>\
  Triggers after a battler successfully Gigantamaxes.

{% hint style="info" %}
Trigger Extensions: You may extend these keys with a species ID or a type ID to specify that they should only trigger when a specific species or species of a specific type triggers Dynamax. For example, <mark style="background-color:purple;">"BeforeDynamax\_PIKACHU"</mark> would trigger only when a Pikachu is about to Dynamax, where <mark style="background-color:purple;">"AfterGigantamax\_ELECTRIC"</mark> would trigger only after an Electric-type has Gigantamaxed.
{% endhint %}

***

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

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

<details>

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

Forces the battler to Dynamax 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 Dynamax triggering. Note that this can even be used to force a wild Pokemon to Dynamax, as long as they are capable of it. If the Pokemon is forced to Dynamax prior to using their move that turn, their selected move will be converted to the Dynamaxed version of that move.\
\
Unlike using Dynamax naturally, you can use this to force it 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>"disableDynamax"</strong></mark> => <mark style="background-color:yellow;">Boolean</mark></summary>

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

</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>

* `pbHasDynamaxBand?(idxBattler)`\
  Returns true if the trainer who owns the battler at index `idxBattler` has an item in their inventory flagged as a Dynamax Band.<br>
* `pbGetDynamaxBandName(idxBattler)`\
  Returns the name of the specific item in a trainer's inventory flagged as a Dynamax Band. The specific trainer's inventory checked for is the one who owns the battler at index `idxBattler`.
* `pbCanDynamax?(idxBattler)`\
  Returns true if the battler at index `idxBattler` is capable of using Dynamax.
* `pbDynamax(idxBattler)`\
  Begins the Dynamax process for the battler at index `idxBattler`.

</details>

<details>

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

* `dynamax?`\
  Returns true if this battler is in the Dynamax state.<br>
* `gmax?`\
  Returns true if this battler is currently Gigantamaxed.<br>
* `emax?`\
  Returns true if this battler is currently Eternamaxed.<br>
* `dynamax_able?`\
  Returns true if this battler is not flagged in some way as being ineligible for Dynamax.<br>
* `gmax_factor?`\
  Returns true if this battler has G-Max Factor.
* `hasDynamax?`\
  Returns true if this battler meets all of the necessary conditions to use Dynamax.<br>
* `hasGmax?`\
  Returns true if this battler has a Gigantamax form.<br>
* `hasEmax?`\
  Returns true if this battler has an Eternamax form.<br>
* `unDynamax`\
  Forces a battler's Dynamax state to end, and reverts them back to their original form if necessary.<br>
* `display_dynamax_moves`\
  This converts all of the battler's moves into their compatible Max Move equivalents to be displayed in the Fight menu.

</details>
