• 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.

Region Map Shows Encounters

150
Posts
8
Years
  • Age 31
  • Seen Jul 13, 2023
Region Map Shows Encounters
Current Version: 1.1

yItL0uI.gif

*This script will work with both PE v16.2 and v17+!
**This script might be incompatible with other scripts that edit the Region Map! If you find an incompatibility, let me know and I will attempt to resolve it.
***Place this script somewhere above Main.


-------
Shows a note on whether or not an area has Wild Pokémon encounters on the Region Map screen.

I've included some options that can be used to control things like when the text should display, what message to use, etc. at the top of the script section.

External Script Download

Changelog:
Spoiler:


Script:
Code:
#==============================================================================#
#//////////////////////////////////////////////////////////////////////////////#
#==============================================================================#
#                                                                              #
#                    Region Map Shows Encounters v1.1                          #
#                          By Ulithium_Dragon                                  #
#                                                                              #
#==============================================================================#
#         ------------------------------------------------------               #
# Displays if a map has wild encounters on hover when viewing the Region Map.  #
#         ------------------------------------------------------               #
#==============================================================================#
#                                                                              #
#       **Place this script somewhere above Main and below Compiler.**         #
#                                                                              #
#==============================================================================#
#------------------------------------------------------------------------------#
#==============================================================================#
# ____________________________________________________________________________ #
#                                                                              #
#                            ::::Options::::                                   #
#                                --------                                      #
#       Below are the options for toggling certain features on or off:         #
# ____________________________________________________________________________ #
#                                                                              #
#---------------------------#                                                  #
#  Shows the Wild Pokemon note only if the player has visited that map before. #
    ONLYSHOWAFTERVISIT = false    #Default: false
#---------------------------#                                                  #
#  Controls whether the Wild Pokemon note should be display on the Fly Map.    #
    DISPLAYONFLYMAP = true    #Default: true
#---------------------------#                                                  #
#  Makes every map show Unknown text regardless of if they have encounters.    #
#  *NOTE: Without this enabled, players could figure out if a map has          #
#   encounters simply by seeing if the Unknown text is displayed or not.       #
    UNKNOWNMSG_ALLMAPS = true    #Default: true
#---------------------------#                                                  #
#  Sets the text to display for Unknown maps                                   #
#   *NOTE: This does nothing unless ONLYSHOWAFTERVISIT is set to "true"        #
    UNKNOWNMAP_ENCMSG = "Unknown"    #Default: "Unknown"
#---------------------------#                                                  #
#  Sets the text to display for maps with Wild Pokémon.                        #
    WILDPOKEMON_MAPMSG = "Wild Pokémon"    #Default: "Wild Pokémon"
#---------------------------#                                                  #
#  Controls if the display should only show up when a certain key is held.     #
    SHOWON_KEYHOLD = false    #Default: false
#---------------------------#                                                  #
#  Defines the key that toggles the display on/off for a specific square.      #
#   *NOTE: Don't set set this to the same key as Activate. If you do, it will  #
#    cause the player to fly to that destination if used on the Fly Map!       #
#   **VERY IMPORTANT!!!: The key you pick here MUST be defined properly in     #
#    in "PSystem_Controls" OR THIS WON'T DO ANYTHING!                          #
    DISPLAYACTIVATE_KEY = Input::CTRL    #Default: Input::CTRL
#------------------------------------------------------------------------------#
#\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\#
#==============================================================================#

