module GameData
class TerrainTag
attr_reader :spin_tile
alias spin_initialize initialize
def initialize(hash)
spin_initialize(hash)
@spin_tile = hash[:spin_tile] || false
end
end
end
# You can renumber terrain tag id number if necessary.
GameData::TerrainTag.register({
:id => :SpinTileUp,
:id_number => 41,
:spin_tile => true
})
GameData::TerrainTag.register({
:id => :SpinTileDown,
:id_number => 42,
:spin_tile => true
})
GameData::TerrainTag.register({
:id => :SpinTileLeft,
:id_number => 43,
:spin_tile => true
})
GameData::TerrainTag.register({
:id => :SpinTileRight,
:id_number => 44,
:spin_tile => true
})
GameData::TerrainTag.register({
:id => :SpinTileStop,
:id_number => 45
})
class PokemonGlobalMetadata
attr_accessor :spinning
alias spin_initialize initialize
def initialize
spin_initialize
@spinning = false
end
end
EventHandlers.add(:on_step_taken, :spin_tile,
proc { |event|
next if !$scene.is_a?(Scene_Map)
next if event != $game_player
currentTag = $game_player.pbTerrainTag
if currentTag.spin_tile
pbSpinTile
end
}
)
def pbSpinTile
tag = $game_player.pbTerrainTag
return if !tag.spin_tile
oldwalkanime = $game_player.walk_anime
$game_player.move_speed == 1
if !$PokemonGlobal.spinning
$game_player.straighten
end
$game_player.walk_anime = false
case tag.id
when :SpinTileUp
$game_player.turn_up
$game_player.pattern = 2 if !$PokemonGlobal.spinning
when :SpinTileDown
$game_player.turn_down
$game_player.pattern = 0 if !$PokemonGlobal.spinning
when :SpinTileRight
$game_player.turn_right
$game_player.pattern = 1 if !$PokemonGlobal.spinning
when :SpinTileLeft
$game_player.turn_left
$game_player.pattern = 3 if !$PokemonGlobal.spinning
end
$game_player.walk_anime = true
$PokemonGlobal.spinning = true
loop do
break if !$game_player.passable?($game_player.x, $game_player.y, $game_player.direction)
break if tag.id == :SpinTileStop
case tag.id
when :SpinTileUp
$game_player.turn_up
when :SpinTileDown
$game_player.turn_down
when :SpinTileRight
$game_player.turn_right
when :SpinTileLeft
$game_player.turn_left
end
$game_player.move_forward
while $game_player.moving?
Graphics.update
Input.update
pbUpdateSceneMap
end
end
$game_player.center($game_player.x, $game_player.y)
$game_player.walk_anime = oldwalkanime
$PokemonGlobal.spinning = false
end