Skip to main content

Customization

Action Battle is configured by responsibility (combat, visual, ui, ai, skills) and can be extended with plugins. Stats use the standard RPGJS API. New action-battle configuration is grouped by responsibility:
  • combat owns gameplay rules: player attack profile, damage, knockback, and hit hooks.
  • visual owns temporary combat feedback: sprite animations, flashes, damage text, CanvasEngine effects, and previews.
  • ui owns client components: action bar, targeting overlay, attack preview, and custom GUI or sprite components.
  • ai owns reusable AI behavior functions.
  • skills.targeting owns action targeting metadata for skills.
Use the same visual preset on the server and client when your project splits configuration by runtime. The server still decides when authoritative hit, hurt, skill, and enemy attack feedback should happen, but it sends one compact action-battle client visual event. The client resolves that visual locally and groups the flash, hit text, sound, component animation, or sprite animation. This keeps gameplay authority on the server while avoiding several visual packets for one combat moment. The client also triggers local input feedback such as the attack preview.
If your game installs action-battle as a combined module, you can import the same helpers from @rpgjs/action-battle.

Visual composition

createActionBattleVisual() accepts a preset or a map of visual parts. A visual part is a function receiving the current combat context and helper methods.
Available presets:
The impact preset selects an official CanvasEngine preset from the combat context: hitSpark for normal hits, slashSpark for combo finishers, impactBurst for charged or critical attacks, magicBurst for skills, and healPulse for healing. Its world-space damage popup changes font size, color, outline, movement, and duration for the same contexts. The built-in component animations are registered as action-battle-hit-fx and action-battle-damage. A skill or weapon action can override its impact presentation with serializable metadata:
These hints only affect the client presentation. Damage, SP consumption, targeting, and hit resolution remain server-authoritative. You can also call any component animation registered by your own client modules with fx.component(entity, id, params). Action-battle visual composition runs through the general Client Visuals mechanism for server-triggered combat feedback. Use direct server visual APIs for isolated one-off effects, and use visual here when you want action-battle to group combat presentation on the client. The legacy animations option still works for sprite animation names and temporary graphics. New orchestration should go through visual, while animations remains useful as the data source used by fx.graphic(entity, "attack"), fx.graphic(entity, "hurt"), and fx.graphic(entity, "castSkill").

Composable UI

Action Battle uses RPGJS’s generic, server-authoritative hotbar. Enable it on the server with ui.hotbar; targeting and attack-preview components remain client-owned and replaceable.
The client can still customize targeting and preview presentation:
The generic hotbar uses LT/RT to cycle through visible slots and LB to open the radial selector. Projects with a custom gamepad layout can override the standard Gamepad API button indexes:
Number keys use their assigned slot immediately. On a standard gamepad, LT/RT change the active slot and X uses it. Instant skills soft-target in front of the player; melee area skills keep the manual targeting confirmation. Shortcuts are accepted:

Compatibility

The legacy attack, systems.combat, systems.ai, and skills.getTargeting options are still supported. New code should prefer combat, ai, and skills.targeting so each part of the action-battle module stays independently replaceable.

Plugin-first extension points

Action battle is structured as replaceable systems. You can keep the default Zelda-like sword attack and only replace the pieces your game needs.
The public extension contracts are exported from @rpgjs/action-battle/server: ActionBattleCombatSystem, ActionBattleAiBehavior, ActionBattleHitHooks, and ActionBattleHitResult. For data-driven enemies, use createActionEnemy():
When the action targets a normal event with no BattleAi, the server lets the event handle onAction and does not create the combat hitbox. Enemy events with BattleAi still trigger the A-RPG attack.

Configure stats with the standard RPGJS API

The AI uses the event’s existing data.

Health and resources

Parameters

Skills

Items and equipment

Classes

States

Combat sounds and dynamic music

Action Battle can play local action cues and crossfade the current map BGM into a looping battle track:
A cue accepts one sound id, several variants, or { id, volume, cooldownMs }. Basic attacks are predicted locally and suppress the matching authoritative cue for 250ms. A skill’s own sound field takes priority over the generic skill cue. Cue cooldowns prevent repeated area hits from producing an unusable wall of sound. Combat threat is authoritative on the server and isolated per player. Alert, combat, fleeing, and stunned enemies keep that player in combat. On equal priority the currently selected enemy stays stable; bosses default to priority 100 and ordinary enemies to 0. Configure an enemy-specific track with:
Track precedence is enemy, map, project/default, then silence. The ambient sound layer is never stopped. With RPGJS Studio, use the combined preset on both client and server:
Studio reads project combatAudio, map combatMusic, and enemy combatMusic plus combatMusicPriority. createStudioActionBattleAudio(config) can provide the same settings statically before these fields are available in a project. Studio media ids are resolved lazily; resolving a new effect does not stop music that is already playing. The Adventure AI director limits how many enemies attack one target simultaneously. Other enemies keep repositioning instead of stacking the same attack: