Skip to main content

Customization

The server options and hooks change the rules; the client options and hooks change only what is shown. The server owns the outcome either way.

Server options (provideTacticalServer)

Server hooks

Any game module can implement tactical hooks (defineModule<RpgServer>({ tactical: { ... } })), or pass them in hooks.
The forecast a player sees before an attack (damage, “lethal”) includes the damage formulas of the map (damagePhysic, damageSkill): they run on the server, which sends their result with each state for the side that plays. It does not include your onDamage hooks, which only run when the action is played: a hook that changes the amount makes the forecast differ from the damage dealt. TacticalBattleHandle gives hooks the battle id, player, players (it keeps the players who left), versus, spectators() and state().

Objectives

New objective types: registerObjectiveType(id, { judge(state, objective) }) returns "ally" or "enemy" when decided. Built-in types cannot be replaced; unregisterObjectiveType(id) removes yours.

Client options (provideTacticalClient)

Texts

The texts of the HUD are tactical.* keys of the RPGJS i18n service (TACTICAL_I18N, exported by @rpgjs/tactical-rpg/client, holds the English and French defaults). A guest without a name is called by tactical.player (Player {index}). A game overrides them, or adds a language, with the i18n of its own module:
The hints that name a key (tactical.moveHint, tactical.skillKeys, tactical.danger…) take the keys the game binds as parameters: {escape}, {action}, {up}, {down}, {left}, {right}, {next} (next unit), {end} (end the phase), {danger} and {entries} (the keys of the action menu). Keep them in your own texts. The names of the keys are the tactical.key.* texts (tactical.key.space, tactical.key.escape…); other keys are shown in capitals.

Controls

The HUD uses the keyboard controls of the game (keyboardControls of the client config) and the gamepad mapping of the built-in GUIs. Every key is configurable, and the HUD always shows the key the game binds:
While the player writes in a text field (the chat), the keys are left to it. Every command also has a button for touch screens, and a right click goes back.

Client hooks

onPlay runs before each event: return false to play its effects yourself (the units still move). A move the player walked on their own screen before sending it reaches onPlay when the server confirms it, and what the hook returns is not used for it. stage gives fx (battle-kit FxPlayer), screen (ScreenEffects), popup(text, x, y, { color, big }), world(cell) (cell centre in map pixels) and unit(id) (reactive view of a unit). The hooks change what is shown, never the outcome: the server owns the rules.

Public API

@rpgjs/tactical-rpg/server exports the module (provideTacticalServer), the battle functions above, the data helpers (tacticalSkill, tacticalItem, tacticalUnit, tacticalRole, tacticalEncounter), registerObjectiveType / unregisterObjectiveType, and the types of the data, options and hooks (BattleState, Unit, Command, TacticalResult, TacticalAi…). @rpgjs/tactical-rpg/client exports provideTacticalClient, walkingSheet, TACTICAL_I18N and the types of the client hooks. The rules, the board, the AI and the HUD state are internal. The battle functions are described in Start a battle.

Not included

The package contains the rules, AI, HUD and battlefield. Wiring to a particular game stays in that game: reading the battle data from your own tools, a multiplayer lobby, launching a battle from a link, signals for scripts. Start a battle shows how to start battles from events, zones and challenges.