#============================================================================== # ** Hear_Steps #------------------------------------------------------------------------------ # by arevulopapo # 9.11.2006 #============================================================================== class Game_Character #-------------------------------------------------------------------------- attr_reader :id # ID attr_reader :x # map x-coordinate (logical) attr_reader :y # map y-coordinate (logical) attr_reader :real_x # map x-coordinate (real * 128) attr_reader :real_y # map y-coordinate (real * 128) attr_reader :tile_id # tile ID (invalid if 0) attr_reader :character_name # character file name attr_reader :character_hue # character hue attr_reader :opacity # opacity level attr_reader :blend_type # blending method attr_reader :direction # direction attr_reader :pattern # pattern attr_reader :move_route_forcing # forced move route flag attr_reader :through # through attr_accessor :animation_id # animation ID attr_accessor :transparent # transparent flag attr_accessor :hear_steps attr_accessor :step_sound #-------------------------------------------------------------------------- def initialize @hear_steps = false @step_sound = "Audio/SE/paso" @id = 0 @x = 0 @y = 0 @real_x = 0 @real_y = 0 @tile_id = 0 @character_name = "" @character_hue = 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 @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 @locked = false @prelock_direction = 0 end def update if self.moving? and self.hear_steps == true and (Graphics.frame_count + 2 * self.id) % (18 - @move_speed) == 0 if self.screen_x > 0 and self.screen_x < 640 and self.screen_y > 0 and self.screen_y < 480 volume = 100 - 5 * Math.sqrt((self.x - $game_player.x)*(self.x - $game_player.x) + (self.y - $game_player.y)*(self.y - $game_player.y)) Audio.se_play(@step_sound, volume, 100) end end # Branch with jumping, moving, and stopping if jumping? update_jump elsif moving? update_move else update_stop end # If animation count exceeds maximum value # * Maximum value is move speed * 1 taken from basic value 18 if @anime_count > 18 - @move_speed * 2 # If stop animation is OFF when stopping if not @step_anime and @stop_count > 0 # Return to original pattern @pattern = @original_pattern # If stop animation is ON when moving else # Update pattern @pattern = (@pattern + 1) % 4 end # Clear animation count @anime_count = 0 end # If waiting if @wait_count > 0 # Reduce wait count @wait_count -= 1 return end # If move route is forced if @move_route_forcing # Custom move move_type_custom return end # When waiting for event execution or locked if @starting or lock? # Not moving by self return end # If stop count exceeds a certain value (computed from move frequency) if @stop_count > (40 - @move_frequency * 2) * (6 - @move_frequency) # Branch by move type case @move_type when 1 # Random move_type_random when 2 # Approach move_type_toward_player when 3 # Custom move_type_custom end end end end