#==============================================================================
# ** Simple Footstep script
# Version 2.5
# Credits:
# Creator: Miget man12, Help improving from: Modern Algebra, Yanfly, Twilight1300
# Formula for getting Tile ID by DerVVulfman
#-----------------------------------------------------------------------------
# I made this just so I could have a not-laggy, easy to use script. It doesn't
# really have any special features, but it works without very much lag. It is
# also being used in "The Legend of Zelda: Realm of the Gods", a Zelda
# fan-game(Hence the SE's from OoT :D) that I'm working on with Twilight1300.
#-----------------------------------------------------------------------------
# Instructions:
# To have an event have footstep sounds, just put Comment:
# [footstep]
# To have an event or the player use footsteps:
# For The Player:
# $game_player.footstep_se = true/false
# For an Event:
# $game_map.events[(Event ID)].footstep_se = true/false
# The Event ID is the ID of the event on the map you are on
# If you want an event to have a special footstep sound effect, put a comment
# like so:
# [footstepse:SE Name]
# e.g.
# [footstepse:OOT_LikeLike_Move]
# ***Event settings are reset when you tranfer*** (this doesn't apply to comment-
# related settings)
#==============================================================================
$imported = {} if $imported == nil
$imported["Mm12Footsteps"] = true
module Mm12
START_WITH_SE = true # Start out with player's footsteps enabled?
BRIDGE_TILES = [272,273,274,275,276,277,278,279]
CARPET_TILES = [30,38,62,218]
DIRT_TILES = []
GRASS_TILES = [16,19,150,204,214]
ICE_TILES = [151,215]
LAVA_TILES = [14,15]
SAND_TILES = [32,35,238,244,245,252,253]
STONE_TILES = [24,27,129,130,131,132,133,134,141,142,151,181,205,215,229,193,194,
195,196,197,200,201,202,205,208,209,210,211,212,213,219,220,221,
222,224,225,226,229]
TGRASS_TILES = [20,180,228]
WOOD_TILES = [160,161,192,216,217]
SNOW_TILES = [40,43,179,203,227,239,246,247,254,255]
LADDER_TILES = [516,524,540]
BRIDGE_SE = ["OOT_Steps_Bridge1", "OOT_Steps_Bridge2"]
CARPET_SE = ["OOT_Steps_Carpet1", "OOT_Steps_Carpet2", "OOT_Steps_Carpet3",
"OOT_Steps_Carpet4", "OOT_Steps_Carpet5"]
DIRT_SE = ["OOT_Steps_Dirt1", "OOT_Steps_Dirt2", "OOT_Steps_Dirt3",
"OOT_Steps_Dirt4", "OOT_Steps_Dirt5", "OOT_Steps_Dirt6"]
GRASS_SE = ["OOT_Steps_Grass1", "OOT_Steps_Grass2", "OOT_Steps_Grass3",
"OOT_Steps_Grass4", "OOT_Steps_Grass5", "OOT_Steps_Grass6",
"OOT_Steps_Grass7"]
ICE_SE = ["OOT_Steps_Ice1", "OOT_Steps_Ice2"]
LAVA_SE = ["OOT_Steps_Lava1", "OOT_Steps_Lava2", "OOT_Steps_Lava3"]
SAND_SE = ["OOT_Steps_Sand1", "OOT_Steps_Sand2", "OOT_Steps_Sand3",
"OOT_Steps_Sand4", "OOT_Steps_Sand5"]
STONE_SE = ["OOT_Steps_Stone1", "OOT_Steps_Stone2", "OOT_Steps_Stone3",
"OOT_Steps_Stone4", "OOT_Steps_Stone5", "OOT_Steps_Stone6"]
TGRASS_SE = ["OOT_Steps_TallGrass1", "OOT_Steps_TallGrass2",
"OOT_Steps_TallGrass3", "OOT_Steps_TallGrass4"]
WOOD_SE = ["OOT_Steps_Wood1", "OOT_Steps_Wood2", "OOT_Steps_Wood3",
"OOT_Steps_Wood4", "OOT_Steps_Wood5"]
SNOW_SE = ["MM_Steps_Snow1", "MM_Steps_Snow2", "MM_Steps_Snow3"]
LADDER_SE = ["TP_LadderStep1", "TP_LadderStep2", "TP_LadderStep3"]
end
#==============================================================================
# ** Game_Character
#------------------------------------------------------------------------------
# This class deals with characters. It's used as a superclass of the
# Game_Player and Game_Event classes.
#==============================================================================
class Game_Character
attr_accessor :footstep_se
end
class Game_Player
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias ftstp_gp_initialize initialize
alias ftstp_gp_increase_steps increase_steps
def initialize
@se_ok = true
@footstep_se = true
ftstp_gp_initialize
end
def increase_steps
ftstp_gp_increase_steps
footstep_se
end
#---------------------------------------------------------------------------
# * Footstep SE
#---------------------------------------------------------------------------
def footstep_se
if @se_ok == true
@num = 0
play_se
@se_ok = false
elsif @se_ok == false
if $game_player.dash?
@se_ok = true
else
@num = 1
play_se
@se_ok = true
end
return
end
end
def play_se
unless $game_map.ship.driving or $game_map.boat.driving or $game_map.airship.driving or !@footstep_se
if Mm12::LADDER_TILES.include?($game_map.tile_index($game_map.data[@x, @y, 2]))
RPG::SE.new(Mm12::LADDER_SE[rand(Mm12::LADDER_SE.size-1)], rand(30) + 80, rand(30) + 80).play
elsif Mm12::BRIDGE_TILES.include?($game_map.tile_index($game_map.data[@x, @y, 0])) or Mm12::BRIDGE_TILES.include?($game_map.tile_index($game_map.data[@x, @y, 2]))
RPG::SE.new(Mm12::BRIDGE_SE[rand(Mm12::BRIDGE_SE.size-1)], rand(30) + 80, rand(30) + 80).play
elsif Mm12::CARPET_TILES.include?($game_map.tile_index($game_map.data[@x, @y, 0]))
RPG::SE.new(Mm12::CARPET_SE[rand(Mm12::CARPET_SE.size-1)], rand(30) + 80, rand(30) + 80).play
elsif Mm12::DIRT_TILES.include?($game_map.tile_index($game_map.data[@x, @y, 0]))
RPG::SE.new(Mm12::DIRT_SE[rand(Mm12::DIRT_SE.size-1)], rand(30) + 80, rand(30) + 80).play
elsif Mm12::GRASS_TILES.include?($game_map.tile_index($game_map.data[@x, @y, 0]))
RPG::SE.new(Mm12::GRASS_SE[rand(Mm12::GRASS_SE.size-1)], rand(30) + 80, rand(30) + 80).play
elsif Mm12::ICE_TILES.include?($game_map.tile_index($game_map.data[@x, @y, 0]))
RPG::SE.new(Mm12::ICE_SE[rand(Mm12::ICE_SE.size-1)], rand(30) + 80, rand(30) + 80).play
elsif Mm12::LAVA_TILES.include?($game_map.tile_index($game_map.data[@x, @y, 0]))
RPG::SE.new(Mm12::LAVA_SE[rand(Mm12::LAVA_SE.size-1)], rand(30) + 80, rand(30) + 80).play
elsif Mm12::SAND_TILES.include?($game_map.tile_index($game_map.data[@x, @y, 0]))
RPG::SE.new(Mm12::SAND_SE[rand(Mm12::SAND_SE.size-1)], rand(30) + 80, rand(30) + 80).play
elsif Mm12::STONE_TILES.include?($game_map.tile_index($game_map.data[@x, @y, 0]))
RPG::SE.new(Mm12::STONE_SE[rand(Mm12::STONE_SE.size-1)], rand(30) + 80, rand(30) + 80).play
elsif Mm12::TGRASS_TILES.include?($game_map.tile_index($game_map.data[@x, @y, 1])) or Mm12::TGRASS_TILES.include?($game_map.tile_index($game_map.data[@x, @y, 0]))
RPG::SE.new(Mm12::TGRASS_SE[rand(Mm12::TGRASS_SE.size-1)], rand(30) + 80, rand(30) + 80).play
elsif Mm12::WOOD_TILES.include?($game_map.tile_index($game_map.data[@x, @y, 0]))
RPG::SE.new(Mm12::WOOD_SE[rand(Mm12::WOOD_SE.size-1)], rand(30) + 80, rand(30) + 80).play
elsif Mm12::SNOW_TILES.include?($game_map.tile_index($game_map.data[@x, @y, 0]))
RPG::SE.new(Mm12::SNOW_SE[rand(Mm12::SNOW_SE.size-1)], rand(30) + 80, rand(30) + 80).play
end
end
if $imported["Mm12Swimming"]
#p "so this works..."
if $game_map.ship.driving or $game_map.boat.driving
#p "Odd..."
RPG::SE.new(Mm12::SWIM_SE[@num], 100, 100).play
end
end
end
end
#==============================================================================
# ** Game_Event
#------------------------------------------------------------------------------
# This class deals with events. It handles functions including event page
# switching via condition determinants, and running parallel process events.
# It's used within the Game_Map class.
#==============================================================================
class Game_Event < Game_Character
alias ftstp_setup setup
alias ftstp_ge_increase_steps increase_steps
#--------------------------------------------------------------------------
# * Event page setup
#--------------------------------------------------------------------------
def setup(new_page)
ftstp_setup(new_page)
if !@list.nil?
for i in 0...@list.size - 1
next if @list[i].code != 108
if @list[i].parameters[0].include?("[footstepse:")
cmd = @list[i].parameters[0].split(':')
@custom_se_name=cmd.last if cmd.size>1 && /footstepse/===cmd.first
@custom_se_name[-1, 1] = ""
#list = @list[i].parameters[0].scan(/\[footstepse:([0-9]|[a-z]|[A-Z])+\]/)
#p $1
@footstep_se_custom = true
#$1
elsif @list[i].parameters[0].include?("[footstep]")
#p "should work, right?"
@footstep_se = true
end
end
end
end
def footstep_se
get_dist_vol
play_se
end
def play_se
if @footstep_se_custom
RPG::SE.new(@custom_se_name, rand(30)+80, rand(30)+80).play
elsif @footstep_se
if Mm12::LADDER_TILES.include?($game_map.tile_index($game_map.data[@x, @y, 2]))
RPG::SE.new(Mm12::LADDER_SE[rand(Mm12::LADDER_SE.size-1)], rand(30) + 80, rand(30) + 80).play
elsif Mm12::BRIDGE_TILES.include?($game_map.tile_index($game_map.data[@x, @y, 0])) or Mm12::BRIDGE_TILES.include?($game_map.tile_index($game_map.data[@x, @y, 2]))
RPG::SE.new(Mm12::BRIDGE_SE[rand(Mm12::BRIDGE_SE.size-1)], rand(30) + 80, rand(30) + 80).play
elsif Mm12::CARPET_TILES.include?($game_map.tile_index($game_map.data[@x, @y, 0]))
RPG::SE.new(Mm12::CARPET_SE[rand(Mm12::CARPET_SE.size-1)], rand(30) + 80, rand(30) + 80).play
elsif Mm12::DIRT_TILES.include?($game_map.tile_index($game_map.data[@x, @y, 0]))
RPG::SE.new(Mm12::DIRT_SE[rand(Mm12::DIRT_SE.size-1)], rand(30) + 80, rand(30) + 80).play
elsif Mm12::GRASS_TILES.include?($game_map.tile_index($game_map.data[@x, @y, 0]))
RPG::SE.new(Mm12::GRASS_SE[rand(Mm12::GRASS_SE.size-1)], rand(30) + 80, rand(30) + 80).play
elsif Mm12::ICE_TILES.include?($game_map.tile_index($game_map.data[@x, @y, 0]))
RPG::SE.new(Mm12::ICE_SE[rand(Mm12::ICE_SE.size-1)], rand(30) + 80, rand(30) + 80).play
elsif Mm12::LAVA_TILES.include?($game_map.tile_index($game_map.data[@x, @y, 0]))
RPG::SE.new(Mm12::LAVA_SE[rand(Mm12::LAVA_SE.size-1)], rand(30) + 80, rand(30) + 80).play
elsif Mm12::SAND_TILES.include?($game_map.tile_index($game_map.data[@x, @y, 0]))
RPG::SE.new(Mm12::SAND_SE[rand(Mm12::SAND_SE.size-1)], rand(30) + 80, rand(30) + 80).play
elsif Mm12::STONE_TILES.include?($game_map.tile_index($game_map.data[@x, @y, 0]))
RPG::SE.new(Mm12::STONE_SE[rand(Mm12::STONE_SE.size-1)], rand(30) + 80, rand(30) + 80).play
elsif Mm12::TGRASS_TILES.include?($game_map.tile_index($game_map.data[@x, @y, 0]))
RPG::SE.new(Mm12::TGRASS_SE[rand(Mm12::TGRASS_SE.size-1)], rand(30) + 80, rand(30) + 80).play
elsif Mm12::WOOD_TILES.include?($game_map.tile_index($game_map.data[@x, @y, 0]))
RPG::SE.new(Mm12::WOOD_SE[rand(Mm12::WOOD_SE.size-1)], rand(30) + 80, rand(30) + 80).play
elsif Mm12::SNOW_TILES.include?($game_map.tile_index($game_map.data[@x, @y, 0]))
RPG::SE.new(Mm12::SNOW_SE[rand(Mm12::SNOW_SE.size-1)], rand(30) + 80, rand(30) + 80).play
end
end
end
def get_dist_vol
@x_dist = $game_player.x - @x
@y_dist = $game_player.y - @y
@x_dist = @x_dist.abs
@y_dist = @y_dist.abs
@ttl_dist = Math.sqrt(@x_dist * @x_dist + @y_dist * @y_dist ).round
#p @ttl_dist
@dist_vol = 60
@dist_vol2 = 20
@dist_vol -= @ttl_dist*3
@dist_vol += rand(30)
if @dist_vol < 0
@dist_vol = 0
end
#p @dist_vol
@dist_vol2 -= @ttl_dist*2
@dist_vol2 += rand(30)
if @dist_vol2 < 0
@dist_vol2 = 0
end
#p "Distance Volume: "+@dist_vol1.to_s
end
def increase_steps
ftstp_ge_increase_steps
footstep_se
end
end
class Game_Map
#--------------------------------------------------------------------------
# * DerVVulfman's method L get_tile_index
#--------------------------------------------------------------------------
def tile_index(tile_id)
case tile_id
# Multi-tiled ids in Tileset 'A'
when 2048..8191; return ((tile_id - 2000) / 48) - 1
# Individual tile ids in Tileset 'A'
when 1536..1663; return(tile_id - 1408)
# Tilesets 'B' to 'E'
when 0..1023; return (tile_id + 256)
end
return 0
end
end