class MapBottomSprite < SpriteWrapper
  # An edited version of the function from PScreen_RegionMap.
  def initialize(viewport=nil)
    super(viewport)
    @mapname=""
    @maplocation=""
    @mapdetails=""
    @mapencounters=""  #For Map Encounters
    @nonests=false
    @thisbitmap=BitmapWrapper.new(Graphics.width,Graphics.height)
    pbSetSystemFont(@thisbitmap)
    self.y=0
    self.x=0
    self.bitmap=@thisbitmap
    refresh
  end

  #For Map Encounters
  def mapencounters=(value)
    if @mapencounters!=value
      @mapencounters=value
      refresh
    end
  end

  def refresh
    self.bitmap.clear
    if @nonests
      imagepos=[[sprintf("Graphics/Pictures/pokedexNestUnknown"),108,172,0,0,-1,-1]]
      pbDrawImagePositions(self.bitmap,imagepos)
    end
    textpos=[
       [@mapname,18,-2,0,Color.new(248,248,248),Color.new(0,0,0)],
       [@maplocation,18,354,0,Color.new(248,248,248),Color.new(0,0,0)],
       [@mapdetails,Graphics.width-16,354,1,Color.new(248,248,248),Color.new(0,0,0)],
       #For Map Encounters
       [@mapencounters,Graphics.width-16,3-2,1,Color.new(248,248,248),Color.new(0,0,0)]
    ]
    if @nonests
      textpos.push([_INTL("Area Unknown"),Graphics.width/2,Graphics.height/2-16,2,
         Color.new(88,88,80),Color.new(168,184,184)])
    end
    pbDrawTextPositions(self.bitmap,textpos)
  end
end


