Class: Game_Vehicle

Inherits:
Game_Character show all
Defined in:
Game_Vehicle.rb

Overview

** Game_Vehicle


This class handles vehicles. It's used within the Game_Map class. If there

are no vehicles on the current map, the coordinates are set to (-1,-1).

Constant Summary

Constant Summary

Constants inherited from Game_Character

Game_Character::ROUTE_CHANGE_BLENDING, Game_Character::ROUTE_CHANGE_FREQ, Game_Character::ROUTE_CHANGE_GRAPHIC, Game_Character::ROUTE_CHANGE_OPACITY, Game_Character::ROUTE_CHANGE_SPEED, Game_Character::ROUTE_DIR_FIX_OFF, Game_Character::ROUTE_DIR_FIX_ON, Game_Character::ROUTE_END, Game_Character::ROUTE_JUMP, Game_Character::ROUTE_MOVE_AWAY, Game_Character::ROUTE_MOVE_BACKWARD, Game_Character::ROUTE_MOVE_DOWN, Game_Character::ROUTE_MOVE_FORWARD, Game_Character::ROUTE_MOVE_LEFT, Game_Character::ROUTE_MOVE_LOWER_L, Game_Character::ROUTE_MOVE_LOWER_R, Game_Character::ROUTE_MOVE_RANDOM, Game_Character::ROUTE_MOVE_RIGHT, Game_Character::ROUTE_MOVE_TOWARD, Game_Character::ROUTE_MOVE_UP, Game_Character::ROUTE_MOVE_UPPER_L, Game_Character::ROUTE_MOVE_UPPER_R, Game_Character::ROUTE_PLAY_SE, Game_Character::ROUTE_SCRIPT, Game_Character::ROUTE_STEP_ANIME_OFF, Game_Character::ROUTE_STEP_ANIME_ON, Game_Character::ROUTE_SWITCH_OFF, Game_Character::ROUTE_SWITCH_ON, Game_Character::ROUTE_THROUGH_OFF, Game_Character::ROUTE_THROUGH_ON, Game_Character::ROUTE_TRANSPARENT_OFF, Game_Character::ROUTE_TRANSPARENT_ON, Game_Character::ROUTE_TURN_180D, Game_Character::ROUTE_TURN_90D_L, Game_Character::ROUTE_TURN_90D_R, Game_Character::ROUTE_TURN_90D_R_L, Game_Character::ROUTE_TURN_AWAY, Game_Character::ROUTE_TURN_DOWN, Game_Character::ROUTE_TURN_LEFT, Game_Character::ROUTE_TURN_RANDOM, Game_Character::ROUTE_TURN_RIGHT, Game_Character::ROUTE_TURN_TOWARD, Game_Character::ROUTE_TURN_UP, Game_Character::ROUTE_WAIT, Game_Character::ROUTE_WALK_ANIME_OFF, Game_Character::ROUTE_WALK_ANIME_ON

Instance Attribute Summary (collapse)

Attributes inherited from Game_Character

#move_route_forcing

Attributes inherited from Game_CharacterBase

#animation_id, #balloon_id, #blend_type, #bush_depth, #character_index, #character_name, #direction, #direction_fix, #id, #move_frequency, #move_speed, #opacity, #pattern, #priority_type, #real_x, #real_y, #step_anime, #through, #tile_id, #walk_anime, #x, #y

Instance Method Summary (collapse)

Methods inherited from Game_Character

#advance_move_route_index, #distance_x_from, #distance_y_from, #force_move_route, #init_private_members, #init_public_members, #jump, #memorize_move_route, #move_away_from_character, #move_away_from_player, #move_backward, #move_forward, #move_random, #move_toward_character, #move_toward_player, #process_move_command, #process_route_end, #restore_move_route, #swap, #turn_180, #turn_away_from_character, #turn_away_from_player, #turn_left_90, #turn_random, #turn_right_90, #turn_right_or_left_90, #turn_toward_character, #turn_toward_player, #update_routine_move, #update_stop

Methods inherited from Game_CharacterBase

#bush?, #check_event_trigger_touch, #check_event_trigger_touch_front, #collide_with_characters?, #collide_with_events?, #collide_with_vehicles?, #dash?, #debug_through?, #diagonal_passable?, #distance_per_frame, #increase_steps, #init_private_members, #init_public_members, #jump_height, #jumping?, #ladder?, #map_passable?, #move_diagonal, #move_straight, #moveto, #moving?, #normal_priority?, #object_character?, #passable?, #pos_nt?, #real_move_speed, #region_id, #reverse_dir, #screen_x, #screen_z, #set_direction, #set_graphic, #shift_y, #stopping?, #straighten, #terrain_tag, #tile?, #update_animation, #update_anime_count, #update_anime_pattern, #update_bush_depth, #update_jump, #update_move, #update_stop

Constructor Details

- (Game_Vehicle) initialize(type)


  • Object Initialization

    type:  vehicle type (:boat, :ship, :airship)



18
19
20
21
22
23
24
25
26
27
28
29
# File 'Game_Vehicle.rb', line 18

def initialize(type)
  super()
  @type = type
  @altitude = 0
  @driving = false
  @direction = 4
  @walk_anime = false
  @step_anime = false
  @walking_bgm = nil
  init_move_speed
  load_system_settings
end

Instance Attribute Details

- (Object) altitude (readonly)


  • Public Instance Variables




12
13
14
# File 'Game_Vehicle.rb', line 12

def altitude
  @altitude
end

- (Object) driving (readonly)

driving flag



