Fixed up code added by previous commit, improved scene closings when using Fly

This commit is contained in:
Maruno17
2021-10-19 22:18:55 +01:00
parent e4e8e60d28
commit e7522321ad
9 changed files with 181 additions and 173 deletions

View File

@@ -254,10 +254,8 @@ module Settings
[0, 52, 20, 14, "mapHiddenFaraday", false] [0, 52, 20, 14, "mapHiddenFaraday", false]
] ]
# Allow the player to fly to a known location directly from the Town Map. # Whether the player can use Fly while looking at the Town Map. This is only
# Checks will still be made for things like badges, dependent events, # allowed if the player can use Fly normally.
# whether the player has a Pokemon in their party that knows Fly and
# whether the player is indoors.
CAN_FLY_FROM_TOWN_MAP = true CAN_FLY_FROM_TOWN_MAP = true
#============================================================================= #=============================================================================

View File

@@ -563,7 +563,9 @@ def pbFadeOutIn(z=99999,nofadeout=false)
end end
pbPushFade pbPushFade
begin 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 ensure
pbPopFade pbPopFade
if !nofadeout if !nofadeout

View File

@@ -492,46 +492,34 @@ HiddenMoveHandlers::UseMove.add(:FLASH,proc { |move,pokemon|
#=============================================================================== #===============================================================================
# Fly # Fly
#=============================================================================== #===============================================================================
HiddenMoveHandlers::CanUseMove.add(:FLY,proc { |move,pkmn,showmsg| def pbCanFly?(pkmn = nil, show_messages = false)
next pbCanFly?(pkmn, showmsg) return false if !pbCheckHiddenMoveBadge(Settings::BADGE_FOR_FLY, show_messages)
}) return false if !$DEBUG && !pkmn && !$Trainer.get_pokemon_with_move(:FLY)
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)
if $game_player.has_follower? 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 return false
end end
if !$game_map.metadata&.outdoor_map 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 return false
end end
return true return true
end end
def pbFlyToNewLocation(pkmn = nil, move = :FLY) def pbFlyToNewLocation(pkmn = nil, move = :FLY)
if !pkmn return false if !$PokemonTemp.flydata
fly_party = $Trainer.pokemon_party.select { |poke| poke.hasMove?(move) } pkmn = $Trainer.get_pokemon_with_move(move) if !pkmn
return false if fly_party.empty? && !$DEBUG if !$DEBUG && !pkmn
pkmn = fly_party[0] $PokemonTemp.flydata = nil
yield if block_given?
return false
end end
if !pkmn || !pbHiddenMoveAnimation(pkmn) 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)) pbMessage(_INTL("{1} used {2}!", name, GameData::Move.get(move).name))
end end
return false if !$PokemonTemp.flydata
pbFadeOutIn { pbFadeOutIn {
pbSEPlay("Anim/Wind1") pbSEPlay("Fly")
$game_temp.player_new_map_id = $PokemonTemp.flydata[0] $game_temp.player_new_map_id = $PokemonTemp.flydata[0]
$game_temp.player_new_x = $PokemonTemp.flydata[1] $game_temp.player_new_x = $PokemonTemp.flydata[1]
$game_temp.player_new_y = $PokemonTemp.flydata[2] $game_temp.player_new_y = $PokemonTemp.flydata[2]
@@ -541,12 +529,25 @@ def pbFlyToNewLocation(pkmn = nil, move = :FLY)
$game_map.autoplay $game_map.autoplay
$game_map.refresh $game_map.refresh
yield if block_given? yield if block_given?
pbWait(Graphics.frame_rate/4) pbWait(Graphics.frame_rate / 4)
} }
pbEraseEscapePoint pbEraseEscapePoint
return true return true
end 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
})
#=============================================================================== #===============================================================================

View File

