Skip to main content

Tactical battle

@rpgjs/tactical-rpg adds grid-based tactical battles to an RPGJS game: units move on a grid, act in phases, use skills with areas, and fight for an objective. The server owns the rules; the client draws the grid on the map and the HUD over it. It works in standalone RPG mode and in MMORPG mode, solo, in co-op and in player versus player, and other players can watch. Unlike the turn-based battle, the fight does not leave the map: the grid is drawn where the player stands and units walk on it, so position, range and areas matter. Unlike the Action Battle System, nothing is real time: each side plays its phase, and your server code starts the battle with startTacticalBattle. See Combat modes to compare the three. It is independent of the turn-based battle: it does not import it and does not need it. Both are built on @rpgjs/battle-kit, the foundation shared by the RPGJS battle systems, so they take the same options and hooks.
Peer dependencies: @rpgjs/client, @rpgjs/common, @rpgjs/server, @rpgjs/battle-kit, canvasengine, @canvasengine/presets.

Plug the module

The styles of the HUD are part of @rpgjs/ui-css (rpg-ui-tactical-* classes): a game that links the ui-css stylesheet has them, and its theme restyles the HUD too. Without provideTacticalServer, startTacticalBattle is not available; without provideTacticalClient, the battle has no HUD and no grid on the client.

Quick start

A sentinel to defeat, an encounter that places the player’s hero and the sentinel on a grid, and an event that starts it.
1

Plug the server and client modules

Add provideTacticalServer() to the server providers and provideTacticalClient() to the client providers, as shown in Plug the module.
2

Add a unit and an encounter to the database

The hero: true placement is the player’s own hero, read from the RpgPlayer (name, HP, SP, parameters, skills, items).
3

Register the battler on the client

A battler is a client spritesheet with stand-<dir> and walk-<dir> textures. walkingSheet turns a 4 × 4 walking sheet into one:
The player’s hero uses the graphic of the player.
4

Start the battle from an event

Place the event on a map (see Create an event) and press the action key next to it. The grid is drawn around the player, on the tiles of the map, unless the encounter or the origin option places it. The battle is drawn at the scale of the map: the characters keep their size, and the events and the other players of the map are hidden for the fighters while it lasts.

Next steps

Start a battle

Every way to start a battle, the result, solo and multiplayer (co-op, PvP, spectators).

Battle data

Skills, units, items, roles, encounters and the hero of a player.

Customization

Server and client options, hooks, objectives, texts and controls.

Battle kit

The foundation shared with the turn-based battle.