Battler
┗> Object > Class
The base class for participants in battles.
This class defines shared logic between types of Battler, but is not used on its own.
See EnemyBattler or PartyBattler depending on which you are working with, as well as this object.
Constructor
Battler(x: number?, y: number?, width: number?, height: number?)
Arguments:
| x: number? | |
| y: number? | |
| width: number? | |
| height: number? |
Methods
Battler:alert(duration: number?, options: (table|"callback"|"layer"|"offset_x"|"offset_y"...(+2))?)
Creates an alert bubble (tiny !) above this battler.
options:
| "play_sound" -- Whether the alert sound will be played. (Defaults to `true`)
| "sprite" -- The sprite to use for the alert bubble. (Defaults to `"effects/alert"`)
| "offset_x" -- The x-offset of the icon.
| "offset_y" -- The y-offset of the icon.
| "layer" -- The layer to put the icon on. (Defaults to `100`)
| "callback" -- A callback that is run when the alert finishes.
Arguments:
| duration: number? | The number of frames to show the bubble for. (Defaults to |
| options: (table|"callback"|"layer"|"offset_x"|"offset_y"...(+2))? | A table defining additional properties to control the bubble. |
Returns:
| 1: Sprite |
Battler:flash(sprite: Sprite?, offset_x: number?, offset_y: number?, layer: number?, color: number, [2]? }?)
Makes the battler flash once.
Arguments:
| sprite: Sprite? | An optional sprite to use for the flash instead of the battler's default sprite. |
| offset_x: number? | |
| offset_y: number? | |
| layer: number? | |
| color: number, [2]? }? | The color used to draw the flash, defaulting to white |
Returns:
| 1: FlashFade |
Battler:getActiveSprite()
Returns the active sprite, out of the battler's main and overlay sprite.
Returns:
| 1: ActorSprite? |
Battler:healEffect(r: number?, g: number?, b: number?)
Creates a standard "healing effect" (flash, sparkles).
Arguments:
| r: number? | |
| g: number? | |
| b: number? |
Battler:onBubbleRemove(bubble: SpeechBubble)
(Override) Called whenever a speech bubble is removed for this battler.
Arguments:
| bubble: SpeechBubble |
Battler:onBubbleSpawn(bubble: SpeechBubble)
(Override) Called whenever a speech bubble is created for this battler.
Arguments:
| bubble: SpeechBubble |
Battler:recruitMessage(x: number, y: number, type: string)
(Called internally) Creates a RECRUIT message for when an enemy is spared and recruit progression advances
Arguments:
| x: number | |
| y: number | |
| type: string |
Returns:
| 1: RecruitMessage |
Battler:resetSprite()
Sets the Battler's sprite back to their default
Battler:setActor(actor: string|Actor, use_overlay: boolean?)
Sets the actor used for this battler.
Arguments:
| actor: string|Actor | The id or instance of the |
| use_overlay: boolean? | Whether to use the overlay sprite system (Defaults to |
Battler:setAnimation(animation: string|table, callback: fun( any)?)
Shorthand for ActorSprite:setAnimation()
Arguments:
| animation: string|table | |
| callback: fun( any)? |
Returns:
| 1: boolean |
Battler:setCustomSprite(sprite: string?, ox: number?, oy: number?, speed: number?, loop: boolean?, after: fun( any)?)
Shorthand for calling ActorSprite:setCustomSprite() and then ActorSprite:play()
Arguments:
| sprite: string? | |
| ox: number? | |
| oy: number? | |
| speed: number? | |
| loop: boolean? | |
| after: fun( any)? |
Battler:setSprite(sprite: string?, speed: number?, loop: boolean?, after: fun( any)?)
Shorthand for ActorSprite:setSprite() and ActorSprite:play()
Arguments:
| sprite: string? | |
| speed: number? | |
| loop: boolean? | |
| after: fun( any)? |
Battler:sparkle(r: number?, g: number?, b: number?)
Creates sparkles around the battler (these appear by default when the battler receives healing)
Arguments:
| r: number? | |
| g: number? | |
| b: number? |
Battler:spawnSpeechBubble(text: string|string[], options: (table|"actor"|"after"|"font"|"line_callback"...(+2))?)
Creates a speech bubble for this battler.
options:
| "style" -- The dialogue bubble style to use (Defaults to [`Battler.dialogue_bubble`](file:///vercel/path0/tmp/kristal/src/engine/game/battle/battler.lua#19))
| "right" -- Whether the dialogue bubble should appear to the right of the battler (Defaults to `false`)
| "font" -- The font to use for the speech bubble
| "actor" -- The actor to use for the speech bubble
| "after" -- A callback that will be run after the dialogue is finished
| "line_callback" -- A callback that will be run after each line of dialogue is advanced
Arguments:
| text: string|string[] | The text to display in the speech bubble. Can be a table defining multiple lines. |
| options: (table|"actor"|"after"|"font"|"line_callback"...(+2))? | A table defining additional properties to control the speech bubble: |
Returns:
| 1: SpeechBubble |
Battler:statusMessage(x: number?, y: number?, type: (string|"damage"|"mercy"|"msg")?, arg: any, color: number, [2]? }?, kill: boolean?, delay: number?)
Creates a status text on the battler.
Used for information such as damage numbers, being downed, or missing a hit
type:
| "mercy" -- Indicates that the message will be a mercy number
| "damage" -- Indicates that the message will be a damage number
| "msg" -- Indicates that the message will use a unique sprite, such as MISS or DOWN text
arg:
| "mercy" -- The amount of mercy added
| "damage" -- The amount of damage dealt
| "msg" -- The path to the sprite, relative to `ui/battle/message`, to use
Arguments:
| x: number? | The x-coordinate the message should appear at, relative to the battler. |
| y: number? | The y-coordinate the message should appear at, relative to the battler. |
| type: (string|"damage"|"mercy"|"msg")? | The type of message to display: |
| arg: any | An additional argument which depends on what |
| color: number, [2]? }? | The color used to draw the status message, defaulting to white |
| kill: boolean? | Whether this status should cause all other statuses to disappear. |
| delay: number? | The number of frames before this message first appears |
Returns:
| 1: DamageNumber |
Battler:toggleOverlay(overlay: boolean?)
Toggles the visibility of the overlay sprite versus main sprite.
Arguments:
| overlay: boolean? | Whether the overlay should be visible. If unset, will invert whatever the current visibility state is. |
Fields
Battler.alert_callback: fun()?
Internal variable used to store a callback for after an alert, if set.
Battler.alert_icon: Sprite?
Internal variable used to store the battler's overhead alert icon.
Battler.alert_timer: number
Internal timer variable for the battler's overhead alert icon.
Battler.dialogue_bubble: string?
The bubble style used for the battler. Defaults to "round" or "cyber", depending on chapter.
Battler.dialogue_offset: [number, number]
The offset of the dialogue bubble from its default position.
Battler.flash_timer: number
Internal timer variable for the battler's selected flash.
Battler.highlight: ColorMaskFX
An instance of a white ColorMaskFX, used for the white flash when the battler is selected in a menu.
Battler.hit_count: number
The number of times the battler has been hit recently, used for the stacking effect of damage numbers.
Battler.last_highlighted: boolean
Internal variable used to determine whether the battler was highlighted last frame.
Battler.overlay_sprite: ActorSprite?
An overlay sprite being used by this battler - special animations such as being hurt or downed take place on this sprite as to preserve the main sprite's animation cycle afterwards.
Battler.sprite: ActorSprite?
The main sprite being used by this battler.
Undocumented
Battler.actor: Actor
Actors are a type of data class that represent the visuals of a character - anything that is some type of character, be it the player, an NPC, or an enemy in battle, it will require an actor.
As a data class, actors are stored in scripts/data/actors/, and extend this class. Their filepath starting from here becomes their id, unless an id is specified as an argument to Class().