Bullet
┗> Object > Class
The class that all Battle bullets in Kristal originate from.
Generic bullets can be spawned into a wave with Wave:spawnBullet(texture, x, y)
Files in scripts/battle/bullets
will also be loaded as bullets and should Extend this class.
Extension bullets can be spawned into a wave with Wave:spawnBullet(id, ...)
- their id
defaults to their filepath, starting from scripts/battle/bullets
. Additional arguments ...
are passed into the bullet type's init function.
Constructor
Bullet(x: number, y: number, texture: (string|love.Image)?)
Arguments:
x: number | |
y: number | |
texture: (string|love.Image)? |
Methods
Bullet:getGrazeTension()
Get the graze tension for this bullet. If this bullet doesn't specify graze tension, it'll use the attacker's default value. If that can't be found either, then it will be the default of 1.6.
@return tension
— The tension to gain when this bullet is grazed.
Returns:
tension: number | The tension to gain when this bullet is grazed. |
Bullet:isBullet(id: string)
Checks whether this bullet is an instance or extension of a specific bullet type, specified by id
.
Arguments:
id: string |
Returns:
1: boolean |
Bullet:onCollide(soul: Soul)
(Override) Called when the bullet collides with the player's soul, before invulnerability checks.
Arguments:
soul: Soul | The Soul is the object the player controls in battle. |
Bullet:onDamage(soul: Soul)
(Override) Called when the bullet hits the player's soul without invulnerability frames.
Not calling super.onDamage()
here will stop the normal damage logic from occurring.
Arguments:
soul: Soul | The Soul is the object the player controls in battle. |
Returns:
battlers_hit: table<PartyBattler> |
Bullet:onGraze(first: boolean)
(Override) Called when the soul grazes a bullet.
@param first
— Whether the bullet has been grazed before or not.
Arguments:
first: boolean | Whether the bullet has been grazed before or not. |
Bullet:onWaveSpawn(wave: Wave)
Arguments:
wave: Wave | Waves are the bullet patterns that enemies use in battle. |
Bullet:setSprite(texture: (string|love.Image)?, speed: number?, loop: boolean?, on_finished: fun( any)?)
@param texture
— The new texture or path to the texture to set on the sprite (Removes the bullet's sprite if undefined)
@param speed
— The time between frames of the sprite, in seconds (Defaults to 1/30th second)
@param loop
— Whether the sprite should continuously loop. (Defaults to true
)
@param on_finished
— A function that is called when the animation finishes.
Arguments:
texture: (string|love.Image)? | The new texture or path to the texture to set on the sprite (Removes the bullet's sprite if undefined) |
speed: number? | The time between frames of the sprite, in seconds (Defaults to 1/30th second) |
loop: boolean? | Whether the sprite should continuously loop. (Defaults to |
on_finished: fun( any)? | A function that is called when the animation finishes. |
Returns:
1: Sprite? |
Bullet:shouldSwoon(damage: number, target: number|"ALL"|"ANY"|PartyBattler, soul: Soul)
(Override) Whether this bullet should swoon the battler if they are downed by it.
Defaults to false
.
@param damage
— The amount of damage the bullet will deal
@param target
— The target of the bullet
@param soul
— The soul
-- `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:
| "ANY"
| "ALL"
Arguments:
damage: number | The amount of damage the bullet will deal |
target: number|"ALL"|"ANY"|PartyBattler | The target of the bullet |
soul: Soul | The soul |
Returns:
1: boolean |
Fields
Bullet.attacker: EnemyBattler
The attacker that owns the wave which created this bullet. Not defined until after Bullet:init()
.
Bullet.wave: Wave
The wave that this bullet was created by. Not defined until after Bullet:init()
.