@@ -53,9 +53,15 @@ ItemHandlers::UseFromBag.add(:ITEMFINDER,proc { |item|
ItemHandlers::UseFromBag.copy(:ITEMFINDER,:DOWSINGMCHN,:DOWSINGMACHINE) ItemHandlers::UseFromBag.copy(:ITEMFINDER,:DOWSINGMCHN,:DOWSINGMACHINE)
ItemHandlers::UseFromBag.add(:TOWNMAP,proc { |item| ItemHandlers::UseFromBag.add(:TOWNMAP, proc { |item|
pbShowMap(-1, false) pbFadeOutIn {
next ($PokemonTemp.flydata ? 2 : 0) 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.copy(:ITEMFINDER,:DOWSINGMCHN,:DOWSINGMACHINE)
ItemHandlers::UseInField.add(:TOWNMAP,proc { |item| ItemHandlers::UseInField.add(:TOWNMAP, proc { |item|
ret = false pbShowMap(-1, false) if !$PokemonTemp.flydata
if !$PokemonTemp.flydata
pbShowMap(-1, false)
ret = !$PokemonTemp.flydata.nil?
end
pbFlyToNewLocation pbFlyToNewLocation
next ret next true
}) })
ItemHandlers::UseInField.add(:COINCASE,proc { |item| ItemHandlers::UseInField.add(:COINCASE,proc { |item|

View File

@@ -115,14 +115,16 @@ class PokemonPauseMenu
cmdQuit = -1 cmdQuit = -1
cmdEndGame = -1 cmdEndGame = -1
if $Trainer.has_pokedex && $Trainer.pokedex.accessible_dexes.length > 0 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 end
commands[cmdPokemon = commands.length] = _INTL("Pokémon") if $Trainer.party_count > 0 commands[cmdPokemon = commands.length] = _INTL("Pokémon") if $Trainer.party_count > 0
commands[cmdBag = commands.length] = _INTL("Bag") if !pbInBugContest? commands[cmdBag = commands.length] = _INTL("Bag") if !pbInBugContest?
commands[cmdPokegear = commands.length] = _INTL("Pokégear") if $Trainer.has_pokegear 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[cmdPokegear = commands.length] = _INTL("Pokégear")
commands[cmdTownMap = commands.length] = _INTL("Town Map") if $PokemonBag.pbHasItem?(:TOWNMAP) && !$Trainer.has_pokegear elsif $bag.has?(:TOWNMAP)
commands[cmdTrainer = commands.length] = $Trainer.name commands[cmdTownMap = commands.length] = _INTL("Town Map")
end
commands[cmdTrainer = commands.length] = $Trainer.name
if pbInSafari? if pbInSafari?
if Settings::SAFARI_STEPS <= 0 if Settings::SAFARI_STEPS <= 0
@scene.pbShowInfo(_INTL("Balls: {1}",pbSafariState.ballcount)) @scene.pbShowInfo(_INTL("Balls: {1}",pbSafariState.ballcount))
@@ -130,7 +132,7 @@ class PokemonPauseMenu
@scene.pbShowInfo(_INTL("Steps: {1}/{2}\nBalls: {3}", @scene.pbShowInfo(_INTL("Steps: {1}/{2}\nBalls: {3}",
pbSafariState.steps, Settings::SAFARI_STEPS, pbSafariState.ballcount)) pbSafariState.steps, Settings::SAFARI_STEPS, pbSafariState.ballcount))
end end
commands[cmdQuit = commands.length] = _INTL("Quit") commands[cmdQuit = commands.length] = _INTL("Quit")
elsif pbInBugContest? elsif pbInBugContest?
if pbBugContestState.lastPokemon if pbBugContestState.lastPokemon
@scene.pbShowInfo(_INTL("Caught: {1}\nLevel: {2}\nBalls: {3}", @scene.pbShowInfo(_INTL("Caught: {1}\nLevel: {2}\nBalls: {3}",
@@ -140,13 +142,13 @@ class PokemonPauseMenu
else else
@scene.pbShowInfo(_INTL("Caught: None\nBalls: {1}",pbBugContestState.ballcount)) @scene.pbShowInfo(_INTL("Caught: None\nBalls: {1}",pbBugContestState.ballcount))
end end
commands[cmdQuit = commands.length] = _INTL("Quit Contest") commands[cmdQuit = commands.length] = _INTL("Quit Contest")
else 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 end
commands[cmdOption = commands.length] = _INTL("Options") commands[cmdOption = commands.length] = _INTL("Options")
commands[cmdDebug = commands.length] = _INTL("Debug") if $DEBUG commands[cmdDebug = commands.length] = _INTL("Debug") if $DEBUG
commands[cmdEndGame = commands.length] = _INTL("Quit Game") commands[cmdEndGame = commands.length] = _INTL("Quit Game")
loop do loop do
command = @scene.pbShowCommands(commands) command = @scene.pbShowCommands(commands)
if cmdPokedex>=0 && command==cmdPokedex if cmdPokedex>=0 && command==cmdPokedex
@@ -212,17 +214,16 @@ class PokemonPauseMenu
screen.pbStartScreen screen.pbStartScreen
($PokemonTemp.flydata) ? @scene.pbEndScene : @scene.pbRefresh ($PokemonTemp.flydata) ? @scene.pbEndScene : @scene.pbRefresh
} }
if pbFlyToNewLocation return if pbFlyToNewLocation
$game_temp.in_menu = false
return
end
elsif cmdTownMap>=0 && command==cmdTownMap elsif cmdTownMap>=0 && command==cmdTownMap
pbShowMap(-1, false) pbFadeOutIn {
($PokemonTemp.flydata) ? @scene.pbEndScene : @scene.pbRefresh scene = PokemonRegionMap_Scene.new(-1, false)
if pbFlyToNewLocation screen = PokemonRegionMapScreen.new(scene)
$game_temp.in_menu = false ret = screen.pbStartScreen
return $PokemonTemp.flydata = ret if ret
end ($PokemonTemp.flydata) ? @scene.pbEndScene : @scene.pbRefresh
}
return if pbFlyToNewLocation
elsif cmdTrainer>=0 && command==cmdTrainer elsif cmdTrainer>=0 && command==cmdTrainer
pbPlayDecisionSE pbPlayDecisionSE
pbFadeOutIn { pbFadeOutIn {

View File

@@ -30,8 +30,8 @@ class PokemonPokedexInfo_Scene
if hidden[0]==@region && hidden[1]>0 && $game_switches[hidden[1]] if hidden[0]==@region && hidden[1]>0 && $game_switches[hidden[1]]
pbDrawImagePositions(@sprites["areamap"].bitmap,[ pbDrawImagePositions(@sprites["areamap"].bitmap,[
["Graphics/Pictures/#{hidden[4]}", ["Graphics/Pictures/#{hidden[4]}",
hidden[2]*PokemonRegionMap_Scene::SQUAREWIDTH, hidden[2]*PokemonRegionMap_Scene::SQUARE_WIDTH,
hidden[3]*PokemonRegionMap_Scene::SQUAREHEIGHT] hidden[3]*PokemonRegionMap_Scene::SQUARE_HEIGHT]
]) ])
end end
end end
@@ -334,8 +334,8 @@ class PokemonPokedexInfo_Scene
# Draw coloured squares on each square of the region map with a nest # Draw coloured squares on each square of the region map with a nest
pointcolor = Color.new(0,248,248) pointcolor = Color.new(0,248,248)
pointcolorhl = Color.new(192,248,248) pointcolorhl = Color.new(192,248,248)
sqwidth = PokemonRegionMap_Scene::SQUAREWIDTH sqwidth = PokemonRegionMap_Scene::SQUARE_WIDTH
sqheight = PokemonRegionMap_Scene::SQUAREHEIGHT sqheight = PokemonRegionMap_Scene::SQUARE_HEIGHT
for j in 0...points.length for j in 0...points.length
if points[j] if points[j]
x = (j%mapwidth)*sqwidth x = (j%mapwidth)*sqwidth

View File

@@ -227,6 +227,10 @@ class PokemonBag_Scene
def pbEndScene def pbEndScene
pbFadeOutAndHide(@sprites) if !@oldsprites pbFadeOutAndHide(@sprites) if !@oldsprites
@oldsprites = nil @oldsprites = nil
dispose
end
def dispose
pbDisposeSpriteHash(@sprites) pbDisposeSpriteHash(@sprites)
@sliderbitmap.dispose @sliderbitmap.dispose
@pocketbitmap.dispose @pocketbitmap.dispose
@@ -563,7 +567,7 @@ class PokemonBagScreen
end end
end end
end end
@scene.pbEndScene ($PokemonTemp.flydata) ? @scene.dispose : @scene.pbEndScene
return item return item
end end

View File

@@ -110,6 +110,10 @@ class PokemonPokegear_Scene
def pbEndScene def pbEndScene
pbFadeOutAndHide(@sprites) { pbUpdate } pbFadeOutAndHide(@sprites) { pbUpdate }
dispose
end
def dispose
pbDisposeSpriteHash(@sprites) pbDisposeSpriteHash(@sprites)
@viewport.dispose @viewport.dispose
end end
@@ -139,7 +143,15 @@ class PokemonPokegearScreen
if cmd<0 if cmd<0
break break
elsif cmdMap>=0 && cmd==cmdMap 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 break if $PokemonTemp.flydata
elsif cmdPhone>=0 && cmd==cmdPhone elsif cmdPhone>=0 && cmd==cmdPhone
pbFadeOutIn { pbFadeOutIn {
@@ -153,6 +165,6 @@ class PokemonPokegearScreen
} }
end end
end end
@scene.pbEndScene ($PokemonTemp.flydata) ? @scene.dispose : @scene.pbEndScene
end end
end end

View File

@@ -4,45 +4,44 @@
class MapBottomSprite < SpriteWrapper class MapBottomSprite < SpriteWrapper
attr_reader :mapname, :maplocation attr_reader :mapname, :maplocation
TEXT_MAIN_COLOR = Color.new(248, 248, 248)
TEXT_SHADOW_COLOR = Color.new(0, 0, 0)
def initialize(viewport = nil) def initialize(viewport = nil)
super(viewport) super(viewport)
@mapname = "" @mapname = ""
@maplocation = "" @maplocation = ""
@mapdetails = "" @mapdetails = ""
@thisbitmap = BitmapWrapper.new(Graphics.width, Graphics.height)
self.bitmap = BitmapWrapper.new(Graphics.width, Graphics.height) self.bitmap = BitmapWrapper.new(Graphics.width, Graphics.height)
pbSetSystemFont(self.bitmap) pbSetSystemFont(self.bitmap)
refresh refresh
end end
def mapname=(value) def mapname=(value)
if @mapname != value return if @mapname == value
@mapname = value @mapname = value
refresh refresh
end
end end
def maplocation=(value) def maplocation=(value)
if @maplocation != value return if @maplocation == value
@maplocation = value @maplocation = value
refresh refresh
end
end end
# From Wichu # From Wichu
def mapdetails=(value) def mapdetails=(value)
if @mapdetails != value return if @mapdetails == value
@mapdetails = value @mapdetails = value
refresh refresh
end
end end
def refresh def refresh
bitmap.clear bitmap.clear
textpos = [ textpos = [
[@mapname, 18, -8, 0, Color.new(248, 248, 248), Color.new(0, 0, 0)], [@mapname, 18, -8, 0, TEXT_MAIN_COLOR, TEXT_SHADOW_COLOR],
[@maplocation, 18, 348, 0, Color.new(248, 248, 248), Color.new(0, 0, 0)], [@maplocation, 18, 348, 0, TEXT_MAIN_COLOR, TEXT_SHADOW_COLOR],
[@mapdetails, Graphics.width - 16, 348, 1, Color.new(248, 248, 248), Color.new(0, 0, 0)] [@mapdetails, Graphics.width - 16, 348, 1, TEXT_MAIN_COLOR, TEXT_SHADOW_COLOR]
] ]
pbDrawTextPositions(bitmap, textpos) pbDrawTextPositions(bitmap, textpos)
end end
@@ -77,17 +76,17 @@ class PokemonRegionMap_Scene
@fly_map = fly_map @fly_map = fly_map
@mode = fly_map ? 1 : 0 @mode = fly_map ? 1 : 0
map_metadata = GameData::MapMetadata.try_get($game_map.map_id) 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 if !playerpos
mapindex = 0 mapindex = 0
@map = @map_data[0] @map = @map_data[0]
@map_x = LEFT @map_x = LEFT
@map_y = TOP @map_y = TOP
elsif @region >= 0 && @region != playerpos[0] && @map_data[@region] elsif @region >= 0 && @region != playerpos[0] && @map_data[@region]
mapindex = @region mapindex = @region
@map = @map_data[@region] @map = @map_data[@region]
@map_x = LEFT @map_x = LEFT
@map_y = TOP @map_y = TOP
else else
mapindex = playerpos[0] mapindex = playerpos[0]
@map = @map_data[playerpos[0]] @map = @map_data[playerpos[0]]
@@ -96,12 +95,12 @@ class PokemonRegionMap_Scene
mapsize = map_metadata.town_map_size mapsize = map_metadata.town_map_size
if mapsize && mapsize[0] && mapsize[0] > 0 if mapsize && mapsize[0] && mapsize[0] > 0
sqwidth = mapsize[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_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 @map_y += ($game_player.y * sqheight / $game_map.height).floor if sqheight > 1
end end
end end
unless @map if !@map
pbMessage(_INTL("The map data cannot be found.")) pbMessage(_INTL("The map data cannot be found."))
return false return false
end end
@@ -110,16 +109,16 @@ class PokemonRegionMap_Scene
@sprites["map"].setBitmap("Graphics/Pictures/#{@map[1]}") @sprites["map"].setBitmap("Graphics/Pictures/#{@map[1]}")
@sprites["map"].x += (Graphics.width - @sprites["map"].bitmap.width) / 2 @sprites["map"].x += (Graphics.width - @sprites["map"].bitmap.width) / 2
@sprites["map"].y += (Graphics.height - @sprites["map"].bitmap.height) / 2 @sprites["map"].y += (Graphics.height - @sprites["map"].bitmap.height) / 2
Settings::REGION_MAP_EXTRAS.each do |hidden| Settings::REGION_MAP_EXTRAS.each do |graphic|
next unless hidden[0] == mapindex && ((@wallmap && hidden[5]) || location_hidden?(hidden[1])) next if graphic[0] != mapindex || !location_shown?(graphic)
unless @sprites["map2"] if !@sprites["map2"]
@sprites["map2"] = BitmapSprite.new(480, 320, @viewport) @sprites["map2"] = BitmapSprite.new(480, 320, @viewport)
@sprites["map2"].x = @sprites["map"].x @sprites["map2"].x = @sprites["map"].x
@sprites["map2"].y = @sprites["map"].y @sprites["map2"].y = @sprites["map"].y
end end
pbDrawImagePositions(@sprites["map2"].bitmap, [ 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 end
@sprites["mapbottom"] = MapBottomSprite.new(@viewport) @sprites["mapbottom"] = MapBottomSprite.new(@viewport)
@sprites["mapbottom"].mapname = pbGetMessage(MessageTypes::RegionNames, mapindex) @sprites["mapbottom"].mapname = pbGetMessage(MessageTypes::RegionNames, mapindex)
@@ -128,18 +127,18 @@ class PokemonRegionMap_Scene
if playerpos && mapindex == playerpos[0] if playerpos && mapindex == playerpos[0]
@sprites["player"] = IconSprite.new(0, 0, @viewport) @sprites["player"] = IconSprite.new(0, 0, @viewport)
@sprites["player"].setBitmap(GameData::TrainerType.player_map_icon_filename($Trainer.trainer_type)) @sprites["player"].setBitmap(GameData::TrainerType.player_map_icon_filename($Trainer.trainer_type))
@sprites["player"].x = get_x_coord_on_grid(@map_x) @sprites["player"].x = point_x_to_screen_x(@map_x)
@sprites["player"].y = get_y_coord_on_grid(@map_y) @sprites["player"].y = point_y_to_screen_y(@map_y)
end end
k = 0 k = 0
(LEFT..RIGHT).each do |i| (LEFT..RIGHT).each do |i|
(TOP..BOTTOM).each do |j| (TOP..BOTTOM).each do |j|
healspot = pbGetHealingSpot(i, 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}"] = AnimatedSprite.create("Graphics/Pictures/mapFly", 2, 16)
@sprites["point#{k}"].viewport = @viewport @sprites["point#{k}"].viewport = @viewport
@sprites["point#{k}"].x = get_x_coord_on_grid(i) @sprites["point#{k}"].x = point_x_to_screen_x(i)
@sprites["point#{k}"].y = get_y_coord_on_grid(j) @sprites["point#{k}"].y = point_y_to_screen_y(j)
@sprites["point#{k}"].visible = @mode == 1 @sprites["point#{k}"].visible = @mode == 1
@sprites["point#{k}"].play @sprites["point#{k}"].play
k += 1 k += 1
@@ -147,25 +146,33 @@ class PokemonRegionMap_Scene
end end
@sprites["cursor"] = AnimatedSprite.create("Graphics/Pictures/mapCursor", 2, 5) @sprites["cursor"] = AnimatedSprite.create("Graphics/Pictures/mapCursor", 2, 5)
@sprites["cursor"].viewport = @viewport @sprites["cursor"].viewport = @viewport
@sprites["cursor"].x = get_x_coord_on_grid(@map_x) @sprites["cursor"].x = point_x_to_screen_x(@map_x)
@sprites["cursor"].y = get_y_coord_on_grid(@map_y) @sprites["cursor"].y = point_y_to_screen_y(@map_y)
@sprites["cursor"].play @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 refresh_fly_screen
@changed = false @changed = false
pbFadeInAndShow(@sprites) { pbUpdate } pbFadeInAndShow(@sprites) { pbUpdate }
end 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 return -SQUARE_WIDTH / 2 + (x * SQUARE_WIDTH) + (Graphics.width - @sprites["map"].bitmap.width) / 2
end 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 return -SQUARE_HEIGHT / 2 + (y * SQUARE_HEIGHT) + (Graphics.height - @sprites["map"].bitmap.height) / 2
end end
def location_hidden?(loc) def location_shown?(point)
return !@wallmap && loc.is_a?(Integer) && loc >0 && $game_switches[loc] return point[5] if @wallmap
return point[1] > 0 && $game_switches[point[1]]
end end
# TODO: Why is this PBS file writer here? # TODO: Why is this PBS file writer here?
@@ -181,35 +188,26 @@ class PokemonRegionMap_Scene
Compiler.csvQuote(map[0]), Compiler.csvQuote(map[1]))) Compiler.csvQuote(map[0]), Compiler.csvQuote(map[1])))
for loc in map[2] for loc in map[2]
f.write("Point = ") f.write("Point = ")
Compiler.pbWriteCsvRecord(loc,f,[nil,"uussUUUU"]) Compiler.pbWriteCsvRecord(loc, f, [nil, "uussUUUU"])
f.write("\r\n") f.write("\r\n")
end end
end end
} }
end end
def pbEndScene
pbFadeOutAndHide(@sprites)
pbDisposeSpriteHash(@sprites)
@viewport.dispose
end
def pbGetMapLocation(x, y) def pbGetMapLocation(x, y)
return "" unless @map[2] return "" if !@map[2]
maps = @map[2].select { |loc| loc[0] == x && loc[1] == y } for point in @map[2]
return "" if maps.empty? next if point[0] != x || point[1] != y
maps.each do |loc| return "" if point[7] && (@wallmap || point[7] <= 0 || !$game_switches[point[7]])
if !location_hidden?(loc[7]) name = pbGetMessageFromHash(MessageTypes::PlaceNames, point[2])
maploc = pbGetMessageFromHash(MessageTypes::PlaceNames, loc[2]) return (@editor) ? point[2] : name
return @editor ? loc[2] : maploc
else
return ""
end
end end
return ""
end end
def pbChangeMapLocation(x,y) def pbChangeMapLocation(x, y)
return "" unless @editor && @map[2] return "" if !@editor || !@map[2]
map = @map[2].select { |loc| loc[0] == x && loc[1] == y }[0] map = @map[2].select { |loc| loc[0] == x && loc[1] == y }[0]
currentobj = map currentobj = map
currentname = map[2] currentname = map[2]
@@ -225,38 +223,37 @@ class PokemonRegionMap_Scene
end end
end end
def pbGetMapDetails(x,y) # From Wichu, with my help def pbGetMapDetails(x, y) # From Wichu, with my help
return "" unless @map[2] return "" if !@map[2]
maps = @map[2].select { |loc| loc[0] == x && loc[1] == y } for point in @map[2]
return "" if maps.empty? next if point[0] != x || point[1] != y
maps.each do |loc| return "" if point[7] && (@wallmap || point[7] <= 0 || !$game_switches[point[7]])
if !location_hidden?(loc[7]) mapdesc = pbGetMessageFromHash(MessageTypes::PlaceDescriptions, point[3])
mapdesc = pbGetMessageFromHash(MessageTypes::PlaceDescriptions,loc[3]) return (@editor) ? point[3] : mapdesc
return (@editor) ? loc[3] : mapdesc
else
return ""
end
end end
return ""
end end
def pbGetHealingSpot(x,y) def pbGetHealingSpot(x, y)
return nil unless @map[2] return nil if !@map[2]
maps = @map[2].select { |loc| loc[0] == x && loc[1] == y } for point in @map[2]
return nil if maps.empty? next if point[0] != x || point[1] != y
maps.each do |loc| return nil if point[7] && (@wallmap || point[7] <= 0 || !$game_switches[point[7]])
return ((loc[4] && loc[5] && loc[6]) ? [loc[4],loc[5],loc[6]] : nil) return (point[4] && point[5] && point[6]) ? [point[4], point[5], point[6]] : nil
end end
return nil
end end
def refresh_fly_screen 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 @sprites["help"].bitmap.clear
pbSetSystemFont(@sprites["help"].bitmap) text = (@mode == 0) ? _INTL("ACTION: Fly") : _INTL("ACTION: Cancel Fly")
text = @mode == 0 ? _INTL("ACTION: Open Fly Menu") : _INTL("ACTION: Close Fly Menu") pbDrawTextPositions(@sprites["help"].bitmap, [
pbDrawTextPositions(@sprites["help"].bitmap, [[text, Graphics.width - 8, -8, 1, Color.new(248,248,248), Color.new(0,0,0)]]) [text, Graphics.width - 16, -8, 1, Color.new(248, 248, 248), Color.new(0, 0, 0)]
])
@sprites.each do |key, sprite| @sprites.each do |key, sprite|
next if !key.include?("point") next if !key.include?("point")
sprite.visible = @mode == 1 sprite.visible = (@mode == 1)
sprite.frame = 0 sprite.frame = 0
end end
end end
@@ -281,25 +278,15 @@ class PokemonRegionMap_Scene
ox = 0 ox = 0
oy = 0 oy = 0
case Input.dir8 case Input.dir8
when 1 # lower left when 1, 2, 3
oy = 1 if @map_y < BOTTOM oy = 1 if @map_y < BOTTOM
ox = -1 if @map_x > LEFT when 7, 8, 9
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
oy = -1 if @map_y > TOP oy = -1 if @map_y > TOP
end
case Input.dir8
when 1, 4, 7
ox = -1 if @map_x > LEFT ox = -1 if @map_x > LEFT
when 8 # up when 3, 6, 9
oy = -1 if @map_y > TOP
when 9 # upper right
oy = -1 if @map_y > TOP
ox = 1 if @map_x < RIGHT ox = 1 if @map_x < RIGHT
end end
if ox != 0 || oy != 0 if ox != 0 || oy != 0
@@ -319,18 +306,19 @@ class PokemonRegionMap_Scene
else else
break break
end 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) healspot = pbGetHealingSpot(@map_x, @map_y)
if healspot && if healspot && ($PokemonGlobal.visitedMaps[healspot[0]] ||
($PokemonGlobal.visitedMaps[healspot[0]] || ($DEBUG && Input.press?(Input::CTRL))) ($DEBUG && Input.press?(Input::CTRL)))
return healspot if @fly_map
name = pbGetMapNameFromId(healspot[0]) 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 end
elsif Input.trigger?(Input::USE) && @editor # Intentionally after other USE input check elsif Input.trigger?(Input::USE) && @editor # Intentionally after other USE input check
pbChangeMapLocation(@map_x, @map_y) pbChangeMapLocation(@map_x, @map_y)
elsif Input.trigger?(Input::ACTION) && !@wallmap && !@fly_map && pbCanFly? elsif Input.trigger?(Input::ACTION) && !@wallmap && !@fly_map && pbCanFly?
pbPlayDecisionSE pbPlayDecisionSE
@mode = (@mode == 1 ? 0 : 1) @mode = (@mode == 1) ? 0 : 1
refresh_fly_screen refresh_fly_screen
end end
end end