13
14
15
# File 'Game_Vehicle.rb', line 13

def driving
  @driving
end

Instance Method Details

- (Object) get_off


  • Get Off Vehicle




108
109
110
111
112
113
114
# File 'Game_Vehicle.rb', line 108

def get_off
  @driving = false
  @walk_anime = false
  @step_anime = false
  @direction = 4
  @walking_bgm.play
end

- (Object) get_on


  • Board Vehicle




98
99
100
101
102
103
104
# File 'Game_Vehicle.rb', line 98

def get_on
  @driving = true
  @walk_anime = true
  @step_anime = true
  @walking_bgm = RPG::BGM.last
  system_vehicle.bgm.play
end

- (Object) init_move_speed


  • Initialize Move Speed




33
34
35
36
37
# File 'Game_Vehicle.rb', line 33

def init_move_speed
  @move_speed = 4 if @type == :boat
  @move_speed = 5 if @type == :ship
  @move_speed = 6 if @type == :airship
end

- (Boolean) land_ok?(x, y, d)


  • Determine if Docking/Landing Is Possible

    d:  Direction (2,4,6,8)

Returns:

  • (Boolean)


180
181
182
183
184
185
186
187
188
189
190
191
192
# File 'Game_Vehicle.rb', line 180

def land_ok?(x, y, d)
  if @type == :airship
    return false unless $game_map.airship_land_ok?(x, y)
    return false unless $game_map.events_xy(x, y).empty?
  else
    x2 = $game_map.round_x_with_direction(x, d)
    y2 = $game_map.round_y_with_direction(y, d)
    return false unless $game_map.valid?(x2, y2)
    return false unless $game_map.passable?(x2, y2, reverse_dir(d))
    return false if collide_with_characters?(x2, y2)
  end
  return true
end

- (Object) load_system_settings


  • Load System Settings




50
51
52
53
54
55
56
# File 'Game_Vehicle.rb', line 50

def load_system_settings
  @map_id           = system_vehicle.start_map_id
  @x                = system_vehicle.start_x
  @y                = system_vehicle.start_y
  @character_name   = system_vehicle.character_name
  @character_index  = system_vehicle.character_index
end

- (Object) max_altitude


  • Get Maximum Altitude of Airship




167
168
169
# File 'Game_Vehicle.rb', line 167

def max_altitude
  return 32
end

- (Boolean) movable?


  • Determine if Movement is Possible


Returns:

  • (Boolean)


141
142
143
# File 'Game_Vehicle.rb', line 141

def movable?
  !moving? && !(@type == :airship && @altitude < max_altitude)
end

- (Boolean) pos?(x, y)


  • Determine Coordinate Match


Returns:

  • (Boolean)


86
87
88
# File 'Game_Vehicle.rb', line 86

def pos?(x, y)
  @map_id == $game_map.map_id && super(x, y)
end

- (Object) refresh


  • Refresh




60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'Game_Vehicle.rb', line 60

def refresh
  if @driving
    @map_id = $game_map.map_id
    sync_with_player
  elsif @map_id == $game_map.map_id
    moveto(@x, @y)
  end
  if @type == :airship
    @priority_type = @driving ? 2 : 0
  else
    @priority_type = 1
  end
  @walk_anime = @step_anime = @driving
end

- (Object) screen_y


  • Get Screen Y-Coordinates




135
136
137
# File 'Game_Vehicle.rb', line 135

def screen_y
  super - altitude
end

- (Object) set_location(map_id, x, y)


  • Change Position




77
78
79
80
81
82
# File 'Game_Vehicle.rb', line 77

def set_location(map_id, x, y)
  @map_id = map_id
  @x = x
  @y = y
  refresh
end

- (Object) speed


  • Get Move Speed




129
130
131
# File 'Game_Vehicle.rb', line 129

def speed
  @move_speed
end

- (Object) sync_with_player


  • Synchronize With Player




118
119
120
121
122
123
124
125
# File 'Game_Vehicle.rb', line 118

def sync_with_player
  @x = $game_player.x
  @y = $game_player.y
  @real_x = $game_player.real_x
  @real_y = $game_player.real_y
  @direction = $game_player.direction
  update_bush_depth
end

- (Object) system_vehicle


  • Get System Settings




41
42
43
44
45
46
# File 'Game_Vehicle.rb', line 41

def system_vehicle
  return $data_system.boat    if @type == :boat
  return $data_system.ship    if @type == :ship
  return $data_system.airship if @type == :airship
  return nil
end

- (Boolean) takeoff_ok?


  • Determine if Takeoff Is Possible


Returns:

  • (Boolean)


173
174
175
# File 'Game_Vehicle.rb', line 173

def takeoff_ok?
  $game_player.followers.gather?
end

- (Object) transparent


  • Determine Transparency




92
93
94
# File 'Game_Vehicle.rb', line 92

def transparent
  @map_id != $game_map.map_id || super
end

- (Object) update


  • Frame Update




147
148
149
150
# File 'Game_Vehicle.rb', line 147

def update
  super
  update_airship_altitude if @type == :airship
end

- (Object) update_airship_altitude


  • Update Airship Altitude




154
155
156
157
158
159
160
161
162
163
# File 'Game_Vehicle.rb', line 154

def update_airship_altitude
  if @driving
    @altitude += 1 if @altitude < max_altitude && takeoff_ok?
  elsif @altitude > 0
    @altitude -= 1
    @priority_type = 0 if @altitude == 0
  end
  @step_anime = (@altitude == max_altitude)
  @priority_type = 2 if @altitude > 0
end