class PokemonRegionMapScene
  # An edited version of the function from PScreen_RegionMap.
  def pbStartScene(aseditor=false,mode=0)
    $mapisfly_mode = mode  #For Map Encounters
    @editor=aseditor
    @viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
    @viewport.z=99999
    @sprites={}
    pbRgssOpen("Data/townmap.dat","rb"){|f|
       @mapdata=Marshal.load(f)
    }
    playerpos=!$game_map ? nil : pbGetMetadata($game_map.map_id,MetadataMapPosition)
    if !playerpos
      mapindex=0
      @map=@mapdata[0]
      @mapX=LEFT
      @mapY=TOP
    elsif @region>=0 && @region!=playerpos[0] && @mapdata[@region]
      mapindex=@region
      @map=@mapdata[@region]
      @mapX=LEFT
      @mapY=TOP
    else
      mapindex=playerpos[0]
      @map=@mapdata[playerpos[0]]
      @mapX=playerpos[1]
      @mapY=playerpos[2]
      mapsize=!$game_map ? nil : pbGetMetadata($game_map.map_id,MetadataMapSize)
      if mapsize && mapsize[0] && mapsize[0]>0
        sqwidth=mapsize[0]
        sqheight=(mapsize[1].length*1.0/mapsize[0]).ceil
        if sqwidth>1
          @mapX+=($game_player.x*sqwidth/$game_map.width).floor
        end
        if sqheight>1
          @mapY+=($game_player.y*sqheight/$game_map.height).floor
        end
      end
    end
    if !@map
      Kernel.pbMessage(_INTL("The map data cannot be found."))
      return false
    end
    addBackgroundOrColoredPlane(@sprites,"background","mapbg",Color.new(0,0,0),@viewport)
    @sprites["map"]=IconSprite.new(0,0,@viewport)
    @sprites["map"].setBitmap("Graphics/Pictures/#{@map[1]}")
    @sprites["map"].x+=(Graphics.width-@sprites["map"].bitmap.width)/2
    @sprites["map"].y+=(Graphics.height-@sprites["map"].bitmap.height)/2
    for hidden in REGIONMAPEXTRAS
      if hidden[0]==mapindex && ((@wallmap && hidden[5]) ||
         (!@wallmap && hidden[1]>0 && $game_switches[hidden[1]]))
        if !@sprites["map2"]
          @sprites["map2"]=BitmapSprite.new(480,320,@viewport)
          @sprites["map2"].x=@sprites["map"].x; @sprites["map2"].y=@sprites["map"].y
        end
        pbDrawImagePositions(@sprites["map2"].bitmap,[
           ["Graphics/Pictures/#{hidden[4]}",hidden[2]*SQUAREWIDTH,hidden[3]*SQUAREHEIGHT,0,0,-1,-1]
        ])
      end
    end
    @sprites["mapbottom"]=MapBottomSprite.new(@viewport)
    @sprites["mapbottom"].mapname=pbGetMessage(MessageTypes::RegionNames,mapindex)
    @sprites["mapbottom"].maplocation=pbGetMapLocation(@mapX,@mapY)
    @sprites["mapbottom"].mapdetails=pbGetMapDetails(@mapX,@mapY)
    #For Map Encounters
    @sprites["mapbottom"].mapencounters=pbGetMapHasEncounters(@mapX,@mapY)
    if playerpos && mapindex==playerpos[0]
      @sprites["player"]=IconSprite.new(0,0,@viewport)
      @sprites["player"].setBitmap(pbPlayerHeadFile($Trainer.trainertype))
      @sprites["player"].x=-SQUAREWIDTH/2+(@mapX*SQUAREWIDTH)+(Graphics.width-@sprites["map"].bitmap.width)/2
      @sprites["player"].y=-SQUAREHEIGHT/2+(@mapY*SQUAREHEIGHT)+(Graphics.height-@sprites["map"].bitmap.height)/2
    end
    if mode>0
      k=0
      for i in LEFT..RIGHT
        for j in TOP..BOTTOM
          healspot=pbGetHealingSpot(i,j)
          if healspot && $PokemonGlobal.visitedMaps[healspot[0]]
            @sprites["point#{k}"]=AnimatedSprite.create("Graphics/Pictures/mapFly",2,30)
            @sprites["point#{k}"].viewport=@viewport
            @sprites["point#{k}"].x=-SQUAREWIDTH/2+(i*SQUAREWIDTH)+(Graphics.width-@sprites["map"].bitmap.width)/2
            @sprites["point#{k}"].y=-SQUAREHEIGHT/2+(j*SQUAREHEIGHT)+(Graphics.height-@sprites["map"].bitmap.height)/2
            @sprites["point#{k}"].play
            k+=1
          end
        end
      end
    end
    @sprites["cursor"]=AnimatedSprite.create("Graphics/Pictures/mapCursor",2,15)
    @sprites["cursor"].viewport=@viewport
    @sprites["cursor"].play
    @sprites["cursor"].x=-SQUAREWIDTH/2+(@mapX*SQUAREWIDTH)+(Graphics.width-@sprites["map"].bitmap.width)/2
    @sprites["cursor"].y=-SQUAREHEIGHT/2+(@mapY*SQUAREHEIGHT)+(Graphics.height-@sprites["map"].bitmap.height)/2
    @changed=false
    pbFadeInAndShow(@sprites){ pbUpdate }
    return true
  end

  #For Map Encounters
  def pbGetMapHasEncounters(x,y)
    data=load_data("Data/encounters.dat")
    return nil if !@map[2]
    for loc in @map[2]
      if loc[0]==x && loc[1]==y
        hovermap_id = loc[4]
        # Doesn't show the info if displaying on the Fly Map is disabled.
        return "" if !DISPLAYONFLYMAP && $mapisfly_mode>0
        if data.is_a?(Hash) && data[hovermap_id]
          # If true, only show the info after the map has been visited before.
          if ONLYSHOWAFTERVISIT
            if $PokemonGlobal.visitedMaps[hovermap_id]
              if SHOWON_KEYHOLD
                if Input.press?(DISPLAYACTIVATE_KEY)
                  return WILDPOKEMON_MAPMSG
                else 
                  return ""
                end
              end
            else
              # Returns the message set to show when the map encounter is unknown.
              if SHOWON_KEYHOLD
                if Input.press?(DISPLAYACTIVATE_KEY)
                  return UNKNOWNMAP_ENCMSG
                else
                  return ""
                end
              end
              return ""
            end
          else
            if SHOWON_KEYHOLD
              if Input.press?(DISPLAYACTIVATE_KEY)
                return WILDPOKEMON_MAPMSG
              else
                return ""
              end
            else
              if SHOWON_KEYHOLD
                if Input.press?(DISPLAYACTIVATE_KEY)
                  return UNKNOWNMAP_ENCMSG
                else
                  return ""
                end
              end
              return ""
            end
          end
        else
          # Returns the Unknown message for all maps regardless of if they
          # actually have encounters or not if UNKNOWNMSGALLMAPS is enabled.
          if UNKNOWNMSG_ALLMAPS && ONLYSHOWAFTERVISIT
            if SHOWON_KEYHOLD
              if Input.press?(DISPLAYACTIVATE_KEY)
                return UNKNOWNMAP_ENCMSG
              else
                return ""
              end
            else
              return UNKNOWNMAP_ENCMSG
            end
          else 
            return ""
          end
        end
      end
    end
    return ""
  end


  # An edited version of the function from PScreen_RegionMap.
  def pbMapScene(mode=0)
    xOffset=0
    yOffset=0
    newX=0
    newY=0
    @sprites["cursor"].x=-SQUAREWIDTH/2+(@mapX*SQUAREWIDTH)+(Graphics.width-@sprites["map"].bitmap.width)/2
    @sprites["cursor"].y=-SQUAREHEIGHT/2+(@mapY*SQUAREHEIGHT)+(Graphics.height-@sprites["map"].bitmap.height)/2
    loop do
      Graphics.update
      Input.update
      pbUpdate
      if xOffset!=0 || yOffset!=0
        xOffset+=xOffset>0 ? -4 : (xOffset<0 ? 4 : 0)
        yOffset+=yOffset>0 ? -4 : (yOffset<0 ? 4 : 0)
        @sprites["cursor"].x=newX-xOffset
        @sprites["cursor"].y=newY-yOffset
        next
      end
      @sprites["mapbottom"].maplocation=pbGetMapLocation(@mapX,@mapY)
      @sprites["mapbottom"].mapdetails=pbGetMapDetails(@mapX,@mapY)
      #For Map Encounters
      @sprites["mapbottom"].mapencounters=pbGetMapHasEncounters(@mapX,@mapY)
      ox=0
      oy=0
      case Input.dir8
      when 1 # lower left
        oy=1 if @mapY<BOTTOM
        ox=-1 if @mapX>LEFT
      when 2 # down
        oy=1 if @mapY<BOTTOM
      when 3 # lower right
        oy=1 if @mapY<BOTTOM
        ox=1 if @mapX<RIGHT
      when 4 # left
        ox=-1 if @mapX>LEFT
      when 6 # right
        ox=1 if @mapX<RIGHT
      when 7 # upper left
        oy=-1 if @mapY>TOP
        ox=-1 if @mapX>LEFT
      when 8 # up
        oy=-1 if @mapY>TOP
      when 9 # upper right
        oy=-1 if @mapY>TOP
        ox=1 if @mapX<RIGHT
      end
      if ox!=0 || oy!=0
        @mapX+=ox
        @mapY+=oy
        xOffset=ox*SQUAREWIDTH
        yOffset=oy*SQUAREHEIGHT
        newX=@sprites["cursor"].x+xOffset
        newY=@sprites["cursor"].y+yOffset
      end
      if Input.trigger?(Input::B)
        if @editor && @changed
          if Kernel.pbConfirmMessage(_INTL("Save changes?")) { pbUpdate }
            pbSaveMapData
          end
          if Kernel.pbConfirmMessage(_INTL("Exit from the map?")) { pbUpdate }
            break
          end
        else
          break
        end
      elsif Input.trigger?(Input::C) && mode==1 # Choosing an area to fly to
        healspot=pbGetHealingSpot(@mapX,@mapY)
        if healspot
          if $PokemonGlobal.visitedMaps[healspot[0]] ||
             ($DEBUG && Input.press?(Input::CTRL))
            return healspot
          end
        end
      elsif Input.trigger?(Input::C) && @editor # Intentionally placed after other C button check
        pbChangeMapLocation(@mapX,@mapY)
      end
    end
    return nil
  end
end
 
Last edited:
5
Posts
6
Years
  • Age 28
  • Seen Mar 31, 2019
amazing <3. Question I gave a quick look cuz I'm in a hurry but there is a key to press for it to appear?
 
Last edited:
150
Posts
8
Years
  • Age 31
  • Seen Jul 13, 2023
Update Released:

v1.1:
- Added some options to control if the message should only be shown if a certain key is held down.
 
Back
Top