Combat Step
Introduction
Initiates turn-based combat encounters with specified enemies and branching outcomes.
Interface
interface CombatStep {
kind: 'combat';
condition?: string;
enemies: EnemyEntity[];
playerBuffs?: Buff[];
numEnemies?: number;
isSpar?: boolean;
bgm?: string[];
victory: EventStep[];
defeat: EventStep[];
}
Properties
kind- Always'combat'enemies- Array of enemy entities to fight. Either the full list to fight, or the pool to draw from ifnumEnemiesis set.playerBuffs(optional) - Buffs to apply to the playernumEnemies(optional) - Number of enemies to spawn. If set, will select this number randomly from the enemies poolisSpar(optional) - Whether this is a sparring match. Whentrue, the player’s HP and any injuries sustained are restored after combat. However, items and qi droplets consumed during the fight are not returned — the resource cost of consumables still applies. Use this for training fights and friendly duels where the outcome shouldn’t leave the player permanently injured, but should still make them think about what they spend.bgm(optional) - Background music for combatvictory- Steps to execute on victorydefeat- Steps to execute on defeatcondition(optional) - Conditional execution
Examples
Basic Combat
{
kind: 'combat',
enemies: [
mountainBear
],
victory: [
{ kind: 'text', text: 'You defeated the mountain bear!' },
{ kind: 'addItem', item: { name: 'BearHide' }, amount: '1' }
],
defeat: [
{ kind: 'text', text: 'The bear overpowers you.' },
]
}
Horde battle
{
kind: 'combat',
enemies: [
ratascar, ratascar, ratascar
],
victory: [
{ kind: 'text', text: 'You defeat the swarm of ratascar' },
],
defeat: [
{ kind: 'text', text: 'The swarm overwhelms you and you flee' },
]
}
Randomised group
{
kind: 'combat',
enemies: [
ratascar, gorashi, xingKulei, stellarShard, gravityAnomaly
],
numEnemies: 2,
victory: [
{ kind: 'text', text: 'You defeat the pair of beasts' },
],
defeat: [
{ kind: 'text', text: 'You lose and run' },
]
}