Class: Game_Character

Inherits:
Object show all
Includes:
GameData::SystemTags
Defined in:
scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00100 Game_Character_1.rb,
scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00110 Game_Character_2.rb,
scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00150 Game_Character_Ext.rb,
scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00120 Game_Character_move.rb,
scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00125 Game_Character_turn.rb,
scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00140 Game_Character_state.rb,
scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00155 Game_Character_bridge.rb,
scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00105 Game_Character_passable.rb,
scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00145 Game_Character_follower.rb,
scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00160 Game_Character_particles.rb,
scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00130 Game_Character_appearance.rb,
scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00170 Game_Character_pathfinding.rb

Overview

Class that describe and manipulate a Character (Player/Events)

Direct Known Subclasses

Game_Event, Game_Player

Constant Summary collapse

StairsTag =

Array of SystemTag that define stairs

[StairsL, StairsD, StairsU, StairsR]
SlideTags =

SystemTags that triggers “sliding” state

[TIce, RapidsL, RapidsR, RapidsU, RapidsD, RocketL, RocketU, RocketD, RocketR, RocketRL, RocketRU, RocketRD, RocketRR]
SurfTag =

SystemTags that trigger Surfing

[TPond, TSea]
SurfLTag =

SystemTags that does not trigger leaving water

SurfTag + [BridgeUD, BridgeRL, RapidsL, RapidsR, RapidsU, RapidsD, AcroBikeRL, AcroBikeUD, WaterFall,
JumpD, JumpL, JumpR, JumpU]
PARTICLES_METHODS =

Constant defining all the particle method to call

{
  TGrass => :particle_push_grass,
  TTallGrass => :particle_push_tall_grass,
  TSand => :particle_push_sand,
  TSnow => :particle_push_snow,
  TPond => :particle_push_pond,
  TWetSand => :particle_push_wetsand
}
SAND_PARTICLE_NAME =

Constant telling the sand particle name to push (according to the direction)

{ 2 => :sand_d, 4 => :sand_l, 6 => :sand_r, 8 => :sand_u }
SNOW_PARTICLE_NAME =

Constant telling the snow particle name to push (according to the direction)

{ 2 => :snow_d, 4 => :snow_l, 6 => :snow_r, 8 => :snow_u }
SHADOW_DISABLED_UPDATE_VALUES =

Values that allows the shadow_disabled update in set_appearance

[false, true, nil]
EMPTY_MOVE_ROUTE =
RPG::MoveRoute.new

Constants included from GameData::SystemTags

GameData::SystemTags::AcroBike, GameData::SystemTags::AcroBikeRL, GameData::SystemTags::AcroBikeUD, GameData::SystemTags::BridgeRL, GameData::SystemTags::BridgeUD, GameData::SystemTags::CrackedSoil, GameData::SystemTags::DeepSwamp, GameData::SystemTags::Empty, GameData::SystemTags::HeadButt, GameData::SystemTags::Hole, GameData::SystemTags::JumpD, GameData::SystemTags::JumpL, GameData::SystemTags::JumpR, GameData::SystemTags::JumpU, GameData::SystemTags::MachBike, GameData::SystemTags::RapidsD, GameData::SystemTags::RapidsL, GameData::SystemTags::RapidsR, GameData::SystemTags::RapidsU, GameData::SystemTags::Road, GameData::SystemTags::RocketD, GameData::SystemTags::RocketL, GameData::SystemTags::RocketR, GameData::SystemTags::RocketRD, GameData::SystemTags::RocketRL, GameData::SystemTags::RocketRR, GameData::SystemTags::RocketRU, GameData::SystemTags::RocketU, GameData::SystemTags::SlopesL, GameData::SystemTags::SlopesR, GameData::SystemTags::StairsD, GameData::SystemTags::StairsL, GameData::SystemTags::StairsR, GameData::SystemTags::StairsU, GameData::SystemTags::SwampBorder, GameData::SystemTags::TCave, GameData::SystemTags::TGrass, GameData::SystemTags::TIce, GameData::SystemTags::TMount, GameData::SystemTags::TPond, GameData::SystemTags::TSand, GameData::SystemTags::TSea, GameData::SystemTags::TSnow, GameData::SystemTags::TTallGrass, GameData::SystemTags::TUnderWater, GameData::SystemTags::TWetSand, GameData::SystemTags::WaterFall, GameData::SystemTags::ZTag

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from GameData::SystemTags

gen, system_tag_db_symbol

Constructor Details

#initializeGame_Character

Default initializer



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00100 Game_Character_1.rb', line 39

def initialize
  @id = 0
  @x = 0
  @y = 0
  @z = 1
  @real_x = 0
  @real_y = 0
  @tile_id = 0
  set_appearance(nil.to_s, 0)
  @opacity = 255
  @blend_type = 0
  @direction = 2
  @pattern = 0
  @move_route_forcing = false
  @through = false
  @animation_id = 0
  @transparent = false
  @original_direction = 2
  @original_pattern = 0
  @move_type = 0
  @move_speed = 4
  self.move_frequency = 6
  @move_route = nil
  @move_route_index = 0
  @original_move_route = nil
  @original_move_route_index = 0
  @walk_anime = true
  @step_anime = false
  @direction_fix = false
  @always_on_top = false
  @anime_count = 0
  @stop_count = 0
  @jump_count = 0
  @jump_peak = 0
  @wait_count = 0
  @slope_offset_y = 0
  @slope_y_modifier = 0
  @locked = false
  @prelock_direction = 0
  @surfing = false # Variable indiquant si le chara est sur l'eau
  @sliding = false # Variable indiquant si le chara slide
  @sliding_parameter = nil # Variable giving extra information for sliding
  @pattern_state = false # Indicateur de la direction du pattern
  @can_make_footprint = true
  @reflection_enabled = $game_player&.reflection_enabled 
end

Instance Attribute Details

#__bridge

The bridge state



7
8
9
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00170 Game_Character_pathfinding.rb', line 7

def __bridge
  @__bridge
end

#animation_idInteger

Returns ID of the animation to play on the character.

Returns:

  • (Integer)

    ID of the animation to play on the character



24
25
26
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00100 Game_Character_1.rb', line 24

def animation_id
  @animation_id
end

#blend_typeInteger (readonly)

Returns blending of the event (0 is the only one that actually works).

Returns:

  • (Integer)

    blending of the event (0 is the only one that actually works)



11
12
13
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00130 Game_Character_appearance.rb', line 11

def blend_type
  @blend_type
end

#can_make_footprintBoolean

Returns tell if the character can make footprint on the ground or not.

Returns:

  • (Boolean)

    tell if the character can make footprint on the ground or not



7
8
9
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00140 Game_Character_state.rb', line 7

def can_make_footprint
  @can_make_footprint
end

#character_hueIntger

Returns must be 0.

Returns:

  • (Intger)

    must be 0



7
8
9
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00130 Game_Character_appearance.rb', line 7

def character_hue
  @character_hue
end

#character_nameString

Returns name of the character graphic used to display the event.

Returns:

  • (String)

    name of the character graphic used to display the event



5
6
7
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00130 Game_Character_appearance.rb', line 5

def character_name
  @character_name
end

#directionInteger

Returns direction where the event is looking (2 = down, 6 = right, 4 = left, 8 = up).

Returns:

  • (Integer)

    direction where the event is looking (2 = down, 6 = right, 4 = left, 8 = up)



18
19
20
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00100 Game_Character_1.rb', line 18

def direction
  @direction
end

#direction_fixBoolean (readonly)

If the direction is fixed

Returns:

  • (Boolean)


33
34
35
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00100 Game_Character_1.rb', line 33

def direction_fix
  @direction_fix
end

#followerGame_Character? (readonly)

Returns the follower.

Returns:



28
29
30
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00100 Game_Character_1.rb', line 28

def follower
  @follower
end

#idInteger (readonly)

Id of the event in the map

Returns:



6
7
8
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00100 Game_Character_1.rb', line 6

def id
  @id
end

#in_swampInteger, false

Returns if the character is in swamp tile and the power of the swamp tile.

Returns:

  • (Integer, false)

    if the character is in swamp tile and the power of the swamp tile



