Added Flying from Town Map (#129)

* Added ability to fly from Town Map

* Refactored UI_RegionMap code
This commit is contained in:
Golisopod-User
2021-10-20 00:33:22 +05:30
committed by GitHub
parent 837208792a
commit e4e8e60d28
7 changed files with 264 additions and 215 deletions

View File

@@ -254,6 +254,12 @@ 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.
# 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.
CAN_FLY_FROM_TOWN_MAP = true
#============================================================================= #=============================================================================
# A list of maps used by roaming Pokémon. Each map has an array of other maps # A list of maps used by roaming Pokémon. Each map has an array of other maps

View File

@@ -493,16 +493,7 @@ HiddenMoveHandlers::UseMove.add(:FLASH,proc { |move,pokemon|
# Fly # Fly
#=============================================================================== #===============================================================================
HiddenMoveHandlers::CanUseMove.add(:FLY,proc { |move,pkmn,showmsg| HiddenMoveHandlers::CanUseMove.add(:FLY,proc { |move,pkmn,showmsg|
next false if !pbCheckHiddenMoveBadge(Settings::BADGE_FOR_FLY,showmsg) next pbCanFly?(pkmn, showmsg)
if $game_player.has_follower?
pbMessage(_INTL("It can't be used when you have someone with you.")) if showmsg
next false
end
if !$game_map.metadata&.outdoor_map
pbMessage(_INTL("Can't use that here.")) if showmsg
next false
end
next true
}) })
HiddenMoveHandlers::UseMove.add(:FLY,proc { |move,pokemon| HiddenMoveHandlers::UseMove.add(:FLY,proc { |move,pokemon|
@@ -510,10 +501,37 @@ HiddenMoveHandlers::UseMove.add(:FLY,proc { |move,pokemon|
pbMessage(_INTL("Can't use that here.")) pbMessage(_INTL("Can't use that here."))
next false next false
end end
if !pbHiddenMoveAnimation(pokemon) pbFlyToNewLocation(pokemon)
pbMessage(_INTL("{1} used {2}!",pokemon.name,GameData::Move.get(move).name)) 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?
pbMessage(_INTL("It can't be used when you have someone with you.")) if showmsg
return false
end end
if !$game_map.metadata&.outdoor_map
pbMessage(_INTL("Can't use that here.")) if showmsg
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]
end
if !pkmn || !pbHiddenMoveAnimation(pkmn)
name = !pkmn ? $Trainer.name : pkmn.name
pbMessage(_INTL("{1} used {2}!", name, GameData::Move.get(move).name))
end
return false if !$PokemonTemp.flydata
pbFadeOutIn { pbFadeOutIn {
pbSEPlay("Anim/Wind1")
$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]
@@ -522,10 +540,12 @@ HiddenMoveHandlers::UseMove.add(:FLY,proc { |move,pokemon|
$scene.transfer_player $scene.transfer_player
$game_map.autoplay $game_map.autoplay
$game_map.refresh $game_map.refresh
yield if block_given?
pbWait(Graphics.frame_rate/4)
} }
pbEraseEscapePoint pbEraseEscapePoint
next true return true
}) end

View File

@@ -53,6 +53,11 @@ ItemHandlers::UseFromBag.add(:ITEMFINDER,proc { |item|
ItemHandlers::UseFromBag.copy(:ITEMFINDER,:DOWSINGMCHN,:DOWSINGMACHINE) ItemHandlers::UseFromBag.copy(:ITEMFINDER,:DOWSINGMCHN,:DOWSINGMACHINE)
ItemHandlers::UseFromBag.add(:TOWNMAP,proc { |item|
pbShowMap(-1, false)
next ($PokemonTemp.flydata ? 2 : 0)
})
#=============================================================================== #===============================================================================
# ConfirmUseInField handlers # ConfirmUseInField handlers
# Return values: true/false # Return values: true/false
@@ -302,8 +307,13 @@ 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|
pbShowMap(-1,false) ret = false
next true if !$PokemonTemp.flydata
pbShowMap(-1, false)
ret = !$PokemonTemp.flydata.nil?
end
pbFlyToNewLocation
next ret
}) })
ItemHandlers::UseInField.add(:COINCASE,proc { |item| ItemHandlers::UseInField.add(:COINCASE,proc { |item|

View File

@@ -110,6 +110,7 @@ class PokemonPauseMenu
cmdSave = -1 cmdSave = -1
cmdOption = -1 cmdOption = -1
cmdPokegear = -1 cmdPokegear = -1
cmdTownMap = -1
cmdDebug = -1 cmdDebug = -1
cmdQuit = -1 cmdQuit = -1
cmdEndGame = -1 cmdEndGame = -1
@@ -119,6 +120,8 @@ class PokemonPauseMenu
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 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[cmdTrainer = commands.length] = $Trainer.name
if pbInSafari? if pbInSafari?
if Settings::SAFARI_STEPS <= 0 if Settings::SAFARI_STEPS <= 0
@@ -207,8 +210,19 @@ class PokemonPauseMenu
scene = PokemonPokegear_Scene.new scene = PokemonPokegear_Scene.new
screen = PokemonPokegearScreen.new(scene) screen = PokemonPokegearScreen.new(scene)
screen.pbStartScreen screen.pbStartScreen
@scene.pbRefresh ($PokemonTemp.flydata) ? @scene.pbEndScene : @scene.pbRefresh
} }
if pbFlyToNewLocation
$game_temp.in_menu = false
return
end
elsif cmdTownMap>=0 && command==cmdTownMap
pbShowMap(-1, false)
($PokemonTemp.flydata) ? @scene.pbEndScene : @scene.pbRefresh
if pbFlyToNewLocation
$game_temp.in_menu = false
return
end
elsif cmdTrainer>=0 && command==cmdTrainer elsif cmdTrainer>=0 && command==cmdTrainer
pbPlayDecisionSE pbPlayDecisionSE
pbFadeOutIn { pbFadeOutIn {

View File

@@ -140,6 +140,7 @@ class PokemonPokegearScreen
break break
elsif cmdMap>=0 && cmd==cmdMap elsif cmdMap>=0 && cmd==cmdMap
pbShowMap(-1,false) pbShowMap(-1,false)
break if $PokemonTemp.flydata
elsif cmdPhone>=0 && cmd==cmdPhone elsif cmdPhone>=0 && cmd==cmdPhone
pbFadeOutIn { pbFadeOutIn {
PokemonPhoneScene.new.start PokemonPhoneScene.new.start

View File

@@ -2,56 +2,49 @@
# #
#=============================================================================== #===============================================================================
class MapBottomSprite < SpriteWrapper class MapBottomSprite < SpriteWrapper
attr_reader :mapname attr_reader :mapname, :maplocation
attr_reader :maplocation
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) @thisbitmap = BitmapWrapper.new(Graphics.width, Graphics.height)
pbSetSystemFont(@thisbitmap) self.bitmap = BitmapWrapper.new(Graphics.width, Graphics.height)
self.x = 0 pbSetSystemFont(self.bitmap)
self.y = 0
self.bitmap = @thisbitmap
refresh refresh
end end
def dispose
@thisbitmap.dispose
super
end
def mapname=(value) def mapname=(value)
if @mapname!=value if @mapname != value
@mapname = value @mapname = value
refresh refresh
end end
end end
def maplocation=(value) def maplocation=(value)
if @maplocation!=value if @maplocation != value
@maplocation = value @maplocation = value
refresh refresh
end end
end end
def mapdetails=(value) # From Wichu # From Wichu
if @mapdetails!=value def mapdetails=(value)
if @mapdetails != value
@mapdetails = value @mapdetails = value
refresh refresh
end end
end end
def refresh def refresh
self.bitmap.clear bitmap.clear
textpos = [ textpos = [
[@mapname,18,-8,0,Color.new(248,248,248),Color.new(0,0,0)], [@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)], [@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)] [@mapdetails, Graphics.width - 16, 348, 1, Color.new(248, 248, 248), Color.new(0, 0, 0)]
] ]
pbDrawTextPositions(self.bitmap,textpos) pbDrawTextPositions(bitmap, textpos)
end end
end end
@@ -59,14 +52,14 @@ end
# #
#=============================================================================== #===============================================================================
class PokemonRegionMap_Scene class PokemonRegionMap_Scene
LEFT = 0 LEFT = 0
TOP = 0 TOP = 0
RIGHT = 29 RIGHT = 29
BOTTOM = 19 BOTTOM = 19
SQUAREWIDTH = 16 SQUARE_WIDTH = 16
SQUAREHEIGHT = 16 SQUARE_HEIGHT = 16
def initialize(region=-1,wallmap=true) def initialize(region =- 1, wallmap = true)
@region = region @region = region
@wallmap = wallmap @wallmap = wallmap
end end
@@ -75,105 +68,112 @@ class PokemonRegionMap_Scene
pbUpdateSpriteHash(@sprites) pbUpdateSpriteHash(@sprites)
end end
def pbStartScene(aseditor=false,mode=0) def pbStartScene(as_editor = false, fly_map = false)
@editor = aseditor @editor = as_editor
@viewport = Viewport.new(0,0,Graphics.width,Graphics.height) @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
@viewport.z = 99999 @viewport.z = 99999
@sprites = {} @sprites = {}
@mapdata = pbLoadTownMapData @map_data = pbLoadTownMapData
map_metadata = $game_map.metadata @fly_map = fly_map
playerpos = (map_metadata) ? map_metadata.town_map_position : nil @mode = fly_map ? 1 : 0
map_metadata = GameData::MapMetadata.try_get($game_map.map_id)
playerpos = map_metadata ? map_metadata.town_map_position : nil
if !playerpos if !playerpos
mapindex = 0 mapindex = 0
@map = @mapdata[0] @map = @map_data[0]
@mapX = LEFT @map_x = LEFT
@mapY = TOP @map_y = TOP
elsif @region>=0 && @region!=playerpos[0] && @mapdata[@region] elsif @region >= 0 && @region != playerpos[0] && @map_data[@region]
mapindex = @region mapindex = @region
@map = @mapdata[@region] @map = @map_data[@region]
@mapX = LEFT @map_x = LEFT
@mapY = TOP @map_y = TOP
else else
mapindex = playerpos[0] mapindex = playerpos[0]
@map = @mapdata[playerpos[0]] @map = @map_data[playerpos[0]]
@mapX = playerpos[1] @map_x = playerpos[1]
@mapY = playerpos[2] @map_y = playerpos[2]
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 * 1.0 / mapsize[0]).ceil
if sqwidth>1 @map_x += ($game_player.x * sqwidth / $game_map.width).floor if sqwidth > 1
@mapX += ($game_player.x*sqwidth/$game_map.width).floor @map_y += ($game_player.y * sqheight / $game_map.height).floor if sqheight > 1
end
if sqheight>1
@mapY += ($game_player.y*sqheight/$game_map.height).floor
end
end end
end end
if !@map unless @map
pbMessage(_INTL("The map data cannot be found.")) pbMessage(_INTL("The map data cannot be found."))
return false return false
end end
addBackgroundOrColoredPlane(@sprites,"background","mapbg",Color.new(0,0,0),@viewport) addBackgroundOrColoredPlane(@sprites, "background", "mapbg", Color.new(0, 0, 0), @viewport)
@sprites["map"] = IconSprite.new(0,0,@viewport) @sprites["map"] = IconSprite.new(0, 0, @viewport)
@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
for hidden in Settings::REGION_MAP_EXTRAS Settings::REGION_MAP_EXTRAS.each do |hidden|
if hidden[0]==mapindex && ((@wallmap && hidden[5]) || next unless hidden[0] == mapindex && ((@wallmap && hidden[5]) || location_hidden?(hidden[1]))
(!@wallmap && hidden[1]>0 && $game_switches[hidden[1]])) 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
pbDrawImagePositions(@sprites["map2"].bitmap,[
["Graphics/Pictures/#{hidden[4]}",hidden[2]*SQUAREWIDTH,hidden[3]*SQUAREHEIGHT]
])
end end
pbDrawImagePositions(@sprites["map2"].bitmap, [
["Graphics/Pictures/#{hidden[4]}", hidden[2] * SQUARE_WIDTH, hidden[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)
@sprites["mapbottom"].maplocation = pbGetMapLocation(@mapX,@mapY) @sprites["mapbottom"].maplocation = pbGetMapLocation(@map_x, @map_y)
@sprites["mapbottom"].mapdetails = pbGetMapDetails(@mapX,@mapY) @sprites["mapbottom"].mapdetails = pbGetMapDetails(@map_x, @map_y)
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 = -SQUAREWIDTH/2+(@mapX*SQUAREWIDTH)+(Graphics.width-@sprites["map"].bitmap.width)/2 @sprites["player"].x = get_x_coord_on_grid(@map_x)
@sprites["player"].y = -SQUAREHEIGHT/2+(@mapY*SQUAREHEIGHT)+(Graphics.height-@sprites["map"].bitmap.height)/2 @sprites["player"].y = get_y_coord_on_grid(@map_y)
end end
if mode>0 k = 0
k = 0 (LEFT..RIGHT).each do |i|
for i in LEFT..RIGHT (TOP..BOTTOM).each do |j|
for j in TOP..BOTTOM healspot = pbGetHealingSpot(i, j)
healspot = pbGetHealingSpot(i,j) next unless healspot && $PokemonGlobal.visitedMaps[healspot[0]]
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 = -SQUAREWIDTH/2+(i*SQUAREWIDTH)+(Graphics.width-@sprites["map"].bitmap.width)/2 @sprites["point#{k}"].y = get_y_coord_on_grid(j)
@sprites["point#{k}"].y = -SQUAREHEIGHT/2+(j*SQUAREHEIGHT)+(Graphics.height-@sprites["map"].bitmap.height)/2 @sprites["point#{k}"].visible = @mode == 1
@sprites["point#{k}"].play @sprites["point#{k}"].play
k += 1 k += 1
end
end
end end
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 = -SQUAREWIDTH/2+(@mapX*SQUAREWIDTH)+(Graphics.width-@sprites["map"].bitmap.width)/2 @sprites["cursor"].x = get_x_coord_on_grid(@map_x)
@sprites["cursor"].y = -SQUAREHEIGHT/2+(@mapY*SQUAREHEIGHT)+(Graphics.height-@sprites["map"].bitmap.height)/2 @sprites["cursor"].y = get_y_coord_on_grid(@map_y)
@sprites["cursor"].play @sprites["cursor"].play
@sprites["help"] = BitmapSprite.new(Graphics.width, 28, @viewport)
refresh_fly_screen
@changed = false @changed = false
pbFadeInAndShow(@sprites) { pbUpdate } pbFadeInAndShow(@sprites) { pbUpdate }
return true end
def get_x_coord_on_grid(x)
return -SQUARE_WIDTH / 2 + (x * SQUARE_WIDTH) + (Graphics.width - @sprites["map"].bitmap.width) / 2
end
def get_y_coord_on_grid(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]
end end
# TODO: Why is this PBS file writer here? # TODO: Why is this PBS file writer here?
def pbSaveMapData def pbSaveMapData
File.open("PBS/town_map.txt","wb") { |f| File.open("PBS/town_map.txt","wb") { |f|
Compiler.add_PBS_header_to_file(f) Compiler.add_PBS_header_to_file(f)
for i in 0...@mapdata.length for i in 0...@map_data.length
map = @mapdata[i] map = @map_data[i]
next if !map next if !map
f.write("\#-------------------------------\r\n") f.write("\#-------------------------------\r\n")
f.write(sprintf("[%d]\r\n",i)) f.write(sprintf("[%d]\r\n",i))
@@ -194,39 +194,31 @@ class PokemonRegionMap_Scene
@viewport.dispose @viewport.dispose
end end
def pbGetMapLocation(x,y) def pbGetMapLocation(x, y)
return "" if !@map[2] return "" unless @map[2]
for loc in @map[2] maps = @map[2].select { |loc| loc[0] == x && loc[1] == y }
if loc[0]==x && loc[1]==y return "" if maps.empty?
if !loc[7] || (!@wallmap && $game_switches[loc[7]]) maps.each do |loc|
maploc = pbGetMessageFromHash(MessageTypes::PlaceNames,loc[2]) if !location_hidden?(loc[7])
return @editor ? loc[2] : maploc maploc = pbGetMessageFromHash(MessageTypes::PlaceNames, loc[2])
else return @editor ? loc[2] : maploc
return "" else
end return ""
end end
end end
return ""
end end
def pbChangeMapLocation(x,y) def pbChangeMapLocation(x,y)
return if !@editor return "" unless @editor && @map[2]
return "" if !@map[2] map = @map[2].select { |loc| loc[0] == x && loc[1] == y }[0]
currentname = "" currentobj = map
currentobj = nil currentname = map[2]
for loc in @map[2] currentname = pbMessageFreeText(_INTL("Set the name for this point."), currentname, false, 250) { pbUpdate }
if loc[0]==x && loc[1]==y
currentobj = loc
currentname = loc[2]
break
end
end
currentname = pbMessageFreeText(_INTL("Set the name for this point."),currentname,false,250) { pbUpdate }
if currentname if currentname
if currentobj if currentobj
currentobj[2] = currentname currentobj[2] = currentname
else else
newobj = [x,y,currentname,""] newobj = [x, y, currentname, ""]
@map[2].push(newobj) @map[2].push(newobj)
end end
@changed = true @changed = true
@@ -234,107 +226,112 @@ class PokemonRegionMap_Scene
end end
def pbGetMapDetails(x,y) # From Wichu, with my help def pbGetMapDetails(x,y) # From Wichu, with my help
return "" if !@map[2] return "" unless @map[2]
for loc in @map[2] maps = @map[2].select { |loc| loc[0] == x && loc[1] == y }
if loc[0]==x && loc[1]==y return "" if maps.empty?
if !loc[7] || (!@wallmap && $game_switches[loc[7]]) maps.each do |loc|
mapdesc = pbGetMessageFromHash(MessageTypes::PlaceDescriptions,loc[3]) if !location_hidden?(loc[7])
return (@editor) ? loc[3] : mapdesc mapdesc = pbGetMessageFromHash(MessageTypes::PlaceDescriptions,loc[3])
else return (@editor) ? loc[3] : mapdesc
return "" else
end return ""
end end
end end
return ""
end end
def pbGetHealingSpot(x,y) def pbGetHealingSpot(x,y)
return nil if !@map[2] return nil unless @map[2]
for loc in @map[2] maps = @map[2].select { |loc| loc[0] == x && loc[1] == y }
if loc[0]==x && loc[1]==y return nil if maps.empty?
if !loc[4] || !loc[5] || !loc[6] maps.each do |loc|
return nil return ((loc[4] && loc[5] && loc[6]) ? [loc[4],loc[5],loc[6]] : nil)
else
return [loc[4],loc[5],loc[6]]
end
end
end end
return nil
end end
def pbMapScene(mode=0) def refresh_fly_screen
xOffset = 0 return if @fly_map || !pbCanFly? || !Settings::CAN_FLY_FROM_TOWN_MAP
yOffset = 0 @sprites["help"].bitmap.clear
newX = 0 pbSetSystemFont(@sprites["help"].bitmap)
newY = 0 text = @mode == 0 ? _INTL("ACTION: Open Fly Menu") : _INTL("ACTION: Close Fly Menu")
@sprites["cursor"].x = -SQUAREWIDTH/2+(@mapX*SQUAREWIDTH)+(Graphics.width-@sprites["map"].bitmap.width)/2 pbDrawTextPositions(@sprites["help"].bitmap, [[text, Graphics.width - 8, -8, 1, Color.new(248,248,248), Color.new(0,0,0)]])
@sprites["cursor"].y = -SQUAREHEIGHT/2+(@mapY*SQUAREHEIGHT)+(Graphics.height-@sprites["map"].bitmap.height)/2 @sprites.each do |key, sprite|
next if !key.include?("point")
sprite.visible = @mode == 1
sprite.frame = 0
end
end
def pbMapScene
x_offset = 0
y_offset = 0
new_x = 0
new_y = 0
dist_per_frame = 8 * 20 / Graphics.frame_rate
loop do loop do
Graphics.update Graphics.update
Input.update Input.update
pbUpdate pbUpdate
if xOffset!=0 || yOffset!=0 if x_offset != 0 || y_offset != 0
distancePerFrame = 8*20/Graphics.frame_rate x_offset += (x_offset > 0) ? -dist_per_frame : (x_offset < 0) ? dist_per_frame : 0
xOffset += (xOffset>0) ? -distancePerFrame : (xOffset<0) ? distancePerFrame : 0 y_offset += (y_offset > 0) ? -dist_per_frame : (y_offset < 0) ? dist_per_frame : 0
yOffset += (yOffset>0) ? -distancePerFrame : (yOffset<0) ? distancePerFrame : 0 @sprites["cursor"].x = new_x - x_offset
@sprites["cursor"].x = newX-xOffset @sprites["cursor"].y = new_y - y_offset
@sprites["cursor"].y = newY-yOffset
next next
end end
@sprites["mapbottom"].maplocation = pbGetMapLocation(@mapX,@mapY)
@sprites["mapbottom"].mapdetails = pbGetMapDetails(@mapX,@mapY)
ox = 0 ox = 0
oy = 0 oy = 0
case Input.dir8 case Input.dir8
when 1 # lower left when 1 # lower left
oy = 1 if @mapY<BOTTOM oy = 1 if @map_y < BOTTOM
ox = -1 if @mapX>LEFT ox = -1 if @map_x > LEFT
when 2 # down when 2 # down
oy = 1 if @mapY<BOTTOM oy = 1 if @map_y < BOTTOM
when 3 # lower right when 3 # lower right
oy = 1 if @mapY<BOTTOM oy = 1 if @map_y < BOTTOM
ox = 1 if @mapX<RIGHT ox = 1 if @map_x < RIGHT
when 4 # left when 4 # left
ox = -1 if @mapX>LEFT ox = -1 if @map_x > LEFT
when 6 # right when 6 # right
ox = 1 if @mapX<RIGHT ox = 1 if @map_x < RIGHT
when 7 # upper left when 7 # upper left
oy = -1 if @mapY>TOP oy = -1 if @map_y > TOP
ox = -1 if @mapX>LEFT ox = -1 if @map_x > LEFT
when 8 # up when 8 # up
oy = -1 if @mapY>TOP oy = -1 if @map_y > TOP
when 9 # upper right when 9 # upper right
oy = -1 if @mapY>TOP oy = -1 if @map_y > TOP
ox = 1 if @mapX<RIGHT ox = 1 if @map_x < RIGHT
end end
if ox!=0 || oy!=0 if ox != 0 || oy != 0
@mapX += ox @map_x += ox
@mapY += oy @map_y += oy
xOffset = ox*SQUAREWIDTH x_offset = ox * SQUARE_WIDTH
yOffset = oy*SQUAREHEIGHT y_offset = oy * SQUARE_HEIGHT
newX = @sprites["cursor"].x+xOffset new_x = @sprites["cursor"].x + x_offset
newY = @sprites["cursor"].y+yOffset new_y = @sprites["cursor"].y + y_offset
end end
@sprites["mapbottom"].maplocation = pbGetMapLocation(@map_x, @map_y)
@sprites["mapbottom"].mapdetails = pbGetMapDetails(@map_x, @map_y)
if Input.trigger?(Input::BACK) if Input.trigger?(Input::BACK)
if @editor && @changed if @editor && @changed
if pbConfirmMessage(_INTL("Save changes?")) { pbUpdate } pbSaveMapData if pbConfirmMessage(_INTL("Save changes?")) { pbUpdate }
pbSaveMapData break if pbConfirmMessage(_INTL("Exit from the map?")) { pbUpdate }
end
if pbConfirmMessage(_INTL("Exit from the map?")) { pbUpdate }
break
end
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(@mapX,@mapY) healspot = pbGetHealingSpot(@map_x, @map_y)
if healspot if healspot &&
if $PokemonGlobal.visitedMaps[healspot[0]] || ($DEBUG && Input.press?(Input::CTRL)) ($PokemonGlobal.visitedMaps[healspot[0]] || ($DEBUG && Input.press?(Input::CTRL)))
return healspot name = pbGetMapNameFromId(healspot[0])
end return healspot if @fly_map || 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(@mapX,@mapY) pbChangeMapLocation(@map_x, @map_y)
elsif Input.trigger?(Input::ACTION) && !@wallmap && !@fly_map && pbCanFly?
pbPlayDecisionSE
@mode = (@mode == 1 ? 0 : 1)
refresh_fly_screen
end end
end end
pbPlayCloseMenuSE pbPlayCloseMenuSE
@@ -351,26 +348,28 @@ class PokemonRegionMapScreen
end end
def pbStartFlyScreen def pbStartFlyScreen
@scene.pbStartScene(false,1) @scene.pbStartScene(false, true)
ret = @scene.pbMapScene(1) ret = @scene.pbMapScene
@scene.pbEndScene @scene.pbEndScene
return ret return ret
end end
def pbStartScreen def pbStartScreen
@scene.pbStartScene($DEBUG) @scene.pbStartScene($DEBUG)
@scene.pbMapScene ret = @scene.pbMapScene
@scene.pbEndScene @scene.pbEndScene
return ret
end end
end end
#=============================================================================== #===============================================================================
# #
#=============================================================================== #===============================================================================
def pbShowMap(region=-1,wallmap=true) def pbShowMap(region = -1, wallmap = true)
pbFadeOutIn { pbFadeOutIn {
scene = PokemonRegionMap_Scene.new(region,wallmap) scene = PokemonRegionMap_Scene.new(region, wallmap)
screen = PokemonRegionMapScreen.new(scene) screen = PokemonRegionMapScreen.new(scene)
screen.pbStartScreen ret = screen.pbStartScreen
$PokemonTemp.flydata = ret if ret && !wallmap
} }
end end

View File

@@ -8,9 +8,6 @@ Other notes:
- If a battle ends because of Rocky Helmet damage, the side that the Rocky - If a battle ends because of Rocky Helmet damage, the side that the Rocky
Helmet holder is on should lose (Gen 7+) or win (Gen 6-). Helmet holder is on should lose (Gen 7+) or win (Gen 6-).
Can use Fly from within the Town Map if possible. (Good QoL, add if possible.)
(Will be implemented by me in the next PR)
Make example event that combines the Gen 8 fossils. Make example event that combines the Gen 8 fossils.
#=============================================================================== #===============================================================================
@@ -24,8 +21,6 @@ toggled. (Probably don't bother implementing.)
Bicycle that can work on water. Bicycle that can work on water.
Town Map added to the pause menu. (Don't bother adding.)
Remote access to storage boxes via the party screen if you have the Pokémon Box Remote access to storage boxes via the party screen if you have the Pokémon Box
Link item (and it's allowed to be used - in Gyms and some other places it's Link item (and it's allowed to be used - in Gyms and some other places it's
forbidden). forbidden).
@@ -92,6 +87,10 @@ New evolution methods:
Added AI for new moves/items/abilities. Added AI for new moves/items/abilities.
Can use Fly from within the Town Map if possible.
Town Map added to the pause menu.
Ability Effect Changes Ability Effect Changes
- Intimidate now triggers Rattled. Rattled needs a new ability handler just for - Intimidate now triggers Rattled. Rattled needs a new ability handler just for
triggering this way. triggering this way.