Rewrote Town Map screen

This commit is contained in:
Maruno17
2025-01-16 00:09:59 +00:00
parent fcb4a1cec3
commit d03f012162
21 changed files with 1446 additions and 118 deletions

View File

@@ -186,30 +186,58 @@ module Settings
66 => [5, 21, 28, 31, 39, 41, 44, 47, 69], 66 => [5, 21, 28, 31, 39, 41, 44, 47, 69],
69 => [5, 21, 28, 31, 39, 41, 44, 47, 66 ] 69 => [5, 21, 28, 31, 39, 41, 44, 47, 66 ]
} }
# A set of arrays, each containing the details of a roaming Pokémon. The # A set of hashes, each containing the details of a roaming Pokémon. The
# information within each array is as follows: # information within each hash is as follows:
# * Species. # * :species
# * Level. # * :level
# * Game Switch; the Pokémon roams while this is ON. # * :icon - Filename in Graphics/UI/Town Map/ of the roamer's Town Map icon.
# * Encounter type (see def pbRoamingMethodAllowed for their use): # * :game_switch - The Pokémon roams if this is nil or <=0 or if that Game
# 0 = grass, walking in cave, surfing # Switch is ON. Optional.
# 1 = grass, walking in cave # * :encounter_type - One of:
# 2 = surfing # :all = grass, walking in cave, surfing (default)
# 3 = fishing # :land = grass, walking in cave
# 4 = surfing, fishing # :water = surfing, fishing
# * Name of BGM to play for that encounter (optional). # :surfing = surfing
# * Roaming areas specifically for this Pokémon (optional; used instead of # :fishing = fishing
# ROAMING_AREAS). # * :bgm - The BGM to play for the encounter. Optional.
# * :areas - A hash of map IDs that determine where this Pokémon roams. Used
# instead of ROAMING_AREAS above. Optional.
ROAMING_SPECIES = [ ROAMING_SPECIES = [
[:LATIAS, 30, 53, 0, "Battle roaming"], {
[:LATIOS, 30, 53, 0, "Battle roaming"], :species => :LATIAS,
[:KYOGRE, 40, 54, 2, nil, { :level => 30,
2 => [ 21, 31 ], :icon => "pin_latias",
21 => [2, 31, 69], :game_switch => 53,
31 => [2, 21, 69], :encounter_type => :all,
69 => [ 21, 31 ] :bgm => "Battle roaming"
}], },
[:ENTEI, 40, 55, 1] {
:species => :LATIOS,
:level => 30,
:icon => "pin_latios",
:game_switch => 53,
:encounter_type => :all,
:bgm => "Battle roaming"
},
{
:species => :KYOGRE,
:level => 40,
:game_switch => 54,
:encounter_type => :surfing,
:areas => {
2 => [ 21, 31 ],
21 => [2, 31, 69],
31 => [2, 21, 69],
69 => [ 21, 31 ]
}
},
{
:species => :ENTEI,
:level => 40,
:icon => "pin_entei",
:game_switch => 55,
:encounter_type => :land
}
] ]
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------

View File

@@ -44,6 +44,13 @@ module Settings
# by the Pokémon that knows it. # by the Pokémon that knows it.
SHOW_MODIFIED_MOVE_PROPERTIES = false SHOW_MODIFIED_MOVE_PROPERTIES = false
# Whether pressing Use in the Town Map will zoom it in to 200% and show a text
# pane on the right showing the selected point's description. The cursor can
# still be moved while zoomed in.
ENABLE_TOWN_MAP_ZOOM_IN_FOR_DETAILS = true
# Whether points in the Town Map can be marked.
ENABLE_TOWN_MAP_MARKING = true
# TODO: Allow renaming a Pokémon from the party screen/summary screen (not # TODO: Allow renaming a Pokémon from the party screen/summary screen (not
# sure which). Gen 9 feature. # sure which). Gen 9 feature.
# TODO: Allow forgetting/remembering moves from the summary screen. Gen 9 # TODO: Allow forgetting/remembering moves from the summary screen. Gen 9

View File

