Character

┗> Object > Class


All types of character in the overworld inherit from the Character class.
This class is not to be confused with the psuedo-event NPC that is used for characters placed in the overworld.


Constructor


Character(actor: any, x: any, y: any)

Arguments:

actor: any
x: any
y: any




Methods


Character:alert(duration: number?, options: (table|"callback"|"layer"|"offset_x"|"offset_y"...(+2))?)

Creates an alert bubble (tiny !) above this character.

@param duration — The number of frames to show the bubble for. (Defaults to 20)

@param options — A table defining additional properties to control the bubble.

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 20)

options: (table|"callback"|"layer"|"offset_x"|"offset_y"...(+2))?

A table defining additional properties to control the bubble.

Returns:

1: Sprite




Character:convertToEnemy(properties: any)

Arguments:

properties: any

Returns:

1: ChaserEnemy


Character:convertToFollower(index: any, save: any)

Arguments:

index: any
save: any

Returns:

1: Follower


Character:convertToNPC(properties: any)

Arguments:

properties: any

Returns:

1: NPC




Character:doMoveAmount(type: any, amount: any, other_amount: any)

Arguments:

type: any
amount: any
other_amount: any

Returns:

1: boolean
2: boolean|Object


Character:doWalkToStep(x: any, y: any, keep_facing: any)

Arguments:

x: any
y: any
keep_facing: any






Character:faceTowards(target: any)

Arguments:

target: any


Character:flash(sprite: any, offset_x: any, offset_y: any, layer: any)

Arguments:

sprite: any
offset_x: any
offset_y: any
layer: any




Character:getFlag(flag: any, default: any)

Arguments:

flag: any
default: any

Returns:

1: unknown






Character:jumpTo(x: number, y: number, speed: number?, time: number?, jump_sprite: string?, land_sprite: string?)

Moves the character to a new position with a jumping arc motion.


@param x — The x-coordinate to move the character to.

@param y — The y-cooridinate to move the character to.

@param marker — The name of a marker in the map to move the character to.

@param speed — The speed, as upwards velocity of the character when they start the jump. Defaults to 0.

@param time — The time, in seconds, that the jump will take. Defaults to 1 second.

@param jump_sprite — The sprite that will be used whilst the character is in midair.

@param land_sprite — The sprite that will be used just as the character leaves the ground and as they land.

Arguments:

x: number

The x-coordinate to move the character to.

y: number

The y-cooridinate to move the character to.

speed: number?

The speed, as upwards velocity of the character when they start the jump. Defaults to 0.

time: number?

The time, in seconds, that the jump will take. Defaults to 1 second.

jump_sprite: string?

The sprite that will be used whilst the character is in midair.

land_sprite: string?

The sprite that will be used just as the character leaves the ground and as they land.



Character:move(x: any, y: any, speed: any, keep_facing: any)

Arguments:

x: any
y: any
speed: any
keep_facing: any

Returns:

1: boolean


Character:moveTo(x: any, y: any, keep_facing: any)

Arguments:

x: any
y: any
keep_facing: any


Character:moveX(amount: any, move_y: any)

Arguments:

amount: any
move_y: any

Returns:

1: boolean
2: boolean|Object


Character:moveY(amount: any, move_x: any)

Arguments:

amount: any
move_x: any

Returns:

1: boolean
2: boolean|Object


Character:onAdd(parent: any)

Arguments:

parent: any


Character:onFootstep(num: any)

Arguments:

num: any


Character:onReturnFromBattle(encounter: Encounter, battler: Battler)

Arguments:

encounter: Encounter

Encounters detail the setup of unique battles in Kristal, from the enemies that appear to the environment and special mechanics.
Encounter files should be placed inside scripts/battle/encounters/.

battler: Battler

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.



Character:play(speed: any, loop: any, reset: any, on_finished: any)

Arguments:

speed: any
loop: any
reset: any
on_finished: any