3
4
5
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00140 Game_Character_state.rb', line 3

def in_swamp
  @in_swamp
end

#is_pokemonBoolean

Returns if the character is a Pokemon (affect the step anime).

Returns:

  • (Boolean)

    if the character is a Pokemon (affect the step anime)



5
6
7
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00140 Game_Character_state.rb', line 5

def is_pokemon
  @is_pokemon
end

#move_route (readonly)

The current move route



3
4
5
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00170 Game_Character_pathfinding.rb', line 3

def move_route
  @move_route
end

#move_route_forcingBoolean (readonly)

Returns if the character is forced to move using a specific route.

Returns:

  • (Boolean)

    if the character is forced to move using a specific route



20
21
22
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00100 Game_Character_1.rb', line 20

def move_route_forcing
  @move_route_forcing
end

#move_route_index (readonly)

The current move route index



5
6
7
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00170 Game_Character_pathfinding.rb', line 5

def move_route_index
  @move_route_index
end

#move_speedInteger

Dynamic move_speed value of the Game_Character, return a different value than @move_speed

Returns:

  • (Integer)

    the dynamic move_speed

Author:

  • Nuri Yuri



26
27
28
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00100 Game_Character_1.rb', line 26

def move_speed
  @move_speed
end

#offset_screen_yInteger?

Returns offset y of the character on the screen.

Returns:

  • (Integer, nil)

    offset y of the character on the screen



21
22
23
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00130 Game_Character_appearance.rb', line 21

def offset_screen_y
  @offset_screen_y
end

#offset_shadow_screen_yInteger?

Returns offset y of the character on the screen.

Returns:

  • (Integer, nil)

    offset y of the character on the screen



23
24
25
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00130 Game_Character_appearance.rb', line 23

def offset_shadow_screen_y
  @offset_shadow_screen_y
end

#opacityInteger

Returns opacity of the event when it's shown.

Returns:

  • (Integer)

    opacity of the event when it's shown



9
10
11
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00130 Game_Character_appearance.rb', line 9

def opacity
  @opacity
end

#particles_disabledBoolean

Returns if the particles are disabled for the Character.

Returns:

  • (Boolean)

    if the particles are disabled for the Character



3
4
5
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00160 Game_Character_particles.rb', line 3

def particles_disabled
  @particles_disabled
end

#pathArray<RPG::MoveCommand>, ...

The current path

Returns:



14
15
16
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00170 Game_Character_pathfinding.rb', line 14

def path
  @path
end

#patternInteger (readonly)

Returns current pattern of the character graphic shown.

Returns:

  • (Integer)

    current pattern of the character graphic shown



13
14
15
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00130 Game_Character_appearance.rb', line 13

def pattern
  @pattern
end

#real_xInteger (readonly)

Returns “real” X position of the event, usually x * 128.

Returns:

  • (Integer)

    “real” X position of the event, usually x * 128



14
15
16
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00100 Game_Character_1.rb', line 14

def real_x
  @real_x
end

#real_yInteger (readonly)

Returns “real” Y position of the event, usually y * 128.

Returns:

  • (Integer)

    “real” Y position of the event, usually y * 128



16
17
18
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00100 Game_Character_1.rb', line 16

def real_y
  @real_y
end

#reflection_enabledBoolean

If the character has reflection

Returns:

  • (Boolean)


36
37
38
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00100 Game_Character_1.rb', line 36

def reflection_enabled
  @reflection_enabled
end

#shadow_disabledBoolean

Returns if the shadow should be shown or not.

Returns:

  • (Boolean)

    if the shadow should be shown or not



19
20
21
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00130 Game_Character_appearance.rb', line 19

def shadow_disabled
  @shadow_disabled
end

#sliding

The current sliding state



30
31
32
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00100 Game_Character_1.rb', line 30

def sliding
  @sliding
end

#step_animeBoolean

Returns if the event has a patern animation while staying.

Returns:

  • (Boolean)

    if the event has a patern animation while staying



17
18
19
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00130 Game_Character_appearance.rb', line 17

def step_anime
  @step_anime
end

#surfing=(value) (writeonly)

The current surfing state



11
12
13
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00170 Game_Character_pathfinding.rb', line 11

def surfing=(value)
  @surfing = value
end

#throughBoolean

Returns if the character is traversable and it can walk through any tiles.

Returns:

  • (Boolean)

    if the character is traversable and it can walk through any tiles



22
23
24
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00100 Game_Character_1.rb', line 22

def through
  @through
end

#tile_idInteger (readonly)

Returns ID of the tile shown as the event (0 = no tile).

Returns:

  • (Integer)

    ID of the tile shown as the event (0 = no tile)



3
4
5
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00130 Game_Character_appearance.rb', line 3

def tile_id
  @tile_id
end

#transparentBoolean

Returns if the event is invisible.

Returns:

  • (Boolean)

    if the event is invisible



15
16
17
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00130 Game_Character_appearance.rb', line 15

def transparent
  @transparent
end

#xInteger

Returns X position of the event in the current map.

Returns:

  • (Integer)

    X position of the event in the current map



8
9
10
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00100 Game_Character_1.rb', line 8

def x
  @x
end

#yInteger

Returns Y position of the event in the current map.

Returns:

  • (Integer)

    Y position of the event in the current map



10
11
12
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00100 Game_Character_1.rb', line 10

def y
  @y
end

#zInteger

Returns Z priority of the event.

Returns:

  • (Integer)

    Z priority of the event



12
13
14
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00100 Game_Character_1.rb', line 12

def z
  @z
end

Instance Method Details

#activated?Boolean

Check if the character is activate. Useful to make difference between event without active page and others.

Returns:

  • (Boolean)


236
237
238
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00100 Game_Character_1.rb', line 236

def activated?
  true
end

#animate_from_charset(lines, duration, reverse: false, repeat: false) ⇒ Boolean

Set the charset animation. It can be needed to set the event in direction fixed.

Parameters:

  • lines (Array<Integer>)

    list of the lines to animates (0,1,2,3)

  • duration (Integer)

    duration of the animation in frame (30 frames per secondes)

  • reverse (Boolean) (defaults to: false)

    <default: false> set it to true if the animation is reversed

  • repeat (Boolean) (defaults to: false)

    <default: false> set it to true if the animation is looped

Returns:

  • (Boolean)


59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00130 Game_Character_appearance.rb', line 59

def animate_from_charset(lines, duration, reverse: false, repeat: false)
  # Calculate and store the frames to display
  frames = []
  lines.each do |dir|
	[0,1,2,3].each do |pattern|
		frames.push ((((dir+1)*2)<<2) | pattern)	# A frame is 0bdddpp with ddd the direction, pp the pattern
	end
  end
  frames.reverse! if reverse  # Invert the animation if asked
  duration *= 2               # Double the frame to match the game framerate (30 / s)
  # Contain the charset animation data
  @charset_animation = {
    running:    true,                                       # Indicate if the animation need to be updated or not
    frames:     frames,                                     # List of frames
    delay:      (duration.to_f / frames.size.to_f).round,   # Delay between two frame in frames
    repeat:     repeat,                                     # Indicate if the animation is looped or not
    counter:    -1,                                         # Frame counter (initialized at -1 so the first update will set the appearance)
    index:      0                                           # Index of the current frame to display
  }
  return update_charset_animation   # First update, display the first frame
end

#bridge_down_check(z) Also known as: bridge_up_check

Adjust the Character informations related to the brige when it moves down (or up)

Parameters:

Author:

  • Nuri Yuri



5
6
7
8
9
10
11
12
13
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00155 Game_Character_bridge.rb', line 5

def bridge_down_check(z)
  if z > 1 and !@__bridge
    if (sys_tag = front_system_tag) == BridgeUD
      @__bridge = [sys_tag, system_tag]
    end
  elsif z > 1 and @__bridge
    @__bridge = nil if @__bridge.last == system_tag
  end
end

#bridge_left_check(z) Also known as: bridge_right_check

Adjust the Character informations related to the brige when it moves left (or right)

Parameters:

Author:

  • Nuri Yuri



19
20
21
22
23
24
25
26
27
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00155 Game_Character_bridge.rb', line 19

