Methods
Battle:advanceBoxes()
Advances all enemy dialogue bubbles
Battle:applyHealBonuses(base_heal: number, healer: PartyMember)
Returns the equipment-modified heal amount from a healing action performed by the specified party member
@param base_heal
— The heal amount to modify
@param healer
— The character performing the heal action
Arguments:
base_heal: number | The heal amount to modify |
healer: PartyMember | The character performing the heal action |
Returns:
1: number |
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
@param text
— The text to set
@param post_func
— When the text is advanced, the name of the state to move to, or a function to run
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:checkGameOver()
Checks to see whether the whole party is downed and starts a GameOver
if they are
Battle:checkSolidCollision(collider: Collider)
Returns whether collider
collides with the arena
Arguments:
collider: Collider |
Returns:
collided: boolean | |
colliding_arena: Arena? |
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:debugPrintOutline(string: string, x: number, y: number, color: table?)
Arguments:
string: string | |
x: number | |
y: number | |
color: table? |
Battle:endActionAnimation(battler: any, action: any, callback: any)
Arguments:
battler: any | |
action: any | |
callback: any |
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.
@param battler
— The current battler about to defend.
@return tension
— The tension gained from defending.
Arguments:
battler: PartyBattler | The current battler about to defend. |
Returns:
tension: number | The tension gained from defending. |
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: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: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[]|nil |
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
@return reduced
— Whether the encounter has reduced tension.
Returns:
reduced: boolean | Whether the encounter has reduced tension. |
Battle:hurt(amount: number, exact: boolean?, target: (number|"ALL"|"ANY"|PartyBattler)?)
Hurts the target
party member(s)
@param target
— The target battler's index, instance, or strings for specific selection logic (defaults to "ANY"
)
-- `PartyBattler`s are a type of `Battler` that represent [`PartyMember`](file:///vercel/path0/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:///vercel/path0/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 | |
exact: boolean? | |
target: (number|"ALL"|"ANY"|PartyBattler)? | The target battler's index, instance, or strings for specific selection logic (defaults to |
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
@param text
— The text to set
Arguments:
text: string[]? | The text to set |
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:onRemove(parent: Object)
Arguments:
parent: Object | The base class of all objects in Kristal. |
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: string, 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()
@param spell
— The name of the spell that should be casted by user
@param battler
— The id of the battler that initiates the ACT
@param user
— The id of the battler that should cast the spell
@param target
— An optional list of battlers that
Arguments:
spell: string|Spell | The name of the spell that should be casted by |
battler: string | The id of 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:///vercel/path0/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:///vercel/path0/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:///vercel/path0/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:///vercel/path0/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
@param party
— The id of the party member who will receive this X-Action
@param name
— The name of this X-Action
@param description
— The description of this X-Action
@param tp
— The tp cost of this X-Action
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:removeEnemy(enemy: EnemyBattler, defeated: boolean?)
Removes an enemy from the battle
@param enemy
— The EnemyBattler
that should be removed
@param defeated
— If true
, the enemy is considered as 'defeated'
Arguments:
enemy: EnemyBattler | The |
defeated: boolean? | If |
Battle:resetEnemiesIndex(reset_xact: boolean?)
Resets the enemies index table, closing all gaps in the enemy select menu
@param reset_xact
— Whether to also reset the XACT position
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:setState(state: string, reason: string?)
Changes the state of the battle and calls onStateChange()
Arguments:
state: string | |
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: table<string|Wave>, allow_duplicates: boolean?)
Sets the waves table to what is specified by waves
@param allow_duplicates
— If true, duplicate waves will coexist with each other
Arguments:
waves: table<string|Wave> | |
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
.
@param x
— The amount of shake in the x
direction. (Defaults to 4
)
@param y
— The amount of shake in the y
direction. (Defaults to 4
)
@param friction
— The amount that the shake should decrease by, per frame at 30FPS. (Defaults to 1
)
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: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 \
@param group
— The name of the group the cutscene is a part of
@param id
— The id of the cutscene
@param dont_finish
— Whether the action should end when the cutscene finishes (defaults to false
)
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
@param group
— The name of the group the cutscene is a part of
@param id
— The id of the cutscene
@param ...
— Additional arguments that will be passed to the cutscene function
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:///vercel/path0/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:///vercel/path0/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 |
Fields
Battle.battler_targets: table<[number, number]>
Target positions for PartyBattler
s 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.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.enemy_beginning_positions: table<[number, number]>
The position of each EnemyBattler
at the start of the battle transition
Battle.enemy_world_characters: table<EnemyBattler, Character>
A list of mappings between EnemyBattler
s and their representations as Character
s 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.party: PartyBattler[]
A table of all the PartyBattler
s in the current battle
Battle.party_beginning_positions: table<[number, number]>
The position of each PartyBattler
at the start of the battle transition
Battle.party_world_characters: table<string, Character>
A list of mappings between PartyBattler
s (by id) and their representations as Character
s in the world, if they exist
Battle.resume_world_music: boolean
(only set during postInit()
)
Battle.soul: Soul?
The Soul is the object the player controls in battle.
The Soul
global stores the default (red) soul. Custom soul types can be created by extending this class in a new global (using a file in scripts/objects/
or scripts/globals/
).
The soul being used in battle is determined by Encounter:createSoul
, and can be altered after the first DEFENDING stage with Battle:swapSoul()
.
Battle.spare_sound: love.Source
A sound source for the spare
sfx, should be used for every time this sound plays in battle
Battle.state: string
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.transitioned: boolean
Whether the battle opened with a transition (only set during postInit()
)
Battle.turn_count: integer
The current turn number
Battle.ui_move: love.Source
A sound source for the ui_move
sfx, should be used for every time this sound plays in battle
Battle.ui_select: love.Source
A sound source for the ui_select
sfx, should be used for every time this sound plays in battle