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

@@ -17,6 +17,15 @@ end
#===============================================================================
# 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.
def pbResetAllRoamers
return if !$PokemonGlobal.roamPokemon
@@ -30,7 +39,7 @@ end
def pbRoamingAreas(idxRoamer)
# [species ID, level, Game Switch, encounter type, battle BGM, area maps hash]
roamData = Settings::ROAMING_SPECIES[idxRoamer]
return roamData[5] if roamData && roamData[5]
return roamData[:areas] if roamData && roamData[:areas]
return Settings::ROAMING_AREAS
end
@@ -47,8 +56,8 @@ def pbRoamPokemon
# Start all roamers off in random maps
if !$PokemonGlobal.roamPosition
$PokemonGlobal.roamPosition = {}
Settings::ROAMING_SPECIES.length.times do |i|
next if !GameData::Species.exists?(Settings::ROAMING_SPECIES[i][0])
Settings::ROAMING_SPECIES.each_with_index do |roamer, i|
next if !GameData::Species.exists?(roamer[:species])
keys = pbRoamingAreas(i).keys
$PokemonGlobal.roamPosition[i] = keys[rand(keys.length)]
end
@@ -62,10 +71,9 @@ end
# 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).
def pbRoamPokemonOne(idxRoamer)
# [species ID, level, Game Switch, encounter type, battle BGM, area maps hash]
roamData = Settings::ROAMING_SPECIES[idxRoamer]
return if roamData[2] > 0 && !$game_switches[roamData[2]] # Game Switch is off
return if !GameData::Species.exists?(roamData[0])
roamer = Settings::ROAMING_SPECIES[idxRoamer]
return if !GameData::Species.exists?(roamer[:species])
return if roamer[:game_switch] && roamer[:game_switch] > 0 && !$game_switches[roamer[:game_switch]]
# Get hash of area patrolled by the roaming Pokémon
mapIDs = pbRoamingAreas(idxRoamer).keys
return if !mapIDs || mapIDs.length == 0 # No roaming area defined somehow
@@ -81,10 +89,10 @@ def pbRoamPokemonOne(idxRoamer)
return if !nextMaps
nextMaps.each { |map| newMapChoices.push(map) }
# 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
if newMapChoices.length > 0
$PokemonGlobal.roamPosition[idxRoamer] = newMapChoices[rand(newMapChoices.length)]
$PokemonGlobal.roamPosition[idxRoamer] = newMapChoices.sample
end
end
@@ -118,16 +126,16 @@ def pbRoamingMethodAllowed(roamer_method)
enc_type = $PokemonEncounters.encounter_type
type = GameData::EncounterType.get(enc_type).type
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)
when 1 # Walking (except Bug Contest)
when :land # Walking (except Bug Contest)
return [:land, :cave].include?(type)
when 2 # Surfing
return type == :water
when 3 # Fishing
return type == :fishing
when 4 # Water-based
when :water # Surfing or rishing
return [:water, :fishing].include?(type)
when :surfing # Surfing
return type == :water
when :fishing # Fishing
return type == :fishing
end
return false
end
@@ -146,11 +154,7 @@ EventHandlers.add(:on_wild_species_chosen, :roaming_pokemon,
currentRegion = pbGetCurrentRegion
currentMapName = $game_map.name
possible_roamers = []
Settings::ROAMING_SPECIES.each_with_index do |data, 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
each_active_roamer do |roamer, i|
# Get the roamer's current map
roamerMap = $PokemonGlobal.roamPosition[i]
if !roamerMap
@@ -168,9 +172,9 @@ EventHandlers.add(:on_wild_species_chosen, :roaming_pokemon,
next if pbGetMapNameFromId(roamerMap) != currentMapName
end
# 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
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
# No encounterable roaming Pokémon were found, just have the regular encounter
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 :pokedexIndex # Last species viewed per Dex
attr_accessor :pokedexMode # Search mode
# Town Map
attr_accessor :townMapMarkings
# Day Care
attr_accessor :day_care
# Special battle modes
@@ -78,6 +80,8 @@ class PokemonGlobalMetadata
(numRegions + 1).times do |i| # National Dex isn't a region, but is included
@pokedexIndex[i] = 0
end
# Town Map
@townMapMarkings = []
# Day Care
@day_care = DayCare.new
# Special battle modes