Options
All
  • Public
  • Public/Protected
  • All
Menu

The NPC class.

Hierarchy

Index

Constructors

Properties

Accessors

Methods

Constructors

  • new NPC(game: any, data: any, key_name: any, label: any, map_index: any, active: any, initial_x: any, initial_y: any, storage_keys: any, initial_action: any, initial_animation: any, enable_footsteps: any, walk_speed: any, dash_speed: any, climb_speed: any, npc_type: any, movement_type: any, message: any, thought_message: any, back_interaction_message: any, allow_only_front_interaction: any, avatar: any, shop_key: any, inn_key: any, healer_key: any, base_collision_layer: any, talk_range: any, events_info: any, no_shadow: any, ignore_world_map_scale: any, anchor_x: any, anchor_y: any, scale_x: any, scale_y: any, interaction_pattern: any, affected_by_reveal: any, sprite_misc_db_key: any, ignore_physics: any, visible: any, voice_key: any, max_distance: any, step_duration: any, wait_duration: any, base_step: any, step_max_variation: any, move_freely_in_event: any, allow_interaction_when_inactive: any, after_psynergy_cast_events: any, force_char_stop_in_event: any, force_idle_action_in_event: any): NPC
  • Parameters

    • game: any
    • data: any
    • key_name: any
    • label: any
    • map_index: any
    • active: any
    • initial_x: any
    • initial_y: any
    • storage_keys: any
    • initial_action: any
    • initial_animation: any
    • enable_footsteps: any
    • walk_speed: any
    • dash_speed: any
    • climb_speed: any
    • npc_type: any
    • movement_type: any
    • message: any
    • thought_message: any
    • back_interaction_message: any
    • allow_only_front_interaction: any
    • avatar: any
    • shop_key: any
    • inn_key: any
    • healer_key: any
    • base_collision_layer: any
    • talk_range: any
    • events_info: any
    • no_shadow: any
    • ignore_world_map_scale: any
    • anchor_x: any
    • anchor_y: any
    • scale_x: any
    • scale_y: any
    • interaction_pattern: any
    • affected_by_reveal: any
    • sprite_misc_db_key: any
    • ignore_physics: any
    • visible: any
    • voice_key: any
    • max_distance: any
    • step_duration: any
    • wait_duration: any
    • base_step: any
    • step_max_variation: any
    • move_freely_in_event: any
    • allow_interaction_when_inactive: any
    • after_psynergy_cast_events: any
    • force_char_stop_in_event: any
    • force_idle_action_in_event: any

    Returns NPC

Properties

_active: boolean
_affected_by_reveal: boolean
_after_psynergy_cast_events: {}

Type declaration

_allow_interaction_when_inactive: boolean
_allow_only_front_interaction: boolean
_angle_direction: number
_avatar: string
_back_interaction_message: string
_base_collision_layer: number
_base_step: number
_body_radius: number
_current_action: string
_current_animation: string
_current_direction: number

The direction that the char is moving.

_current_speed: { x: number; y: number }

Type declaration

  • x: number
  • y: number
_emoticon_sprite: Sprite
_events: GameEvent[]
_extra_speed: number
_extra_speed_force: { x: number; y: number }

Type declaration

  • x: number
  • y: number
_force_diagonal_speed: { x: number; y: number }

Type declaration

  • x: number
  • y: number
_healer_key: string
_ice_slide_direction: number

The direction of the ice sliding movement that can be different of char direction.

_ignore_physics: boolean
_ignore_world_map_scale: boolean
_initial_x: number
_initial_y: number
_inn_key: string
_interaction_pattern: interaction_patterns
_label: string
_map_index: number
_max_distance: number
_message: string
_npc_type: npc_types
_push_timer: Timer
_required_direction: number

The direction determined by the input.

_shapes_collision_active: boolean
_shop_key: string
_snapshot_info: { action: string; active_filters: { color_blend: boolean; colorize: boolean; flame: boolean; gray: boolean; hue: boolean; levels: boolean; mode7: boolean; outline: boolean; pixel_shift: boolean; tint: boolean; watery: boolean }; anchor: { x: number; y: number }; anim_is_playing: boolean; animation: string; base_collision_layer: number; body_in_map: boolean; filter_settings?: FilterSettings; frame: string; index: number; key_name: string; move_freely_in_event: boolean; movement_type: npc_movement_types; position: { x: number; x_px: number; y: number; y_px: number }; scale: { x: number; y: number }; send_to_back: boolean; send_to_front: boolean; shadow: { x: number; y: number }; shadow_following: boolean; shapes_collision_active: boolean; visible: boolean }

Type declaration

  • action: string
  • active_filters: { color_blend: boolean; colorize: boolean; flame: boolean; gray: boolean; hue: boolean; levels: boolean; mode7: boolean; outline: boolean; pixel_shift: boolean; tint: boolean; watery: boolean }
    • color_blend: boolean
    • colorize: boolean
    • flame: boolean
    • gray: boolean
    • hue: boolean
    • levels: boolean
    • mode7: boolean
    • outline: boolean
    • pixel_shift: boolean
    • tint: boolean
    • watery: boolean
  • anchor: { x: number; y: number }
    • x: number
    • y: number
  • anim_is_playing: boolean
  • animation: string
  • base_collision_layer: number
  • body_in_map: boolean
  • Optional filter_settings?: FilterSettings
  • frame: string
  • index: number
  • key_name: string
  • move_freely_in_event: boolean
  • movement_type: npc_movement_types
  • position: { x: number; x_px: number; y: number; y_px: number }
    • x: number
    • x_px: number
    • y: number
    • y_px: number
  • scale: { x: number; y: number }
    • x: number
    • y: number
  • send_to_back: boolean
  • send_to_front: boolean
  • shadow: { x: number; y: number }
    • x: number
    • y: number
  • shadow_following: boolean
  • shapes_collision_active: boolean
  • visible: boolean
_sprite_info: SpriteBase
_step_destination: { x: number; y: number }

Type declaration

  • x: number
  • y: number
_step_duration: number
_step_frame_counter: number
_step_max_variation: number
_stepping: boolean
_talk_range: number
_temp_speed: { x: number; y: number }

Type declaration

  • x: number
  • y: number
_thought_message: string
_tile_x_pos: number
_tile_y_pos: number
_transition_direction: number

When changing directions, the char smoothly changes to the target direction. This var holds the intermediate directions.

_trying_to_push_direction: number

The direction that the char is trying to push an interactable object

_voice_key: string
_wait_duration: number
anchor_x: number
anchor_y: number
casting_aura_stop_function: ((reset_casting_psy_flag?: boolean, reset_map_tint?: boolean) => Promise<void>)

Type declaration

    • (reset_casting_psy_flag?: boolean, reset_map_tint?: boolean): Promise<void>
    • The function used to stop this char casting aura.

      Parameters

      • Optional reset_casting_psy_flag: boolean
      • Optional reset_map_tint: boolean

      Returns Promise<void>

casting_psynergy: boolean

Whether this char is casting psynergy.

climb_speed: number
climbing: boolean

Whether this char is climbing.

climbing_rope: boolean

Whether this char is climbing a rope.

colliding_directions_mask: number

A mask that contains in which directions the hero is colliding. Example:

  • If the hero is colliding on left direction, which has 4 as value, then this variable will have this value: 00010000.
  • If the hero is colliding on right direction, which has 0 as value, then this variable will have this value: 00000001.
  • Colliding in both left and right direction: 00010001.
crop_texture: boolean

Whether the char is prone to have it's texture halved when going through forests.

dash_speed: number
dashing: boolean

Whether this char is dashing.

data: GoldenSun
enable_footsteps: boolean

Whether the char will let footprints in the ground.

force_char_stop_in_event: boolean

Forces this char to stop while in game event.

force_direction: boolean

Whether the char had its direction changed due to side collision.

force_idle_action_in_event: boolean

Forces char to assume idle action if it's forced to stop while in a game event.

game: Game
ice_sliding_active: boolean

Whether this char is under an ice sliding ground.

idle_climbing: boolean

Whether this char is idle during climbing state.

ignore_play: boolean

If true, animation play will be ignored.

initially_visible: boolean
jumping: boolean

Whether this char is jumping.

look_target: ControllableChar = null
misc_busy: boolean

Whether this char is busy by any misc. reason.

move_freely_in_event: boolean

If true, this NPC will move freely while a game event is happening.

movement_type: npc_movement_types

The type of movement of this NPC. Idle or random walk.

no_shadow: boolean
on_custom_psynergy_effect: boolean

Whether this char is under custom psynergy effect.

on_reveal: boolean

Whether this char is under Reveal psynergy effect.

on_stair: boolean

If true, it will assume that this char is walking over a stair. This will impact this char facing direction.

pushing: boolean

Whether this char is pushing an Interactable Object.

sand_mode: boolean

Whether this char is melted in sand.

scale_x: number
scale_y: number
shadow: Sprite

The shadow sprite object.

shadow_following: boolean

Whether the shadow is following or not this char.

sliding: boolean

Whether this char is cliff sliding.

sliding_on_ice: boolean

Whether this char is sliding/moving over an ice ground.

sprite: Sprite

The char main sprite object.

sprite_misc_db_key: string
stop_by_colliding: boolean

Whether the char is idle/stopped due to collision.

storage_keys: { action?: string; active?: string; affected_by_reveal?: string; animation?: string; base_collision_layer?: string; interaction_pattern?: string; move_freely_in_event?: string; movement_type?: string; position?: string; visible?: string }

Type declaration

  • Optional action?: string
  • Optional active?: string
  • Optional affected_by_reveal?: string
  • Optional animation?: string
  • Optional base_collision_layer?: string
  • Optional interaction_pattern?: string
  • Optional move_freely_in_event?: string
  • Optional movement_type?: string
  • Optional position?: string
  • Optional visible?: string
teleporting: boolean

Whether this char is teleporting by the teleport TileEvent.

trying_to_push: boolean

Whether thic char is trying to push an Interactable Object.

walk_speed: number
walking_over_rope: boolean

Whether this char is walking over a rope.

MAX_DIR_GET_TRIES: 7 = 7
NPC_TALK_RANGE: 21 = 21
STOP_MINIMAL_DISTANCE_SQR: number = ...

Accessors

  • get active(): boolean
  • get active_filters(): { color_blend: boolean; colorize: boolean; flame: boolean; gray: boolean; hue: boolean; levels: boolean; mode7: boolean; outline: boolean; pixel_shift: boolean; tint: boolean; watery: boolean }
  • An object containing which filters are active in this char.

    Returns { color_blend: boolean; colorize: boolean; flame: boolean; gray: boolean; hue: boolean; levels: boolean; mode7: boolean; outline: boolean; pixel_shift: boolean; tint: boolean; watery: boolean }

    • color_blend: boolean
    • colorize: boolean
    • flame: boolean
    • gray: boolean
    • hue: boolean
    • levels: boolean
    • mode7: boolean
    • outline: boolean
    • pixel_shift: boolean
    • tint: boolean
    • watery: boolean
  • get affected_by_reveal(): boolean
  • Whether this NPC is affected by Reveal psynergy or not.

    Returns boolean

  • get after_psynergy_cast_events(): {}
  • Object that contains lists of Game Events to fired per psynergy after it finishes. Psynergy is the key, the list of events is the value of this object.

    Returns {}

  • get allow_interaction_when_inactive(): boolean
  • If true, the hero will be allowed to interact with this NPC even if it's inactive.

    Returns boolean

  • get allow_only_front_interaction(): boolean
  • If true, the hero will only be able to interact with this NPC when he's on the front of it.

    Returns boolean

  • get avatar(): string
  • get back_interaction_message(): string
  • The message to be displayed if interacting from the back.

    Returns string

  • get base_collision_layer(): number
  • The collision layer that this NPC is.

    Returns number

  • get body(): Body
  • get body_radius(): number
  • get collision_layer(): number
  • The collision layer that this NPC is.

    Returns number

  • get color_blend_filter(): ColorBlend
  • The Phaser.Filter that controls the blend of colors of the texture of this char sprite.

    Returns ColorBlend

  • get colorize_filter(): Colorize
  • The Phaser.Filter that controls the colors of the texture of this char sprite.

    Returns Colorize

  • get current_action(): string
  • get current_animation(): string
  • get current_direction(): number
  • The current active direction of this char according to it movement.

    Returns number

  • get current_speed(): { x: number; y: number }
  • This char current speed normalized vector. This pretty much indicates the char direction.

    Returns { x: number; y: number }

    • x: number
    • y: number
  • get extra_speed(): number
  • The extra char speed that might be applied to current speed.

    Returns number

  • get extra_speed_force(): { x: number; y: number }
  • The extra char speed that might be applied to current speed even if it's idle.

    Returns { x: number; y: number }

    • x: number
    • y: number
  • get flame_filter(): Flame
  • The Phaser.Filter that sets flame colors into char sprite.

    Returns Flame

  • get force_diagonal_speed(): { x: number; y: number }
  • This char speed according to the collision slope.

    Returns { x: number; y: number }

    • x: number
    • y: number
  • get gray_filter(): Gray
  • The Phaser.Filter that controls the saturation of the texture of this char sprite.

    Returns Gray

  • get healer_key(): string
  • If it's a Healer NPC, returns the key of the healer establishment that it owns.

    Returns string

  • get height(): number
  • get hue_filter(): Hue
  • The Phaser.Filter that controls the hue of the texture of this char sprite.

    Returns Hue

  • get ice_slide_direction(): number
  • The direction in which this char is sliding in the ice. It's not necessarily the direction that this char is facing.

    Returns number

  • get ignore_physics(): boolean
  • If true, this NPC won't have collision body.

    Returns boolean

  • get ignore_world_map_scale(): boolean
  • If true, this NPC scale won't change when it's in World Map.

    Returns boolean

  • get inn_key(): string
  • If it's a Inn NPC, returns the key of the inn that it owns.

    Returns string

  • get is_interactable_object(): boolean
  • Returns whether it's an IO. Always returns false.

    Returns boolean

  • get is_npc(): boolean
  • get key_name(): string
  • get label(): string
  • The unique label that identifies this NPC.

    Returns string

  • get levels_filter(): Levels
  • The Phaser.Filter that controls the color levels of the texture of this char sprite.

    Returns Levels

  • get map_index(): number
  • The map unique index of this NPC.

    Returns number

  • get message(): string
  • The default interaction message of this NPC.

    Returns string

  • get outline_filter(): Outline
  • The Phaser.Filter that activates an outline in this char sprite.

    Returns Outline

  • get pixel_shift_filter(): PixelShift
  • The Phaser.Filter that ashifts the texture of this char sprite.

    Returns PixelShift

  • get push_timer(): Timer
  • The Phaser.TimerEvent used in the Interactable Object push process.

    Returns Timer

  • get required_direction(): number
  • The directing that's being requested to this char to go.

    Returns number

  • get shapes_collision_active(): boolean
  • Whether the shapes of this char body are active (colliding) or not.

    Returns boolean

  • get shop_key(): string
  • If it's a shop NPC, returns the key of the shop that it owns.

    Returns string

  • get snapshot_info(): { action: string; active_filters: { color_blend: boolean; colorize: boolean; flame: boolean; gray: boolean; hue: boolean; levels: boolean; mode7: boolean; outline: boolean; pixel_shift: boolean; tint: boolean; watery: boolean }; anchor: { x: number; y: number }; anim_is_playing: boolean; animation: string; base_collision_layer: number; body_in_map: boolean; filter_settings?: FilterSettings; frame: string; index: number; key_name: string; move_freely_in_event: boolean; movement_type: npc_movement_types; position: { x: number; x_px: number; y: number; y_px: number }; scale: { x: number; y: number }; send_to_back: boolean; send_to_front: boolean; shadow: { x: number; y: number }; shadow_following: boolean; shapes_collision_active: boolean; visible: boolean }
  • Returns the snapshot info of this NPC when the game is restored.

    Returns { action: string; active_filters: { color_blend: boolean; colorize: boolean; flame: boolean; gray: boolean; hue: boolean; levels: boolean; mode7: boolean; outline: boolean; pixel_shift: boolean; tint: boolean; watery: boolean }; anchor: { x: number; y: number }; anim_is_playing: boolean; animation: string; base_collision_layer: number; body_in_map: boolean; filter_settings?: FilterSettings; frame: string; index: number; key_name: string; move_freely_in_event: boolean; movement_type: npc_movement_types; position: { x: number; x_px: number; y: number; y_px: number }; scale: { x: number; y: number }; send_to_back: boolean; send_to_front: boolean; shadow: { x: number; y: number }; shadow_following: boolean; shapes_collision_active: boolean; visible: boolean }

    • action: string
    • active_filters: { color_blend: boolean; colorize: boolean; flame: boolean; gray: boolean; hue: boolean; levels: boolean; mode7: boolean; outline: boolean; pixel_shift: boolean; tint: boolean; watery: boolean }
      • color_blend: boolean
      • colorize: boolean
      • flame: boolean
      • gray: boolean
      • hue: boolean
      • levels: boolean
      • mode7: boolean
      • outline: boolean
      • pixel_shift: boolean
      • tint: boolean
      • watery: boolean
    • anchor: { x: number; y: number }
      • x: number
      • y: number
    • anim_is_playing: boolean
    • animation: string
    • base_collision_layer: number
    • body_in_map: boolean
    • Optional filter_settings?: FilterSettings
    • frame: string
    • index: number
    • key_name: string
    • move_freely_in_event: boolean
    • movement_type: npc_movement_types
    • position: { x: number; x_px: number; y: number; y_px: number }
      • x: number
      • x_px: number
      • y: number
      • y_px: number
    • scale: { x: number; y: number }
      • x: number
      • y: number
    • send_to_back: boolean
    • send_to_front: boolean
    • shadow: { x: number; y: number }
      • x: number
      • y: number
    • shadow_following: boolean
    • shapes_collision_active: boolean
    • visible: boolean
  • get talk_range(): number
  • The interaction range factor. Determines how far the hero need to be at least to start an interaction.

    Returns number

  • get temp_speed(): { x: number; y: number }
  • This char pre-caculated speed. It might change due to collision.

    Returns { x: number; y: number }

    • x: number
    • y: number
  • get thought_message(): string
  • The default interaction message by using Mind Read of this NPC.

    Returns string

  • get tile_pos(): { x: number; y: number }
  • Gets the tile pos object for this char.

    Returns { x: number; y: number }

    • x: number
    • y: number
  • get tile_x_pos(): number
  • get tile_y_pos(): number
  • get tint_filter(): Tint
  • The Phaser.Filter that tints the texture of this char sprite.

    Returns Tint

  • get transition_direction(): number
  • When changing direction, the char doesn't face immediately the requested direction. This property holds the transion directions till it reaches the requested direction.

    Returns number

  • get trying_to_push_direction(): number
  • The direction that this char is trying to push an Interactable Object.

    Returns number

  • get voice_key(): string
  • The voicec sound key of this NPC.

    Returns string

  • get watery_filter(): Watery
  • The Phaser.Filter that sets water colors into char sprite.

    Returns Watery

  • get width(): number
  • get x(): number
  • set x(x: number): void
  • get y(): number
  • set y(y: number): void