@@ -6,7 +6,10 @@ module GameData
attr_reader :id attr_reader :id
attr_reader :real_name attr_reader :real_name
attr_reader :filename attr_reader :filename
attr_reader :point attr_reader :margins
attr_reader :point_size
attr_reader :size
attr_reader :points
attr_reader :flags attr_reader :flags
attr_reader :pbs_file_suffix attr_reader :pbs_file_suffix
@@ -14,23 +17,43 @@ module GameData
DATA_FILENAME = "town_map.dat" DATA_FILENAME = "town_map.dat"
PBS_BASE_FILENAME = "town_map" PBS_BASE_FILENAME = "town_map"
SCHEMA = { SCHEMA = {
"SectionName" => [:id, "u"], "SectionName" => [:id, "u"],
"Name" => [:real_name, "s"], "Name" => [:real_name, "s"],
"Filename" => [:filename, "s"], "Filename" => [:filename, "s"],
"Point" => [:point, "^uusSUUUU"], "Margins" => [:margins, "uu"], # Left/right and top/bottom padding in pixels
"Flags" => [:flags, "*s"] "PointSize" => [:point_size, "vv"], # Size of a point in pixels
"Size" => [:size, "vv"], # Width and height in points
"Point" => [:points, "^uusSUUUU"],
"Flags" => [:flags, "*s"]
}
# This schema is for definable properties of individual points (apart from
# position and name which are above).
SUB_SCHEMA = {
"Image" => [:image, "s"],
"Description" => [:real_description, "q"],
"FlySpot" => [:fly_spot, "vuu"], # Map ID, x coord, y coord
"HideFlyIcon" => [:hide_fly_icon, "b"],
"FlyIconOffset" => [:fly_icon_offset, "ii"], # x and y offsets in pixels
"Switch" => [:switch, "v"] # Game Switch ID
} }
extend ClassMethodsIDNumbers extend ClassMethodsIDNumbers
include InstanceMethods include InstanceMethods
def self.sub_schema
return SUB_SCHEMA
end
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
def initialize(hash) def initialize(hash)
@id = hash[:id] @id = hash[:id]
@real_name = hash[:real_name] || "???" @real_name = hash[:real_name] || "???"
@filename = hash[:filename] @filename = hash[:filename]
@point = hash[:point] || [] @margins = hash[:margins] || [0, 0]
@point_size = hash[:point_size] || [16, 16]
@size = hash[:size] || [30, 20]
@points = hash[:points] || []
@flags = hash[:flags] || [] @flags = hash[:flags] || []
@pbs_file_suffix = hash[:pbs_file_suffix] || "" @pbs_file_suffix = hash[:pbs_file_suffix] || ""
end end
@@ -43,5 +66,18 @@ module GameData
def has_flag?(flag) def has_flag?(flag)
return @flags.any? { |f| f.downcase == flag.downcase } return @flags.any? { |f| f.downcase == flag.downcase }
end end
def get_point_property_for_PBS(key, index = 0)
return [*@points[index][:position], @points[index][:real_name]] if key == "Point"
ret = @points[index][SUB_SCHEMA[key][0]]
ret = nil if ret == false || (ret.is_a?(Array) && ret.length == 0) || ret == ""
case key
when "Margins"
ret = nil if ret == [0, 0]
when "FlySpot"
ret = nil if ret && ret.compact.empty?
end
return ret
end
end end
end end

View File

