The runtime's battle event feed: a read-only, synchronous notification channel the engine emits into at fixed points of a battle — start and end, turns, actions, HP/MP/TP changes, death, revival, state changes — so that a plugin which only needs to OBSERVE combat can subscribe here instead of wrapping a dozen prototype methods it never meant to change.
Additive by design. Nothing existing is routed through it: every wrapper a
plugin already installs on Game_Action.prototype.apply or
Game_Battler.prototype.gainHp runs exactly as before, and a listener's
return value is ignored, so a subscriber cannot alter an outcome — that is
still what the prototype chain is for. Listeners run in subscription order.
A listener that throws is reported on the console and skipped, and the ones
after it still run, because a statistics plugin's bug must not end a battle.
Costs one property read per emit point while nobody is listening.
The event names, their payloads and their exact emit points are documented
in docs/RUNTIME-EVENTS.md, and a test holds that document and this source
to the same list, so neither can drift from the other.
const off = ReactorEvents.on("hpChanged", ({ battler, delta }) => {
if (battler.isActor() && delta < 0) tally(battler, -delta);
});
off(); // unsubscribe
function ReactorEvents()
Quick Reference
Actions 1
| clear() | Drops every listener of name, or of every event when called with no name. |
Events, Commands & Input 2
| on() | Subscribes listener to the event name. |
| emit() | Delivers payload to every listener of name, in subscription order. |
Other 3
| once() | Subscribes for one delivery only; the subscription removes itself before the listener runs. |
| off() | Removes one subscription. |
| listenerCount() | How many listeners name has right now. |
Actions
clear
static sourceReactorEvents.clear(name)
Drops every listener of name, or of every event when called with no name.
Details
Drops every listener of name, or of every event when called with no name.
For tests and hot-reload tooling; the engine never calls it.
Events, Commands & Input
on
static sourceReactorEvents.on(name, listener)
Subscribes listener to the event name.
Details
Subscribes listener to the event name. Returns a function that removes
exactly this subscription — the tidy way to unsubscribe a closure.
emit
static sourceReactorEvents.emit(name, payload)
Delivers payload to every listener of name, in subscription order.
Details
Delivers payload to every listener of name, in subscription order. The
engine calls this at its emit points. A plugin may emit its own events too,
and should prefix their names so they cannot collide with the runtime's.
Other
once
static sourceReactorEvents.once(name, listener)
Subscribes for one delivery only; the subscription removes itself before the listener runs.
Details
Subscribes for one delivery only; the subscription removes itself before the listener runs.
off
static sourceReactorEvents.off(name, listener)
Removes one subscription.
Details
Removes one subscription. Removing a listener that is not subscribed is a no-op. Removing from inside a listener takes effect for the next emit, not for the one in flight.
listenerCount
static sourceReactorEvents.listenerCount(name)
How many listeners name has right now.
Details
How many listeners name has right now.