Character:recruitMessage(type: any, color: any)

Arguments:

type: any
color: any

Returns:

1: RecruitMessage


Character:resetSprite()

Resets the character's to their default animation or sprite.



Character:setActor(actor: any)

Arguments:

actor: any


Character:setAnimation(animation: any, after: any)

Arguments:

animation: any
after: any


Character:setCustomSprite(sprite: any, ox: any, oy: any)

Arguments:

sprite: any
ox: any
oy: any


Character:setFacing(dir: string)

Makes the character face in the direction specified by dir.

@param dir — The direction the character should face. Must be "up", "down", "left", or "right".

Arguments:

dir: string

The direction the character should face. Must be "up", "down", "left", or "right".



Character:setFlag(flag: any, value: any)

Arguments:

flag: any
value: any


Character:setSprite(sprite: any)

Arguments:

sprite: any


Character:setWalkSprite(sprite: any)

Arguments:

sprite: any


Character:shake(x: any, y: any, friction: any, delay: any)

Arguments:

x: any
y: any
friction: any
delay: any


Character:shakeSelf(x: any, y: any, friction: any, delay: any)

Arguments:

x: any
y: any
friction: any
delay: any


Character:spin(speed: number)

Makes the character start spinning.

@param speed — The spin speed to set on the character. Negative numbers = anticlockwise, positive numbers = clockwise. Higher value = slower spin.

Arguments:

speed: number

The spin speed to set on the character. Negative numbers = anticlockwise, positive numbers = clockwise. Higher value = slower spin.



Character:statusMessage(type: any, arg: any, color: any, kill: any)

Arguments:

type: any
arg: any
color: any
kill: any

Returns:

1: DamageNumber








Character:walkPath(path: string|table, options: table|"after"|"ease"|"facing"|"keep_facing"...(+7))

Walks the character along a given path.

@param path — The name of a path in the current map file, or a table defining several points (as additional tables) that constitute a path.

@param options — A table defining additional properties to control the walk.

options:
    | "facing" -- The direction the character should face when they finish their walk. If `keep_facing` is `true`, they will instead face way immediately.
    | "keep_facing" -- If `true`, the facing direction of the character will be preserved. Otherwise, they will face the direction they are walking. (Defaults to `false`)
    | "time" -- The amount of time, in seconds, that the object should take to travel along the full path.
    | "speed" -- The speed at which the object should travel along the path, in pixels per frame at 30FPS.
    | "ease" -- The ease type to use when travelling along the path. Unused if `speed` is specified instead of `time`. (Defaults to "linear")
    | "after" -- A function that will be called when the end of the path is reached. Receives no arguments.
    | "relative" -- Whether the path should be relative to the object's current position, or simply set its position directly.
    | "loop" -- Whether the path should loop back to the first point when reaching the end, or if it should stop.
    | "reverse" -- If true, reverse all of the points on the path.
    | "skip" -- A number defining how many points of the path to skip.
    | "snap" -- Whether the object's position should immediately "snap" to the first point, or if its initial position should be counted as a point on the path.

Arguments:

path: string|table

The name of a path in the current map file, or a table defining several points (as additional tables) that constitute a path.

options: table|"after"|"ease"|"facing"|"keep_facing"...(+7)

A table defining additional properties to control the walk.

Returns:

1: nil


Character:walkTo(x: number, y: number, time: number?, facing: string?, keep_facing: boolean?, ease: any, after: fun( Character)?)

Walks this character to a new x and y over time seconds.


@param x — The new x value to approach.

@param y — The new y value to approach.

@param marker — A map marker whose position the object should approach.

@param time — The amount of time, in seconds, that the slide should take. (Defaults to 1 second)

@param facing — The direction the character should face when they finish their walk. If keep_facing is true, they will instead face way immediately.

@param keep_facing — If true, the facing direction of the character will be preserved. Otherwise, they will face the direction they are walking. (Defaults to false)

