> For the complete documentation index, see [llms.txt](https://lucidious89-tutorials.gitbook.io/deluxe-battle-kit-tutorial/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lucidious89-tutorials.gitbook.io/deluxe-battle-kit-tutorial/deluxe-battle-kit-for-v21.1/mid-battle-scripting/trigger-keys/triggers-switching.md).

# Triggers: Switching

These are keys which trigger upon a trainer withdrawing or sending out a new Pokemon.

* <mark style="background-color:purple;">**"BeforeSwitchOut"**</mark>\
  Triggers when a trainer chooses to manually switch out an active Pokemon, but before that Pokemon is actually recalled.<br>
* <mark style="background-color:purple;">**"BeforeSwitchIn"**</mark>\
  Triggers when a trainer sends out a new Pokemon, but before that Pokemon actually enters the field.<br>
* <mark style="background-color:purple;">**"BeforeLastSwitchIn"**</mark>\
  Triggers when a trainer is about to send out the last remaining Pokemon in reserve, but before that Pokemon actually enters the field. If there are multiple trainers on a side, this only counts the last remaining Pokemon for that *side*, not any particular trainer.<br>
* <mark style="background-color:purple;">**"AfterSwitchIn"**</mark>\
  Triggers after a trainer has successfully sent out a new Pokemon.<br>
* <mark style="background-color:purple;">**"AfterLastSwitchIn"**</mark>\
  Triggers after a trainer has successfully sent out the last remaining Pokemon in reserve. If there are multiple trainers on a side, this only counts the last remaining Pokemon for that *side*, not any particular trainer.<br>
* <mark style="background-color:purple;">**"AfterSendOut"**</mark>\
  This is identical to <mark style="background-color:purple;">"AfterSwitchIn"</mark>, except this will trigger whenever a Pokemon is sent out, and not specifically when sent out due to a switch (for example, when sending out the lead Pokemon at the start of battle).<br>
* <mark style="background-color:purple;">**"AfterLastSendOut"**</mark>\
  This is identical to <mark style="background-color:purple;">"AfterLastSwitchIn"</mark>, except this will trigger whenever a trainer sends out the last remaining Pokemon in reserve, and not specifically when sent out due to a switch (for example, when sending out the lead Pokemon at the start of battle). If there are multiple trainers on a side, this only counts the last remaining Pokemon for that *side*, not any particular trainer.

{% 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 switching a specific species, or species of a specific type. For example, <mark style="background-color:purple;">"BeforeSwitchOut\_MEOWTH"</mark> would trigger only before switching out an active Meowth, where <mark style="background-color:purple;">"AfterSwitchIn\_DARK"</mark> would trigger only after sending out a Dark-type.
{% endhint %}
