Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MAX_RANDOM_STEPS = 20 # Leave this alone, it's set at 20 for a reason :3
- GRASS = 3 # Terrain Tag 3
- WATER = 4 # Terrain Tag 4
- LEDGE = 5 # Terrain Tag 5
- #-------------------------------------------------------------------------------
- # * TerrainTag class.
- # * This checks the Player's current terrain tag, and if it's an encounter tag,
- # * Runs encounter processes.
- #-------------------------------------------------------------------------------
- class TerrainTag
- attr_accessor :max_steps
- attr_accessor :play_sound
- #-----------------------------------------------------------------------------
- # * Initialize the TerrainTag class and create initial values
- #-----------------------------------------------------------------------------
- def initialize
- @terraintag = $game_player.terrain_tag
- @max_steps = (18.75 * 10 / 8.5)
- @play_sound = true
- @sound_frames = 0
- @goframes = true
- end # initialize
- #-----------------------------------------------------------------------------
- # * Update the Terrain Tag detection and run encounter processes.
- #-----------------------------------------------------------------------------
- def update
- if @terraintag != $game_player.terrain_tag
- @terraintag = $game_player.terrain_tag
- @max_steps = (18.75 * 10 / 8.5) - rand(MAX_RANDOM_STEPS)
- end
- case @terraintag
- when GRASS
- if @max_steps <= 0
- @max_steps = (18.75 * 10 / 8.5) - rand(MAX_RANDOM_STEPS)
- if $party.members.size == 0
- $game_temp.battle_calling = false
- p "You have no Pokemon in your party to battle with"
- p "Bypassing Battle System to prevent errors."
- else
- select_random_pokemon
- $game_temp.map_bgm = $game_system.playing_bgm
- $game_system.bgm_stop
- $game_system.se_play($data_system.battle_start_se)
- $game_system.bgm_play($game_system.battle_bgm)
- $game_player.straighten
- $scene = Scene_WildBattle.new(@enemy, @level)
- end
- end
- when LEDGE
- @move_route = RPG::MoveRoute.new
- @route = RPG::MoveCommand.new
- case $game_player.direction
- when 2 # Down
- @route.parameters = [0, 1]
- @x = 0
- @y = 1
- when 4 # Left
- @route.parameters = [-1, 0]
- @x = -1
- @y = 0
- when 6 # Right
- @route.parameters = [1, 0]
- @x = 1
- @y = 0
- when 8 # Up
- @route.parameters = [0, -1]
- @x = 0
- @y = -1
- end
- @route.code = 14
- @dummy = RPG::MoveCommand.new
- @dummy.parameters = []
- @dummy.code = 0
- @move_route.list = [@route, @dummy]
- @move_route.skippable = false
- @move_route.repeat = false
- if $game_player.passable?($game_player.x + @x, $game_player.y + @y, $game_player.direction)
- if @play_sound == true
- Audio.se_play("Audio/SE/Jump", 100, 100)
- @goframes = true
- @play_sound = false
- end
- $game_player.refresh
- $game_player.force_move_route(@move_route)
- end
- end
- if @goframes
- if Config::FPSBOOST
- if @sound_frames < 20
- @sound_frames += 1
- elsif @sound_frames == 20
- @play_sound = true
- @goframes = false
- @sound_frames = 0
- end
- else
- if @sound_frames < 10
- @sound_frames += 1
- elsif @sound_frames == 10
- @play_sound = true
- @goframes = false
- @sound_frames = 0
- end
- end
- end
- end # update
- #-----------------------------------------------------------------------------
- # * Make sure that the wild Pokemon's ID and Level are not 0.
- # * If so, choose again and again until both values are not 0.
- #-----------------------------------------------------------------------------
- def select_random_pokemon
- @map = WildPokemon.fetch($game_map.map_id)
- @enemy = @map[0][rand(@map[0].size)]
- @level = @map[1][rand(@map[1].size)]
- end # select_random_pokemon
- end # TerrainTag
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement