diff --git a/Data/Scripts/001_Settings.rb b/Data/Scripts/001_Settings.rb index d8220f49f..58422fc8c 100644 --- a/Data/Scripts/001_Settings.rb +++ b/Data/Scripts/001_Settings.rb @@ -254,10 +254,8 @@ module Settings [0, 52, 20, 14, "mapHiddenFaraday", false] ] - # Allow the player to fly to a known location directly from the Town Map. - # Checks will still be made for things like badges, dependent events, - # whether the player has a Pokemon in their party that knows Fly and - # whether the player is indoors. + # Whether the player can use Fly while looking at the Town Map. This is only + # allowed if the player can use Fly normally. CAN_FLY_FROM_TOWN_MAP = true #============================================================================= diff --git a/Data/Scripts/007_Objects and windows/002_MessageConfig.rb b/Data/Scripts/007_Objects and windows/002_MessageConfig.rb index 50fe0c877..62146dd6e 100644 --- a/Data/Scripts/007_Objects and windows/002_MessageConfig.rb +++ b/Data/Scripts/007_Objects and windows/002_MessageConfig.rb @@ -563,7 +563,9 @@ def pbFadeOutIn(z=99999,nofadeout=false) end pbPushFade begin - yield if block_given? + val = 0 + val = yield if block_given? + nofadeout = true if val == 99999 # Ugly hack used by Town Map in the Bag/Pokégear ensure pbPopFade if !nofadeout diff --git a/Data/Scripts/012_Overworld/004_Overworld_FieldMoves.rb b/Data/Scripts/012_Overworld/004_Overworld_FieldMoves.rb index 3edb5f54b..d656070b3 100644 --- a/Data/Scripts/012_Overworld/004_Overworld_FieldMoves.rb +++ b/Data/Scripts/012_Overworld/004_Overworld_FieldMoves.rb @@ -492,46 +492,34 @@ HiddenMoveHandlers::UseMove.add(:FLASH,proc { |move,pokemon| #=============================================================================== # Fly #=============================================================================== -HiddenMoveHandlers::CanUseMove.add(:FLY,proc { |move,pkmn,showmsg| - next pbCanFly?(pkmn, showmsg) -}) - -HiddenMoveHandlers::UseMove.add(:FLY,proc { |move,pokemon| - if !$PokemonTemp.flydata - pbMessage(_INTL("Can't use that here.")) - next false - end - pbFlyToNewLocation(pokemon) - next true -}) - -def pbCanFly?(pkmn = nil, showmsg = false) - return false if !$DEBUG && !pkmn && $Trainer.pokemon_party.none? { |poke| poke.hasMove?(:FLY) } - return false if !pbCheckHiddenMoveBadge(Settings::BADGE_FOR_FLY, showmsg) +def pbCanFly?(pkmn = nil, show_messages = false) + return false if !pbCheckHiddenMoveBadge(Settings::BADGE_FOR_FLY, show_messages) + return false if !$DEBUG && !pkmn && !$Trainer.get_pokemon_with_move(:FLY) if $game_player.has_follower? - pbMessage(_INTL("It can't be used when you have someone with you.")) if showmsg + pbMessage(_INTL("It can't be used when you have someone with you.")) if show_messages return false end if !$game_map.metadata&.outdoor_map - pbMessage(_INTL("Can't use that here.")) if showmsg + pbMessage(_INTL("Can't use that here.")) if show_messages return false end return true end def pbFlyToNewLocation(pkmn = nil, move = :FLY) - if !pkmn - fly_party = $Trainer.pokemon_party.select { |poke| poke.hasMove?(move) } - return false if fly_party.empty? && !$DEBUG - pkmn = fly_party[0] + return false if !$PokemonTemp.flydata + pkmn = $Trainer.get_pokemon_with_move(move) if !pkmn + if !$DEBUG && !pkmn + $PokemonTemp.flydata = nil + yield if block_given? + return false end if !pkmn || !pbHiddenMoveAnimation(pkmn) - name = !pkmn ? $Trainer.name : pkmn.name + name = pkmn&.name || $Trainer.name pbMessage(_INTL("{1} used {2}!", name, GameData::Move.get(move).name)) end - return false if !$PokemonTemp.flydata pbFadeOutIn { - pbSEPlay("Anim/Wind1") + pbSEPlay("Fly") $game_temp.player_new_map_id = $PokemonTemp.flydata[0] $game_temp.player_new_x = $PokemonTemp.flydata[1] $game_temp.player_new_y = $PokemonTemp.flydata[2] @@ -541,12 +529,25 @@ def pbFlyToNewLocation(pkmn = nil, move = :FLY) $game_map.autoplay $game_map.refresh yield if block_given? - pbWait(Graphics.frame_rate/4) + pbWait(Graphics.frame_rate / 4) } pbEraseEscapePoint return true end +HiddenMoveHandlers::CanUseMove.add(:FLY,proc { |move, pkmn, showmsg| + next pbCanFly?(pkmn, showmsg) +}) + +HiddenMoveHandlers::UseMove.add(:FLY,proc { |move, pkmn| + if !$PokemonTemp.flydata + pbMessage(_INTL("Can't use that here.")) + next false + end + pbFlyToNewLocation(pkmn) + next true +}) + #=============================================================================== diff --git a/Data/Scripts/013_Items/002_Item_Effects.rb b/Data/Scripts/013_Items/002_Item_Effects.rb index 4a218fd8b..81a888818 100644 --- a/Data/Scripts/013_Items/002_Item_Effects.rb +++ b/Data/Scripts/013_Items/002_Item_Effects.rb @@ -53,9 +53,15 @@ ItemHandlers::UseFromBag.add(:ITEMFINDER,proc { |item| ItemHandlers::UseFromBag.copy(:ITEMFINDER,:DOWSINGMCHN,:DOWSINGMACHINE) -ItemHandlers::UseFromBag.add(:TOWNMAP,proc { |item| - pbShowMap(-1, false) - next ($PokemonTemp.flydata ? 2 : 0) +ItemHandlers::UseFromBag.add(:TOWNMAP, proc { |item| + pbFadeOutIn { + scene = PokemonRegionMap_Scene.new(-1, false) + screen = PokemonRegionMapScreen.new(scene) + ret = screen.pbStartScreen + $PokemonTemp.flydata = ret if ret + next 99999 if ret # Ugly hack to make Bag scene not reappear if flying + } + next $PokemonTemp.flydata ? 2 : 0 }) #=============================================================================== @@ -306,14 +312,10 @@ ItemHandlers::UseInField.add(:ITEMFINDER,proc { |item| ItemHandlers::UseInField.copy(:ITEMFINDER,:DOWSINGMCHN,:DOWSINGMACHINE) -ItemHandlers::UseInField.add(:TOWNMAP,proc { |item| - ret = false - if !$PokemonTemp.flydata - pbShowMap(-1, false) - ret = !$PokemonTemp.flydata.nil? - end +ItemHandlers::UseInField.add(:TOWNMAP, proc { |item| + pbShowMap(-1, false) if !$PokemonTemp.flydata pbFlyToNewLocation - next ret + next true }) ItemHandlers::UseInField.add(:COINCASE,proc { |item| diff --git a/Data/Scripts/016_UI/001_UI_PauseMenu.rb b/Data/Scripts/016_UI/001_UI_PauseMenu.rb index 43a038973..2f753d4c9 100644 --- a/Data/Scripts/016_UI/001_UI_PauseMenu.rb +++ b/Data/Scripts/016_UI/001_UI_PauseMenu.rb @@ -115,14 +115,16 @@ class PokemonPauseMenu cmdQuit = -1 cmdEndGame = -1 if $Trainer.has_pokedex && $Trainer.pokedex.accessible_dexes.length > 0 - commands[cmdPokedex = commands.length] = _INTL("Pokédex") + commands[cmdPokedex = commands.length] = _INTL("Pokédex") end - commands[cmdPokemon = commands.length] = _INTL("Pokémon") if $Trainer.party_count > 0 - commands[cmdBag = commands.length] = _INTL("Bag") if !pbInBugContest? - commands[cmdPokegear = commands.length] = _INTL("Pokégear") if $Trainer.has_pokegear - # Any reasonable game will have either have the Town Map as an item or in the Pokegear. Never both at once. - commands[cmdTownMap = commands.length] = _INTL("Town Map") if $PokemonBag.pbHasItem?(:TOWNMAP) && !$Trainer.has_pokegear - commands[cmdTrainer = commands.length] = $Trainer.name + commands[cmdPokemon = commands.length] = _INTL("Pokémon") if $Trainer.party_count > 0 + commands[cmdBag = commands.length] = _INTL("Bag") if !pbInBugContest? + if $Trainer.has_pokegear + commands[cmdPokegear = commands.length] = _INTL("Pokégear") + elsif $bag.has?(:TOWNMAP) + commands[cmdTownMap = commands.length] = _INTL("Town Map") + end + commands[cmdTrainer = commands.length] = $Trainer.name if pbInSafari? if Settings::SAFARI_STEPS <= 0 @scene.pbShowInfo(_INTL("Balls: {1}",pbSafariState.ballcount)) @@ -130,7 +132,7 @@ class PokemonPauseMenu @scene.pbShowInfo(_INTL("Steps: {1}/{2}\nBalls: {3}", pbSafariState.steps, Settings::SAFARI_STEPS, pbSafariState.ballcount)) end - commands[cmdQuit = commands.length] = _INTL("Quit") + commands[cmdQuit = commands.length] = _INTL("Quit") elsif pbInBugContest? if pbBugContestState.lastPokemon @scene.pbShowInfo(_INTL("Caught: {1}\nLevel: {2}\nBalls: {3}", @@ -140,13 +142,13 @@ class PokemonPauseMenu else @scene.pbShowInfo(_INTL("Caught: None\nBalls: {1}",pbBugContestState.ballcount)) end - commands[cmdQuit = commands.length] = _INTL("Quit Contest") + commands[cmdQuit = commands.length] = _INTL("Quit Contest") else - commands[cmdSave = commands.length] = _INTL("Save") if $game_system && !$game_system.save_disabled + commands[cmdSave = commands.length] = _INTL("Save") if $game_system && !$game_system.save_disabled end - commands[cmdOption = commands.length] = _INTL("Options") - commands[cmdDebug = commands.length] = _INTL("Debug") if $DEBUG - commands[cmdEndGame = commands.length] = _INTL("Quit Game") + commands[cmdOption = commands.length] = _INTL("Options") + commands[cmdDebug = commands.length] = _INTL("Debug") if $DEBUG + commands[cmdEndGame = commands.length] = _INTL("Quit Game") loop do command = @scene.pbShowCommands(commands) if cmdPokedex>=0 && command==cmdPokedex @@ -212,17 +214,16 @@ class PokemonPauseMenu screen.pbStartScreen ($PokemonTemp.flydata) ? @scene.pbEndScene : @scene.pbRefresh } - if pbFlyToNewLocation - $game_temp.in_menu = false - return - end + return if pbFlyToNewLocation elsif cmdTownMap>=0 && command==cmdTownMap - pbShowMap(-1, false) - ($PokemonTemp.flydata) ? @scene.pbEndScene : @scene.pbRefresh - if pbFlyToNewLocation - $game_temp.in_menu = false - return - end + pbFadeOutIn { + scene = PokemonRegionMap_Scene.new(-1, false) + screen = PokemonRegionMapScreen.new(scene) + ret = screen.pbStartScreen + $PokemonTemp.flydata = ret if ret + ($PokemonTemp.flydata) ? @scene.pbEndScene : @scene.pbRefresh + } + return if pbFlyToNewLocation elsif cmdTrainer>=0 && command==cmdTrainer pbPlayDecisionSE pbFadeOutIn { diff --git a/Data/Scripts/016_UI/004_UI_Pokedex_Entry.rb b/Data/Scripts/016_UI/004_UI_Pokedex_Entry.rb index 0cea72617..5ba7f6ad5 100644 --- a/Data/Scripts/016_UI/004_UI_Pokedex_Entry.rb +++ b/Data/Scripts/016_UI/004_UI_Pokedex_Entry.rb @@ -30,8 +30,8 @@ class PokemonPokedexInfo_Scene if hidden[0]==@region && hidden[1]>0 && $game_switches[hidden[1]] pbDrawImagePositions(@sprites["areamap"].bitmap,[ ["Graphics/Pictures/#{hidden[4]}", - hidden[2]*PokemonRegionMap_Scene::SQUAREWIDTH, - hidden[3]*PokemonRegionMap_Scene::SQUAREHEIGHT] + hidden[2]*PokemonRegionMap_Scene::SQUARE_WIDTH, + hidden[3]*PokemonRegionMap_Scene::SQUARE_HEIGHT] ]) end end @@ -334,8 +334,8 @@ class PokemonPokedexInfo_Scene # Draw coloured squares on each square of the region map with a nest pointcolor = Color.new(0,248,248) pointcolorhl = Color.new(192,248,248) - sqwidth = PokemonRegionMap_Scene::SQUAREWIDTH - sqheight = PokemonRegionMap_Scene::SQUAREHEIGHT + sqwidth = PokemonRegionMap_Scene::SQUARE_WIDTH + sqheight = PokemonRegionMap_Scene::SQUARE_HEIGHT for j in 0...points.length if points[j] x = (j%mapwidth)*sqwidth diff --git a/Data/Scripts/016_UI/007_UI_Bag.rb b/Data/Scripts/016_UI/007_UI_Bag.rb index c738499c9..143db4189 100644 --- a/Data/Scripts/016_UI/007_UI_Bag.rb +++ b/Data/Scripts/016_UI/007_UI_Bag.rb @@ -227,6 +227,10 @@ class PokemonBag_Scene def pbEndScene pbFadeOutAndHide(@sprites) if !@oldsprites @oldsprites = nil + dispose + end + + def dispose pbDisposeSpriteHash(@sprites) @sliderbitmap.dispose @pocketbitmap.dispose @@ -563,7 +567,7 @@ class PokemonBagScreen end end end - @scene.pbEndScene + ($PokemonTemp.flydata) ? @scene.dispose : @scene.pbEndScene return item end diff --git a/Data/Scripts/016_UI/008_UI_Pokegear.rb b/Data/Scripts/016_UI/008_UI_Pokegear.rb index c7cae7a16..6902b4d0d 100644 --- a/Data/Scripts/016_UI/008_UI_Pokegear.rb +++ b/Data/Scripts/016_UI/008_UI_Pokegear.rb @@ -110,6 +110,10 @@ class PokemonPokegear_Scene def pbEndScene pbFadeOutAndHide(@sprites) { pbUpdate } + dispose + end + + def dispose pbDisposeSpriteHash(@sprites) @viewport.dispose end @@ -139,7 +143,15 @@ class PokemonPokegearScreen if cmd<0 break elsif cmdMap>=0 && cmd==cmdMap - pbShowMap(-1,false) + pbFadeOutIn { + scene = PokemonRegionMap_Scene.new(-1, false) + screen = PokemonRegionMapScreen.new(scene) + ret = screen.pbStartScreen + if ret + $PokemonTemp.flydata = ret + next 99999 # Ugly hack to make Pokégear scene not reappear if flying + end + } break if $PokemonTemp.flydata elsif cmdPhone>=0 && cmd==cmdPhone pbFadeOutIn { @@ -153,6 +165,6 @@ class PokemonPokegearScreen } end end - @scene.pbEndScene + ($PokemonTemp.flydata) ? @scene.dispose : @scene.pbEndScene end end diff --git a/Data/Scripts/016_UI/009_UI_RegionMap.rb b/Data/Scripts/016_UI/009_UI_RegionMap.rb index 21a73bb93..cead965ac 100644 --- a/Data/Scripts/016_UI/009_UI_RegionMap.rb +++ b/Data/Scripts/016_UI/009_UI_RegionMap.rb @@ -4,45 +4,44 @@ class MapBottomSprite < SpriteWrapper attr_reader :mapname, :maplocation + TEXT_MAIN_COLOR = Color.new(248, 248, 248) + TEXT_SHADOW_COLOR = Color.new(0, 0, 0) + def initialize(viewport = nil) super(viewport) @mapname = "" @maplocation = "" @mapdetails = "" - @thisbitmap = BitmapWrapper.new(Graphics.width, Graphics.height) self.bitmap = BitmapWrapper.new(Graphics.width, Graphics.height) pbSetSystemFont(self.bitmap) refresh end def mapname=(value) - if @mapname != value - @mapname = value - refresh - end + return if @mapname == value + @mapname = value + refresh end def maplocation=(value) - if @maplocation != value - @maplocation = value - refresh - end + return if @maplocation == value + @maplocation = value + refresh end # From Wichu def mapdetails=(value) - if @mapdetails != value - @mapdetails = value - refresh - end + return if @mapdetails == value + @mapdetails = value + refresh end def refresh bitmap.clear textpos = [ - [@mapname, 18, -8, 0, Color.new(248, 248, 248), Color.new(0, 0, 0)], - [@maplocation, 18, 348, 0, Color.new(248, 248, 248), Color.new(0, 0, 0)], - [@mapdetails, Graphics.width - 16, 348, 1, Color.new(248, 248, 248), Color.new(0, 0, 0)] + [@mapname, 18, -8, 0, TEXT_MAIN_COLOR, TEXT_SHADOW_COLOR], + [@maplocation, 18, 348, 0, TEXT_MAIN_COLOR, TEXT_SHADOW_COLOR], + [@mapdetails, Graphics.width - 16, 348, 1, TEXT_MAIN_COLOR, TEXT_SHADOW_COLOR] ] pbDrawTextPositions(bitmap, textpos) end @@ -77,17 +76,17 @@ class PokemonRegionMap_Scene @fly_map = fly_map @mode = fly_map ? 1 : 0 map_metadata = GameData::MapMetadata.try_get($game_map.map_id) - playerpos = map_metadata ? map_metadata.town_map_position : nil + playerpos = (map_metadata) ? map_metadata.town_map_position : nil if !playerpos mapindex = 0 @map = @map_data[0] - @map_x = LEFT - @map_y = TOP + @map_x = LEFT + @map_y = TOP elsif @region >= 0 && @region != playerpos[0] && @map_data[@region] mapindex = @region @map = @map_data[@region] - @map_x = LEFT - @map_y = TOP + @map_x = LEFT + @map_y = TOP else mapindex = playerpos[0] @map = @map_data[playerpos[0]] @@ -96,12 +95,12 @@ class PokemonRegionMap_Scene mapsize = map_metadata.town_map_size if mapsize && mapsize[0] && mapsize[0] > 0 sqwidth = mapsize[0] - sqheight = (mapsize[1].length * 1.0 / mapsize[0]).ceil + sqheight = (mapsize[1].length.to_f / mapsize[0]).ceil @map_x += ($game_player.x * sqwidth / $game_map.width).floor if sqwidth > 1 @map_y += ($game_player.y * sqheight / $game_map.height).floor if sqheight > 1 end end - unless @map + if !@map pbMessage(_INTL("The map data cannot be found.")) return false end @@ -110,16 +109,16 @@ class PokemonRegionMap_Scene @sprites["map"].setBitmap("Graphics/Pictures/#{@map[1]}") @sprites["map"].x += (Graphics.width - @sprites["map"].bitmap.width) / 2 @sprites["map"].y += (Graphics.height - @sprites["map"].bitmap.height) / 2 - Settings::REGION_MAP_EXTRAS.each do |hidden| - next unless hidden[0] == mapindex && ((@wallmap && hidden[5]) || location_hidden?(hidden[1])) - unless @sprites["map2"] + Settings::REGION_MAP_EXTRAS.each do |graphic| + next if graphic[0] != mapindex || !location_shown?(graphic) + if !@sprites["map2"] @sprites["map2"] = BitmapSprite.new(480, 320, @viewport) @sprites["map2"].x = @sprites["map"].x @sprites["map2"].y = @sprites["map"].y end pbDrawImagePositions(@sprites["map2"].bitmap, [ - ["Graphics/Pictures/#{hidden[4]}", hidden[2] * SQUARE_WIDTH, hidden[3] * SQUARE_HEIGHT] - ]) + ["Graphics/Pictures/#{graphic[4]}", graphic[2] * SQUARE_WIDTH, graphic[3] * SQUARE_HEIGHT] + ]) end @sprites["mapbottom"] = MapBottomSprite.new(@viewport) @sprites["mapbottom"].mapname = pbGetMessage(MessageTypes::RegionNames, mapindex) @@ -128,18 +127,18 @@ class PokemonRegionMap_Scene if playerpos && mapindex == playerpos[0] @sprites["player"] = IconSprite.new(0, 0, @viewport) @sprites["player"].setBitmap(GameData::TrainerType.player_map_icon_filename($Trainer.trainer_type)) - @sprites["player"].x = get_x_coord_on_grid(@map_x) - @sprites["player"].y = get_y_coord_on_grid(@map_y) + @sprites["player"].x = point_x_to_screen_x(@map_x) + @sprites["player"].y = point_y_to_screen_y(@map_y) end k = 0 (LEFT..RIGHT).each do |i| (TOP..BOTTOM).each do |j| healspot = pbGetHealingSpot(i, j) - next unless healspot && $PokemonGlobal.visitedMaps[healspot[0]] + next if !healspot || !$PokemonGlobal.visitedMaps[healspot[0]] @sprites["point#{k}"] = AnimatedSprite.create("Graphics/Pictures/mapFly", 2, 16) @sprites["point#{k}"].viewport = @viewport - @sprites["point#{k}"].x = get_x_coord_on_grid(i) - @sprites["point#{k}"].y = get_y_coord_on_grid(j) + @sprites["point#{k}"].x = point_x_to_screen_x(i) + @sprites["point#{k}"].y = point_y_to_screen_y(j) @sprites["point#{k}"].visible = @mode == 1 @sprites["point#{k}"].play k += 1 @@ -147,25 +146,33 @@ class PokemonRegionMap_Scene end @sprites["cursor"] = AnimatedSprite.create("Graphics/Pictures/mapCursor", 2, 5) @sprites["cursor"].viewport = @viewport - @sprites["cursor"].x = get_x_coord_on_grid(@map_x) - @sprites["cursor"].y = get_y_coord_on_grid(@map_y) + @sprites["cursor"].x = point_x_to_screen_x(@map_x) + @sprites["cursor"].y = point_y_to_screen_y(@map_y) @sprites["cursor"].play - @sprites["help"] = BitmapSprite.new(Graphics.width, 28, @viewport) + @sprites["help"] = BitmapSprite.new(Graphics.width, 32, @viewport) + pbSetSystemFont(@sprites["help"].bitmap) refresh_fly_screen @changed = false pbFadeInAndShow(@sprites) { pbUpdate } end - def get_x_coord_on_grid(x) + def pbEndScene + pbFadeOutAndHide(@sprites) + pbDisposeSpriteHash(@sprites) + @viewport.dispose + end + + def point_x_to_screen_x(x) return -SQUARE_WIDTH / 2 + (x * SQUARE_WIDTH) + (Graphics.width - @sprites["map"].bitmap.width) / 2 end - def get_y_coord_on_grid(y) + def point_y_to_screen_y(y) return -SQUARE_HEIGHT / 2 + (y * SQUARE_HEIGHT) + (Graphics.height - @sprites["map"].bitmap.height) / 2 end - def location_hidden?(loc) - return !@wallmap && loc.is_a?(Integer) && loc >0 && $game_switches[loc] + def location_shown?(point) + return point[5] if @wallmap + return point[1] > 0 && $game_switches[point[1]] end # TODO: Why is this PBS file writer here? @@ -181,35 +188,26 @@ class PokemonRegionMap_Scene Compiler.csvQuote(map[0]), Compiler.csvQuote(map[1]))) for loc in map[2] f.write("Point = ") - Compiler.pbWriteCsvRecord(loc,f,[nil,"uussUUUU"]) + Compiler.pbWriteCsvRecord(loc, f, [nil, "uussUUUU"]) f.write("\r\n") end end } end - def pbEndScene - pbFadeOutAndHide(@sprites) - pbDisposeSpriteHash(@sprites) - @viewport.dispose - end - def pbGetMapLocation(x, y) - return "" unless @map[2] - maps = @map[2].select { |loc| loc[0] == x && loc[1] == y } - return "" if maps.empty? - maps.each do |loc| - if !location_hidden?(loc[7]) - maploc = pbGetMessageFromHash(MessageTypes::PlaceNames, loc[2]) - return @editor ? loc[2] : maploc - else - return "" - end + return "" if !@map[2] + for point in @map[2] + next if point[0] != x || point[1] != y + return "" if point[7] && (@wallmap || point[7] <= 0 || !$game_switches[point[7]]) + name = pbGetMessageFromHash(MessageTypes::PlaceNames, point[2]) + return (@editor) ? point[2] : name end + return "" end - def pbChangeMapLocation(x,y) - return "" unless @editor && @map[2] + def pbChangeMapLocation(x, y) + return "" if !@editor || !@map[2] map = @map[2].select { |loc| loc[0] == x && loc[1] == y }[0] currentobj = map currentname = map[2] @@ -225,38 +223,37 @@ class PokemonRegionMap_Scene end end - def pbGetMapDetails(x,y) # From Wichu, with my help - return "" unless @map[2] - maps = @map[2].select { |loc| loc[0] == x && loc[1] == y } - return "" if maps.empty? - maps.each do |loc| - if !location_hidden?(loc[7]) - mapdesc = pbGetMessageFromHash(MessageTypes::PlaceDescriptions,loc[3]) - return (@editor) ? loc[3] : mapdesc - else - return "" - end + def pbGetMapDetails(x, y) # From Wichu, with my help + return "" if !@map[2] + for point in @map[2] + next if point[0] != x || point[1] != y + return "" if point[7] && (@wallmap || point[7] <= 0 || !$game_switches[point[7]]) + mapdesc = pbGetMessageFromHash(MessageTypes::PlaceDescriptions, point[3]) + return (@editor) ? point[3] : mapdesc end + return "" end - def pbGetHealingSpot(x,y) - return nil unless @map[2] - maps = @map[2].select { |loc| loc[0] == x && loc[1] == y } - return nil if maps.empty? - maps.each do |loc| - return ((loc[4] && loc[5] && loc[6]) ? [loc[4],loc[5],loc[6]] : nil) + def pbGetHealingSpot(x, y) + return nil if !@map[2] + for point in @map[2] + next if point[0] != x || point[1] != y + return nil if point[7] && (@wallmap || point[7] <= 0 || !$game_switches[point[7]]) + return (point[4] && point[5] && point[6]) ? [point[4], point[5], point[6]] : nil end + return nil end def refresh_fly_screen - return if @fly_map || !pbCanFly? || !Settings::CAN_FLY_FROM_TOWN_MAP + return if @fly_map || !Settings::CAN_FLY_FROM_TOWN_MAP || !pbCanFly? @sprites["help"].bitmap.clear - pbSetSystemFont(@sprites["help"].bitmap) - text = @mode == 0 ? _INTL("ACTION: Open Fly Menu") : _INTL("ACTION: Close Fly Menu") - pbDrawTextPositions(@sprites["help"].bitmap, [[text, Graphics.width - 8, -8, 1, Color.new(248,248,248), Color.new(0,0,0)]]) + text = (@mode == 0) ? _INTL("ACTION: Fly") : _INTL("ACTION: Cancel Fly") + pbDrawTextPositions(@sprites["help"].bitmap, [ + [text, Graphics.width - 16, -8, 1, Color.new(248, 248, 248), Color.new(0, 0, 0)] + ]) @sprites.each do |key, sprite| next if !key.include?("point") - sprite.visible = @mode == 1 + sprite.visible = (@mode == 1) sprite.frame = 0 end end @@ -281,25 +278,15 @@ class PokemonRegionMap_Scene ox = 0 oy = 0 case Input.dir8 - when 1 # lower left + when 1, 2, 3 oy = 1 if @map_y < BOTTOM - ox = -1 if @map_x > LEFT - when 2 # down - oy = 1 if @map_y < BOTTOM - when 3 # lower right - oy = 1 if @map_y < BOTTOM - ox = 1 if @map_x < RIGHT - when 4 # left - ox = -1 if @map_x > LEFT - when 6 # right - ox = 1 if @map_x < RIGHT - when 7 # upper left + when 7, 8, 9 oy = -1 if @map_y > TOP + end + case Input.dir8 + when 1, 4, 7 ox = -1 if @map_x > LEFT - when 8 # up - oy = -1 if @map_y > TOP - when 9 # upper right - oy = -1 if @map_y > TOP + when 3, 6, 9 ox = 1 if @map_x < RIGHT end if ox != 0 || oy != 0 @@ -319,18 +306,19 @@ class PokemonRegionMap_Scene else break end - elsif Input.trigger?(Input::USE) && @mode == 1 # Choosing an area to fly to + elsif Input.trigger?(Input::USE) && @mode == 1 # Choosing an area to fly to healspot = pbGetHealingSpot(@map_x, @map_y) - if healspot && - ($PokemonGlobal.visitedMaps[healspot[0]] || ($DEBUG && Input.press?(Input::CTRL))) + if healspot && ($PokemonGlobal.visitedMaps[healspot[0]] || + ($DEBUG && Input.press?(Input::CTRL))) + return healspot if @fly_map name = pbGetMapNameFromId(healspot[0]) - return healspot if @fly_map || pbConfirmMessage(_INTL("Would you like to fly to {1}?", name)) { pbUpdate } + return healspot if pbConfirmMessage(_INTL("Would you like to fly to {1}?", name)) { pbUpdate } end elsif Input.trigger?(Input::USE) && @editor # Intentionally after other USE input check pbChangeMapLocation(@map_x, @map_y) elsif Input.trigger?(Input::ACTION) && !@wallmap && !@fly_map && pbCanFly? pbPlayDecisionSE - @mode = (@mode == 1 ? 0 : 1) + @mode = (@mode == 1) ? 0 : 1 refresh_fly_screen end end