Methods

  • add_animation_callback(callback: (() => void)): number
  • Adds a callback for this char that will be called when this char animation changes.

    Parameters

    • callback: (() => void)

      the callback that will be called.

        • (): void
        • Returns void

    Returns number

    returns the key to track this callback, so you can identify it later to remove.

  • apply_speed(): void
  • blink(count: number, interval: number, options?: { color?: { b: number; g: number; r: number }; keep_filter?: boolean; outline_blink?: boolean; transparent_outline?: boolean }): Promise<void>
  • Blinks this char by tintint and untinting it or outlining it.

    Parameters

    • count: number

      how many times this char will blink.

    • interval: number

      the time interval between each blink.

    • Optional options: { color?: { b: number; g: number; r: number }; keep_filter?: boolean; outline_blink?: boolean; transparent_outline?: boolean }

      some options.

      • Optional color?: { b: number; g: number; r: number }

        The color to tint/outline the char.

        • b: number

          The blue color component to tint. 0 to 1. Default 1.

        • g: number

          The green color component to tint. 0 to 1. Default 1.

        • r: number

          The red color component to tint. 0 to 1. Default 1.

      • Optional keep_filter?: boolean

        if true, will keep the color filter on blink finish.

      • Optional outline_blink?: boolean

        If true, the char will be outlined instead of tinted. Default is false.

      • Optional transparent_outline?: boolean

        If 'outline_blink' is true, whether the char will be transparent or not when outlined. Default is true.

    Returns Promise<void>

  • calculate_speed(): void
  • change_collision_layer(destination_collision_layer: number, update_on_map?: boolean): void
  • Changes the collision layer of this NPC.

    Parameters

    • destination_collision_layer: number

      the desitination collision layer index.

    • update_on_map: boolean = true

      whether you want this modification to propagate to map structure.

    Returns void

  • check_interactable_objects(contacts: ContactEquation[]): void
  • check_sand_quit(contacts: ContactEquation[]): boolean
  • Checks if this char will quit sand mode by colliding with a tile that has quit_sand property true.

    Parameters

    • contacts: ContactEquation[]

      p2 contact equation array.

    Returns boolean

    returns true if it exited sand mode.

  • check_storage_keys(): void
  • Updates this NPC properties according to current storage values.

    Returns void

  • choose_action_based_on_char_state(check_on_event?: boolean): void
  • choose_direction_by_speed(): void
  • clear_snapshot(): void
  • Removes this NPC snapshot reference.

    Returns void

  • config_body(): void
  • Initializes the collision body of this NPC.

    Returns void

  • create_engine_storage_key(property_name: string): string
  • Creates an unique engine storage key name for a given property.

    Parameters

    • property_name: string

      the name of the property that this storage value relates with.

    Returns string

    return the engine storage key name.

  • create_half_crop_mask(): void
  • destroy_body(update_map?: boolean): void
  • Destroys the collision body of this NPC.

    Parameters

    • update_map: boolean = true

      if true, will tell the map that this body was removed.

    Returns void

  • destroy_emoticon(): void
  • face_direction(direction: number, time_between_frames?: number): Promise<void>
  • fall(options: { dest_collision_layer?: number; ground_hit_animation?: boolean; show_exclamation_emoticon?: boolean; splash_sweat_drops?: boolean; teleport?: { dest_collision_layer: number; destination: string; destination_position: { x: number; y: number }; diminish_on_transition?: boolean; origin_position?: { x: number; y: number }; send_to_front_on_teleport?: boolean; on_before_teleport?: any }; walking_in_the_air?: boolean; y_destination_position: number; on_fall_finish_callback?: any }): Promise<void>
  • Make the char to fall to a given destination.

    Parameters

    • options: { dest_collision_layer?: number; ground_hit_animation?: boolean; show_exclamation_emoticon?: boolean; splash_sweat_drops?: boolean; teleport?: { dest_collision_layer: number; destination: string; destination_position: { x: number; y: number }; diminish_on_transition?: boolean; origin_position?: { x: number; y: number }; send_to_front_on_teleport?: boolean; on_before_teleport?: any }; walking_in_the_air?: boolean; y_destination_position: number; on_fall_finish_callback?: any }

      fall options object.

      • Optional dest_collision_layer?: number

        The destination collision layer index.

      • Optional ground_hit_animation?: boolean

        Whether the char will perform a ground hit animation.

      • Optional show_exclamation_emoticon?: boolean

        Whether an exclamation emoticon will appear over the char before falling.

      • Optional splash_sweat_drops?: boolean

        The char will splash sweat drops before falling.

      • Optional teleport?: { dest_collision_layer: number; destination: string; destination_position: { x: number; y: number }; diminish_on_transition?: boolean; origin_position?: { x: number; y: number }; send_to_front_on_teleport?: boolean; on_before_teleport?: any }

        Teleport info. If passed, the char will teleport to another map while falling.

        • dest_collision_layer: number

          The destination collision layer index in the dest map.

        • destination: string

          The teleport map key name destination.

        • destination_position: { x: number; y: number }

          The destination position.

          • x: number

            The x tile position.

          • y: number

            The y tile position.

        • Optional diminish_on_transition?: boolean

          If true, the char will diminish instead of fall before teleport.

        • Optional origin_position?: { x: number; y: number }

          The origin position that the char will be just after the teleport.

          • x: number

            The x tile position.

          • y: number

            The y tile position.

        • Optional send_to_front_on_teleport?: boolean

          If true, the char sprite will be brought to the top on z-index while falling.

        • on_before_teleport?:function
          • on_before_teleport(): void
      • Optional walking_in_the_air?: boolean

        Whether the char will performa a walking in the air animation before falling.

      • y_destination_position: number

        The final y-tile position that the char will reach after falling.

      • on_fall_finish_callback?:function
        • on_fall_finish_callback(): void

    Returns Promise<void>

  • get_associated_storage_key(property: "position" | "base_collision_layer" | "active" | "visible" | "action" | "animation" | "affected_by_reveal" | "movement_type" | "move_freely_in_event" | "interaction_pattern"): string
  • Gets the storage key name associated to a given NPC property.

    Parameters

    • property: "position" | "base_collision_layer" | "active" | "visible" | "action" | "animation" | "affected_by_reveal" | "movement_type" | "move_freely_in_event" | "interaction_pattern"

      the property name that you want to get the storage key.

    Returns string

    returns the storage key name for the given property.

  • get_move_callback(dest: { x: number; y: number }, on_position_reach_callback: (() => void), minimal_distance?: number): (() => void)
  • Gets the update callback that need to be fired under a loop in order to move this char to a specific position.

    Parameters

    • dest: { x: number; y: number }

      the desitiona position object.

      • x: number
      • y: number
    • on_position_reach_callback: (() => void)

      the callback that will be called when this char reaches the position.

        • (): void
        • Returns void

    • minimal_distance: number = 3

      the minimal distance to be regarded to when check whether this char is close enough to the destination.

    Returns (() => void)

    return the update callback to keep this char moving and checking whether it should stop.

      • (): void
      • Returns void

  • ground_hit_dust_animation(on_animation_end: (() => void)): void
  • in_action(allow_climbing?: boolean): boolean
  • in_movement(walk_dash_only?: boolean): boolean
  • increase_extra_speed(delta_value: number): void
  • increase_forced_extra_speed(delta_value: { x?: number; y?: number }): void
  • init_npc(map: Map, snapshot_info?: { action: string; active_filters: { color_blend: boolean; colorize: boolean; flame: boolean; gray: boolean; hue: boolean; levels: boolean; mode7: boolean; outline: boolean; pixel_shift: boolean; tint: boolean; watery: boolean }; anchor: { x: number; y: number }; anim_is_playing: boolean; animation: string; base_collision_layer: number; body_in_map: boolean; filter_settings?: FilterSettings; frame: string; index: number; key_name: string; move_freely_in_event: boolean; movement_type: npc_movement_types; position: { x: number; x_px: number; y: number; y_px: number }; scale: { x: number; y: number }; send_to_back: boolean; send_to_front: boolean; shadow: { x: number; y: number }; shadow_following: boolean; shapes_collision_active: boolean; visible: boolean }, custom_pos?: { x?: number; y?: number }): void
  • Initializes this NPC.

    Parameters

    • map: Map

      the map that's being mounted.

    • Optional snapshot_info: { action: string; active_filters: { color_blend: boolean; colorize: boolean; flame: boolean; gray: boolean; hue: boolean; levels: boolean; mode7: boolean; outline: boolean; pixel_shift: boolean; tint: boolean; watery: boolean }; anchor: { x: number; y: number }; anim_is_playing: boolean; animation: string; base_collision_layer: number; body_in_map: boolean; filter_settings?: FilterSettings; frame: string; index: number; key_name: string; move_freely_in_event: boolean; movement_type: npc_movement_types; position: { x: number; x_px: number; y: number; y_px: number }; scale: { x: number; y: number }; send_to_back: boolean; send_to_front: boolean; shadow: { x: number; y: number }; shadow_following: boolean; shapes_collision_active: boolean; visible: boolean }

      the snapshot data of this npc.

      • action: string
      • active_filters: { color_blend: boolean; colorize: boolean; flame: boolean; gray: boolean; hue: boolean; levels: boolean; mode7: boolean; outline: boolean; pixel_shift: boolean; tint: boolean; watery: boolean }
        • color_blend: boolean
        • colorize: boolean
        • flame: boolean
        • gray: boolean
        • hue: boolean
        • levels: boolean
        • mode7: boolean
        • outline: boolean
        • pixel_shift: boolean
        • tint: boolean
        • watery: boolean
      • anchor: { x: number; y: number }
        • x: number
        • y: number
      • anim_is_playing: boolean
      • animation: string
      • base_collision_layer: number
      • body_in_map: boolean
      • Optional filter_settings?: FilterSettings
      • frame: string
      • index: number
      • key_name: string
      • move_freely_in_event: boolean
      • movement_type: npc_movement_types
      • position: { x: number; x_px: number; y: number; y_px: number }
        • x: number
        • x_px: number
        • y: number
        • y_px: number
      • scale: { x: number; y: number }
        • x: number
        • y: number
      • send_to_back: boolean
      • send_to_front: boolean
      • shadow: { x: number; y: number }
        • x: number
        • y: number
      • shadow_following: boolean
      • shapes_collision_active: boolean
      • visible: boolean
    • Optional custom_pos: { x?: number; y?: number }

      an initial custom position for this npc in px.

      • Optional x?: number
      • Optional y?: number

    Returns void

  • is_close(target_char: NPC): number
  • is_pos_colliding(tile_x_pos: number, tile_y_pos: number): boolean
  • Tests whether this NPC would collide in a given position.

    Parameters

    • tile_x_pos: number

      the tile x position.

    • tile_y_pos: number

      the tile y position.

    Returns boolean

    returns true if the NPC is going to collide.

  • jump(options: { bounce?: boolean; dest?: { distance?: number; distance_multiplier?: number; tile_x?: number; tile_y?: number; x?: number; y?: number }; dont_play_jump_animation?: boolean; duration?: number; jump_direction?: directions; jump_height?: number; keep_shadow_hidden?: boolean; sfx_key?: string; time_on_finish?: number }): Promise<void>
  • Makes this char to jump vertically or to a specific destination.

    Parameters

    • options: { bounce?: boolean; dest?: { distance?: number; distance_multiplier?: number; tile_x?: number; tile_y?: number; x?: number; y?: number }; dont_play_jump_animation?: boolean; duration?: number; jump_direction?: directions; jump_height?: number; keep_shadow_hidden?: boolean; sfx_key?: string; time_on_finish?: number }
      • Optional bounce?: boolean

        Whether the char will bounce on jump finish. Only for vertical jumps.

      • Optional dest?: { distance?: number; distance_multiplier?: number; tile_x?: number; tile_y?: number; x?: number; y?: number }

        If this object is set, the char will perform a jump towards a given direction.

        • Optional distance?: number

          The jump distance that this char will perform. If not given, this char will jump into the center of the destination. This option is not valid if it's a diagonal direction jumping.

        • Optional distance_multiplier?: number

          The distance multiplier that will be applied to the final jump distance.

        • Optional tile_x?: number

          The x tile position destination. If position in px is defined, this one won't be used.

        • Optional tile_y?: number

          The y tile position destination. If position in px is defined, this one won't be used.

        • Optional x?: number

          The x position destination in px. This position has preference over tile position.

        • Optional y?: number

          The y position destination in px. This position has preference over tile position.

      • Optional dont_play_jump_animation?: boolean

        If true, char jump animation won't be played.

      • Optional duration?: number

        The duration of the jump in ms.

      • Optional jump_direction?: directions

        The direction that the char is going to be while jumping.

      • Optional jump_height?: number

        The height of the jump in px. This option is not valid if it's a diagonal direction jumping.

      • Optional keep_shadow_hidden?: boolean

        Whether the char shadow will remain hidden after jump.

      • Optional sfx_key?: string

        The sound effect to play while jumping.

      • Optional time_on_finish?: number

        A time to wait on jump finish in ms.

    Returns Promise<void>

  • manage_filter(filter: Filter, set: boolean): void
  • play(action?: string, animation?: string, start?: boolean, frame_rate?: number, loop?: boolean, reset_before_start?: boolean, reversed?: boolean): Animation
  • Plays an animation of this char.

    Parameters

    • Optional action: string

      the action that this char is going to doing.

    • Optional animation: string

      an specific animation of the given action that this char is going to be executing.

    • start: boolean = true

      whether you want the animation to start. Otherwise it will be stopped.

    • Optional frame_rate: number

      a custom frame rate value.

    • Optional loop: boolean

      whether the animation will be looping.

    • Optional reset_before_start: boolean

      whether the animation will reset before start.

    • Optional reversed: boolean

      whether the animation will be played on reverse sense.

    Returns Animation

    Returns the resulting Phaser.Animation object.

  • play_current_action(check_on_event?: boolean, force_squat?: boolean): void
  • remove_animation_callback(key: number): boolean
  • reset_anchor(property?: "x" | "y"): void
  • reset_scale(): void
  • set_collision_layer(layer: number): void
  • set_direction(direction?: directions, force_change?: boolean, transition_also?: boolean): void
  • Changes the char current direction to the given direction.

    Parameters

    • Optional direction: directions

      the direction to change.

    • force_change: boolean = false

      plays this new direction.

    • transition_also: boolean = true

      also change the transition direction.

    Returns void

  • set_events(events_info: any[], after_psynergy_cast_events: any): void
  • Initialize the Game Events related to this NPC.

    Parameters

    • events_info: any[]

      the events info json.

    • after_psynergy_cast_events: any

      the after psynergy cast events info json.

    Returns void

  • set_frame(animation: string | directions, frame_index?: number, action?: string): void
  • set_hue(activate: boolean, angle?: number): void
  • set_ice_slide_direction(direction: directions): void
  • set_outline(activate: boolean, options?: { b?: number; g?: number; keep_transparent?: boolean; r?: number }): void
  • Sets or unsets an outline in this char. You can also use this function to update options. Otherwise, use ControllableChar.outline_filter directly.

    Parameters

    • activate: boolean

      whether you want to activate the outline or not.

    • Optional options: { b?: number; g?: number; keep_transparent?: boolean; r?: number }

      some options.

      • Optional b?: number

        The blue color component of the outline. 0 to 1. Default 1.

      • Optional g?: number

        The green color component of the outline. 0 to 1. Default 1.

      • Optional keep_transparent?: boolean

        If this property is true, the char will be transparent excepting the outline. Default false.

      • Optional r?: number

        The red color component of the outline. 0 to 1. Default 1.

    Returns void

  • set_position(position: { x?: number; y?: number }, update_shadow?: boolean): void
  • set_push_timer(callback: (() => void), delay?: number): void
  • Sets the push timer for this char. This timer is used to start the object pushing. The char must wait for this timer before pushing.

    Parameters

    • callback: (() => void)

      the timer callback.

        • (): void
        • Returns void

    • delay: number = Phaser.Timer.QUARTER

      the initial delay.

    Returns void

  • set_rotation(rotate: boolean, interframe_interval?: number, frame_index?: number): void
  • Activates or deactivates this char rotation on z-axis.

    Parameters

    • rotate: boolean

      if true, activates the rotation.

    • interframe_interval: number = -1

      frame change rate interval in ms. -1 to change every frame.

    • Optional frame_index: number

      optionally specifies a frame index to be in when rotating.

    Returns void

  • set_shadow(group: Group, options?: { is_world_map?: boolean; key_name?: string; shadow_anchor_x?: number; shadow_anchor_y?: number }): void
  • Initialize the shadow sprite of this char.

    Parameters

    • group: Group

      the group where the shadow sprite is going to be inserted.

    • Optional options: { is_world_map?: boolean; key_name?: string; shadow_anchor_x?: number; shadow_anchor_y?: number }

      options to be set like anchor values and whether it's a world map.

      • Optional is_world_map?: boolean
      • Optional key_name?: string
      • Optional shadow_anchor_x?: number
      • Optional shadow_anchor_y?: number

    Returns void

  • set_speed(x_speed: number, y_speed: number, apply_speed?: boolean): void
  • set_speed_factors(): boolean
  • Sets the x-y speed values that this NPC is going to be using to move.

    Returns boolean

    Returns true if the speed values were set. Going towards a collision direction is not acceptable, then returns false.

  • set_sprite(group: Group, sprite_info: SpriteBase, layer: number, map: Map, anchor_x?: number, anchor_y?: number, scale_x?: number, scale_y?: number, initial_x_px?: number, initial_y_px?: number): void
  • Initializes the char sprite.

    Parameters

    • group: Group

      the group that this is char is going to be inserted.

    • sprite_info: SpriteBase

      the frames and animations information of this char.

    • layer: number

      the collision layer that this char is.

    • map: Map

      the map where this char is going to be in.

    • Optional anchor_x: number

      optional x anchor value of the sprite.

    • Optional anchor_y: number

      optional y anchor value of the sprite.

    • Optional scale_x: number

      optional x scale value of the sprite.

    • Optional scale_y: number

      optional y scale value of the sprite.

    • Optional initial_x_px: number
    • Optional initial_y_px: number

    Returns void

  • set_temporary_speed(x_speed?: number, y_speed?: number): void
  • Sets some temporary speed values. These temporary values are set before collision analysis and may suffer changes on it. After collision analysis, they are indeed applied to actual speed values.

    Parameters

    • Optional x_speed: number

      the x speed value.

    • Optional y_speed: number

      the y speed value.

    Returns void

  • set_trying_to_push_direction(direction: directions): void
  • set_visible(visible: boolean): void
  • Sets this NPC visibility.

    Parameters

    • visible: boolean

      whether to be visible or not.

    Returns void

  • shake(options?: { max_scale_mult?: number; repeat_period?: number; repeats_number?: number; side_shake?: boolean }): Promise<void>
  • Shakes this char by changing its scale.

    Parameters

    • Optional options: { max_scale_mult?: number; repeat_period?: number; repeats_number?: number; side_shake?: boolean }
      • Optional max_scale_mult?: number

        Max scale multiplier

      • Optional repeat_period?: number

        Duration of each shake

      • Optional repeats_number?: number

        How many times the char should shake

      • Optional side_shake?: boolean

        If true, the char will shake horizontally

    Returns Promise<void>

  • show_emoticon(emoticon_key: string, options?: { duration?: number; location?: { x?: number; y?: number }; sound_effect?: string }): Promise<Sprite>
  • Shows an emoticon above this char.

    Parameters

    • emoticon_key: string

      The emoticon key name.

    • Optional options: { duration?: number; location?: { x?: number; y?: number }; sound_effect?: string }

      Some custom options.

      • Optional duration?: number

        The duration that this emoticon is going to be shown in ms. -1 for forever.

      • Optional location?: { x?: number; y?: number }

        A custom location for the emoticon.

        • Optional x?: number
        • Optional y?: number
      • Optional sound_effect?: string

        Sound effect key to be played.

    Returns Promise<Sprite>

    returns the emoticon sprite.

  • splash_sweat_drops(times?: number): Promise<void>
  • stop_animation(reset_frame?: boolean): void
  • stop_char(change_sprite?: boolean): void
  • toggle_active(active: boolean): void
  • toggle_collision(enable: boolean): boolean
  • unset(): void
  • unset_push_timer(): void
  • update(): void
  • The main update function of this NPC.

    Returns void

  • update_half_crop(force?: boolean): void
  • update_initial_position(x: number, y: number): void
  • Updates this NPC initial position.

    Parameters

    • x: number

      the x pos in px.

    • y: number

      the y pos in px.

    Returns void

  • update_movement(ignore_collide_action_change?: boolean): void
  • update_on_event(): void
  • update_random_walk(flip_direction?: boolean): any
  • Tries to find a direction for this NPC to move in the random walk.

    Parameters

    • flip_direction: boolean = false

      If true, this function will try to find directions in the opposite direction.

    Returns any

    Returns true if a direction to move was found.

  • update_shadow(): void
  • update_sweat_drops_position(): void
  • update_tile_position(update_on_map?: boolean): void

Generated using TypeDoc