def bridge_left_check(z)
  if z > 1 and !@__bridge
    if (sys_tag = front_system_tag) == BridgeRL
      @__bridge = [sys_tag, system_tag]
    end
  elsif z > 1 and @__bridge
    @__bridge = nil if @__bridge.last == system_tag
  end
end

#bush_depthInteger

bush_depth of the sprite of the character

Returns:



40
41
42
43
44
45
46
47
48
49
50
51
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00130 Game_Character_appearance.rb', line 40

def bush_depth
  # タイルの場合、または最前面に表示フラグが ON の場合
  if @tile_id > 0 or @always_on_top
    return 0
  end
  # return 12 if @in_swamp #> Ajout des marais
  if @jump_count == 0 and $game_map.bush?(@x, @y)
    return 12
  else
    return 0
  end
end

#cancel_charset_animation

Cancel the charset animation



82
83
84
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00130 Game_Character_appearance.rb', line 82

def cancel_charset_animation
  @charset_animation = nil
end

#check_event_trigger_touch(*args)

Define the function check_event_trigger_touch to prevent bugs



232
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00100 Game_Character_1.rb', line 232

def check_event_trigger_touch(*args); end

#contact?(x, y, z) ⇒ Boolean

Check if it's possible to have contact interaction with this Game_Character at certain coordinates

Parameters:

Returns:

  • (Boolean)

Author:

  • Nuri Yuri



172
173
174
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00150 Game_Character_Ext.rb', line 172

def contact?(x, y, z)
  return (@x == x and y == @y and (@z - z).abs <= 1)
end

#define_path(path)

Define the path from path_finding

Parameters:



50
51
52
53
54
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00170 Game_Character_pathfinding.rb', line 50

def define_path(path)
  @move_route_index_path_finder ||= @move_route_index
  @move_route_index = 0
  @path = path
end

#detect_swamp

Detect if the event walks in a swamp or a deep swamp and change the Game_Character states.

Author:

  • Nuri Yuri



178
179
180
181
182
183
184
185
186
187
188
189
190
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00150 Game_Character_Ext.rb', line 178

def detect_swamp
  sys_tag = system_tag
  if sys_tag == SwampBorder
    change_shadow_disabled_state(true)
    @in_swamp = 1
  elsif sys_tag == DeepSwamp
    change_shadow_disabled_state(true)
    @in_swamp = 4 + (rand(2) == 0 ? 4 + rand(4) : 0)
  else
    change_shadow_disabled_state(false)
    @in_swamp = false
  end
end

#each_front_tiles(nb_steps) {|x, y, d| ... }

Iterate through each front tiles including current tile

Parameters:

  • nb_steps (Integer)

    number of step in front of the event to iterate

Yield Parameters:



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00150 Game_Character_Ext.rb', line 26

def each_front_tiles(nb_steps)
  x = @x
  y = @y
  d = @direction
  dx = d[2] * (2 * d[1] - 1)
  dy = (1 - d[2]) * (2 * d[1] - 1)
  if block_given?
    0.upto(nb_steps) do
      yield(x, y, d)
      x += dx
      y += dy
    end
  else
    return Enumerator.new do |yielder|
      0.upto(nb_steps) { |i| yielder << [x + i * dx, y + i * dy, d] }
    end
  end
end

#each_front_tiles_rect(nb_steps, dist) {|x, y, d| ... }

Iterate through each front tiles including current tile

Parameters:

  • nb_steps (Integer)

    number of step in front of the event to iterate

  • dist (Integer)

    distance in both side of the detection

Yield Parameters:



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00150 Game_Character_Ext.rb', line 51

def each_front_tiles_rect(nb_steps, dist)
  x = @x
  y = @y
  d = @direction
  dx = d[2] * (2 * d[1] - 1)
  dy = (1 - d[2]) * (2 * d[1] - 1)
  if block_given?
    0.upto(nb_steps) do
      (dist*2+1).times { |line| yield(x + (line - dist) * dy, y + (line - dist) * dx, d) }
      x += dx
      y += dy
    end
  else
    return Enumerator.new do |yielder|
      (dist*2+1).times do |line|
        0.upto(nb_steps) { |i| yielder << [x + (line - dist) * dy + i * dx, y + (line - dist) * dx + i * dy, d] }
      end
    end
  end
end

#emotion(type, wait = 34, params = {})

Show an emotion to an event or the player

Parameters:

  • type (Symbol)

    the type of emotion (see wiki)

  • wait (Integer) (defaults to: 34)

    the number of frame the event will wait after this command.

  • params (Hash) (defaults to: {})

    particle params



9
10
11
12
13
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00160 Game_Character_particles.rb', line 9

def emotion(type, wait = 34, params = {})
  Yuki::Particles.add_particle(self, type, params)
  @wait_count = wait
  @move_type_custom_special_result = true if wait > 0
end

#event_passable_check?(new_x, new_y, z, game_map) ⇒ Boolean

Check the passage related to events

Parameters:

Returns:

  • (Boolean)

    if the tile has no event that block the way



92
93
94
95
96
97
98
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00105 Game_Character_passable.rb', line 92

def event_passable_check?(new_x, new_y, z, game_map)
  game_map.events.each_value do |event|
    next unless event.contact?(new_x, new_y, z)
    return false unless event.through
  end
  return true
end

#find_path(to:, radius: 0, tries: Pathfinding::TRY_COUNT, type: nil, tags: :DEFAULT)

Request a path to the target and follow it as soon as it found



20
21
22
23
24
25
26
27
28
29
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00170 Game_Character_pathfinding.rb', line 20

def find_path(to:, radius: 0, tries: Pathfinding::TRY_COUNT, type: nil, tags: :DEFAULT)
  # Wrap data to match
  type ||= (to.is_a?(Array) ? :Coords : :Character)
  # Create the request
  Pathfinding.add_request(self, [type, to, radius], tries, tags)
  # Set move route forcing to true
  @move_route_forcing_path_finder ||= @move_route_forcing
  @move_route_forcing = true
  @move_type_custom_special_result = true
end

#follower_check?(new_x, new_y, z) ⇒ Boolean

Check the passage related to events

Parameters:

  • new_x (Integer)

    new x position

  • new_y (Integer)

    new y position

  • z (Integer)

    current z position

Returns:

  • (Boolean)

    if the tile has no event that block the way



105
106
107
108
109
110
111
112
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00105 Game_Character_passable.rb', line 105

def follower_check?(new_x, new_y, z)
  unless Yuki::FollowMe.is_player_follower?(self) || self == $game_player
    Yuki::FollowMe.each_follower do |event|
      return false if event.contact?(new_x, new_y, z)
    end
  end
  return true
end

#follower_move

Move a follower

Author:

  • Nuri Yuri



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00145 Game_Character_follower.rb', line 11

def follower_move
  return unless @follower
  return if @sliding && @follower.sliding && ROCKET_TAGS.include?(@sliding_parameter)
  return if $game_variables[Yuki::Var::FM_Sel_Foll] > 0 && @follower.class == Game_Character

  @follower.move_speed = @move_speed
  if @memorized_move
    @memorized_move_arg ? @follower.send(@memorized_move, *@memorized_move_arg) : @follower.send(@memorized_move)
    @memorized_move_arg = nil
    @memorized_move = nil
    return
  end
  x = @x - @follower.x
  y = @y - @follower.y
  d = @direction
  case d
  when 2
    if x < 0
      @follower.move_left
    elsif x > 0
      @follower.move_right
    elsif y > 1
      @follower.move_down
    elsif y == 0
      @follower.move_up
    end
  when 4
    if y < 0
      @follower.move_up
    elsif y > 0
      @follower.move_down
    elsif x < -1
      @follower.move_left
    elsif x == 0
      @follower.move_right
    end
  when 6
    if y < 0
      @follower.move_up
    elsif y > 0
      @follower.move_down
    elsif x > 1
      @follower.move_right
    elsif x == 0
      @follower.move_left
    end
  when 8
    if x < 0
      @follower.move_left
    elsif x > 0
      @follower.move_right
    elsif y < -1
      @follower.move_up
    elsif y == 0
      @follower.move_down
    end
  end
end

