Targeting
Targeting
Section titled “Targeting”The target field on an action decides which side and slot the resulting Showdown volatile is registered against. The volatile’s onStart fires when the Pokémon in that slot switches in, so picking the right target is what determines who receives the effect.
target = "SELF" # defaultFive modes are supported. The differences mostly matter for asymmetric effects — “I burn the foe’s lead”, “Kyogre sets rain for everyone” — where you need the volatile to attach to a side or slot that isn’t the Pokémon that triggered the match.
| Mode | Side | Slot | Use when… |
|---|---|---|---|
SELF | matched trainer’s side | 0 | The matched Pokémon itself receives the effect. (Default.) |
ALLIES | matched trainer’s side | 0 | Same as SELF in singles; in doubles/triples it’s the lead-position slot. |
FOES | opposing side | 0 | The opponent’s lead receives the effect at switch-in. Use for “Magmar burns the foe”, “Intimidate on send-out”, etc. |
EVERYONE | matched trainer’s side | 0 | Currently equivalent to SELF (per-actor iteration). Reserved for future expansion. |
FIELD | matched trainer’s side | 0 | The matched trainer’s slot, but the effect block typically uses weather / terrain for global field state. |
The “side” is one of p1 or p2 — ShowdownActions resolves the matched actor’s index in the battle and uses p1 for index 0, p2 for index 1. FOES flips it.
How Targeting Affects the Match Guard
Section titled “How Targeting Affects the Match Guard”A guard is auto-applied inside the switch-in hook so an effect doesn’t bleed onto a different Pokémon when the host switches out. The guard checks species, form, type, ability, held item, tera type, and level bounds against the switching-in Pokémon.
Whether the guard is generated depends on the target:
SELF,ALLIES,EVERYONE— guard is generated. The effect is identity-tied; it must only fire for the matching Pokémon.FOES— no guard. The effect fires on the opposing side, where the identity check makes no sense (the foe has its own species, not yours).FIELD— no guard. The effect is field-level (weather/terrain); it doesn’t matter which Pokémon is in the slot.
If you write a tier-3 showdown {} block, no guard is generated regardless of target — you control the entire effect. Add your own identity check inside the hook if your effect needs one.
Examples
Section titled “Examples”SELF — the default
Section titled “SELF — the default”Lycanroc transforms to its Dusk variant and gets a stat boost when it switches in at dusk:
id = "lycanroc_dusk"target = "SELF"
match { species = "lycanroc" sugar { time = "dusk" }}
apply { aspect = "dusk" boosts { spe = 1, atk = 1 }}The volatile registers on the trainer’s side, slot 0. When Lycanroc switches in there, the auto-guard verifies species and the effect fires.
FOES — punishing the opposing lead
Section titled “FOES — punishing the opposing lead”A Magmar that burns the opponent’s lead at battle start:
id = "magmar_burn_foe"target = "FOES"
match { species = "magmar"}
apply { status = "brn" message = "{name} radiates intense heat!"}The volatile registers on the opposing side, slot 0. No guard is generated — the effect should fire whoever the foe sends in, regardless of their species. pokemon.trySetStatus('brn', pokemon) will respect the foe’s type immunity (a fire-type lead can’t be burned), so you don’t have to special-case it.
FIELD — weather and terrain setters
Section titled “FIELD — weather and terrain setters”A Kyogre that always sets Rain Dance on switch-in:
id = "kyogre_rain"target = "FIELD"
match { species = "kyogre"}
apply { weather = "raindance" message = "{name} commands the storm!"}The volatile registers on the trainer’s side, slot 0 (same as SELF). What makes it FIELD is the conventional intent: the effect changes global field state, not anything about a specific Pokémon. The auto-guard is skipped because re-applying rain when the trainer switches their lead out and a different Pokémon in is fine — the field setter is idempotent.
ALLIES — doubles-relevant
Section titled “ALLIES — doubles-relevant”In singles, ALLIES is identical to SELF. In doubles or triples, ALLIES routes the volatile to the trainer’s slot 0 (the lead position) regardless of which slot the matched Pokémon was actually in. Use it when you want a side-wide effect tied to the matcher’s team but anchored at the lead slot.
id = "team_safeguard_on_match"target = "ALLIES"
match { species = "clefable" ability = "magicguard"}
apply { volatile = "safeguard"}(safeguard is a registered Showdown side condition; addVolatile on a side slot promotes it to side-level, depending on the volatile.)
How target Resolves
Section titled “How target Resolves”target resolves to a Showdown side and slot at battle start:
SELF,ALLIES,EVERYONE,FIELDmap to the matched trainer’s side, slot 0 (p1/p2depending on which actor index they hold).FOESmaps to the other side, slot 0.
Every matched action’s effect is queued on the resolved side+slot for the duration of the battle. When the Pokémon in that slot switches in, Showdown attaches the queued volatiles and runs each one’s onStart.
In this Cobblemon environment, Showdown’s onStart re-fires on every switch-in, not just the first. That’s why sugar effects targeting SELF/ALLIES/EVERYONE come with an auto-applied guard — without it, the same effect would re-apply when the slot changes hands. FOES and FIELD skip the guard because the effect is intended to fire regardless of who’s in the slot.
Picking the Right Target
Section titled “Picking the Right Target”| If the effect is… | Use |
|---|---|
| Modifying the matched Pokémon’s stats / status / aspect | SELF |
| Targeting the opponent’s lead | FOES |
| Setting field-wide state (weather, terrain) | FIELD |
| A side condition you want anchored at the lead slot in doubles | ALLIES |
| You’re not sure | SELF — it’s the default for a reason |
EVERYONE exists as a placeholder for future expansion (multi-side effects without per-actor iteration). For now it behaves identically to SELF; don’t use it unless you specifically want the future semantics.
Next Steps
Section titled “Next Steps”- Molang Predicates — the
whenMolangsurface and helpers. - Raw Showdown Hooks — writing your own hook bodies.
- Recipes — worked examples for each target mode.