EnemyBattler
┗> Battler > Object > Class
Constructor
EnemyBattler(actor: (string|Actor)?, use_overlay: boolean?)
Arguments:
actor: (string|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. |
use_overlay: boolean? |
Methods
EnemyBattler:addFlag(flag: string, amount: number?)
Adds amount
to a numeric flag named flag
(or defines it if it does not exist)
This variant of Game:addFlag()
interacts with flags specific to this enemy id
@param flag
— The name of the flag to add to
@param amount
— (Defaults to 1
)
Arguments:
flag: string | The name of the flag to add to |
amount: number? | (Defaults to |
Returns:
new_value: number |
EnemyBattler:addMercy(amount: number)
Adds (or removes) mercy from this enemy
Arguments:
amount: number |
EnemyBattler:addTemporaryMercy(amount: number, play_sound: boolean?, clamp: [number, number]?, kill_condition: function?)
Adds (or removes) temporary mercy from this enemy. Temporary mercy persists until kill_condition is true at any point.
@param play_sound
— Whether to play a sound the first time temporary mercy is added
@param clamp
— A table containing 2 number values that controls the range of the temporary mercy. Defaults to {0, 100}
@param kill_condition
— A function that should return true when the temporary mercy should start to fade out.
Arguments:
amount: number | |
play_sound: boolean? | Whether to play a sound the first time temporary mercy is added |
clamp: [number, number]? | A table containing 2 number values that controls the range of the temporary mercy. Defaults to {0, 100} |
kill_condition: function? | A function that should return true when the temporary mercy should start to fade out. |
EnemyBattler:checkHealth(on_defeat: fun( any, number), amount: number, battler: PartyBattler)
Checks the health of the enemy and defeats it if it is below zero.
@param on_defeat
— A callback to run if the enemy is defeated
@param amount
— The amount of damage taken by the last hit
@param battler
— The party member that dealt the last hit
Arguments:
on_defeat: fun( any, number) | A callback to run if the enemy is defeated |
amount: number | The amount of damage taken by the last hit |
battler: PartyBattler | The party member that dealt the last hit |
EnemyBattler:defeat(reason: string?, violent: boolean?)
Called when an enemy is defeated by any means, controls recruit status, battle rewards, and removing the enemy from battle
@param reason
— The mode the enemy was defeated by - default reasons are "SPARED"
, "PACIFIED"
(Non-violent), "VIOLENCED"
, "FROZEN"
, "KILLED"
(Violent), "DEFEATED"
(Default)
@param violent
— Whetehr the kill method is classed as violent and would result in the enemy's recruit becoming LOST.
Arguments:
reason: string? | The mode the enemy was defeated by - default reasons are |
violent: boolean? | Whetehr the kill method is classed as violent and would result in the enemy's recruit becoming LOST. |
EnemyBattler:forceDefeat(amount: number?, battler: PartyBattler?)
Immediately defeats an enemy
@param amount
— The amount of damage taken by the last hit
@param battler
— The party member that dealt the last hit
Arguments:
amount: number? | The amount of damage taken by the last hit |
battler: PartyBattler? | The party member that dealt the last hit |
EnemyBattler:freeze()
Freezes this enemy and defeats them with the reason "FROZEN"
If this enemy can not be frozen, it makes them run away instead
EnemyBattler:getAct(name: string)
Retrieves the data of an act on this enemy by its name
Arguments:
name: string |
Returns:
1: table |
EnemyBattler:getAttackDamage(damage: number, battler: PartyBattler, points: number)
(Override) Gets the attack damage dealt to this enemy
By default, returns damage
if it is a number greater than 0, otherwise using the attacking battler
and points
against this enemy's defense
to calculate damage
@param points
— The points of the hit, based on closeness to the target box when attacking, maximum value is 150
Arguments:
damage: number | |
battler: PartyBattler |
|
points: number | The points of the hit, based on closeness to the target box when attacking, maximum value is |
Returns:
1: number |
EnemyBattler:getAttackTension(points: number)
(Override) Gets the tension earned by hitting this enemy
By default, returns points / 25
, or if you have reduced tension, points / 65
@param points
— The points of the hit, based on closeness to the target box when attacking, maximum value is 150
Arguments:
points: number | The points of the hit, based on closeness to the target box when attacking, maximum value is |
Returns:
tension: number |
EnemyBattler:getDamageSound()
Gets the name of the damage sound used when this enemy is hit (defaults to "damage"
)
Returns:
sound: string? |
EnemyBattler:getEncounterText()
Gets the encounter text that should be shown in the battle box if this enemy is chosen for encounter text. Called at the start of each turn.
Returns:
text: string? |
EnemyBattler:getEnemyDialogue()
(Override) Gets the dialogue the enemy should say each turn.
*By default, picks a random dialogue from dialogue
unless dialogue_override
is set.
Returns:
1: (string|string[])? |
EnemyBattler:getFlag(flag: string, default: any)
Gets the value of the flag named flag
, returning default
if the flag does not exist
This variant of Game:getFlag()
interacts with flags specific to this enemy id
Arguments:
flag: string | |
default: any |
Returns:
1: any |
EnemyBattler:getGrazeTension()
Get the default graze tension for this enemy. Any bullets which don't specify graze tension will use this value.
@return tension
— The tension to gain when bullets spawned by this enemy are grazed.
Returns:
tension: number | The tension to gain when bullets spawned by this enemy are grazed. |
EnemyBattler:getNameColors()
(Override) Returns a nested table of colors {r, g, b}
that the enemy's name will display in, with multiple colors forming a gradient, and one forming a solid color.
*By default, returns a table with the spareable and tired colors, if the enemy meets their conditions
Returns:
colors: table<[number, number, number]> |
EnemyBattler:getNextWaves()
(Override) Gets the list of waves this enemy can use each turn.
*By default, returns the waves
table, unless wave_override
is set.
Returns:
1: string[] |
EnemyBattler:getSpareText(battler: PartyBattler, success: boolean)
Gets the text that should appear in the battle box when a battler attempts to spare this enemy
@param success
— Whether the enemy was spared successfully
Arguments:
battler: PartyBattler |
|
success: boolean | Whether the enemy was spared successfully |
Returns:
1: string|string[] |
EnemyBattler:getXAction(battler: PartyBattler)
Gets the name of the X-Action usable on this enemy for each individual party member
@param battler
— The battler the X-Action name is being retrieved for
Arguments:
battler: PartyBattler | The battler the X-Action name is being retrieved for |
Returns:
name: string |
EnemyBattler:hurt(amount: number, battler: PartyBattler?, on_defeat: fun( any, number)?, color: table?, show_status: boolean?, attacked: boolean?)
Deals damage to this enemy
@param amount
— The amount of damage the enemy should take
@param battler
— The party member dealing this damage
@param on_defeat
— A callback to run if the enmy is defeated by this hit
@param color
— The color of the damage, overriding the default damage color of the attacker
@param show_status
— Whether to show the damage numbers from this hit
Arguments:
amount: number | The amount of damage the enemy should take |
battler: PartyBattler? | The party member dealing this damage |
on_defeat: fun( any, number)? | A callback to run if the enmy is defeated by this hit |
color: table? | The color of the damage, overriding the default damage color of the attacker |
show_status: boolean? | Whether to show the damage numbers from this hit |
attacked: boolean? |
EnemyBattler:isRecruitable()
Whether the enemy is recruitable - automatically checks to see whether a recruit exists for this enemy
Returns:
1: Recruit? |
EnemyBattler:isXActionShort(battler: PartyBattler)
Whether the X-Action is a short act (Short acts all activate simultaneously) for each individual party member
@param battler
— The battler the X-Action type is being retrieved for
Arguments:
battler: PartyBattler | The battler the X-Action type is being retrieved for |
Returns:
short: boolean |
EnemyBattler:mercyFlash(color: table?)
Creates the particular flash effect used when a party member uses mercy on the enemy, but the spare fails
@param color
— The color the enemy should flash (defaults to yellow)
Arguments:
color: table? | The color the enemy should flash (defaults to yellow) |
EnemyBattler:onAct(battler: PartyBattler, name: string)
(Override) Called when an ACT (including X-Acts, excluding short acts, see EnemyBattler:onShortAct()
) is used on this enemy - This function should be overriden to define behaviour for every act
By default, manages the "Check"
act - call super.onAct(self, battler, name)
in any override to ensure Check is still handled
Acts will softlock Kristal if a string value or table is not returned by this function when they are used
Arguments:
battler: PartyBattler |
|
name: string |
Returns:
text: string|string[] |
EnemyBattler:onActStart(battler: PartyBattler, name: string)
(Override) Called when an ACT on this enemy starts
*By default, sets the sprties of all battlers involved in the act to "battle/act"
@param battler
— The battler using this act - if it is a multi-act, this only specifies the one who used the command
@param name
— The name of the act used
Arguments:
battler: PartyBattler | The battler using this act - if it is a multi-act, this only specifies the one who used the command |
name: string | The name of the act used |
EnemyBattler:onCheck(battler: PartyBattler)
(Override) Called whenever the enemy is checked
Arguments:
battler: PartyBattler |
|
EnemyBattler:onDefeat(damage: number?, battler: PartyBattler?)
(Override) Called when an enemy is defeated through violence
*By default, makes the enemy run via EnemyBattler:onDefeatRun()
if exit_on_defeat
is true
Arguments:
damage: number? | |
battler: PartyBattler? |
|
EnemyBattler:onDefeatFatal(damage: number?, battler: PartyBattler?)
(Override) Normally unused, called to fatally defeat the enemy and defeat them with the reason "KILLED"
Arguments:
damage: number? | |
battler: PartyBattler? |
|
EnemyBattler:onDefeatRun(damage: number?, battler: PartyBattler?)
(Override) Called to defeat an enemy by making them flee when their hp is reduced to 0
Arguments:
damage: number? | |
battler: PartyBattler? |
|
EnemyBattler:onDodge(battler: PartyBattler?, attacked: boolean?)
(Override) Called when the enemy is attacked by a party member, but their hit misses
Arguments:
battler: PartyBattler? |
|
attacked: boolean? |
EnemyBattler:onHurt(damage: number, battler: PartyBattler?)
(Override) Called when an enemy is hurt
By default, starts the hit effects including shaking, hurt sprite, and checks whether the enemy can be made TIRED
@param battler
— The battler that dealt the damage
Arguments:
damage: number | |
battler: PartyBattler? | The battler that dealt the damage |
EnemyBattler:onHurtEnd()
(Override) Called when this enemy finishes hurting
*By default, stops the hurt shake and resets the enemy's sprite.
EnemyBattler:onMercy(battler: PartyBattler)
(Override) Called when a battler uses mercy on (spares) the enemy
By default, responsible for sparing the enemy or increasing their mercy points by spare_points
@return success
— Whether the mercy resulted in a spare
Arguments:
battler: PartyBattler |
|
Returns:
success: boolean | Whether the mercy resulted in a spare |
EnemyBattler:onShortAct(battler: PartyBattler, name: string)
(Override) Called when a short ACT is used, functions identically to EnemyBattler:onAct()
but for short acts
Arguments:
battler: PartyBattler |
|
name: string |
Returns:
text: string|string[] |
EnemyBattler:onSpareable()
(Override) Called when the enemy becomes spareable
By default, sets the enemy's animation to "spared"
(if it exists)
EnemyBattler:onSpared()
(Override) Called when the enemy is spared
EnemyBattler:onTurnEnd()
(Override) Called at the end of every turn in battle
EnemyBattler:onTurnStart()
(Override) Called at the start of every new turn in battle
EnemyBattler:recruitMessage(: unknown)
An override of Battler:recruitMessage()
Arguments:
: unknown |
Returns:
1: RecruitMessage |
EnemyBattler:registerAct(name: string, description: string?, party: (string|string[])?, tp: number?, highlight: Battler[]?, icons: string[]?)
Registers a new ACT for this enemy. This function is best called in EnemyBattler:init()
for most acts, unless they only appear under specific conditions.
What happens when this act is used is controlled by EnemyBattler:onAct()
- acts that do not return text there will softlock Kristal.
@param name
— The name of the act
@param description
— The short description of the act that appears in the menu
@param party
— A list of party member ids required to use this act. Alternatively, the keyword "all"
can be used to insert the entire current party
@param tp
— An amount of TP required to use this act
@param highlight
— A list of battlers that will be highlighted when the act is used, overriding default highlighting logic
@param icons
— A list of texture paths to icons that will display next to the name of this act (party member heads are drawn automatically as required)
@return act
— The data of the act, also added to the acts
table
Arguments:
name: string | The name of the act |
description: string? | The short description of the act that appears in the menu |
party: (string|string[])? | A list of party member ids required to use this act. Alternatively, the keyword |
tp: number? | An amount of TP required to use this act |
highlight: Battler[]? | A list of battlers that will be highlighted when the act is used, overriding default highlighting logic |
icons: string[]? | A list of texture paths to icons that will display next to the name of this act (party member heads are drawn automatically as required) |
Returns:
act: table | The data of the act, also added to the |
EnemyBattler:registerActFor(char: string, name: string, description: string?, party: (string|string[])?, tp: number?, highlight: Battler[]?, icons: string[]?)
Registers a new ACT for this enemy that is usable by a specific character. This function is best called in EnemyBattler:init()
for most acts, unless they only appear under specific conditions.
What happens when this act is used is controlled by EnemyBattler:onAct()
- acts that do not return text there will softlock Kristal.
@param char
— The id of the character that can use this act
@param name
— The name of the act
@param description
— The short description of the act that appears in the menu
@param party
— A list of party member ids required to use this act. Alternatively, the keyword "all"
can be used to insert the entire current party
@param tp
— An amount of TP required to use this act
@param highlight
— A list of battlers that will be highlighted when the act is used, overriding default highlighting logic
@param icons
— A list of texture paths to icons that will display next to the name of this act (party member heads are drawn automatically as required)
Arguments:
char: string | The id of the character that can use this act |
name: string | The name of the act |
description: string? | The short description of the act that appears in the menu |
party: (string|string[])? | A list of party member ids required to use this act. Alternatively, the keyword |
tp: number? | An amount of TP required to use this act |
highlight: Battler[]? | A list of battlers that will be highlighted when the act is used, overriding default highlighting logic |
icons: string[]? | A list of texture paths to icons that will display next to the name of this act (party member heads are drawn automatically as required) |
EnemyBattler:registerShortAct(name: string, description: string?, party: (string|string[])?, tp: number?, highlight: Battler[]?, icons: string[]?)
Registers a new Short ACT for this enemy. This function is best called in EnemyBattler:init()
for most acts, unless they only appear under specific conditions.
What happens when this act is used is controlled by EnemyBattler:onShortAct()
- acts that do not return text there will softlock Kristal.
@param name
— The name of the act
@param description
— The short description of the act that appears in the menu
@param party
— A list of party member ids required to use this act. Alternatively, the keyword "all"
can be used to insert the entire current party
@param tp
— An amount of TP required to use this act
@param highlight
— A list of battlers that will be highlighted when the act is used, overriding default highlighting logic
@param icons
— A list of texture paths to icons that will display next to the name of this act (party member heads are drawn automatically as required)
@return act
— The data of the act, also added to the acts
table
Arguments:
name: string | The name of the act |
description: string? | The short description of the act that appears in the menu |
party: (string|string[])? | A list of party member ids required to use this act. Alternatively, the keyword |
tp: number? | An amount of TP required to use this act |
highlight: Battler[]? | A list of battlers that will be highlighted when the act is used, overriding default highlighting logic |
icons: string[]? | A list of texture paths to icons that will display next to the name of this act (party member heads are drawn automatically as required) |
Returns:
act: table | The data of the act, also added to the |
EnemyBattler:registerShortActFor(char: string, name: string, description: string?, party: (string|string[])?, tp: number?, highlight: Battler[]?, icons: string[]?)
Registers a new Short ACT for this enemy, usable by a specific character. This function is best called in EnemyBattler:init()
for most acts, unless they only appear under specific conditions.
What happens when this act is used is controlled by EnemyBattler:onShortAct()
- acts that do not return text there will softlock Kristal.
@param char
— The id of the character that can use this act
@param name
— The name of the act
@param description
— The short description of the act that appears in the menu
@param party
— A list of party member ids required to use this act. Alternatively, the keyword "all"
can be used to insert the entire current party
@param tp
— An amount of TP required to use this act
@param highlight
— A list of battlers that will be highlighted when the act is used, overriding default highlighting logic
@param icons
— A list of texture paths to icons that will display next to the name of this act (party member heads are drawn automatically as required)
Arguments:
char: string | The id of the character that can use this act |
name: string | The name of the act |
description: string? | The short description of the act that appears in the menu |
party: (string|string[])? | A list of party member ids required to use this act. Alternatively, the keyword |
tp: number? | An amount of TP required to use this act |
highlight: Battler[]? | A list of battlers that will be highlighted when the act is used, overriding default highlighting logic |
icons: string[]? | A list of texture paths to icons that will display next to the name of this act (party member heads are drawn automatically as required) |
EnemyBattler:selectWave()
(Override) Selects the wave that this enemy will use each turn.
By default, picks from the available selection provided by EnemyBattler:getNextWaves()
Returns:
wave_id: string? |
EnemyBattler:setActor(actor: string|Actor, use_overlay: boolean?)
Sets the actor used for this enemy.
@param actor
— The id or instance of the Actor
to set on this battler.
@param use_overlay
— Whether to use the overlay sprite system (Defaults to true
)
Arguments:
actor: string|Actor | The id or instance of the |
use_overlay: boolean? | Whether to use the overlay sprite system (Defaults to |
EnemyBattler:setFlag(flag: string, value: any)
Sets the value of the flag named flag
to value
This variant of Game:setFlag()
interacts with flags specific to this enemy id
Arguments:
flag: string | |
value: any |
EnemyBattler:setSprite(sprite: string?, speed: number?, loop: boolean?, after: fun( any)?)
Shorthand for ActorSprite:setSprite()
and Sprite:play()
Arguments:
sprite: string? | |
speed: number? | |
loop: boolean? | |
after: fun( any)? |
EnemyBattler:spare(pacify: boolean?)
Non-violently defeats the enemy and removes them from battle (if exit_on_defeat
is true
)
@param pacify
— Whether the enemy was defeated by pacifying them rather than sparing them (defaults to false
)
Arguments:
pacify: boolean? | Whether the enemy was defeated by pacifying them rather than sparing them (defaults to |
EnemyBattler:statusMessage(: unknown)
An override of Battler:statusMessage()
that positions the message for this EnemyBattler
Arguments:
: unknown |
Returns:
1: DamageNumber |
Fields
EnemyBattler.acts: table<table>
(Used internally) Stores the data of all ACTs available on this enemy
EnemyBattler.attack: integer
The attack stat of this enemy
EnemyBattler.can_freeze: boolean
Whether this enemy can be frozen
EnemyBattler.check: string|string[]
The flavour text displayed when this enemy is checked. Stat text is added automatically.
EnemyBattler.comment: string
The text displayed next to this enemy's name in menu's (such as "(Tired)" in DELTARUNE)
EnemyBattler.defeated: boolean
Whether this enemy has been defeated
EnemyBattler.defense: integer
The defense stat of this enemy
EnemyBattler.dialogue: table<string|string[]>
A list of dialogue choices this enemy will select one from at the start of every attacking turn
EnemyBattler.dialogue_offset: [number, number]
The offset of this enemy's dialogue bubble
EnemyBattler.dialogue_override: (string|string[])?
An instance of dialogue that will be used on the enemy this turn instead of a randomly selected dialogue. Reset every turn.
EnemyBattler.disable_mercy: boolean
Whether this enemy has mercy disabled (such as with snowgrave Spamton NEO). Only affects the mercy bar.
EnemyBattler.dmg_sprite_offset: [number, number]
The offset of this enemy's damage sprites
EnemyBattler.dmg_sprites: Sprite[]
A list of this enemy's damage sprites
EnemyBattler.experience: number
The experience gained when this enemy is defeated
EnemyBattler.health: integer
The current health of this enemy
EnemyBattler.hurt_timer: number
How long this enemy's hurt sprite should be displayed for when hit
EnemyBattler.low_health_percentage: number
A number from 0-1 that defines what percentage of maximum hp the low_health_text
of this enemy starts displaying
EnemyBattler.low_health_text: string?
A special text that displays when this enemy is at low HP. See low_health_percentage
for defining the low HP threshold.
EnemyBattler.max_health: integer
The maximum health of this enemy
EnemyBattler.mercy: number
The amount of mercy points this enemy has
EnemyBattler.money: integer
The money added to the battle prize money when this enemy is defeated
EnemyBattler.selectable: boolean
Whether this enemy is selectable in menus
EnemyBattler.spare_points: number
The amount of mercy that is added to this enemy when a character spares them below max mercy
EnemyBattler.spareable_text: string?
A special text that displays when this enemy is spareable.
EnemyBattler.temporary_mercy: number
The current amount of temporary mercy
EnemyBattler.temporary_mercy_percent: DamageNumber|nil
The DamageNumber object, used to update the mercy display
EnemyBattler.text: string[]
A list of encounter flavour texts that can be selected from at random to display in the battle box at the start of each turn
EnemyBattler.tired: boolean
Whether this enemy is tired
EnemyBattler.tired_percentage: number
A number from 0-1 that defines what percentage of maximum hp this enemy should become tired at
EnemyBattler.tired_text: string?
A special text that displays when this enemy is TIRED.
EnemyBattler.wave_override: string
A wave id that will be used by the enemy this turn rather than a randomly selected wave. Reset every turn.
EnemyBattler.waves: string[]
A list of wave ids this enemy can use - one is selected each turn in EnemyBattler:selectWave()