From 5f39363e690bcb090ce0cee22f19e60100c66444 Mon Sep 17 00:00:00 2001 From: Maruno17 Date: Mon, 14 Feb 2022 23:25:10 +0000 Subject: [PATCH] =?UTF-8?q?Added=20map=20metadata=20flag=20"HideEncounters?= =?UTF-8?q?InPokedex",=20fixed=20Pok=C3=A9dex=20not=20showing=20the=20area?= =?UTF-8?q?s=20of=20some=20maps=20that=20span=20multiple=20Town=20Map=20po?= =?UTF-8?q?ints?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../001_Technical/005_PluginManager.rb | 1 + Data/Scripts/016_UI/004_UI_Pokedex_Entry.rb | 90 +++++++++++-------- .../008_Debug_BattlePkmnCommands.rb | 18 +++- 3 files changed, 68 insertions(+), 41 deletions(-) diff --git a/Data/Scripts/001_Technical/005_PluginManager.rb b/Data/Scripts/001_Technical/005_PluginManager.rb index c2a8375ac..329849c43 100644 --- a/Data/Scripts/001_Technical/005_PluginManager.rb +++ b/Data/Scripts/001_Technical/005_PluginManager.rb @@ -677,6 +677,7 @@ module PluginManager # collect garbage GC.start Console.echo_done(true) + echoln "" if scripts.length == 0 end #----------------------------------------------------------------------------- # Check if plugins need compiling diff --git a/Data/Scripts/016_UI/004_UI_Pokedex_Entry.rb b/Data/Scripts/016_UI/004_UI_Pokedex_Entry.rb index f81c6a539..cc9947bb3 100644 --- a/Data/Scripts/016_UI/004_UI_Pokedex_Entry.rb +++ b/Data/Scripts/016_UI/004_UI_Pokedex_Entry.rb @@ -288,64 +288,80 @@ class PokemonPokedexInfo_Scene return false end + # Returns a 1D array of values corresponding to points on the Town Map. Each + # value is true or false. + def pbGetEncounterPoints + # Determine all visible points on the Town Map (i.e. only ones with a + # defined point in town_map.txt, and which either have no Self Switch + # controlling their visibility or whose Self Switch is ON) + visible_points = [] + @mapdata[@region][2].each do |loc| + next if loc[7] && !$game_switches[loc[7]] # Point is not visible + visible_points.push([loc[0], loc[1]]) + end + # Find all points with a visible area for @species + town_map_width = 1 + PokemonRegionMap_Scene::RIGHT - PokemonRegionMap_Scene::LEFT + ret = [] + GameData::Encounter.each_of_version($PokemonGlobal.encounter_version) do |enc_data| + next if !pbFindEncounter(enc_data.types, @species) # Species isn't in encounter table + # Get the map belonging to the encounter table + map_metadata = GameData::MapMetadata.try_get(enc_data.map) + next if !map_metadata || map_metadata.has_flag?("HideEncountersInPokedex") + mappos = map_metadata.town_map_position + next if mappos[0] != @region # Map isn't in the region being shown + # Get the size and shape of the map in the Town Map + map_size = map_metadata.town_map_size + map_width = 1 + map_height = 1 + map_shape = "1" + if map_size && map_size[0] && map_size[0] > 0 # Map occupies multiple points + map_width = map_size[0] + map_shape = map_size[1] + map_height = (map_shape.length.to_f / map_width).ceil + end + # Mark each visible point covered by the map as containing the area + map_width.times do |i| + map_height.times do |j| + next if map_shape[i + (j * map_width), 1].to_i == 0 # Point isn't part of map + next if !visible_points.include?([mappos[1] + i, mappos[2] + j]) # Point isn't visible + ret[mappos[1] + i + ((mappos[2] + j) * town_map_width)] = true + end + end + end + return ret + end + def drawPageArea @sprites["background"].setBitmap(_INTL("Graphics/Pictures/Pokedex/bg_area")) overlay = @sprites["overlay"].bitmap base = Color.new(88, 88, 80) shadow = Color.new(168, 184, 184) @sprites["areahighlight"].bitmap.clear - # Fill the array "points" with all squares of the region map in which the - # species can be found - points = [] - mapwidth = 1 + PokemonRegionMap_Scene::RIGHT - PokemonRegionMap_Scene::LEFT - GameData::Encounter.each_of_version($PokemonGlobal.encounter_version) do |enc_data| - next if !pbFindEncounter(enc_data.types, @species) - map_metadata = GameData::MapMetadata.try_get(enc_data.map) - mappos = (map_metadata) ? map_metadata.town_map_position : nil - next if !mappos || mappos[0] != @region - showpoint = true - @mapdata[@region][2].each do |loc| - showpoint = false if loc[0] == mappos[1] && loc[1] == mappos[2] && - loc[7] && !$game_switches[loc[7]] - end - next if !showpoint - mapsize = map_metadata.town_map_size - if mapsize && mapsize[0] && mapsize[0] > 0 - sqwidth = mapsize[0] - sqheight = (mapsize[1].length.to_f / mapsize[0]).ceil - sqwidth.times do |i| - sqheight.times do |j| - if mapsize[1][i + (j * sqwidth), 1].to_i > 0 - points[mappos[1] + i + ((mappos[2] + j) * mapwidth)] = true - end - end - end - else - points[mappos[1] + (mappos[2] * mapwidth)] = true - end - end - # Draw coloured squares on each square of the region map with a nest + # Get all points to be shown as places where @species can be encountered + points = pbGetEncounterPoints + # Draw coloured squares on each point of the Town Map with a nest pointcolor = Color.new(0, 248, 248) pointcolorhl = Color.new(192, 248, 248) + town_map_width = 1 + PokemonRegionMap_Scene::RIGHT - PokemonRegionMap_Scene::LEFT sqwidth = PokemonRegionMap_Scene::SQUARE_WIDTH sqheight = PokemonRegionMap_Scene::SQUARE_HEIGHT points.length.times do |j| next if !points[j] - x = (j % mapwidth) * sqwidth + x = (j % town_map_width) * sqwidth x += (Graphics.width - @sprites["areamap"].bitmap.width) / 2 - y = (j / mapwidth) * sqheight + y = (j / town_map_width) * sqheight y += (Graphics.height + 32 - @sprites["areamap"].bitmap.height) / 2 @sprites["areahighlight"].bitmap.fill_rect(x, y, sqwidth, sqheight, pointcolor) - if j - mapwidth < 0 || !points[j - mapwidth] + if j - town_map_width < 0 || !points[j - town_map_width] @sprites["areahighlight"].bitmap.fill_rect(x, y - 2, sqwidth, 2, pointcolorhl) end - if j + mapwidth >= points.length || !points[j + mapwidth] + if j + town_map_width >= points.length || !points[j + town_map_width] @sprites["areahighlight"].bitmap.fill_rect(x, y + sqheight, sqwidth, 2, pointcolorhl) end - if j % mapwidth == 0 || !points[j - 1] + if j % town_map_width == 0 || !points[j - 1] @sprites["areahighlight"].bitmap.fill_rect(x - 2, y, 2, sqheight, pointcolorhl) end - if (j + 1) % mapwidth == 0 || !points[j + 1] + if (j + 1) % town_map_width == 0 || !points[j + 1] @sprites["areahighlight"].bitmap.fill_rect(x + sqwidth, y, 2, sqheight, pointcolorhl) end end diff --git a/Data/Scripts/020_Debug/003_Debug menus/008_Debug_BattlePkmnCommands.rb b/Data/Scripts/020_Debug/003_Debug menus/008_Debug_BattlePkmnCommands.rb index e45082af3..e6c330a72 100644 --- a/Data/Scripts/020_Debug/003_Debug menus/008_Debug_BattlePkmnCommands.rb +++ b/Data/Scripts/020_Debug/003_Debug menus/008_Debug_BattlePkmnCommands.rb @@ -1,10 +1,16 @@ =begin # TODO: -Trigger ability (probably not) -Some stuff relating to Shadow Pokémon? Actual stats? @attack, @defense, etc. @turnCount +Toggle Hyper Mode for a Shadow Pokémon + +Stuff for Pokémon that aren't in battle: +* Set HP to 0 +* Set species +* Set Poké Ball +* Set nickname +* Make a Shadow Pokémon, set Heart Gauge (perhaps also for battlers) =end @@ -582,8 +588,12 @@ MenuHandlers.add(:battle_pokemon_debug_menu, :set_ability, { commands.push(_INTL("Set ability for battler")) if battler commands.push(_INTL("Reset")) loop do - msg = _INTL("Battler's ability is {1}. Pokémon's ability is {2}.", - battler.abilityName, pkmn.ability.name) + if battler + msg = _INTL("Battler's ability is {1}. Pokémon's ability is {2}.", + battler.abilityName, pkmn.ability.name) + else + msg = _INTL("Pokémon's ability is {1}.", pkmn.ability.name) + end cmd = pbMessage("\\ts[]" + msg, commands, -1, nil, cmd) break if cmd < 0 cmd = 2 if cmd >= 1 && !battler # Correct command for Pokémon (no battler)