@@ -17,6 +17,15 @@ end
#=============================================================================== #===============================================================================
# Making roaming Pokémon roam around. # Making roaming Pokémon roam around.
#=============================================================================== #===============================================================================
def each_active_roamer(ignore_caught = true)
Settings::ROAMING_SPECIES.each_with_index do |roamer, i|
next if !GameData::Species.exists?(roamer[:species])
next if roamer[:game_switch] && roamer[:game_switch] > 0 && !$game_switches[roamer[:game_switch]]
next if ignore_caught && $PokemonGlobal.roamPokemon[i] == true # Has been caught
yield roamer, i
end
end
# Resets all roaming Pokemon that were defeated without having been caught. # Resets all roaming Pokemon that were defeated without having been caught.
def pbResetAllRoamers def pbResetAllRoamers
return if !$PokemonGlobal.roamPokemon return if !$PokemonGlobal.roamPokemon
@@ -30,7 +39,7 @@ end
def pbRoamingAreas(idxRoamer) def pbRoamingAreas(idxRoamer)
# [species ID, level, Game Switch, encounter type, battle BGM, area maps hash] # [species ID, level, Game Switch, encounter type, battle BGM, area maps hash]
roamData = Settings::ROAMING_SPECIES[idxRoamer] roamData = Settings::ROAMING_SPECIES[idxRoamer]
return roamData[5] if roamData && roamData[5] return roamData[:areas] if roamData && roamData[:areas]
return Settings::ROAMING_AREAS return Settings::ROAMING_AREAS
end end
@@ -47,8 +56,8 @@ def pbRoamPokemon
# Start all roamers off in random maps # Start all roamers off in random maps
if !$PokemonGlobal.roamPosition if !$PokemonGlobal.roamPosition
$PokemonGlobal.roamPosition = {} $PokemonGlobal.roamPosition = {}
Settings::ROAMING_SPECIES.length.times do |i| Settings::ROAMING_SPECIES.each_with_index do |roamer, i|
next if !GameData::Species.exists?(Settings::ROAMING_SPECIES[i][0]) next if !GameData::Species.exists?(roamer[:species])
keys = pbRoamingAreas(i).keys keys = pbRoamingAreas(i).keys
$PokemonGlobal.roamPosition[i] = keys[rand(keys.length)] $PokemonGlobal.roamPosition[i] = keys[rand(keys.length)]
end end
@@ -62,10 +71,9 @@ end
# Makes a single roaming Pokémon roam to another map. Doesn't roam if it isn't # Makes a single roaming Pokémon roam to another map. Doesn't roam if it isn't
# currently possible to encounter it (i.e. its Game Switch is off). # currently possible to encounter it (i.e. its Game Switch is off).
def pbRoamPokemonOne(idxRoamer) def pbRoamPokemonOne(idxRoamer)
# [species ID, level, Game Switch, encounter type, battle BGM, area maps hash] roamer = Settings::ROAMING_SPECIES[idxRoamer]
roamData = Settings::ROAMING_SPECIES[idxRoamer] return if !GameData::Species.exists?(roamer[:species])
return if roamData[2] > 0 && !$game_switches[roamData[2]] # Game Switch is off return if roamer[:game_switch] && roamer[:game_switch] > 0 && !$game_switches[roamer[:game_switch]]
return if !GameData::Species.exists?(roamData[0])
# Get hash of area patrolled by the roaming Pokémon # Get hash of area patrolled by the roaming Pokémon
mapIDs = pbRoamingAreas(idxRoamer).keys mapIDs = pbRoamingAreas(idxRoamer).keys
return if !mapIDs || mapIDs.length == 0 # No roaming area defined somehow return if !mapIDs || mapIDs.length == 0 # No roaming area defined somehow
@@ -81,10 +89,10 @@ def pbRoamPokemonOne(idxRoamer)
return if !nextMaps return if !nextMaps
nextMaps.each { |map| newMapChoices.push(map) } nextMaps.each { |map| newMapChoices.push(map) }
# Rarely, add a random possible map into the mix # Rarely, add a random possible map into the mix
newMapChoices.push(mapIDs[rand(mapIDs.length)]) if rand(32) == 0 newMapChoices.push(mapIDs.sample) if rand(32) == 0
# Choose a random new map to roam to # Choose a random new map to roam to
if newMapChoices.length > 0 if newMapChoices.length > 0
$PokemonGlobal.roamPosition[idxRoamer] = newMapChoices[rand(newMapChoices.length)] $PokemonGlobal.roamPosition[idxRoamer] = newMapChoices.sample
end end
end end
@@ -118,16 +126,16 @@ def pbRoamingMethodAllowed(roamer_method)
enc_type = $PokemonEncounters.encounter_type enc_type = $PokemonEncounters.encounter_type
type = GameData::EncounterType.get(enc_type).type type = GameData::EncounterType.get(enc_type).type
case roamer_method case roamer_method
when 0 # Any step-triggered method (except Bug Contest) when :all # Any step-triggered method (except Bug Contest)
return [:land, :cave, :water].include?(type) return [:land, :cave, :water].include?(type)
when 1 # Walking (except Bug Contest) when :land # Walking (except Bug Contest)
return [:land, :cave].include?(type) return [:land, :cave].include?(type)
when 2 # Surfing when :water # Surfing or rishing
return type == :water
when 3 # Fishing
return type == :fishing
when 4 # Water-based
return [:water, :fishing].include?(type) return [:water, :fishing].include?(type)
when :surfing # Surfing
return type == :water
when :fishing # Fishing
return type == :fishing
end end
return false return false
end end
@@ -146,11 +154,7 @@ EventHandlers.add(:on_wild_species_chosen, :roaming_pokemon,
currentRegion = pbGetCurrentRegion currentRegion = pbGetCurrentRegion
currentMapName = $game_map.name currentMapName = $game_map.name
possible_roamers = [] possible_roamers = []
Settings::ROAMING_SPECIES.each_with_index do |data, i| each_active_roamer do |roamer, i|
# data = [species, level, Game Switch, roamer method, battle BGM, area maps hash]
next if !GameData::Species.exists?(data[0])
next if data[2] > 0 && !$game_switches[data[2]] # Isn't roaming
next if $PokemonGlobal.roamPokemon[i] == true # Roaming Pokémon has been caught
# Get the roamer's current map # Get the roamer's current map
roamerMap = $PokemonGlobal.roamPosition[i] roamerMap = $PokemonGlobal.roamPosition[i]
if !roamerMap if !roamerMap
@@ -168,9 +172,9 @@ EventHandlers.add(:on_wild_species_chosen, :roaming_pokemon,
next if pbGetMapNameFromId(roamerMap) != currentMapName next if pbGetMapNameFromId(roamerMap) != currentMapName
end end
# Check whether the roamer's roamer method is currently possible # Check whether the roamer's roamer method is currently possible
next if !pbRoamingMethodAllowed(data[3]) next if !pbRoamingMethodAllowed(roamer[:encounter_type])
# Add this roaming Pokémon to the list of possible roaming Pokémon to encounter # Add this roaming Pokémon to the list of possible roaming Pokémon to encounter
possible_roamers.push([i, data[0], data[1], data[4]]) # [i, species, level, BGM] possible_roamers.push([i, roamer[:species], roamer[:level], roamer[:bgm]])
end end
# No encounterable roaming Pokémon were found, just have the regular encounter # No encounterable roaming Pokémon were found, just have the regular encounter
next if possible_roamers.length == 0 next if possible_roamers.length == 0

View File

@@ -23,6 +23,8 @@ class PokemonGlobalMetadata
attr_accessor :pokedexDex # Dex currently looking at (-1 is National Dex) attr_accessor :pokedexDex # Dex currently looking at (-1 is National Dex)
attr_accessor :pokedexIndex # Last species viewed per Dex attr_accessor :pokedexIndex # Last species viewed per Dex
attr_accessor :pokedexMode # Search mode attr_accessor :pokedexMode # Search mode
# Town Map
attr_accessor :townMapMarkings
# Day Care # Day Care
attr_accessor :day_care attr_accessor :day_care
# Special battle modes # Special battle modes
@@ -78,6 +80,8 @@ class PokemonGlobalMetadata
(numRegions + 1).times do |i| # National Dex isn't a region, but is included (numRegions + 1).times do |i| # National Dex isn't a region, but is included
@pokedexIndex[i] = 0 @pokedexIndex[i] = 0
end end
# Town Map
@townMapMarkings = []
# Day Care # Day Care
@day_care = DayCare.new @day_care = DayCare.new
# Special battle modes # Special battle modes

View File

@@ -313,11 +313,10 @@ ItemHandlers::UseInField.copy(:ITEMFINDER, :DOWSINGMCHN, :DOWSINGMACHINE)
ItemHandlers::UseFromBag.add(:TOWNMAP, proc { |item, bag_screen| ItemHandlers::UseFromBag.add(:TOWNMAP, proc { |item, bag_screen|
pbFadeOutInWithUpdate(bag_screen&.sprites) do pbFadeOutInWithUpdate(bag_screen&.sprites) do
scene = PokemonRegionMap_Scene.new(-1, false) town_map_screen = UI::TownMap.new
screen = PokemonRegionMapScreen.new(scene) town_map_screen.main
ret = screen.pbStartScreen if town_map_screen.result
if ret $game_temp.fly_destination = town_map_screen.result
$game_temp.fly_destination = ret
bag_screen&.silent_end_screen bag_screen&.silent_end_screen
end end
end end

View File

@@ -2,6 +2,13 @@
# #
#=============================================================================== #===============================================================================
class PokemonPokedexInfo_Scene class PokemonPokedexInfo_Scene
LEFT = 0
TOP = 0
RIGHT = 29
BOTTOM = 19
SQUARE_WIDTH = 16
SQUARE_HEIGHT = 16
def pbStartScene(dexlist, index, region) def pbStartScene(dexlist, index, region)
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
@viewport.z = 99999 @viewport.z = 99999
@@ -31,8 +38,8 @@ class PokemonPokedexInfo_Scene
pbDrawImagePositions( pbDrawImagePositions(
@sprites["areamap"].bitmap, @sprites["areamap"].bitmap,
[["Graphics/UI/Town Map/#{hidden[4]}", [["Graphics/UI/Town Map/#{hidden[4]}",
hidden[2] * PokemonRegionMap_Scene::SQUARE_WIDTH, hidden[2] * SQUARE_WIDTH,
hidden[3] * PokemonRegionMap_Scene::SQUARE_HEIGHT]] hidden[3] * SQUARE_HEIGHT]]
) )
end end
@sprites["areahighlight"] = BitmapSprite.new(Graphics.width, Graphics.height, @viewport) @sprites["areahighlight"] = BitmapSprite.new(Graphics.width, Graphics.height, @viewport)
@@ -315,12 +322,12 @@ class PokemonPokedexInfo_Scene
# defined point in town_map.txt, and which either have no Self Switch # defined point in town_map.txt, and which either have no Self Switch
# controlling their visibility or whose Self Switch is ON) # controlling their visibility or whose Self Switch is ON)
visible_points = [] visible_points = []
@mapdata.point.each do |loc| @mapdata.points.each do |loc|
next if loc[7] && !$game_switches[loc[7]] # Point is not visible next if loc[:switch] && !$game_switches[loc[:switch]] # Point is not visible
visible_points.push([loc[0], loc[1]]) visible_points.push(loc[:position])
end end
# Find all points with a visible area for @species # Find all points with a visible area for @species
town_map_width = 1 + PokemonRegionMap_Scene::RIGHT - PokemonRegionMap_Scene::LEFT town_map_width = 1 + RIGHT - LEFT
ret = [] ret = []
GameData::Encounter.each_of_version($PokemonGlobal.encounter_version) do |enc_data| GameData::Encounter.each_of_version($PokemonGlobal.encounter_version) do |enc_data|
next if !pbFindEncounter(enc_data.types, @species) # Species isn't in encounter table next if !pbFindEncounter(enc_data.types, @species) # Species isn't in encounter table
@@ -362,9 +369,9 @@ class PokemonPokedexInfo_Scene
# Draw coloured squares on each point of the Town Map with a nest # Draw coloured squares on each point of the Town 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)
town_map_width = 1 + PokemonRegionMap_Scene::RIGHT - PokemonRegionMap_Scene::LEFT town_map_width = 1 + RIGHT - LEFT
sqwidth = PokemonRegionMap_Scene::SQUARE_WIDTH sqwidth = SQUARE_WIDTH
sqheight = PokemonRegionMap_Scene::SQUARE_HEIGHT sqheight = SQUARE_HEIGHT
points.length.times do |j| points.length.times do |j|
next if !points[j] next if !points[j]
x = (j % town_map_width) * sqwidth x = (j % town_map_width) * sqwidth

View File

@@ -164,11 +164,10 @@ MenuHandlers.add(:pokegear_menu, :map, {
"order" => 10, "order" => 10,
"effect" => proc { |menu| "effect" => proc { |menu|
pbFadeOutIn do pbFadeOutIn do
scene = PokemonRegionMap_Scene.new(-1, false) town_map_screen = UI::TownMap.new
screen = PokemonRegionMapScreen.new(scene) town_map_screen.main
ret = screen.pbStartScreen if town_map_screen.result
if ret $game_temp.fly_destination = town_map_screen.result
$game_temp.fly_destination = ret
menu.dispose menu.dispose
next 99999 next 99999
end end

View File

@@ -263,9 +263,9 @@ class PokemonReadyMenu
ret = nil ret = nil
pbFadeOutInWithUpdate(@scene.sprites) do pbFadeOutInWithUpdate(@scene.sprites) do
pbHideMenu pbHideMenu
scene = PokemonRegionMap_Scene.new(-1, false) town_map_screen = UI::TownMap.new(mode: :fly)
screen = PokemonRegionMapScreen.new(scene) town_map_screen.main
ret = screen.pbStartFlyScreen ret = town_map_screen.result
pbShowMenu if !ret pbShowMenu if !ret
end end
if ret if ret

View File

@@ -307,6 +307,7 @@ module UI
#============================================================================= #=============================================================================
class BaseVisuals class BaseVisuals
attr_reader :sprites attr_reader :sprites
attr_reader :mode
BACKGROUND_FILENAME = "bg" BACKGROUND_FILENAME = "bg"
@@ -709,6 +710,7 @@ module UI
#============================================================================= #=============================================================================
class BaseScreen class BaseScreen
attr_reader :visuals attr_reader :visuals
attr_reader :mode
attr_accessor :result attr_accessor :result
def initialize def initialize

View File

@@ -256,9 +256,9 @@ MenuHandlers.add(:pause_menu, :town_map, {
"effect" => proc { |menu| "effect" => proc { |menu|
pbPlayDecisionSE pbPlayDecisionSE
pbFadeOutIn do pbFadeOutIn do
scene = PokemonRegionMap_Scene.new(-1, false) town_map_screen = UI::TownMap.new
screen = PokemonRegionMapScreen.new(scene) town_map_screen.main
ret = screen.pbStartScreen ret = town_map_screen.result
$game_temp.fly_destination = ret if ret $game_temp.fly_destination = ret if ret
($game_temp.fly_destination) ? menu.silent_end_screen : menu.refresh ($game_temp.fly_destination) ? menu.silent_end_screen : menu.refresh
end end

View File

@@ -738,7 +738,7 @@ end
# #
#=============================================================================== #===============================================================================
class UI::Party < UI::BaseScreen class UI::Party < UI::BaseScreen
attr_reader :party, :mode attr_reader :party
SCREEN_ID = :party_screen SCREEN_ID = :party_screen
@@ -930,13 +930,12 @@ class UI::Party < UI::BaseScreen
if pbCanUseHiddenMove?(pkmn, move_id) && pbConfirmUseHiddenMove(pkmn, move_id) if pbCanUseHiddenMove?(pkmn, move_id) && pbConfirmUseHiddenMove(pkmn, move_id)
if move_id == :FLY if move_id == :FLY
pbFadeOutInWithUpdate(sprites) do pbFadeOutInWithUpdate(sprites) do
town_map_scene = PokemonRegionMap_Scene.new(-1, false) town_map_screen = UI::TownMap.new(mode: :fly)
town_map_screen = PokemonRegionMapScreen.new(town_map_scene) town_map_screen.main
ret = town_map_screen.pbStartFlyScreen if town_map_screen.result
if ret
$game_temp.field_move_to_use = move_id $game_temp.field_move_to_use = move_id
$game_temp.field_move_user = pkmn $game_temp.field_move_user = pkmn
$game_temp.fly_destination = ret $game_temp.fly_destination = town_map_screen.result
silent_end_screen silent_end_screen
end end
end end

View File

@@ -1372,7 +1372,7 @@ end
# #
#=============================================================================== #===============================================================================
class UI::PokemonSummary < UI::BaseScreen class UI::PokemonSummary < UI::BaseScreen
attr_reader :party, :mode attr_reader :party
attr_accessor :party_index, :pokemon attr_accessor :party_index, :pokemon
SCREEN_ID = :summary_screen SCREEN_ID = :summary_screen

File diff suppressed because it is too large Load Diff

View File

@@ -1604,7 +1604,7 @@ end
# #
#=============================================================================== #===============================================================================
class UI::PokemonStorage < UI::BaseScreen class UI::PokemonStorage < UI::BaseScreen
attr_reader :storage, :mode attr_reader :storage
SCREEN_ID = :pokemon_storage_screen SCREEN_ID = :pokemon_storage_screen

View File

@@ -263,7 +263,7 @@ end
# #
#=============================================================================== #===============================================================================
class UI::MoveReminder < UI::BaseScreen class UI::MoveReminder < UI::BaseScreen
attr_reader :pokemon, :mode attr_reader :pokemon
SCREEN_ID = :move_reminder_screen SCREEN_ID = :move_reminder_screen

View File

@@ -1,3 +1,4 @@
=begin
#=============================================================================== #===============================================================================
# #
#=============================================================================== #===============================================================================
@@ -356,3 +357,4 @@ def pbShowMap(region = -1, wallmap = true)
$game_temp.fly_destination = ret if ret && !wallmap $game_temp.fly_destination = ret if ret && !wallmap
end end
end end
=end

View File

@@ -448,10 +448,10 @@ class SpriteWindow_DebugRoamers < Window_DrawableCommand
self.shadowtext(_INTL("[Clear all current roamer locations]"), rect.x, rect.y, nameWidth, rect.height) self.shadowtext(_INTL("[Clear all current roamer locations]"), rect.x, rect.y, nameWidth, rect.height)
else else
pkmn = Settings::ROAMING_SPECIES[index] pkmn = Settings::ROAMING_SPECIES[index]
name = GameData::Species.get(pkmn[0]).name + " (Lv. #{pkmn[1]})" name = GameData::Species.get(pkmn[:species]).name + " (Lv. #{pkmn[:level]})"
status = "" status = ""
statuscolor = 0 statuscolor = 0
if pkmn[2] <= 0 || $game_switches[pkmn[2]] if !pkmn[:game_switch] || pkmn[:game_switch] <= 0 || $game_switches[pkmn[:game_switch]]
status = $PokemonGlobal.roamPokemon[index] status = $PokemonGlobal.roamPokemon[index]
if status == true if status == true
if $PokemonGlobal.roamPokemonCaught[index] if $PokemonGlobal.roamPokemonCaught[index]
@@ -472,7 +472,7 @@ class SpriteWindow_DebugRoamers < Window_DrawableCommand
statuscolor = 2 statuscolor = 2
end end
else else
status = "[NOT ROAMING][Switch #{pkmn[2]} is off]" status = "[NOT ROAMING][Switch #{pkmn[:game_switch]} is off]"
end end
self.shadowtext(name, rect.x, rect.y, nameWidth, rect.height) self.shadowtext(name, rect.x, rect.y, nameWidth, rect.height)
self.shadowtext(status, rect.x + nameWidth, rect.y, statusWidth, rect.height, 1, statuscolor) self.shadowtext(status, rect.x + nameWidth, rect.y, statusWidth, rect.height, 1, statuscolor)
@@ -500,7 +500,7 @@ def pbDebugRoamers
pkmn = nil pkmn = nil
end end
if Input.trigger?(Input::ACTION) && cmdwindow.index < cmdwindow.roamerCount && if Input.trigger?(Input::ACTION) && cmdwindow.index < cmdwindow.roamerCount &&
(pkmn[2] <= 0 || $game_switches[pkmn[2]]) && (!pkmn[:game_switch] || pkmn[:game_switch] <= 0 || $game_switches[pkmn[:game_switch]]) &&
$PokemonGlobal.roamPokemon[cmdwindow.index] != true $PokemonGlobal.roamPokemon[cmdwindow.index] != true
# Roam selected Pokémon # Roam selected Pokémon
pbPlayDecisionSE pbPlayDecisionSE
@@ -527,9 +527,9 @@ def pbDebugRoamers
if cmdwindow.index < cmdwindow.roamerCount if cmdwindow.index < cmdwindow.roamerCount
pbPlayDecisionSE pbPlayDecisionSE
# Toggle through roaming, not roaming, defeated # Toggle through roaming, not roaming, defeated
if pkmn[2] > 0 && !$game_switches[pkmn[2]] if pkmn[:game_switch] && pkmn[:game_switch] > 0 && !$game_switches[pkmn[:game_switch]]
# not roaming -> roaming # not roaming -> roaming
$game_switches[pkmn[2]] = true $game_switches[pkmn[:game_switch]] = true
elsif $PokemonGlobal.roamPokemon[cmdwindow.index] != true elsif $PokemonGlobal.roamPokemon[cmdwindow.index] != true
# roaming -> defeated # roaming -> defeated
$PokemonGlobal.roamPokemon[cmdwindow.index] = true $PokemonGlobal.roamPokemon[cmdwindow.index] = true
@@ -538,9 +538,9 @@ def pbDebugRoamers
!$PokemonGlobal.roamPokemonCaught[cmdwindow.index] !$PokemonGlobal.roamPokemonCaught[cmdwindow.index]
# defeated -> caught # defeated -> caught
$PokemonGlobal.roamPokemonCaught[cmdwindow.index] = true $PokemonGlobal.roamPokemonCaught[cmdwindow.index] = true
elsif pkmn[2] > 0 elsif pkmn[:game_switch] && pkmn[:game_switch] > 0
# caught -> not roaming (or roaming if Switch ID is 0) # caught -> not roaming (or roaming if Switch ID is 0)
$game_switches[pkmn[2]] = false if pkmn[2] > 0 $game_switches[pkmn[:game_switch]] = false if pkmn[:game_switch] && pkmn[:game_switch] > 0
$PokemonGlobal.roamPokemon[cmdwindow.index] = nil $PokemonGlobal.roamPokemon[cmdwindow.index] = nil
$PokemonGlobal.roamPokemonCaught[cmdwindow.index] = false $PokemonGlobal.roamPokemonCaught[cmdwindow.index] = false
end end

View File

@@ -207,9 +207,79 @@ module Compiler
# Compile Town Map data. # Compile Town Map data.
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
def compile_town_map(*paths) def compile_town_map(*paths)
compile_PBS_file_generic(GameData::TownMap, *paths) do |final_validate, hash| GameData::TownMap::DATA.clear
(final_validate) ? validate_all_compiled_town_maps : validate_compiled_town_map(hash) schema = GameData::TownMap.schema
sub_schema = GameData::TownMap.sub_schema
idx = 0
# Read from PBS file(s)
paths.each do |path|
compile_pbs_file_message_start(path)
file_suffix = File.basename(path, ".txt")[GameData::TownMap::PBS_BASE_FILENAME.length + 1, path.length] || ""
data_hash = nil
current_point = nil
section_name = nil
section_line = nil
# Read each line of town_map.txt at a time and compile it as a town map property
pbCompilerEachPreppedLine(path) do |line, line_no|
echo "." if idx % 100 == 0
idx += 1
Graphics.update if idx % 500 == 0
FileLineData.setSection(section_name, nil, section_line)
if line[/^\s*\[\s*(.+)\s*\]\s*$/]
# New section [region_number]
section_name = $~[1]
section_line = line
if data_hash
validate_compiled_town_map(data_hash)
GameData::TownMap.register(data_hash)
end
FileLineData.setSection(section_name, nil, section_line)
# Construct data hash
data_hash = {
:pbs_file_suffix => file_suffix
}
data_hash[schema["SectionName"][0]] = get_csv_record(section_name.clone, schema["SectionName"])
data_hash[schema["Point"][0]] = []
current_point = nil
elsif line[/^\s*(\w+)\s*=\s*(.*)$/]
# XXX=YYY lines
if !data_hash
raise _INTL("Expected a section at the beginning of the file.") + "\n" + FileLineData.linereport
end
key = $~[1]
if schema[key] # Property of the town map
property_value = get_csv_record($~[2], schema[key])
if key == "Point"
current_point = {
:position => [property_value[0], property_value[1]],
:real_name => property_value[2]
}
current_point[:real_description] = property_value[3] if property_value[3]
current_point[:fly_spot] = [property_value[4], property_value[5], property_value[6]] if property_value[4]
current_point[:switch] = property_value[7] if property_value[7]
data_hash[schema[key][0]].push(current_point)
else
data_hash[schema[key][0]] = property_value
end
elsif sub_schema[key] # Property of a point
if !current_point
raise _INTL("Property \"{1}\" is point-specific, but a point hasn't been defined yet.", key) + "\n" + FileLineData.linereport
end
current_point[sub_schema[key][0]] = get_csv_record($~[2], sub_schema[key])
end
end
end
# Add last town map's data to records
if data_hash
FileLineData.setSection(section_name, nil, section_line)
validate_compiled_town_map(data_hash)
GameData::TownMap.register(data_hash)
end
process_pbs_file_message_end
end end
validate_all_compiled_town_maps
# Save all data
GameData::TownMap.save
end end
def validate_compiled_town_map(hash) def validate_compiled_town_map(hash)
@@ -219,19 +289,19 @@ module Compiler
# Get town map names and descriptions for translating # Get town map names and descriptions for translating
region_names = [] region_names = []
point_names = [] point_names = []
interest_names = [] point_descriptions = []
GameData::TownMap.each do |town_map| GameData::TownMap.each do |town_map|
region_names[town_map.id] = town_map.real_name region_names[town_map.id] = town_map.real_name
town_map.point.each do |point| town_map.points.each do |point|
point_names.push(point[2]) point_names.push(point[:real_name])
interest_names.push(point[3]) point_descriptions.push(point[:real_description])
end end
end end
point_names.uniq! point_names.uniq!
interest_names.uniq! point_descriptions.uniq!
MessageTypes.setMessagesAsHash(MessageTypes::REGION_NAMES, region_names) MessageTypes.setMessagesAsHash(MessageTypes::REGION_NAMES, region_names)
MessageTypes.setMessagesAsHash(MessageTypes::REGION_LOCATION_NAMES, point_names) MessageTypes.setMessagesAsHash(MessageTypes::REGION_LOCATION_NAMES, point_names)
MessageTypes.setMessagesAsHash(MessageTypes::REGION_LOCATION_DESCRIPTIONS, interest_names) MessageTypes.setMessagesAsHash(MessageTypes::REGION_LOCATION_DESCRIPTIONS, point_descriptions)
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------

View File

@@ -107,7 +107,57 @@ module Compiler
# Save Town Map data to PBS file. # Save Town Map data to PBS file.
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
def write_town_map def write_town_map
write_PBS_file_generic(GameData::TownMap) paths = get_all_PBS_file_paths(GameData::TownMap)
schema = GameData::TownMap.schema
sub_schema = GameData::TownMap.sub_schema
idx = 0
paths.each do |path|
write_pbs_file_message_start(path[0])
File.open(path[0], "wb") do |f|
add_PBS_header_to_file(f)
# Write each element in turn
GameData::TownMap.each do |element|
next if element.pbs_file_suffix != path[1]
echo "." if idx % 100 == 0
Graphics.update if idx % 500 == 0
idx += 1
f.write("\#-------------------------------\r\n")
if schema["SectionName"]
f.write("[")
pbWriteCsvRecord(element.get_property_for_PBS("SectionName"), f, schema["SectionName"])
f.write("]\r\n")
else
f.write("[#{element.id}]\r\n")
end
# Write each town map property
schema.each_key do |key|
next if ["SectionName", "Point"].include?(key)
val = element.get_property_for_PBS(key)
next if val.nil?
f.write(sprintf("%s = ", key))
pbWriteCsvRecord(val, f, schema[key])
f.write("\r\n")
end
# Write each point in turn
element.points.each_with_index do |point, i|
# Write position/name
val = element.get_point_property_for_PBS("Point", i)
f.write("Point = ")
pbWriteCsvRecord(val, f, schema["Point"])
f.write("\r\n")
# Write other point properties
sub_schema.each_key do |key|
val = element.get_point_property_for_PBS(key, i)
next if val.nil?
f.write(sprintf(" %s = ", key))
pbWriteCsvRecord(val, f, sub_schema[key])
f.write("\r\n")
end
end
end
end
process_pbs_file_message_end
end
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------

View File

@@ -3,34 +3,77 @@
[0] [0]
Name = Essen Name = Essen
Filename = mapRegion0.png Filename = mapRegion0.png
Point = 13,12,Lappet Town,Oak's Lab,2,8,8 PointSize = 16,16
Size = 30,20
Point = 13,12,Lappet Town
Image = image_lappet_town
Description = \PN's house\nProfessor Oak's lab
FlySpot = 2,8,8
Point = 13,11,Route 1 Point = 13,11,Route 1
Point = 13,10,Cedolan City,Cedolan Dept. Store,7,47,11 Description = Kurt's house
Point = 14,10,Cedolan City,,7,47,11 Point = 13,10,Cedolan City
Image = image_cedolan_city
Description = Cedolan Dept. Store\nCedolan Gym\nMove Maniac House
FlySpot = 7,47,11
FlyIconOffset = 8,0
Point = 14,10,Cedolan City
Image = image_cedolan_city
Description = Game Corner\nPokémon Institute
FlySpot = 7,47,11
HideFlyIcon = true
Point = 14,9,Route 2 Point = 14,9,Route 2
Description = Bridges
Point = 14,8,Route 2 Point = 14,8,Route 2
Point = 15,8,Lerucean Town,,23,11,15 Description = Bridges
Point = 15,8,Lerucean Town
Image = image_lerucean_town
Description = Day Care Center\nPokémon Fan Club\nLerucean Market
FlySpot = 23,11,15
Point = 16,8,Natural Park Point = 16,8,Natural Park
Description = A Bug Catching Contest is held here every Tuesday, Thursday and Saturday.
Point = 15,7,Route 3 Point = 15,7,Route 3
Point = 15,6,Route 3,Ice Cave Point = 15,6,Route 3
Description = Ice Cave
Point = 14,6,Route 3 Point = 14,6,Route 3
Point = 13,6,Ingido Plateau,,35,17,7 Description = Examples of trainer battles.
Point = 13,6,Ingido Plateau
Image = image_ingido_plateau
Description = Pokémon League
FlySpot = 35,17,7
Point = 12,6,Route 4 Point = 12,6,Route 4
Point = 11,6,Route 4 Point = 11,6,Route 4
Point = 11,7,Route 5,Cycle Road Description = Cycle Road
Point = 11,8,Route 5,Cycle Road Point = 11,7,Route 5
Point = 11,9,Route 5,Cycle Road Description = Cycle Road
Point = 11,8,Route 5
Description = Cycle Road
Point = 11,9,Route 5
Description = Cycle Road
Point = 11,10,Route 6 Point = 11,10,Route 6
Description = Cycle Road
Point = 12,10,Route 6 Point = 12,10,Route 6
Point = 15,10,Route 7 Point = 15,10,Route 7
Point = 16,10,Route 7,Rock Cave Point = 16,10,Route 7
Point = 17,10,Battle Frontier,,52,17,14 Description = Rock Cave
Point = 17,10,Battle Frontier
Image = image_battle_frontier
Description = Battle Palace\nBattle Tower\nBattle Arena\nBattle Factory
FlySpot = 52,17,14
Point = 12,12,Safari Zone Point = 12,12,Safari Zone
Point = 13,13,Route 8,Diving area Description = Challenge yourself by catching Pokémon without using your own.
Point = 18,17,Berth Island,,,,,51 Point = 13,13,Route 8
Point = 22,16,Faraday Island,,,,,52 Image = image_route_8
Description = Harbor\nDiving area
Point = 18,17,Berth Island
Description = Four mysterious meteorites can be found here.
Switch = 51
Point = 22,16,Faraday Island
Description = A blue Mew can be found here every so often.
Switch = 52
#------------------------------- #-------------------------------
[1] [1]
Name = Tiall Name = Tiall
Filename = mapRegion1.png Filename = mapRegion1.png
PointSize = 16,16
Size = 30,20
Point = 13,16,Here Point = 13,16,Here