#follower_sliding?Boolean

Check if the follower slides

Returns:

  • (Boolean)

Author:

  • Nuri Yuri



85
86
87
88
89
90
91
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00145 Game_Character_follower.rb', line 85

def follower_sliding?
  if @follower
    return @follower.follower_sliding? unless @follower.sliding?
    return true
  end
  return false
end

#follower_tailGame_Character, self

Return the tail of the following queue

Returns:



102
103
104
105
106
107
108
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00145 Game_Character_follower.rb', line 102

def follower_tail
  return self unless (current_follower = @follower)
  while (next_follower = current_follower.follower)
    current_follower = next_follower
  end
  return current_follower
end

#force_move_route(move_route)

Force the character to adopt a move route and save the original one

Parameters:



105
106
107
108
109
110
111
112
113
114
115
116
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00100 Game_Character_1.rb', line 105

def force_move_route(move_route)
  if @original_move_route.nil?
    @original_move_route = @move_route
    @original_move_route_index = @move_route_index
  end
  @move_route = move_route
  @move_route_index = 0
  @move_route_forcing = true
  @prelock_direction = 0
  @wait_count = 0
  move_type_custom
end

#front_name_check(name) ⇒ Boolean Also known as: front_name_detect

Check a the #front_event has a specific name

Returns:

  • (Boolean)

Author:

  • Nuri Yuri



75
76
77
78
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00150 Game_Character_Ext.rb', line 75

def front_name_check(name)
  return true if front_tile_event&.event&.name == name
  return false
end

#front_system_tagInteger

Return the SystemTag in the front of the Game_Character

Returns:

  • (Integer)

    ID of the SystemTag

Author:

  • Nuri Yuri



91
92
93
94
95
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00150 Game_Character_Ext.rb', line 91

