Battle
┗> Object > Class
The Battle Object manages everything related to battles in Kristal.
A globally available reference to the in-use Battle instance is stored in Game.battle.
Methods
Battle:advanceBoxes()
Advances all enemy dialogue bubbles
Battle:applyHealBonuses(heal: number, caster: PartyMember?, target: PartyMember?)
Applies equipment modifiers to the heal amount from a healing action performed by the specified party member.
Arguments:
| heal: number | The base heal amount to apply bonuses to. |
| caster: PartyMember? | The party member performing the heal, if applicable. |
| target: PartyMember? | The party member targeted by the heal, if applicable. |
Returns:
| new_heal: number | The modified heal amount. |
Battle:applyMoneyBonuses(money: number)
Returns the equipment-modified money amount from a battle victory payout.
Arguments:
| money: number | The base amount of money to apply bonuses to. |
Returns:
| new_money: number | The modified amount of money. |
Battle:battleText(text: string|string[], post_func: (fun()boolean|string)?)
Sets the current message in the battlebox and moves to the BATTLETEXT state until it is advanced, where it returns to the previous state by default
Arguments:
| text: string|string[] | The text to set |
| post_func: (fun()boolean|string)? | When the text is advanced, the name of the state to move to, or a function to run |
Battle:checkEndWaves(old: "ACTING"|"ACTIONS"|"ACTIONSDONE"|"ACTIONSELECT"|"ATTACKING"...(+18), new: "ACTING"|"ACTIONS"|"ACTIONSDONE"|"ACTIONSELECT"|"ATTACKING"...(+18), reason: string?)
Checks the current state on a state change. If waves shouldn't be active, stop them.
old:
| "NONE" -- An empty state which does nothing.
| "TRANSITION" -- The state used when first entering a battle.
| "INTRO" -- The state used after TRANSITION, where the battle intro animation plays.
| "ACTIONSELECT" -- The state for letting the user choose actions.
| "MENUSELECT" -- The state used when selecting an action from the menu.
| "ENEMYSELECT" -- The state used when selecting an enemy target.
| "PARTYSELECT" -- The state used when selecting a party member.
| "ACTIONS" -- The state used when processing actions. Most of the time, other states will be used instead.
| "ACTING" -- The state used when party members act.
| "BATTLETEXT" -- A generic "writing text" state.
| "SHORTACTTEXT" -- The state used when multiple lines of text are being written out at once, for "short acts".
| "ATTACKING" -- The state used while party members are attacking.
| "SPARING" -- The state used when party members spare.
| "USINGITEMS" -- The state used when party members use items.
| "ACTIONSDONE" -- The state used when all "actions" are done.
| "ENEMYDIALOGUE" -- The state used when enemies are displaying dialogue.
| "DIALOGUEEND" -- The state used after enemy dialogue ends.
| "DEFENDINGBEGIN" -- The state used before defending begins.
| "DEFENDING" -- The state used when the player is defending against enemy waves.
| "DEFENDINGEND" -- The state used after defending ends.
| "VICTORY" -- The state used when the player has won the battle.
| "TRANSITIONOUT" -- The state used when transitioning out of battle.
| "CUTSCENE" -- The state used when a battle cutscene is active.
new:
| "NONE" -- An empty state which does nothing.
| "TRANSITION" -- The state used when first entering a battle.
| "INTRO" -- The state used after TRANSITION, where the battle intro animation plays.
| "ACTIONSELECT" -- The state for letting the user choose actions.
| "MENUSELECT" -- The state used when selecting an action from the menu.
| "ENEMYSELECT" -- The state used when selecting an enemy target.
| "PARTYSELECT" -- The state used when selecting a party member.
| "ACTIONS" -- The state used when processing actions. Most of the time, other states will be used instead.
| "ACTING" -- The state used when party members act.
| "BATTLETEXT" -- A generic "writing text" state.
| "SHORTACTTEXT" -- The state used when multiple lines of text are being written out at once, for "short acts".
| "ATTACKING" -- The state used while party members are attacking.
| "SPARING" -- The state used when party members spare.
| "USINGITEMS" -- The state used when party members use items.
| "ACTIONSDONE" -- The state used when all "actions" are done.
| "ENEMYDIALOGUE" -- The state used when enemies are displaying dialogue.
| "DIALOGUEEND" -- The state used after enemy dialogue ends.
| "DEFENDINGBEGIN" -- The state used before defending begins.
| "DEFENDING" -- The state used when the player is defending against enemy waves.
| "DEFENDINGEND" -- The state used after defending ends.
| "VICTORY" -- The state used when the player has won the battle.
| "TRANSITIONOUT" -- The state used when transitioning out of battle.
| "CUTSCENE" -- The state used when a battle cutscene is active.
Arguments:
| old: "ACTING"|"ACTIONS"|"ACTIONSDONE"|"ACTIONSELECT"|"ATTACKING"...(+18) | The old state. |
| new: "ACTING"|"ACTIONS"|"ACTIONSDONE"|"ACTIONSELECT"|"ATTACKING"...(+18) | The new state. |
| reason: string? | The reason for the state change. |
Battle:checkGameOver()
Checks to see whether the whole party is downed and starts a GameOver if they are
Battle:checkSolidCollision(collider: Collider|Object)
Returns whether collider collides with a Solid or the arena
Arguments:
| collider: Collider|Object | The base class of all objects in Kristal. |
Returns:
| collided: boolean | |
| colliding_with: (Arena|Solid)? |
Battle:commitAction(battler: any, action_type: any, target: any, data: any, extra: any)
Arguments:
| battler: any | |
| action_type: any | |
| target: any | |
| data: any | |
| extra: any |
Battle:darken()
Darken the battle background & party members.
Battle:debugPrintOutline(string: string, x: number, y: number, color: number, [2]? }?)
Arguments:
| string: string | |
| x: number | |
| y: number | |
| color: number, [2]? }? | Three values representing a color, with an optional alpha value. Values are between 0 and 1. |
Battle:doGreenApronHeal(battler: PartyBattler, num_equipped: integer)
Arguments:
| battler: PartyBattler |
|
| num_equipped: integer |
Battle:endActionAnimation(battler: any, action: any, callback: any)
Arguments:
| battler: any | |
| action: any | |
| callback: any |
Battle:endWaves()
Forcibly end the wave.
This should not be called in place of normal wave ending via time or enemy defeat.
This ends up entering the DEFENDINGEND state.
Battle:getActionBy(battler: any, ignore_current: any)
Arguments:
| battler: any | |
| ignore_current: any |
Returns:
| 1: unknown|nil |
Battle:getActiveEnemies()
Gets a list of all the active (not defeated/spared) enemies
Returns:
| 1: EnemyBattler[] |
Battle:getActiveParty()
Gets a list of all the active (not downed) party members
Returns:
| 1: PartyBattler[] |
Battle:getDefendTension(battler: PartyBattler)
Returns the tension gained from defending. By default, this redirects to Encounter.
Arguments:
| battler: PartyBattler | The current battler about to defend. |
Returns:
| tension: number | The tension gained from defending. |
Battle:getEncounterText()
A simple redirect to the Encounter's getEncounterText.
Here for encapsulation and hooking, if you need more complex behavior.
Returns:
| text: string|string[] | If a table, you should use [next] to advance the text |
| portrait: string? | The portrait to show |
| actor: (string|Actor|PartyBattler|PartyMember)? | The actor to use for the text settings (ex. voice, portrait settings) |
Battle:getEnemyBattler(string_id: string)
Gets an EnemyBattler in the current battle from their id
Arguments:
| string_id: string |
Returns:
| 1: EnemyBattler? |
Battle:getEnemyFromCharacter(chara: Character)
Gets an enemy in battle from their corresponding world Character
Arguments:
| chara: Character | All types of character in the overworld inherit from the |
Returns:
| 1: EnemyBattler? |
Battle:getInitialEncounterText()
A simple redirect to the Encounter's getInitialEncounterText.
Here for encapsulation and hooking, if you need more complex behavior.
Returns:
| text: string|string[] | If a table, you should use [next] to advance the text |
| portrait: string? | The portrait to show |
| actor: (string|Actor|PartyBattler|PartyMember)? | The actor to use for the text settings (ex. voice, portrait settings) |
Battle:getPartyBattler(string_id: string)
Gets a PartyBattler in the current battle from their id
Arguments:
| string_id: string |
Returns:
| 1: PartyBattler? |
Battle:getPartyIndex(string_id: string)
Gets the index of a party member with the given id
Arguments:
| string_id: string |
Returns:
| 1: integer? |
Battle:getSoulLocation(always_origin: boolean?)
Gets the location the soul should spawn at when waves start by default
Arguments:
| always_origin: boolean? |
Returns:
| 1: number | |
| 2: number |
Battle:getState()
Returns the current state of the battle.
return #1:
| "NONE" -- An empty state which does nothing.
| "TRANSITION" -- The state used when first entering a battle.
| "INTRO" -- The state used after TRANSITION, where the battle intro animation plays.
| "ACTIONSELECT" -- The state for letting the user choose actions.
| "MENUSELECT" -- The state used when selecting an action from the menu.
| "ENEMYSELECT" -- The state used when selecting an enemy target.
| "PARTYSELECT" -- The state used when selecting a party member.
| "ACTIONS" -- The state used when processing actions. Most of the time, other states will be used instead.
| "ACTING" -- The state used when party members act.
| "BATTLETEXT" -- A generic "writing text" state.
| "SHORTACTTEXT" -- The state used when multiple lines of text are being written out at once, for "short acts".
| "ATTACKING" -- The state used while party members are attacking.
| "SPARING" -- The state used when party members spare.
| "USINGITEMS" -- The state used when party members use items.
| "ACTIONSDONE" -- The state used when all "actions" are done.
| "ENEMYDIALOGUE" -- The state used when enemies are displaying dialogue.
| "DIALOGUEEND" -- The state used after enemy dialogue ends.
| "DEFENDINGBEGIN" -- The state used before defending begins.
| "DEFENDING" -- The state used when the player is defending against enemy waves.
| "DEFENDINGEND" -- The state used after defending ends.
| "VICTORY" -- The state used when the player has won the battle.
| "TRANSITIONOUT" -- The state used when transitioning out of battle.
| "CUTSCENE" -- The state used when a battle cutscene is active.
Returns:
| 1: "ACTING"|"ACTIONS"|"ACTIONSDONE"|"ACTIONSELECT"|"ATTACKING"...(+18) |
Battle:getTargetForItem(item: table, default_ally: PartyBattler?, default_enemy: EnemyBattler?)
Arguments:
| item: table | |
| default_ally: PartyBattler? |
|
| default_enemy: EnemyBattler? |
Recruit data is separate to enemies, see |
Returns:
| 1: (EnemyBattler[]|PartyBattler[])? |
Battle:hasAction(character_id: integer)
Gets whether a specific character has an action lined up
Arguments:
| character_id: integer |
Returns:
| 1: boolean |
Battle:hasReducedTension()
Checks if the current encounter has reduced tension. By default, this redirects to Encounter
Returns:
| reduced: boolean | Whether the encounter has reduced tension. |
Battle:hideTargets()
Hide the target indicators on all party members.
Battle:hurt(amount: number, exact: boolean?, target: (number|"ALL"|"ANY"|PartyBattler)?, swoon: boolean?)
Hurts the target party member(s)
-- `PartyBattler`s are a type of `Battler` that represent [`PartyMember`](file:///srv/shadow/tmp/kristal/src/engine/game/common/data/partymember.lua#73)s when they are in battle. \
-- The set of `PartyBattler`s in the current battle are stored in [`Game.battle.party`](file:///srv/shadow/tmp/kristal/src/engine/game/battle.lua#6). \
-- Unlike `EnemyBattler`, party members do not need to define a `PartyBattler` in a file as their PartyMember file defines everything necessary and is utilised by `PartyBattler`.
--
target:
| "ALL"
| "ANY"
Arguments:
| amount: number | The amount of damage which should be dealt. |
| exact: boolean? | Whether or not the damage should be applied exactly (defaults to |
| target: (number|"ALL"|"ANY"|PartyBattler)? | The target of the attack. Can be a battler's index, a battler, "ANY" or "ALL" (defaults to |
| swoon: boolean? | Whether or not the damage will swoon the battler if they're downed |
Returns:
| 1: table? |
Battle:infoText(text: string[]?)
Sets the current message in the battlebox - this text can not be advanced, only overwritten if another text is set
Arguments:
| text: string[]? | The text to set |
Battle:internalEndWaves()
Responsible for actually ending the waves.
This removes the arena, returns the soul, ends all of the waves, and moves to the next turn if specified.
This should NOT be called by user code; instead, use Battle:endWaves() to end the waves if an immediate end is needed.
Battle:isHighlighted(battler: Battler)
Arguments:
| battler: Battler | The base class for participants in battles.
This class defines shared logic between types of |
Returns:
| 1: boolean |
Battle:nextTurn()
Advances to the next turn of the battle
Battle:onActionSelectState()
Called when the BattleState is set to ACTIONSELECT.
Battle:onActionsState()
Called when the BattleState is changed to ACTIONS.
Battle:onBattleTextState()
Called when the BattleState is changed to BATTLETEXT.
Battle:onDefendingBeginState()
Called when the BattleState is changed to DEFENDINGBEGIN.
Battle:onDefendingEndState()
Called when the BattleState is changed to DEFENDINGEND.
Battle:onDefendingState()
Called when the BattleState is changed to DEFENDING.
Battle:onDialogueEndState()
Called when the BattleState is changed to DIALOGUEEND.
Battle:onEnemyDialogueState()
Called when the BattleState is changed to ENEMYDIALOGUE.
Battle:onEnemySelectState()
Called when the BattleState is changed to ENEMYSELECT.
Battle:onIntroState()
Called when the BattleState is set to INTRO.
Battle:onMenuSelectState()
Called when the BattleState is changed to MENUSELECT.
Battle:onPartySelectState()
Called when the BattleState is changed to PARTYSELECT.
Battle:onRemove(parent: Object)
Arguments:
| parent: Object | The base class of all objects in Kristal. |
Battle:onStateChange(old: "ACTING"|"ACTIONS"|"ACTIONSDONE"|"ACTIONSELECT"|"ATTACKING"...(+18), new: "ACTING"|"ACTIONS"|"ACTIONSDONE"|"ACTIONSELECT"|"ATTACKING"...(+18), reason: string?)
Called when the BattleState is changed via Battle:setState().
old:
| "NONE" -- An empty state which does nothing.
| "TRANSITION" -- The state used when first entering a battle.
| "INTRO" -- The state used after TRANSITION, where the battle intro animation plays.
| "ACTIONSELECT" -- The state for letting the user choose actions.
| "MENUSELECT" -- The state used when selecting an action from the menu.
| "ENEMYSELECT" -- The state used when selecting an enemy target.
| "PARTYSELECT" -- The state used when selecting a party member.
| "ACTIONS" -- The state used when processing actions. Most of the time, other states will be used instead.
| "ACTING" -- The state used when party members act.
| "BATTLETEXT" -- A generic "writing text" state.
| "SHORTACTTEXT" -- The state used when multiple lines of text are being written out at once, for "short acts".
| "ATTACKING" -- The state used while party members are attacking.
| "SPARING" -- The state used when party members spare.
| "USINGITEMS" -- The state used when party members use items.
| "ACTIONSDONE" -- The state used when all "actions" are done.
| "ENEMYDIALOGUE" -- The state used when enemies are displaying dialogue.
| "DIALOGUEEND" -- The state used after enemy dialogue ends.
| "DEFENDINGBEGIN" -- The state used before defending begins.
| "DEFENDING" -- The state used when the player is defending against enemy waves.
| "DEFENDINGEND" -- The state used after defending ends.
| "VICTORY" -- The state used when the player has won the battle.
| "TRANSITIONOUT" -- The state used when transitioning out of battle.
| "CUTSCENE" -- The state used when a battle cutscene is active.
new:
| "NONE" -- An empty state which does nothing.
| "TRANSITION" -- The state used when first entering a battle.
| "INTRO" -- The state used after TRANSITION, where the battle intro animation plays.
| "ACTIONSELECT" -- The state for letting the user choose actions.
| "MENUSELECT" -- The state used when selecting an action from the menu.
| "ENEMYSELECT" -- The state used when selecting an enemy target.
| "PARTYSELECT" -- The state used when selecting a party member.
| "ACTIONS" -- The state used when processing actions. Most of the time, other states will be used instead.
| "ACTING" -- The state used when party members act.
| "BATTLETEXT" -- A generic "writing text" state.
| "SHORTACTTEXT" -- The state used when multiple lines of text are being written out at once, for "short acts".
| "ATTACKING" -- The state used while party members are attacking.
| "SPARING" -- The state used when party members spare.
| "USINGITEMS" -- The state used when party members use items.
| "ACTIONSDONE" -- The state used when all "actions" are done.
| "ENEMYDIALOGUE" -- The state used when enemies are displaying dialogue.
| "DIALOGUEEND" -- The state used after enemy dialogue ends.
| "DEFENDINGBEGIN" -- The state used before defending begins.
| "DEFENDING" -- The state used when the player is defending against enemy waves.
| "DEFENDINGEND" -- The state used after defending ends.
| "VICTORY" -- The state used when the player has won the battle.
| "TRANSITIONOUT" -- The state used when transitioning out of battle.
| "CUTSCENE" -- The state used when a battle cutscene is active.
Arguments:
| old: "ACTING"|"ACTIONS"|"ACTIONSDONE"|"ACTIONSELECT"|"ATTACKING"...(+18) | |
| new: "ACTING"|"ACTIONS"|"ACTIONSDONE"|"ACTIONSELECT"|"ATTACKING"...(+18) | |
| reason: string? |
Battle:onSubStateChange(old: string, new: string, reason: any)
Arguments:
| old: string | |
| new: string | |
| reason: any |
Battle:onTransitionOutState()
Called when the BattleState is changed to TRANSITIONOUT.
Battle:onVictory()
Called when the BattleState is changed to VICTORY.
Battle:postInit(state: string, encounter: string|Encounter)
Arguments:
| state: string | |
| encounter: string|Encounter | Encounters detail the setup of unique battles in Kristal, from the enemies that appear to the environment and special mechanics. |
Battle:powerAct(spell: string|Spell, battler: Battler, user: string, target: (Battler|Battler[])?)
Turns a party member's turn from an ACT into a SPELL cast
Should be called from inside EnemyBattler:onAct()
Arguments:
| spell: string|Spell | The name of the spell that should be casted by |
| battler: Battler | The battler that initiates the ACT |
| user: string | The id of the battler that should cast the spell |
| target: (Battler|Battler[])? | An optional list of battlers that |
Battle:pushAction(action_type: any, target: any, data: any, character_id: any, extra: any)
Arguments:
| action_type: any | |
| target: any | |
| data: any | |
| character_id: any | |
| extra: any |
Battle:pushForcedAction(battler: any, action: any, target: any, data: any, extra: any)
Arguments:
| battler: any | |
| action: any | |
| target: any | |
| data: any | |
| extra: any |
Battle:randomTarget()
-- `PartyBattler`s are a type of `Battler` that represent [`PartyMember`](file:///srv/shadow/tmp/kristal/src/engine/game/common/data/partymember.lua#73)s when they are in battle. \
-- The set of `PartyBattler`s in the current battle are stored in [`Game.battle.party`](file:///srv/shadow/tmp/kristal/src/engine/game/battle.lua#6). \
-- Unlike `EnemyBattler`, party members do not need to define a `PartyBattler` in a file as their PartyMember file defines everything necessary and is utilised by `PartyBattler`.
--
return #1:
| "ANY"
Returns:
| 1: "ANY"|PartyBattler |
Battle:randomTargetOld()
-- `PartyBattler`s are a type of `Battler` that represent [`PartyMember`](file:///srv/shadow/tmp/kristal/src/engine/game/common/data/partymember.lua#73)s when they are in battle. \
-- The set of `PartyBattler`s in the current battle are stored in [`Game.battle.party`](file:///srv/shadow/tmp/kristal/src/engine/game/battle.lua#6). \
-- Unlike `EnemyBattler`, party members do not need to define a `PartyBattler` in a file as their PartyMember file defines everything necessary and is utilised by `PartyBattler`.
--
return #1:
| "ALL"
Returns:
| 1: "ALL"|PartyBattler |
Battle:registerXAction(party: string, name: string, description: string?, tp: number?)
Registers an additional X-Action for a specific party member
Arguments:
| party: string | The id of the party member who will receive this X-Action |
| name: string | The name of this X-Action |
| description: string? | The description of this X-Action |
| tp: number? | The tp cost of this X-Action |
Battle:removeAction(character_id: integer, from_defeat: boolean?)
Remove a party member's action from the list of actions.
Arguments:
| character_id: integer | The index of the party member whose action should be removed |
| from_defeat: boolean? | Whether this removal is due to the character being defeated |
Battle:removeEnemy(enemy: EnemyBattler, defeated: boolean?)
Removes an enemy from the battle
Arguments:
| enemy: EnemyBattler | The |
| defeated: boolean? | If |
Battle:removeSingleAction(action: any, from_defeat: any)
Removes a single action from the list of actions.
Arguments:
| action: any | |
| from_defeat: any |
Battle:resetEnemiesIndex(reset_xact: boolean?)
Resets the enemies index table, closing all gaps in the enemy select menu
Arguments:
| reset_xact: boolean? | Whether to also reset the XACT position |
Battle:returnToWorld()
Ends the battle and removes itself from Game.battle
Battle:setActText(text: string|string[], dont_finish: boolean?)
Arguments:
| text: string|string[] | |
| dont_finish: boolean? |
Battle:setEncounterText(options: EncounterTextOptions, instant: any)
Arguments:
| options: EncounterTextOptions | |
| instant: any |
Battle:setState(state: "ACTING"|"ACTIONS"|"ACTIONSDONE"|"ACTIONSELECT"|"ATTACKING"...(+18), reason: string?)
Changes the state of the battle and calls onStateChange()
state:
| "NONE" -- An empty state which does nothing.
| "TRANSITION" -- The state used when first entering a battle.
| "INTRO" -- The state used after TRANSITION, where the battle intro animation plays.
| "ACTIONSELECT" -- The state for letting the user choose actions.
| "MENUSELECT" -- The state used when selecting an action from the menu.
| "ENEMYSELECT" -- The state used when selecting an enemy target.
| "PARTYSELECT" -- The state used when selecting a party member.
| "ACTIONS" -- The state used when processing actions. Most of the time, other states will be used instead.
| "ACTING" -- The state used when party members act.
| "BATTLETEXT" -- A generic "writing text" state.
| "SHORTACTTEXT" -- The state used when multiple lines of text are being written out at once, for "short acts".
| "ATTACKING" -- The state used while party members are attacking.
| "SPARING" -- The state used when party members spare.
| "USINGITEMS" -- The state used when party members use items.
| "ACTIONSDONE" -- The state used when all "actions" are done.
| "ENEMYDIALOGUE" -- The state used when enemies are displaying dialogue.
| "DIALOGUEEND" -- The state used after enemy dialogue ends.
| "DEFENDINGBEGIN" -- The state used before defending begins.
| "DEFENDING" -- The state used when the player is defending against enemy waves.
| "DEFENDINGEND" -- The state used after defending ends.
| "VICTORY" -- The state used when the player has won the battle.
| "TRANSITIONOUT" -- The state used when transitioning out of battle.
| "CUTSCENE" -- The state used when a battle cutscene is active.
Arguments:
| state: "ACTING"|"ACTIONS"|"ACTIONSDONE"|"ACTIONSELECT"|"ATTACKING"...(+18) | |
| reason: string? |
Battle:setSubState(state: string, reason: string?)
Changes the substate of the battle and calls onSubStateChange()
Arguments:
| state: string | |
| reason: string? |
Battle:setWaves(waves: string|Wave|table<string|, allow_duplicates: boolean?)
Sets the waves table to what is specified by waves
Arguments:
| waves: string|Wave|table<string| | Waves are the bullet patterns that enemies use in battle. |
| allow_duplicates: boolean? | If true, duplicate waves will coexist with each other |
Returns:
| 1: Wave[] |
Battle:shakeCamera(x: number?, y: number?, friction: number?)
Shakes the camera by the specified x, y.
Arguments:
| x: number? | The amount of shake in the |
| y: number? | The amount of shake in the |
| friction: number? | The amount that the shake should decrease by, per frame at 30FPS. (Defaults to |
Battle:shouldDecreaseInvuln()
Whether the battle should decrease the invulnerability timer.
By default, this redirects to Encounter:shouldDecreaseInvuln().
Returns:
| decrease_invuln: boolean? |
|
Battle:showTargets()
Show the target indicators on all currently targeted party members.
Battle:spawnSoul(x: number?, y: number?)
Spawns the soul and sets up its transition from the source character to its starting position
Arguments:
| x: number? | |
| y: number? |
Battle:startActCutscene(group: string, id: string, dont_finish: boolean?)
Starts a cutscene in battle where the cutscene receives the the currently ACTing character and the ACT's target as additional arguments \
Arguments:
| group: string | The name of the group the cutscene is a part of |
| id: string | The id of the cutscene |
| dont_finish: boolean? | Whether the action should end when the cutscene finishes (defaults to |
Returns:
| 1: Cutscene? |
Battle:startCutscene(group: string, id: string, ...: any)
Starts a cutscene in battle
When setting a cutscene during the ACTIONS state, see `Battle:startActCutscene() instead
Arguments:
| group: string | The name of the group the cutscene is a part of |
| id: string | The id of the cutscene |
| ...: any | Additional arguments that will be passed to the cutscene function |
Returns:
| 1: BattleCutscene? |
Battle:swapSoul(object: Soul)
Replaces the current soul (if it exists) with a different soul instance
Arguments:
| object: Soul | The Soul is the object the player controls in battle. |
Battle:target(target: number|PartyBattler)
-- `PartyBattler`s are a type of `Battler` that represent [`PartyMember`](file:///srv/shadow/tmp/kristal/src/engine/game/common/data/partymember.lua#73)s when they are in battle. \
-- The set of `PartyBattler`s in the current battle are stored in [`Game.battle.party`](file:///srv/shadow/tmp/kristal/src/engine/game/battle.lua#6). \
-- Unlike `EnemyBattler`, party members do not need to define a `PartyBattler` in a file as their PartyMember file defines everything necessary and is utilised by `PartyBattler`.
--
return #1:
| "ALL"
| "ANY"
Arguments:
| target: number|PartyBattler |
|
Returns:
| 1: "ALL"|"ANY"|PartyBattler |
Battle:undarken()
Undarken the battle background & any party members which were darkened.
Fields
Battle.arena: Arena?
The current Arena instance, if any
Battle.background: BattleBackground?
The BattleBackground, if any
Battle.battler_targets:
Target positions for PartyBattlers to transition to at the start of battle
Battle.cutscene: BattleCutscene?
The active battle cutscene, if it exists - see Battle:startCutscene() or Battle:startActCutscene() for how to start cutscenes
Battle.darkener: BattleDarkener?
The BattleDarkener, if any
Battle.encounter: Encounter
The encounter currently being used for this battle (only set during postInit())
Battle.encounter_context: ChaserEnemy?
An optional ChaserEnemy instance that initiated the battle
Battle.enemies_index: EnemyBattler|`false`[]
EnemyBattlers are a type of Battler that represent enemies, defining all their properties and behaviours.
Every enemy defined in a project should be located in its own file in scripts/battle/enemies/, and should extend this class.
Each enemy is assigned an id that defaults to their filepath starting from scripts/battle/enemies, unless an id is specified as an argument to Class().
Enemies are added to battles in the encounter, with Encounter:addEnemy(enemy, x, y, ...), where enemy is their unique id, and all enemies for the current battle reside in Game.battle.enemies
Recruit data is separate to enemies, see Recruit for how to set up a corresponding recruit.
Battle.enemy_beginning_positions:
The position of each EnemyBattler at the start of the battle transition
Battle.enemy_world_characters:
A list of mappings between EnemyBattlers and their representations as Characters in the world, if they exist
Battle.mask: ArenaMask
Objects parented to this will be masked to the arena
Battle.money: integer
Current amount of victory money
Battle.music: Music
The battle music
Battle.party: PartyBattler[]
A table of all the PartyBattlers in the current battle
Battle.party_beginning_positions:
The position of each PartyBattler at the start of the battle transition
Battle.party_world_characters:
A list of mappings between PartyBattlers (by id) and their representations as Characters in the world, if they exist
Battle.resume_world_music: boolean
(only set during postInit())
Battle.soul: Soul?
The current Soul instance, if any
Battle.spare_sound: Sound
A sound source for the spare sfx, should be used for every time this sound plays in battle
Battle.state: "ACTING"|"ACTIONS"|"ACTIONSDONE"|"ACTIONSELECT"|"ATTACKING"...(+18)
The current state of the battle - should never be set manually, see Battle:setState() instead
Battle.state_reason: string?
The reason for the current state of the battle - should never be set manually, see Battle:setState() instead
Battle.substate: string
The current substate of the battle - should never be set manually, see Battle:setSubState() instead
Battle.tension_bar: TensionBar
The bar you see on the left of the battle UI.
This is simply a display for tension, but not where tension itself is stored.
Does not depend on battle.
Battle.timer: Timer
A generic timer object for the battle system
Battle.transitioned: boolean
Whether the battle opened with a transition (only set during postInit())
Battle.turn_count: integer
The current turn number
Battle.ui_move: Sound
A sound source for the ui_move sfx, should be used for every time this sound plays in battle
Battle.ui_select: Sound
A sound source for the ui_select sfx, should be used for every time this sound plays in battle
Battle.used_violence: boolean
Whether any enemy was defeated through violence or not