Skip to content

Battle Script Events

NightfallAlicorn edited this page Sep 5, 2015 · 6 revisions

Scripting/Battle/Events

I've made a start on the Battle Events. I add more when the use for them occur.


Battle Events

  • onBattleEnd(result, winner) Triggers at the end of the battle when someone wins, loses, forfeits or runs out of time. result provides an int of 0 if someone forfeits. 1 if either they win, lose or run out of time. 2 if it's a tie. winner is an int of 0 or 1 with 0 being the the user who requested the challenge while 1 is the opponent. Use battle.me to check.
  • onBeginTurn(turn) Triggers on every turn. turn provides an int of the current turn count.
  • onCriticalHit(spot) Triggers when a Pokémon deals a critical hit, including from multi hit moves. spot is the Pokémon that dealt the critical hit, not the Pokémon getting hit from it.
  • onFlinch(spot) Triggers when a Pokémon flinches. spot is the Pokémon that flinched and was unable to move due to their opponent, not the Pokémon that dealt the attack that caused it.
  • onMiss(spot) Triggers when a Pokémon misses their attack. spot is the Pokémon that missed, not the one who evaded. Type immunity does not count. (Exmaple: Normal type move can't hit Ghost types.) Evading with Dig, Fly, Phantom Force and Shadow Force does count. Status moves that are blocked with Safe Guard does not count. Hitting a Pokémon with Wonder Guard does not count.
  • onPlayerMessage(spot, message) Triggers when a battler sends a message. This doesn't include spectator messages.
  • onTierNotification(tier) Triggers when the notification is shown at the start of battle. tier is a string of the name of the tier being played. This is the only event that catches the tier name.

Event Perimeter Index and Explanations

This index explains all the perimeters you'll find in these events.

  • result This provides an int of 0 if someone forfeits. 1 if either they win, lose or run out of time. 2 if it's a tie. Only onBattleEnd(result, winner) can obtain this perimeter.
  • spot This provides an int of 1 of 3 from the player's pokemon team position when the event is called. 0, 2, 4 is the user's 3 sides. 1, 3, 5 is the opponent's 3 sides. battle.me for 0 and battle.opp for 1 can be used for checking this but won't detect double or triple modes.
  • tier This provides a string of the tier name being played. Only onTierNotification(tier) can obtain this perimeter.
  • turn This provides an int of the turn counter. Only onBeginTurn(turn) can obtain this perimeter.
  • winner This provides an int of 0 or 1 with 0 being the the user who requested the challenge while 1 is the opponent. Use battle.me to check. Only onBattleEnd(result, winner) can obtain this perimeter.