def front_system_tag
  xf = @x + (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
  yf = @y + (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
  return $game_map.system_tag(xf, yf)
end

#front_system_tag_db_symbolSymbol

Return the db_symbol of the front system tag

Returns:

  • (Symbol)


107
108
109
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00150 Game_Character_Ext.rb', line 107

def front_system_tag_db_symbol
  GameData::SystemTags.system_tag_db_symbol(front_system_tag)
end

#front_terrain_tagInteger?

Terrain tag in front of the character

Returns:



99
100
101
102
103
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00150 Game_Character_Ext.rb', line 99

def front_terrain_tag
  xf = @x + (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
  yf = @y + (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
  return $game_map.terrain_tag(xf, yf)
end

#front_tileArray(Integer, Integer)

Return tile position in front of the player

Returns:



4
5
6
7
8
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00150 Game_Character_Ext.rb', line 4

def front_tile
  xf = @x + (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
  yf = @y + (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
  return [xf, yf]
end

#front_tile_eventGame_Event?

Return the event that stand in the front of the Player

Returns:



12
13
14
15
16
17
18
19
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00150 Game_Character_Ext.rb', line 12

def front_tile_event
  xf = @x + (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
  yf = @y + (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
  $game_map.events.each_value do |event|
    return event if event.x == xf and event.y == yf
  end
  return nil
end

#front_tile_idInteger, 0

Return the id of the #front_tile_event

Returns:

  • (Integer, 0)

    0 if no front_tile_event

Author:

  • Nuri Yuri



84
85
86
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00150 Game_Character_Ext.rb', line 84

def front_tile_id
  return front_tile_event&.event&.id.to_i
end

#increase_steps

Increase step prototype (sets @stop_count to 0)



399
400
401
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00110 Game_Character_2.rb', line 399

def increase_steps
  @stop_count = 0
end

#jump(x_plus, y_plus, follow_move = true) ⇒ Boolean

Make the Game_Character jump

Parameters:

  • x_plus (Integer)

    the number of tile the Game_Character will jump on x

  • y_plus (Integer)

    the number of tile the Game_Character will jump on y

  • follow_move (Boolean) (defaults to: true)

    if the follower moves when the Game_Character starts jumping

Returns:

  • (Boolean)

    if the character is jumping



435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00120 Game_Character_move.rb', line 435

def jump(x_plus, y_plus, follow_move = true)
  jump_bridge_check(x_plus, y_plus)
  new_x = @x + x_plus
  new_y = @y + y_plus

  if (x_plus == 0 && y_plus == 0) || passable?(new_x, new_y, 0) ||
     ($game_switches[::Yuki::Sw::EV_AccroBike] && front_system_tag == AcroBike)
    straighten
    @x = new_x
    @y = new_y
    distance = Math.sqrt(x_plus * x_plus + y_plus * y_plus).round
    @jump_peak = 10 + distance - @move_speed
    @jump_count = @jump_peak * 2
    @stop_count = 0
    @pattern = (rand(2) == 0 ? 1 : 3) unless follow_move
    movement_process_end(true)
    if follow_move && @follower && $game_variables[Yuki::Var::FM_Sel_Foll] == 0 && (x_plus != 0 || y_plus != 0)
      follower_move
      @memorized_move = :jump
      @memorized_move_arg = [x_plus, y_plus]
    end
  end
  particle_push
  return @jump_count > 0
end

#jump_bridge_check(x_plus, y_plus)

Perform the bridge check for the jump operation

Parameters:

  • x_plus (Integer)

    the number of tile the Game_Character will jump on x

  • y_plus (Integer)

    the number of tile the Game_Character will jump on y



464
465
466
467
468
469
470
471
472
473
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00120 Game_Character_move.rb', line 464

def jump_bridge_check(x_plus, y_plus)
  return if x_plus == 0 && y_plus == 0
  if x_plus.abs > y_plus.abs
    x_plus < 0 ? turn_left : turn_right
    bridge_left_check(@z)
  else
    y_plus < 0 ? turn_up : turn_down
    bridge_down_check(@z)
  end
end

#jumping?Boolean

is the character jumping ?

Returns:

  • (Boolean)


17
18
19
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00140 Game_Character_state.rb', line 17

def jumping?
  return @jump_count > 0
end

#lock

Make the character look the player during a dialog



48
49
50
51
52
53
54
55
56
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00140 Game_Character_state.rb', line 48

def lock
  return if @locked
  # Store the old direction
  @prelock_direction = @direction
  # Make it look to the player
  turn_toward_player
  # Store the state
  @locked = true
end

#lock?Boolean

Note:

in this state, the character is not able to perform automatic moveroute (rmxp conf)

Is the character locked ? (looking to the player when it's activated)

Returns:

  • (Boolean)


61
62
63
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00140 Game_Character_state.rb', line 61

def lock?
  return @locked
end

#look_this_event

Look directly to the current event



134
135
136
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00150 Game_Character_Ext.rb', line 134

def look_this_event
  look_to($game_system.map_interpreter.event_id)
end

#look_to(event_id)

Look directly to a specific event

Parameters:

  • event_id (Integer)

    id of the event on the Map

Author:

  • Nuri Yuri



114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00150 Game_Character_Ext.rb', line 114

def look_to(event_id)
  return unless (event = $game_map.events[event_id])
  delta_x = event.x - @x
  delta_y = event.y - @y
  if delta_x.abs <= delta_y.abs
    if delta_y < 0
      turn_up
    else
      turn_down
    end
  else
    if delta_x < 0
      turn_left
    else
      turn_right
    end
  end
end

#movable?Boolean

Is the character able to execute a move action

Returns:

  • (Boolean)


22
23
24
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00140 Game_Character_state.rb', line 22

def movable?
  !(moving? || jumping?)
end

#move_away_from_player

Move the Game_Character away from the player



351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00120 Game_Character_move.rb', line 351

def move_away_from_player
  sx = @x - $game_player.x
  sy = @y - $game_player.y
  return if sx == 0 && sy == 0

  abs_sx = sx.abs
  abs_sy = sy.abs
  if abs_sx == abs_sy
    rand(2) == 0 ? abs_sx += 1 : abs_sy += 1
  end

  if abs_sx > abs_sy
    sx > 0 ? move_right : move_left
    unless moving? || sy == 0
      sy > 0 ? move_down : move_up
    end
  else
    sy > 0 ? move_down : move_up
    unless moving? || sx == 0
      sx > 0 ? move_right : move_left
    end
  end
end

#move_backward

Move the Game_Character backward



414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00120 Game_Character_move.rb', line 414

def move_backward
  last_direction_fix = @direction_fix
  @direction_fix = true
  case @direction
  when 2  # 下
    move_up(false)
  when 4  # 左
    move_right(false)
  when 6  # 右
    move_left(false)
  when 8  # 上
    move_down(false)
  end
  @direction_fix = last_direction_fix
end

#move_down(turn_enabled = true)

Move Game_Character down

Parameters:

  • turn_enabled (Boolean) (defaults to: true)

    if the Game_Character turns when impossible move



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00120 Game_Character_move.rb', line 4

def move_down(turn_enabled = true)
  turn_down if turn_enabled
  if passable?(@x, @y, 2)
    if $game_map.system_tag(@x, @y + 1) == JumpD
      jump(0, 2, false)
      return follower_move
    end
    turn_down
    bridge_down_check(@z)
    @y += 1
    movement_process_end
    increase_steps
  else
    @sliding = false
    check_event_trigger_touch(@x, @y + 1)
  end
end

#move_follower_to_character

Warp the follower to the event it follows

Author:

  • Nuri Yuri



72
73
74
75
76
77
78
79
80
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00145 Game_Character_follower.rb', line 72

def move_follower_to_character
  return unless @follower
  return if $game_variables[Yuki::Var::FM_Sel_Foll] > 0
  @follower.move_follower_to_character # Fix left<->right stair issue but there's still a graphic glitch ^^'
  @follower.x = @x
  @follower.y = @y
  @follower.increase_steps
  @follower.update
end

#move_forward

Move the Game_Character forward



400
401
402
403
404
405
406
407
408
409
410
411
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00120 Game_Character_move.rb', line 400

def move_forward
  case @direction
  when 2
    move_down(false)
  when 4
    move_left(false)
  when 6
    move_right(false)
  when 8
    move_up(false)
  end
end

#move_frequency=(value)

Set the move_frequency (and define the max_stop_count value)

Parameters:

  • value (Numeric)


88
89
90
91
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00100 Game_Character_1.rb', line 88

def move_frequency=(value)
  @move_frequency = value
  @max_stop_count = (40 - value * 2) * (6 - value)
end

#move_left(turn_enabled = true)

Move Game_Character left

Parameters:

  • turn_enabled (Boolean) (defaults to: true)

    if the Game_Character turns when impossible move



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00120 Game_Character_move.rb', line 24

def move_left(turn_enabled = true)
  turn_left if turn_enabled
  return if stair_move_left
  y_modifier = slope_check_left
  if passable?(@x, @y + y_modifier, 4)
    if $game_map.system_tag(@x - 1, @y + y_modifier) == JumpL
      jump(-2, 0, false)
      return follower_move
    end
    turn_left
    bridge_left_check(@z)
    @x -= 1
    movement_process_end
    if y_modifier != 0
      @memorized_move = :move_toward
      @memorized_move_arg = [@x, @y]
      process_slope_y_modifier(y_modifier)
    end
    increase_steps
  else
    @sliding = false
    check_event_trigger_touch(@x - 1, @y + y_modifier)
  end
end

#move_lower_left

Move the Game_Character lower left



232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00120 Game_Character_move.rb', line 232

def move_lower_left
  unless @direction_fix
    @direction = (@direction == 6 ? 4 : @direction == 8 ? 2 : @direction)
  end
  if (passable?(@x, @y, 2) && passable?(@x, @y + 1, 4)) ||
     (passable?(@x, @y, 4) && passable?(@x - 1, @y, 2)) # 8 a la place de 2 sur les deux lignes
    move_follower_to_character
    @x -= 1
    @y += 1
    if @follower && $game_variables[Yuki::Var::FM_Sel_Foll] == 0
      @memorized_move = :move_lower_left
      @memorized_move_arg = nil
      @follower.direction = @direction
    end
    movement_process_end(true)
    increase_steps
  end
end

#move_lower_right

Move the Game_Character lower right



252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00120 Game_Character_move.rb', line 252

def move_lower_right
  unless @direction_fix
    @direction = (@direction == 4 ? 6 : @direction == 8 ? 2 : @direction)
  end
  if (passable?(@x, @y, 2) && passable?(@x, @y + 1, 6)) ||
     (passable?(@x, @y, 6) && passable?(@x + 1, @y, 2))
    move_follower_to_character
    @x += 1
    @y += 1
    if @follower && $game_variables[Yuki::Var::FM_Sel_Foll] == 0
      @memorized_move = :move_lower_right
      @memorized_move_arg = nil
      @follower.direction = @direction
    end
    movement_process_end(true)
    increase_steps
  end
end

#move_random

Move the Game_Character to a random direction



312
313
314
315
316
317
318
319
320
321
322
323
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00120 Game_Character_move.rb', line 312

def move_random
  case rand(4)
  when 0
    move_down(false)
  when 1
    move_left(false)
  when 2
    move_right(false)
  when 3
    move_up(false)
  end
end

#move_right(turn_enabled = true)

Move Game_Character right

Parameters:

  • turn_enabled (Boolean) (defaults to: true)

    if the Game_Character turns when impossible move



119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00120 Game_Character_move.rb', line 119

def move_right(turn_enabled = true)
  turn_right if turn_enabled
  return if stair_move_right
  y_modifier = slope_check_right
  if passable?(@x, @y + y_modifier, 6)
    if $game_map.system_tag(@x + 1, @y) == JumpR
      return (jump(2, 0, false) ? follower_move : nil)
    end
    turn_right
    bridge_right_check(@z)
    @x += 1
    movement_process_end
    if y_modifier != 0
      @memorized_move = :move_toward
      @memorized_move_arg = [@x, @y]
      process_slope_y_modifier(y_modifier)
    end
    increase_steps
  else
    @sliding = false
    check_event_trigger_touch(@x + 1, @y + y_modifier)
  end
end

#move_toward(tx, ty)



375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00120 Game_Character_move.rb', line 375

def move_toward(tx, ty)
  sx = @x - tx
  sy = @y - ty
  return if sx == 0 && sy == 0

  abs_sx = sx.abs
  abs_sy = sy.abs
  if abs_sx == abs_sy
    rand(2) == 0 ? abs_sx += 1 : abs_sy += 1
  end

  if abs_sx > abs_sy
    sx > 0 ? move_left : move_right
    unless moving? || sy == 0
      sy > 0 ? move_up : move_down
    end
  else
    sy > 0 ? move_up : move_down
    unless moving? || sx == 0
      sx > 0 ? move_left : move_right
    end
  end
end

#move_toward_player

Move the Game_Character toward the player



326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00120 Game_Character_move.rb', line 326

def move_toward_player
  sx = @x - $game_player.x
  sy = @y - $game_player.y
  return if sx == 0 && sy == 0

  abs_sx = sx.abs
  abs_sy = sy.abs
  if abs_sx == abs_sy
    rand(2) == 0 ? abs_sx += 1 : abs_sy += 1
  end

  if abs_sx > abs_sy
    sx > 0 ? move_left : move_right
    unless moving? || sy == 0
      sy > 0 ? move_up : move_down
    end
  else
    sy > 0 ? move_up : move_down
    unless moving? || sx == 0
      sx > 0 ? move_left : move_right
    end
  end
end

#move_type_path

Movement induced by the Path Finding



39
40
41
42
43
44
45
46
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00170 Game_Character_pathfinding.rb', line 39

def move_type_path
  return if @path == :pending
  return unless movable?
  while (command = @path[@move_route_index])
    # @move_route_index += 1
    break if move_type_custon_exec_command(command)
  end
end

#move_up(turn_enabled = true)

Move Game_Character up

Parameters:

  • turn_enabled (Boolean) (defaults to: true)

    if the Game_Character turns when impossible move



214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00120 Game_Character_move.rb', line 214

def move_up(turn_enabled = true)
  turn_up if turn_enabled
  if passable?(@x, @y, 8)
    if $game_map.system_tag(@x, @y - 1) == JumpU
      return (jump(0, -2, false) ? follower_move : nil)
    end
    turn_up
    bridge_up_check(@z)
    @y -= 1
    movement_process_end
    increase_steps
  else
    @sliding = false
    check_event_trigger_touch(@x, @y-1)
  end
end

#move_upper_left

Move the Game_Character upper left



272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00120 Game_Character_move.rb', line 272

def move_upper_left
  unless @direction_fix
    @direction = (@direction == 6 ? 4 : @direction == 2 ? 8 : @direction)
  end
  if (passable?(@x, @y, 8) && passable?(@x, @y - 1, 4)) ||
     (passable?(@x, @y, 4) && passable?(@x - 1, @y, 8))
    move_follower_to_character
    @x -= 1
    @y -= 1
    if @follower && $game_variables[Yuki::Var::FM_Sel_Foll] == 0
      @memorized_move = :move_upper_left
      @memorized_move_arg = nil
      @follower.direction = @direction
    end
    movement_process_end(true)
    increase_steps
  end
end

#move_upper_right

Move the Game_Character upper right



292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00120 Game_Character_move.rb', line 292

def move_upper_right
  unless @direction_fix
    @direction = (@direction == 4 ? 6 : @direction == 2 ? 8 : @direction)
  end
  if (passable?(@x, @y, 8) && passable?(@x, @y - 1, 6)) ||
     (passable?(@x, @y, 6) && passable?(@x + 1, @y, 8))
    move_follower_to_character
    @x += 1
    @y -= 1
    if @follower && $game_variables[Yuki::Var::FM_Sel_Foll] == 0
      @memorized_move = :move_upper_right
      @memorized_move_arg = nil
      @follower.direction = @direction
    end
    movement_process_end(true)
    increase_steps
  end
end

#movement_process_end(no_follower_move = false)

End of the movement process

Parameters:

  • no_follower_move (Boolean) (defaults to: false)

    if the follower should not move

Author:

  • Nuri Yuri



481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00120 Game_Character_move.rb', line 481

def movement_process_end(no_follower_move = false)
  follower_move unless no_follower_move
  particle_push
  if SlideTags.include?(sys_tag = system_tag) ||
     (sys_tag == MachBike && !($game_switches[::Yuki::Sw::EV_Bicycle] && @lastdir4 == 8))
    @sliding = true
    @sliding_parameter = sys_tag
    Scheduler::EventTasks.trigger(:begin_slide, self)
  end
  z_bridge_check(sys_tag)
  detect_swamp
  if jumping?
    Scheduler::EventTasks.trigger(:begin_jump, self)
  elsif moving?
    Scheduler::EventTasks.trigger(:begin_step, self)
  end
end

#moveto(x, y)

Warps the character on the Map to specific coordinates. Adjust the z position of the character.

Parameters:

  • x (Integer)

    new x position of the character

  • y (Integer)

    new y position of the character



122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00100 Game_Character_1.rb', line 122

def moveto(x, y)
  @x = x # % $game_map.width # Removed because of new tilemap
  @y = y # % $game_map.height
  @real_x = @x * 128
  @real_y = @y * 128
  @prelock_direction = 0
  # Warp the follower
  if @follower
    @follower.moveto(x, y)
    @follower.direction = @direction
  end
  # Update the stop count
  self.move_frequency = @move_frequency
  moveto_system_tag_manage
end

#moving?Boolean

is the character moving ?

Returns:

  • (Boolean)


11
12
13
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00140 Game_Character_state.rb', line 11

def moving?
  return (@real_x != @x * 128 || @real_y != @y * 128)
end

#next_event_followerGame_Event?

Rerturn the first follower that is a Game_Event in the queue

Returns:



112
113
114
115
116
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00145 Game_Character_follower.rb', line 112

def next_event_follower
  f = @follower
  f = f.follower while !f.nil? && !f.is_a?(Game_Event)
  return f.is_a?(Game_Event) ? f : nil
end

#original_move_speedInteger

Return the original move speed of the character

Returns:



162
163
164
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00150 Game_Character_Ext.rb', line 162

def original_move_speed
  return @move_speed
end

#particle_push

Push a particle to the particle stack if possible

Author:

  • Nuri Yuri



27
28
29
30
31
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00160 Game_Character_particles.rb', line 27

def particle_push
  return if @particles_disabled
  method_name = PARTICLES_METHODS[system_tag]
  send(method_name) if method_name
end

#particle_push_grass

Push a grass particle



34
35
36
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00160 Game_Character_particles.rb', line 34

def particle_push_grass
  Yuki::Particles.add_particle(self, 1)
end

#particle_push_pond

Push a pond particle



67
68
69
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00160 Game_Character_particles.rb', line 67

def particle_push_pond
  Yuki::Particles.add_particle(self, :pond) if surfing?
end

#particle_push_sand

Push a sand particle



47
48
49
50
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00160 Game_Character_particles.rb', line 47

def particle_push_sand
  particle = SAND_PARTICLE_NAME[@direction]
  Yuki::Particles.add_particle(self, particle) if particle && @can_make_footprint
end

#particle_push_snow

Push a snow particle



61
62
63
64
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00160 Game_Character_particles.rb', line 61

def particle_push_snow
  particle = SNOW_PARTICLE_NAME[@direction]
  Yuki::Particles.add_particle(self, particle) if particle && @can_make_footprint
end

#particle_push_tall_grass

Push a tall grass particle



39
40
41
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00160 Game_Character_particles.rb', line 39

def particle_push_tall_grass
  Yuki::Particles.add_particle(self, 2)
end

#particle_push_wetsand

Push a wet sand particle



53
54
55
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00160 Game_Character_particles.rb', line 53

def particle_push_wetsand
  Yuki::Particles.add_particle(self, :wetsand)
end

#passable?(x, y, d, skip_event = false) ⇒ Boolean

Is the tile in front of the character passable ?

Parameters:

  • x (Integer)

    x position on the Map

  • y (Integer)

    y position on the Map

  • d (Integer)

    direction : 2, 4, 6, 8, 0. 0 = current position

  • skip_event (Boolean) (defaults to: false)

    if the function does not check events

Returns:

  • (Boolean)

    if the front/current tile is passable



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00105 Game_Character_passable.rb', line 13

def passable?(x, y, d, skip_event = false)
  new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
  new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
  z = @z
  game_map = $game_map
  return false unless game_map.valid?(new_x, new_y) || instance_of?(Game_Character)

  # Case where the event can pass through anything
  if @through
    return true unless @sliding
    return true if $game_switches[::Yuki::Sw::ThroughEvent] # Event is sliding here
  end
  sys_tag = game_map.system_tag(new_x, new_y)
  return false unless passable_bridge_check?(x, y, d, new_x, new_y, z, game_map, sys_tag) &&
                      passage_surf_check?(sys_tag)

  return true if skip_event
  return false unless event_passable_check?(new_x, new_y, z, game_map)

  # Game Player check
  if $game_player.contact?(new_x, new_y, z)
    return false unless $game_player.through || @character_name.empty?
  end

  return false unless follower_check?(new_x, new_y, z)

  return true
end

#passable_bridge_check?(x, y, d, new_x, new_y, z, game_map, sys_tag) ⇒ Boolean

Check the bridge related passabilities

Parameters:

  • x (Integer)

    current x position

  • y (Integer)

    current y position

  • d (Integer)

    current direction

  • new_x (Integer)

    new x position

  • new_y (Integer)

    new y position

  • z (Integer)

    current z position

  • game_map (Game_Map)

    map object

  • sys_tag (Integer)

    current system_tag

Returns:

  • (Boolean)

    if the tile is passable according to the bridge rules



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00105 Game_Character_passable.rb', line 52

def passable_bridge_check?(x, y, d, new_x, new_y, z, game_map, sys_tag)
  bridge = @__bridge
  no_game_map = false
  if z > 1
    if bridge
      return false unless game_map.system_tag_here?(new_x, new_y, bridge[0]) ||
                          game_map.system_tag_here?(new_x, new_y, bridge[1]) ||
                          game_map.system_tag_here?(x, y, bridge[1])
    end
    case d
    when 2, 8
      no_game_map = true if sys_tag == BridgeUD
    when 4, 6
      no_game_map = true if sys_tag == BridgeRL
    end
  end
  return true if bridge || no_game_map
  return false unless game_map.passable?(x, y, d, self)
  return false unless game_map.passable?(new_x, new_y, 10 - d)
  return true
end

#passage_surf_check?(sys_tag) ⇒ Boolean

Check the surf related passabilities

Parameters:

  • sys_tag (Integer)

    current system_tag

Returns:

  • (Boolean)

    if the tile is passable according to the surf rules



77
78
79
80
81
82
83
84
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00105 Game_Character_passable.rb', line 77

def passage_surf_check?(sys_tag)
  return false if !@surfing && SurfTag.include?(sys_tag)
  if @surfing
    return false unless SurfLTag.include?(sys_tag)
    return false if sys_tag == WaterFall
  end
  return true
end

#process_slope_y_modifier(y_modifier)



403
404
405
406
407
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00110 Game_Character_2.rb', line 403

def process_slope_y_modifier(y_modifier)
  @y += y_modifier
  @real_y = @y * 128
  update_slope_offset_y
end

#reset_follower



118
119
120
121
122
123
124
125
126
127
128
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00145 Game_Character_follower.rb', line 118

def reset_follower
  return unless (current_follower = @follower)

  while (next_follower = current_follower.follower)
    current_follower.set_follower(nil)
    current_follower = next_follower
    break unless next_follower.is_a?(Game_Event)
  end
  # @follower = nil
  set_follower(nil)
end

#reset_follower_move

Remove the memorized moves of the follower

Author:

  • Nuri Yuri



4
5
6
7
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00145 Game_Character_follower.rb', line 4

def reset_follower_move
  @memorized_move_arg = @memorized_move = nil if @memorized_move
  @follower&.reset_follower_move
end

#screen_xInteger

Return the x position of the sprite on the screen

Returns:



190
191
192
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00100 Game_Character_1.rb', line 190

def screen_x
  return (@real_x - $game_map.display_x + 3) / 4 + 16
end

#screen_yInteger

Return the y position of the sprite on the screen

Returns:



196
197
198
199
200
201
202
203
204
205
206
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00100 Game_Character_1.rb', line 196

def screen_y
  y = (@real_y - $game_map.display_y + 3) / 4 + 32
  y += @offset_screen_y if @offset_screen_y
  y += @slope_offset_y if @slope_offset_y
  if @jump_count >= @jump_peak
    n = @jump_count - @jump_peak
  else
    n = @jump_peak - @jump_count
  end
  return y - (@jump_peak * @jump_peak - n * n) / 2
end

#screen_z(_height = 0) ⇒ Integer

Return the z superiority of the sprite of the character

Parameters:

  • _height (Integer) (defaults to: 0)

    height of a frame of the character (ignored)

Returns:



223
224
225
226
227
228
229
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00100 Game_Character_1.rb', line 223

def screen_z(_height = 0)
  return 999 if @always_on_top
  z = (@real_y - $game_map.display_y + 3) / 4 + 32 * @z
  return z + $game_map.priorities[@tile_id].to_i * 32 if @tile_id > 0
  return z + 31
  # return z + ((height > 64) ? 31 : 0)
end

#set_appearance(character_name, character_hue = 0)

Define the new appearance of the character

Parameters:

  • character_name (String)

    name of the character graphic to display

  • character_hue (Integer) (defaults to: 0)

    must be 0



31
32
33
34
35
36
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00130 Game_Character_appearance.rb', line 31

def set_appearance(character_name, character_hue = 0)
  @character_name = character_name
  @character_hue = character_hue
  @shadow_disabled = character_name.empty? if @event && SHADOW_DISABLED_UPDATE_VALUES.include?(@shadow_disabled)
  change_shadow_disabled_state(true) if @surfing && !is_a?(Game_Player)
end

#set_follower(follower)

Define the follower of the event

Parameters:

Author:

  • Nuri Yuri



96
97
98
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00145 Game_Character_follower.rb', line 96

def set_follower(follower)
  @follower = follower
end

#set_surfing

Set the Game_Character in the “surfing” mode (not able to walk on ground but able to walk on water)

Author:

  • Nuri Yuri



28
29
30
31
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00140 Game_Character_state.rb', line 28

def set_surfing
  change_shadow_disabled_state(true)
  @surfing = true
end

#shadow_screen_xInteger

Return the x position of the shadow of the character on the screen

Returns:



210
211
212
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00100 Game_Character_1.rb', line 210

def shadow_screen_x
  return (@real_x - $game_map.display_x + 3) / 4 + 16
end

#shadow_screen_yInteger

Return the y position of the shadow of the character on the screen

Returns:



216
217
218
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00100 Game_Character_1.rb', line 216

def shadow_screen_y
  return (@real_y - $game_map.display_y + 3) / 4 + 34 + (@offset_shadow_screen_y || 0) + (@slope_offset_y || 0) # +3 => +5
end

#sliding?Boolean

Check if the Game_Character slides

Returns:

  • (Boolean)

Author:

  • Nuri Yuri



43
44
45
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00140 Game_Character_state.rb', line 43

def sliding?
  return @sliding
end

#slope_check_left(write = true)

Update the slope values when moving to left



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00120 Game_Character_move.rb', line 66

def slope_check_left(write = true)
  # No slope move check if no slope involved
  front_sys_tag = front_system_tag
  return 0 unless (sys_tag = system_tag) == SlopesL || sys_tag == SlopesR ||
                front_sys_tag == SlopesL || front_sys_tag == SlopesR

  # Begining of Left up slope
  if sys_tag != SlopesL && front_sys_tag == SlopesL
    if write
      @slope_length = 0
      nx = @x - 1
      ny = @y
      while $game_map.system_tag(nx, ny) == SlopesL
        nx -= 1
        @slope_length += 1
      end
      # Prepare the data
      @slope_origin_x = @real_x
      @slope_length *= -128 # display_length conversion
    end
  
  # End of the left up slope
  elsif sys_tag == SlopesL && front_sys_tag != SlopesL
    @slope_offset_y = @slope_origin_x = @slope_length = nil if passable?(@x, @y - 1, 4) && write
    return -1

  # Start to go down the right slope
  elsif sys_tag != SlopesR && front_sys_tag == SlopesR
    return 1 unless passable?(@x, @y + 1, 4)

    if write
      @slope_length = 0
      nx = @x - 1
      ny = @y + 1
      while $game_map.system_tag(nx, ny) == SlopesR
        nx -= 1
        @slope_length += 1
      end
      # Prepare data
      @slope_origin_x = (nx + 1) * 128 # Begin at next tile
      @slope_length *= -128
    end
    return 1

  # End of the slope left down
  elsif sys_tag == SlopesR && front_sys_tag != SlopesR
    @slope_offset_y = @slope_origin_x = @slope_length = nil if write
  end
  return 0
end

#slope_check_right(write = true) ⇒ Integer

Update the slope values when moving to right, and return y slope modifier

Returns:



161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00120 Game_Character_move.rb', line 161

def slope_check_right(write = true)
  # No slope move check if no slope involved
  front_sys_tag = front_system_tag
  return 0 unless (sys_tag = system_tag) == SlopesL || sys_tag == SlopesR ||
                front_sys_tag == SlopesL || front_sys_tag == SlopesR

  # Begining of Right up slope
  if sys_tag != SlopesR && front_sys_tag == SlopesR
    if write
      @slope_length = 0
      nx = @x + 1
      ny = @y
      while $game_map.system_tag(nx, ny) == SlopesR
        nx += 1
        @slope_length += 1
      end
      # Prepare the data
      @slope_origin_x = @real_x
      @slope_length *= -128 # display_length conversion
    end
  
  # End of the right up slope
  elsif sys_tag == SlopesR && front_sys_tag != SlopesR
    @slope_offset_y = @slope_origin_x = @slope_length = nil if passable?(@x, @y - 1, 6) && write
    return -1

  # Start to go down the left slope
  elsif sys_tag != SlopesL && front_sys_tag == SlopesL
    return 1 unless passable?(@x, @y + 1, 6)

    if write
      @slope_length = 0
      nx = @x + 1
      ny = @y + 1
      while $game_map.system_tag(nx, ny) == SlopesL
        nx += 1
        @slope_length += 1
      end
      # Prepare data
      @slope_origin_x = (nx - 1) * 128 # Begin at next tile
      @slope_length *= -128
    end
    return 1

  # End of the slope left down
  elsif sys_tag == SlopesL && front_sys_tag != SlopesL
    @slope_offset_y = @slope_origin_x = @slope_length = nil if write
  end
  return 0
end

#stair_move_leftBoolean

Try to move the Game_Character on a stair to the left

Returns:

  • (Boolean)

    if the player cannot perform a regular movement (success or blocked)



51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00120 Game_Character_move.rb', line 51

def stair_move_left
  # unless @through
  if front_system_tag == StairsL
    return true unless $game_map.system_tag(@x - 1, @y - 1) == StairsL
    move_upper_left
    return true
  elsif system_tag == StairsR
    move_lower_left
    return true
  end
  # end
  return false
end

#stair_move_rightBoolean

Try to move the Game_Character on a stair to the right

Returns:

  • (Boolean)

    if the player cannot perform a regular movement (success or blocked)



145
146
147
148
149
150
151
152
153
154
155
156
157
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00120 Game_Character_move.rb', line 145

def stair_move_right
  # unless @through
  if system_tag == StairsL
    move_lower_right
    return true
  elsif front_system_tag == StairsR
    return true unless $game_map.system_tag(@x + 1, @y - 1) == StairsR
    move_upper_right
    return true
  end
  # end
  return false
end

#stop_path

Stop following the path if there is one and clear the agent



32
33
34
35
36
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00170 Game_Character_pathfinding.rb', line 32

def stop_path
  # force_move_route(EMPTY_MOVE_ROUTE)
  clear_path
  Pathfinding.remove_request(self)
end

#straighten

Adjust the character position



94
95
96
97
98
99
100
101
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00100 Game_Character_1.rb', line 94

def straighten
  if @walk_anime or @step_anime
    @pattern = 0
    @pattern_state = false
  end
  @anime_count = 0
  @prelock_direction = 0
end

#surfing?Boolean

Check if the Game_Character is in the “surfing” mode

Returns:

  • (Boolean)

Author:

  • Nuri Yuri



36
37
38
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00140 Game_Character_state.rb', line 36

def surfing?
  return @surfing
end

#system_tagInteger

Return the SystemTag where the Game_Character stands

Returns:

  • (Integer)

    ID of the SystemTag

Author:

  • Nuri Yuri



85
86
87
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00140 Game_Character_state.rb', line 85

def system_tag
  return $game_map.system_tag(@x,@y)
end

#system_tag_db_symbolSymbol

Return the db_symbol of the system tag

Returns:

  • (Symbol)


91
92
93
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00140 Game_Character_state.rb', line 91

def system_tag_db_symbol
  GameData::SystemTags.system_tag_db_symbol(system_tag)
end

#terrain_tagInteger?

current terrain tag on which the character steps

Returns:



78
79
80
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00140 Game_Character_state.rb', line 78

def terrain_tag
  return $game_map.terrain_tag(@x, @y)
end

#turn_180

Turn 180°



63
64
65
66
67
68
69
70
71
72
73
74
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00125 Game_Character_turn.rb', line 63

def turn_180
  case @direction
  when 2
    turn_up
  when 4
    turn_right
  when 6
    turn_left
  when 8
    turn_down
  end
end

#turn_away_from_player

Turn away from the player



118
119
120
121
122
123
124
125
126
127
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00125 Game_Character_turn.rb', line 118

def turn_away_from_player
  sx = @x - $game_player.x
  sy = @y - $game_player.y
  return if sx == 0 && sy == 0
  if sx.abs > sy.abs
    sx > 0 ? turn_right : turn_left
  else
    sy > 0 ? turn_down : turn_up
  end
end

#turn_down

Turn down unless direction fix



3
4
5
6
7
8
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00125 Game_Character_turn.rb', line 3

def turn_down
  unless @direction_fix
    @direction = 2
    @stop_count = 0
  end
end

#turn_left

Turn left unless direction fix



11
12
13
14
15
16
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00125 Game_Character_turn.rb', line 11

def turn_left
  unless @direction_fix
    @direction = 4
    @stop_count = 0
  end
end

#turn_left_90

Turn 90° to the left of the Game_Character



49
50
51
52
53
54
55
56
57
58
59
60
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00125 Game_Character_turn.rb', line 49

def turn_left_90
  case @direction
  when 2
    turn_right
  when 4
    turn_down
  when 6
    turn_up
  when 8
    turn_left
  end
end

#turn_random

Turn in a random direction



86
87
88
89
90
91
92
93
94
95
96
97
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00125 Game_Character_turn.rb', line 86

def turn_random
  case rand(4)
  when 0
    turn_up
  when 1
    turn_right
  when 2
    turn_left
  when 3
    turn_down
  end
end

#turn_right

Turn right unless direction fix



19
20
21
22
23
24
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00125 Game_Character_turn.rb', line 19

def turn_right
  unless @direction_fix
    @direction = 6
    @stop_count = 0
  end
end

#turn_right_90

Turn 90° to the right of the Game_Character



35
36
37
38
39
40
41
42
43
44
45
46
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00125 Game_Character_turn.rb', line 35

def turn_right_90
  case @direction
  when 2
    turn_left
  when 4
    turn_up
  when 6
    turn_down
  when 8
    turn_right
  end
end

#turn_right_or_left_90

Turn random right or left 90°



77
78
79
80
81
82
83
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00125 Game_Character_turn.rb', line 77

def turn_right_or_left_90
  if rand(2) == 0
    turn_right_90
  else
    turn_left_90
  end
end

#turn_toward_character(character)

Turn toward another character

Parameters:



106
107
108
109
110
111
112
113
114
115
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00125 Game_Character_turn.rb', line 106

def turn_toward_character(character)
  sx = @x - character.x
  sy = @y - character.y
  return if sx == 0 && sy == 0
  if sx.abs > sy.abs
    sx > 0 ? turn_left : turn_right
  else
    sy > 0 ? turn_up : turn_down
  end
end

#turn_toward_player

Turn toward the player



100
101
102
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00125 Game_Character_turn.rb', line 100

def turn_toward_player
  turn_toward_character($game_player)
end

#turn_up

Turn up unless direction fix



27
28
29
30
31
32
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00125 Game_Character_turn.rb', line 27

def turn_up
  unless @direction_fix
    @direction = 8
    @stop_count = 0
  end
end

#unlock

Release the character, can perform its natural movements



66
67
68
69
70
71
72
73
74
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00140 Game_Character_state.rb', line 66

def unlock
  return unless @locked
  # Store the state
  @locked = false
  # We don't change the direction if it's a fix direction
  return if @direction_fix
  # We change the direction if the prelock direction is not zero
  @direction = @prelock_direction unless @prelock_direction == 0
end

#update

Update the Game_Character (manages movements and some animations)



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00110 Game_Character_2.rb', line 3

def update
  if jumping?
    update_jump
  elsif moving?
    update_move
  elsif @sliding
    update_sliding
  else
    update_stop
  end

  update_pattern

  return if @sliding
  return @wait_count -= 1 if @wait_count > 0 # or follower_sliding?
  return move_type_path if @path # Needs to have priority over move_type_custom
  return move_type_custom if @move_route_forcing
  return if @starting || lock?
  return unless @stop_count > @max_stop_count

  # Automatic movement
  case @move_type
  when 1
    move_type_random
  when 2
    move_type_toward_player
  when 3
    move_type_custom
  end
end

#z_bridge_check(sys_tag)

Check bridge information and adjust the z position of the Game_Character

Parameters:

  • sys_tag (Integer)

    the SystemTag

Author:

  • Nuri Yuri



33
34
35
36
37
38
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00650 RMXP/00155 Game_Character_bridge.rb', line 33

def z_bridge_check(sys_tag)
  @z = ZTag.index(sys_tag) if ZTag.include?(sys_tag)
  @z = 1 if @z < 1
  @z = 0 if @z == 1 and BRIDGE_TILES.include?(sys_tag)
  @__bridge = nil if @__bridge and @__bridge.last == sys_tag
end