> 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 %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://lucidious89-tutorials.gitbook.io/deluxe-battle-kit-tutorial/deluxe-battle-kit-for-v21.1/mid-battle-scripting/trigger-keys/triggers-switching.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
