• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Script: [v17+] Roaming Icon on Map

FL

Pokémon Island Creator
2,452
Posts
13
Years
    • Seen yesterday
    Any plan to update this to be compatible with v19?
    I updated the main post.

    The old version. Tested on v17.2 and v18.1:
    Code:
    #===============================================================================
    # * Roaming Icon - by FL (Credits will be apreciated)
    #===============================================================================
    #
    # This script is for Pokémon Essentials. It displays icons on map for roaming
    # pokémon.
    #
    #===============================================================================
    #
    # To this script works, put it above main. On script section PScreen_RegionMap,
    # add line 'drawRoamingPosition(mapindex)' before line 
    # 'if playerpos && mapindex==playerpos[0]'. For each roaming pokémon icon, put
    # an image on "Graphics/Pictures/mapPokemonXXX.png" changing XXX for species
    # number, where "Graphics/Pictures/mapPokemon000.png" is the default one.
    #
    #===============================================================================
    
    class PokemonRegionMap_Scene
      def drawRoamingPosition(mapindex)
        for roamPos in $PokemonGlobal.roamPosition
          roamingData = RoamingSpecies[roamPos[0]]
          active = $game_switches[roamingData[2]] && (
            $PokemonGlobal.roamPokemon.size <= roamPos[0] || 
            $PokemonGlobal.roamPokemon[roamPos[0]]!=true
          )
          next if !active
          species=getID(PBSpecies,roamingData[0])
          next if !species || species<=0
          pokepos = $game_map ? pbGetMetadata(roamPos[1],MetadataMapPosition) : nil 
          next if mapindex!=pokepos[0]
          x = pokepos[1]
          y = pokepos[2]
          @sprites["roaming#{species}"] = IconSprite.new(0,0,@viewport)
          @sprites["roaming#{species}"].setBitmap(getRoamingIcon(species))
          @sprites["roaming#{species}"].x = -SQUAREWIDTH/2+(x*SQUAREWIDTH)+(
            Graphics.width-@sprites["map"].bitmap.width
          )/2
          @sprites["roaming#{species}"].y = -SQUAREHEIGHT/2+(y*SQUAREHEIGHT)+(
            Graphics.height-@sprites["map"].bitmap.height
          )/2
        end
      end
      
      def getRoamingIcon(species)
        return nil if !species
        fileName = sprintf("Graphics/Pictures/mapPokemon%03d", species)
        ret = pbResolveBitmap(fileName)
        if !ret
          fileName = "Graphics/Pictures/mapPokemon000"
          ret = pbResolveBitmap(fileName)
        end
        return ret
      end
    end
     

    FL

    Pokémon Island Creator
    2,452
    Posts
    13
    Years
    • Seen yesterday
    The icons don't show up for any Roaming Pokémon with different forms (for example, the Galarian Legendary Birds' icons don't show up on the map (they work just fine in terms of gameplay)).
    Script updated to support forms!
     

    FL

    Pokémon Island Creator
    2,452
    Posts
    13
    Years
    • Seen yesterday
    Script updated to work with Essentials v20.1.
     

    WolfPP

    Spriter/ Pixel Artist
    1,309
    Posts
    5
    Years
  • Enamorus one! :)
    Credit me if used.

    Also lemme know if we have more pokémons that use that mechanic (since gen 8).
    Cya!

    Enamorus.png
     
    • Like
    Reactions: FL
    137
    Posts
    1
    Years
    • Seen May 5, 2024
    Hello, I am using PE 20.1 and the icons are not appearing on the map, even though I followed the installation steps in the script. Do you have any idea where this could be coming from?
     

    FL

    Pokémon Island Creator
    2,452
    Posts
    13
    Years
    • Seen yesterday
    Hello, I am using PE 20.1 and the icons are not appearing on the map, even though I followed the installation steps in the script. Do you have any idea where this could be coming from?
    I tested here in v20.1 and it is working.
    • If you converted it into a plugin, make sure that it was compiled and correctly converted.
    • Make sure that the graphics and his folder have the right names. I suggest testing with the examples.
    • Make sure that the roaming pokémon were enabled (you can easily check in debug).
    • Make sure that you pasted the line in the right place.
    • If nothing works, test in a vanilla v20.1, maybe is something in your project interfering.
     
    137
    Posts
    1
    Years
    • Seen May 5, 2024
    I tested here in v20.1 and it is working.
    • If you converted it into a plugin, make sure that it was compiled and correctly converted.
    • Make sure that the graphics and his folder have the right names. I suggest testing with the examples.
    • Make sure that the roaming pokémon were enabled (you can easily check in debug).
    • Make sure that you pasted the line in the right place.
    • If nothing works, test in a vanilla v20.1, maybe is something in your project interfering.
    Do you think the issue could be related to the fact that I'm using 4 regions?
     

    FL

    Pokémon Island Creator
    2,452
    Posts
    13
    Years
    • Seen yesterday
    Do you think the issue could be related to the fact that I'm using 4 regions?
    I tested now, the script work with other regions. You can find the roaming pokémon in these regions?
     

    Attachments

    • Roamtiall.png
      Roamtiall.png
      9.6 KB · Views: 3
    137
    Posts
    1
    Years
    • Seen May 5, 2024
    I tested now, the script work with other regions. You can find the roaming pokémon in these regions?
    Yes, the Pokémon in question are findable/capturable. Here's the list of plugins I'm using with PE 20.1. Please let me know if you have any compatibility concerns with any of these or if you know of any. Thank you in advance for your help and your work:
    Spoiler: Plugin list
     

    FL

    Pokémon Island Creator
    2,452
    Posts
    13
    Years
    • Seen yesterday
    Yes, the Pokémon in question are findable/capturable. Here's the list of plugins I'm using with PE 20.1. Please let me know if you have any compatibility concerns with any of these or if you know of any. Thank you in advance for your help and your work:
    Spoiler: Plugin list
    By name, no one looks like it was changing the map system.

    If you have a code editor (like Atom, VS Code and Notepad++) you can make sure. Search for 'class PokemonRegionMap_Scene' (you can search at all files once, opening the folder and using the editor global Ctrl+F, the command is Ctrl+Shif+F for VS Code). If this piece of code was found, some script redefines something in the map. If the scripts redefines pbStartScene (the 'def pbStartScene' was inside of class PokemonRegionMap_Scene) doing this script instructions (pasting 'draw_roaming_position(mapindex)' in the right spot) may make the script compatible.
     
    137
    Posts
    1
    Years
    • Seen May 5, 2024
    By name, no one looks like it was changing the map system.

    If you have a code editor (like Atom, VS Code and Notepad++) you can make sure. Search for 'class PokemonRegionMap_Scene' (you can search at all files once, opening the folder and using the editor global Ctrl+F, the command is Ctrl+Shif+F for VS Code). If this piece of code was found, some script redefines something in the map. If the scripts redefines pbStartScene (the 'def pbStartScene' was inside of class PokemonRegionMap_Scene) doing this script instructions (pasting 'draw_roaming_position(mapindex)' in the right spot) may make the script compatible.
    Thank you very much for your help, the issue was with the use of the plugin: Lin's Pokegear Themes, it was just necessary to integrate your function into it. Everything is functional now!
     
    • Like
    Reactions: FL
    2
    Posts
    3
    Years
    • Seen today
    Hey Fl, Great script I love it.

    Any way to make it be shown in the Pokedex instead of townmaps?

    Also found a "glitch" I think.
    When flip a switch for the "Roaming" encounter, and I open the Pokegear's Town map before changing map, so that the roaming encounter updates, my game crashes.
    If I wait with opening the town map til after I've changed map once it works.

    I haven't converted it into a plugin or any of the sorts.
     

    Attachments

    • 1712611975776.png
      1712611975776.png
      26.3 KB · Views: 2

    FL

    Pokémon Island Creator
    2,452
    Posts
    13
    Years
    • Seen yesterday
    Any way to make it be shown in the Pokedex instead of townmaps?
    After the last `end` in my script, add

    Code:
    class PokemonRegionMap_Scene
      def self.refresh_pokedex(sprites, visible)
        icon_index = 0
        loop do
          break if !sprites["roaming#{icon_index}"]
          sprites["roaming#{icon_index}"].visible = visible
          icon_index+=1
        end
      end
      def self.draw_roaming_position2(sprites, viewport, mapindex)
        icon_index = 0
        for roam_pos in $PokemonGlobal.roamPosition
          active = $game_switches[Settings::ROAMING_SPECIES[roam_pos[0]][2]] && (
            $PokemonGlobal.roamPokemon.size <= roam_pos[0] || 
            $PokemonGlobal.roamPokemon[roam_pos[0]]!=true
          )
          next if !active
          roam_town_map_pos = GameData::MapMetadata.try_get(
            roam_pos[1]
          )&.town_map_position
          next if mapindex!=roam_town_map_pos&.[](0)
          x = roam_town_map_pos[1]
          y = roam_town_map_pos[2]
          sprites["roaming#{icon_index}"] = IconSprite.new(0,0,viewport)
          sprites["roaming#{icon_index}"].setBitmap(
            get_roaming_icon2(Settings::ROAMING_SPECIES[roam_pos[0]][0])
          )
          sprites["roaming#{icon_index}"].x = -SQUARE_WIDTH/2+(x*SQUARE_WIDTH)+(
            Graphics.width-sprites["areamap"].bitmap.width
          )/2
          sprites["roaming#{icon_index}"].y = -SQUARE_HEIGHT/2+(y*SQUARE_HEIGHT)+(
            Graphics.height-sprites["areamap"].bitmap.height
          )/2
          icon_index+=1
        end
      end
      def self.get_roaming_icon2(species)
        species_data = GameData::Species.try_get(species)
        return nil if !species_data
        path = "Graphics/Pokemon/Map icons/"
        if species_data.form > 0
          ret = pbResolveBitmap(
            sprintf("%s%s_%d",path, species_data.species, species_data.form)
          )
          return ret if ret
        end
        ret = pbResolveBitmap(sprintf("%s%s", path, species_data.species))
        return ret if ret
        return pbResolveBitmap(path+"000")
      end
    end

    Then, in UI Pokédex Entry, before line
    Code:
    @sprites["areahighlight"] = BitmapSprite.new(Graphics.width, Graphics.height, @viewport)
    add
    Code:
    PokemonRegionMap_Scene.draw_roaming_position2(@sprites,@viewport,@region)

    After line
    Code:
    overlay.clear
    add line
    Code:
    PokemonRegionMap_Scene.refresh_pokedex(@sprites, @page == 2)
    .

    Also found a "glitch" I think.
    When flip a switch for the "Roaming" encounter, and I open the Pokegear's Town map before changing map, so that the roaming encounter updates, my game crashes.
    If I wait with opening the town map til after I've changed map once it works.

    I haven't converted it into a plugin or any of the sorts.
    Fixed. Thanks!
     
    2
    Posts
    3
    Years
    • Seen today
    After the last `end` in my script, add

    Code:
    class PokemonRegionMap_Scene
      def self.refresh_pokedex(sprites, visible)
        icon_index = 0
        loop do
          break if !sprites["roaming#{icon_index}"]
          sprites["roaming#{icon_index}"].visible = visible
          icon_index+=1
        end
      end
      def self.draw_roaming_position2(sprites, viewport, mapindex)
        icon_index = 0
        for roam_pos in $PokemonGlobal.roamPosition
          active = $game_switches[Settings::ROAMING_SPECIES[roam_pos[0]][2]] && (
            $PokemonGlobal.roamPokemon.size <= roam_pos[0] ||
            $PokemonGlobal.roamPokemon[roam_pos[0]]!=true
          )
          next if !active
          roam_town_map_pos = GameData::MapMetadata.try_get(
            roam_pos[1]
          )&.town_map_position
          next if mapindex!=roam_town_map_pos&.[](0)
          x = roam_town_map_pos[1]
          y = roam_town_map_pos[2]
          sprites["roaming#{icon_index}"] = IconSprite.new(0,0,viewport)
          sprites["roaming#{icon_index}"].setBitmap(
            get_roaming_icon2(Settings::ROAMING_SPECIES[roam_pos[0]][0])
          )
          sprites["roaming#{icon_index}"].x = -SQUARE_WIDTH/2+(x*SQUARE_WIDTH)+(
            Graphics.width-sprites["areamap"].bitmap.width
          )/2
          sprites["roaming#{icon_index}"].y = -SQUARE_HEIGHT/2+(y*SQUARE_HEIGHT)+(
            Graphics.height-sprites["areamap"].bitmap.height
          )/2
          icon_index+=1
        end
      end
      def self.get_roaming_icon2(species)
        species_data = GameData::Species.try_get(species)
        return nil if !species_data
        path = "Graphics/Pokemon/Map icons/"
        if species_data.form > 0
          ret = pbResolveBitmap(
            sprintf("%s%s_%d",path, species_data.species, species_data.form)
          )
          return ret if ret
        end
        ret = pbResolveBitmap(sprintf("%s%s", path, species_data.species))
        return ret if ret
        return pbResolveBitmap(path+"000")
      end
    end

    Then, in UI Pokédex Entry, before line
    Code:
    @sprites["areahighlight"] = BitmapSprite.new(Graphics.width, Graphics.height, @viewport)
    add
    Code:
    PokemonRegionMap_Scene.draw_roaming_position2(@sprites,@viewport,@region)

    After line
    Code:
    overlay.clear
    add line
    Code:
    PokemonRegionMap_Scene.refresh_pokedex(@sprites, @page == 2)
    .

    Fixed. Thanks!
    Hey Fl. Thanks alot, I updated the script. and did the changes you've done, the image shows in the Pokedex as I want, but the "Area unknown" text is still in the middle of the screen is there a way to remove that?
     
    Back
    Top