@param after — A callback function that is run after the character has finished walking.

@return success — Whether the walking will occur. False if the character's current position is already at the specified position, and true otherwise.

Arguments:

x: number

The new x value to approach.

y: number

The new y value to approach.

time: number?

The amount of time, in seconds, that the slide should take. (Defaults to 1 second)

facing: string?

The direction the character should face when they finish their walk. If keep_facing is true, they will instead face way immediately.

keep_facing: boolean?

If true, the facing direction of the character will be preserved. Otherwise, they will face the direction they are walking. (Defaults to false)

ease: any
after: fun( Character)?

A callback function that is run after the character has finished walking.

Returns:

success: boolean

Whether the walking will occur. False if the character's current position is already at the specified position, and true otherwise.



Character:walkToSpeed(x: number, y: number, speed: number?, facing: string?, keep_facing: boolean?, after: fun( Character)?)

Walks this character to a new x and y at speed pixels per frame.


@param x — The new x value to approach.

@param y — The new y value to approach.

@param marker — A map marker whose position the object should approach.

@param speed — The amount that the object's x and y should approach the specified position, in pixels per frame at 30FPS. (Defaults to 4)

@param facing — The direction the character should face when they finish their walk. If keep_facing is true, they will instead face way immediately.

@param keep_facing — If true, the facing direction of the character will be preserved. Otherwise, they will face the direction they are walking. (Defaults to false)

@param after — A callback function that is run after the character has finished walking.

@return success — Whether the walking will occur. False if the character's current position is already at the specified position, and true otherwise.

Arguments:

x: number

The new x value to approach.

y: number

The new y value to approach.

speed: number?

The amount that the object's x and y should approach the specified position, in pixels per frame at 30FPS. (Defaults to 4)

facing: string?

The direction the character should face when they finish their walk. If keep_facing is true, they will instead face way immediately.

keep_facing: boolean?

If true, the facing direction of the character will be preserved. Otherwise, they will face the direction they are walking. (Defaults to false)

after: fun( Character)?

A callback function that is run after the character has finished walking.

Returns:

success: boolean

Whether the walking will occur. False if the character's current position is already at the specified position, and true otherwise.




Fields





Undocumented



Character.actor: any

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().









Character.alert_icon: nil

A simple object that renders a texture.
This texture must be placed inside assets/sprites/.



Character.alert_icon: Sprite

A simple object that renders a texture.
This texture must be placed inside assets/sprites/.



Character.alert_icon: nil

A simple object that renders a texture.
This texture must be placed inside assets/sprites/.















































Character.jump_progress: integer

if (landsprite == spr_kris_dw_landed) -- If it's the Kris kneeling one, { self.x = self.x - 4 self.y = self.y + 2 self.false_end_x = self.false_end_x - 8 self.jump_start_x = self.jump_start_x - 8 self.jump_start_y = self.jump_start_y - 8 } if (landsprite == spr_susie_dw_landed) { self.x = self.x - 8 self.false_end_x = self.false_end_x - 8 self.jump_start_x = self.jump_start_x + 12 self.jump_start_y = self.jump_start_y - 12 } if (landsprite == spr_teacup_ralsei_land) { self.y = self.y + 4 self.jump_start_y = self.jump_start_y + 8 self.jump_start_x = self.jump_start_x - 12 self.false_end_x = self.false_end_x - 6 self.false_end_y = self.false_end_y + 4 } if (jumpsprite == spr_ralsei_jump) { shadowoffx = shadowoffx - 10 shadowoffy = shadowoffy - 4 } }



































Character.jump_use_sprites: boolean

dark = (global.darkzone + 1)































Character.party: nil

The party member id represented by this character





















Character.sprite: ActorSprite

An extension of Sprite that can integrate with an actor. If an object defines an Actor, it will use this over Sprite for its sprite.





Character.world: World

The World Object manages everything relating to the overworld in Kristal.
A globally available instance of World is stored in Game.world.