Skip to content

Showdown Events

necro50n3 edited this page Apr 3, 2026 · 3 revisions

Showdown Event Engine

Additional scripts and events can be defined by an addon mod. Events are triggered using Showdown's >eval trigger to send Javascript (not Typescript!) code as a string directly into the Showdown engine.

Types of Events

There are four types of event interfaces, depending on the purpose of the event.

RaidEvent

The RaidEvent is used for events that modify the raid instance or a specific player in the raid instance, without modifying the battle state of each individual battle, such as the boss's HP and timer.

BroadcastingRaidEvent

A RaidEvent which is run for each player in a raid instance.

ShowdownEvent

The usage of the basic ShowdownEvent can be confusing. It is meant to be used for either single-use events, or silent update events. Single-use events, such as most scripts, are only triggered one time in a raid instance to update the battle state and emit silent synchronisation events to all other battles. Silent update events are used in response to a change in the raid battle state, and update each battle instance without notifying the Minecraft server.

                                                                ┌──> Silent Update Event (Battle #2)
Single-Use Event (Battle #1) ──> Cobblemon Interpreter (Server) ┼──> Silent Update Event (Battle #3)
                                                                └──> Silent Update Event (Battle #4)

BroadcastingShowdownEvent

Events which are broadcast to all battles immediately and do not expect corresponding Silent Update Events. Generally used for events which are not synchronised between battles, such as player stat changes.

Broadcasting Event (Battle #1) ┐
Broadcasting Event (Battle #2) ┼──> Cobblemon Interpreter (Server)
Broadcasting Event (Battle #3) ┘

Triggering Events

Events can be triggered in three different ways.

Scripts

The most basic method is by defining a new script trigger via a static Mixin to RaidScriptHandler.class and then calling the script within a raid battle.

Cobblemon Interpreter

You can use a Mixin to inject events to trigger from certain instructions which are processed by the Cobblemon interpreter. The events triggered here MUST be silent update events to avoid recursion. These events should be called via the RaidInstance.class using updateBattleState() or updateBattleContext(). Both methods accept the original battle as well as a corresponding Functional Interface, and the events are sent to all battles except the original.

Direct Trigger

The RaidInstance.class also has two other methods sendEvent() and broadcastToOthers() which accepts a ShowdownEvent and a (nullable) battle.

The sendEvent() method will send to all battles if it is a BroadcastingShowdownEvent, or the specified battle if its a ShowdownEvent and the battle was specified. If no battle was specified, it will send to a random battle in the raid.

The broadcastToOthers() method will send to all battles, excluding the specified battle if one was specified.

Clone this wiki locally