Skip to main content

Battle data

Battle data lives in the RPGJS database like any other game data. The native fields (name, description, spCost, power, hpValue, spValue, gain…) are shared with every battle system; the turnBattle field carries what only a turn-based battle needs.
Record kinds and their helpers: skills (default, turnBattleSkill), item (turnBattleItem), enemy (turnBattleEnemy), troop (turnBattleTroop), weapon (turnBattleWeapon), summon (turnBattleSummon) and command (turnBattleAction, an action described as data). Each helper returns the record unchanged, with its _type. The fields of each turnBattle object are typed and commented in SkillBattleData, ItemBattleData, WeaponBattleData, EnemyBattleData, SummonBattleData and TroopBattleData. A tactical battle reads the tactical field of the same records, so one skill can serve both. The data is read on the server only, when a battle starts. The server options skills, items, enemies, troops and summons give extra data by id, used before the database, and adapt turns records of another source into these shapes (see Customization).

Skill

turnBattleSkill(record). Native fields: name, description, spCost, power, element, coefficient (multipliers of the damageSkill formula of the map). The turnBattle field (SkillBattleData):

Item

turnBattleItem(record) (_type: "item"). Native fields: name, description, hpValue, spValue, consumable, price. The turnBattle field (ItemBattleData):

Weapon

turnBattleWeapon(record) (_type: "weapon"). Native fields: name, description, atk (added to the attack), elements ({ rate, element }[]: the first one colours its attack), price. The turnBattle field (WeaponBattleData):

Enemy

turnBattleEnemy(record) (_type: "enemy") takes one of two shapes. With a turnBattle field (EnemyBattleData), and the native rewards in gain (exp, gold, items: { id, chance, quantity }[]): Shaped like an RPGJS actor (TurnBattleEnemyRecord): its parameters are read at initialLevel, as for a player.

Troop

turnBattleTroop(record) (_type: "troop"): the enemies that fight together. The data sits in turnBattle, or at the root of the record (TroopBattleData):
A troop given as an object (to startTurnBattle, or in the troops server option, TroopDef) can also list TroopMembers in enemies: { enemy, level, levelSpread, invincible, position, condition }. level is a number or "party" (the average level of the players); condition is checked by the enemyCondition server option. It also takes forbid (commands the heroes cannot use; escape is the same as canEscape: false; skill covers the limit burst and the skills of the database played as commands, action the other custom commands) and heroesPosition.

Summon

turnBattleSummon(record) (_type: "summon"): a creature an action calls (act.summon(id)). The turnBattle field (SummonBattleData):

Action

turnBattleAction(record) (_type: "command"): a custom command described as data instead of code. Give it to units with commands: ["<id>"].
The effects (ActionEffect), each with an optional target (self or target) when it applies: A command written as code (turnBattleCommand) goes in the commands server option instead (see Customization).

Visual Effects

Skills (SkillDef) and actions carry the Visual Effects of the Studio, resolved by the server: effect plays from the caster to each target and the damage lands at its hitAt; castEffect plays on the caster while it casts and impactEffect on each target when it is hit. They replace castFx / fx and, when they have sounds, castSound / impactSound. An item (ItemDef) takes effect, the heal landing at its hitAt. Records of another shape reach them through the adapt server option, whose lookup(id) reads the Visual Effect a skill names. See the battle kit.