• 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: Visible Overworld Wild Encounter

308
Posts
4
Years
  • OverworldEncounter.gif

    * Visible Overworld Wild Encounters Version - by derFischae (Credits if used please) *

    UPDATED TO VERSION 20.0.0.4 FOR POKEMON ESSENTIALS V20 AND V21.

    This script is for Pokémon Essentials V16.2, V17, V17.2, V18, V18.1, V19.1, V20, V20.1, V21 and V21.1.

    As in Pokemon Let's go Pikachu/Eevee or Pokemon Shield and Sword wild encounters pop up on the overworld, they move around and you can start the battle with them simply by moving to the pokemon. Clearly, you also can omit the battle by circling around them.

    Credits: Originally written for PEv17 and PEv17.2 by me. Downscaled to PEv16.2 by ArchyTheArc. Additionally, upscaled for PEv18 and PEv18.1 by me and upscaled and updated for PEv19.1 by TrankerGolD, redesigned as a plugin for PEv19.1 by me. Updated for PEv20 by me.

    FEATURES
    • Easy Install as Plugin
    • see the pokemon on the overworld before going into battle
    • no forced battling against overworld encounters
    • Supports individual sprites for shiny, female and alternative forms
    • plays the pokemon cry while spawning
    • Overworld pokemon will despawn after some steps
    • you can have instant wild battle and overworld spawning at the same time and set the propability of that in percentage
    • In caves, pokemon don't spawn on impassable Rock-Tiles, which have the Tile-ID 4
    • In water, pokemon won't spawn above other tiles, which made them stuck or walk on ground
    • Rich source of additional features, depending on your Pokemon Essentials Version (follow links below)

    INSTALLATION: Just click on the link for your Pokemon Essentials version below and follow the installation guide there.

    * VERSION 20.0.0.4 FOR POKEMON ESSENTIALS V20 AND V20.1, and V21 and V21.1*
    https://www.pokecommunity.com/threads/visible-overworld-wild-encounter.429019/post-10509636

    * VERSION 19.1.0.4 FOR POKEMON ESSENTIALS V19.1 *
    https://www.pokecommunity.com/threads/visible-overworld-wild-encounter.429019/post-10472596

    * VERSION 19.0.10 FOR POKEMON ESSENTIALS V19.1 *
    https://www.pokecommunity.com/threads/visible-overworld-wild-encounter.429019/post-10391656

    * VERSION 18.0.8 FOR POKEMON ESSENTIALS V18 and V18.1 *
    https://www.pokecommunity.com/threads/visible-overworld-wild-encounter.429019/post-10203908

    * VERSION 17.0.8 FOR POKEMON ESSENTIALS V17 and V17.2 *
    https://www.pokecommunity.com/threads/visible-overworld-wild-encounter.429019/post-10202528

    * VERSION 16.0.1.11.5 FOR POKEMON ESSENTIALS V16.2 *
    https://www.pokecommunity.com/threads/visible-overworld-wild-encounter.429019/post-10202501

    * DOWNSCALE OF VERSION 1.6 FOR POKEMON ESSENTIALS V16.2 *
    https://www.pokecommunity.com/threads/visible-overworld-wild-encounter.429019/post-10210917

    Following these links, you will also get the script and all informations, including various add-ons and modifications

    CHANGELOG
    Spoiler:


    THANKS to BulbasaurLvl5 for the animated gif.
    THANKS to ArchyTheArc for downscaling to Pokemon Essentials V16.2.
    THANKS to TrankerGolD for upscaling to Pokemon Essentials V19.1.
     
    Last edited:
    163
    Posts
    7
    Years
    • Seen May 3, 2024
    This is a beautiful script. I am slightly scared that It can produce some lag ...

    Do you think there is any way to make it work only if a switch is activated? Perhaps in this way we can make special maps or items that allow you to see the Pokemon in the grass for a certain amount of time ...

    Thank you very much for this great job!
     
    308
    Posts
    4
    Years
  • This is a beautiful script. I am slightly scared that It can produce some lag ...

    Do you think there is any way to make it work only if a switch is activated? Perhaps in this way we can make special maps or items that allow you to see the Pokemon in the grass for a certain amount of time ...

    Thank you very much for this great job!

    In the second part "SPAWNING THE OVERWORLD ENCOUNTER" of my script, I overwrite the method Kernel.pbOnStepTaken. This method was originally defined in script PField_Field and is used to generate the wild pokemon battle.
    To include the switch dependency (as you mentioned above), you have to replace the code of Kernel.pbOnStepTaken in my overworld encounter script by something like that:

    Code:
    def Kernel.pbOnStepTaken(eventTriggered)
      if $game_switches[OVERWORLD_ENCOUNTER_SWITCH]==false
        #Insert the code from Kernel.pbOnStepTaken in script PField_Field
        [...]
      else
        #Insert the code from Kernel.pbOnStepTaken in script Visible Overworld Wild Encounter (see above)
        [...]
      end
    end

    Here, OVERWORLD_ENCOUNTER_SWITCH denotes your favourite switch you want to use. And the dots [...] stand for the actual code you have to insert. That's it. The rest of the script doesn't have to be changed.

    Well, I haven't tested it. So please let us know if it works as suggested.
     
    163
    Posts
    7
    Years
    • Seen May 3, 2024
    I tried it this way, but I only got both types of encounters to work ... But not one or the other ...

    Code:
    #===============================================================================
    # * Visible Overworld Encounters - by derFischae (Credits if used please) *
    #===============================================================================
    
    # This script is for Pokémon Essentials 17.
    # As in Pokemon Let's go Pikachu/Eevee or Pokemon Shild and Sword
    # random encounters pop up on the overworld,
    # they move around and you can start the battle
    # with them simply by moving to the pokemon.
    # Clearly, you also can omit the battle by circling around them.
    # 
    #
    # FEATURES INCLUDED:
    #   - see the pokemon on the overworld before going into battle
    #   - no forced battling against random encounters
    #   - plays the pokemon cry while spawning
    #   - Choose whether encounters occure on all terrains or only on 
    #     the terrain of the player
    #   - if you kill the same species in a row, then you increase
    #     the chance of spawning a shiny of that species 
    #
    # INSTALLATION:
    # Installation as simple as it can be.
    # Step 1) You need sprites for the overworld pokemon in your \Graphics\Characters
    # folder named by there number 001.png, 002.png, ...,
    # with the corresponding shiny versions 001s.png, 002s.png, ....
    # For instance you can use Gen 1-7 OV SPrites or whatever you want for 
    # your fakemon
    # Step 2) Insert a new file in the script editor above main,
    # name it Overworld_Random_Encounters and copy this code into it. 
    # 
    # PROPERTIES:
    # 1) If you want to have water encounters only while surfing,
    # you also have to change the value of the
    # upcoming parameter RESTRICTENCOUNTERSTOPLAYERMOVEMENT to
    #     RESTRICTENCOUNTERSTOPLAYERMOVEMENT = true
    # 2) You can choose how many steps the encounter moves before vanishing 
    # in parameter
    #     STEPSBEFOREVANISHING
    # 3) You can choose how many encounters you have to kill to obtain the increased
    # Shiny-Chance in parameter
    #     CHAINLENGTH
    # and the increased Shiny-Chance in parameter
    #     SHINYPROBABILITY
    #
    # NOTE: I have not checked Roaming Encounters. Feel free to test it.
    
    #===============================================================================
    #                             Settings            
    #===============================================================================
    
    RESTRICTENCOUNTERSTOPLAYERMOVEMENT = false
    #true - means that water encounters are popping up
    #       if and only if player is surfing
    #       (perhaps decreases encounter rate)
    #false - means that all encounter types can pop up
    #        close to the player (as long as there is a suitable tile)
    
    CHAINLENGTH      = 10 # default 10
    #       number describes how many pokemon of the same species
    #       you have to kill in a row to increase shiny propability
    
    SHINYPROBABILITY = 100 # default 100 --> 10%
    #       increasing this value decreases the probability of spawning a shiny
    
    STEPSBEFOREVANISHING = 6 # default 10
    #      STEPSBEFOREVANISHING is the number of steps a wild Encounter goes
    #      before vanishing on the map.
    
    OVERWORLD_ENCOUNTER_SWITCH = 97
    
    
    #===============================================================================
    #                              THE SCRIPT
    #===============================================================================
    
              #########################################################
              #                                                       #
              #             1. PART: THE CATCHCOMBO                   #
              #                                                       #
              #########################################################
    #===============================================================================
    # adding a new instance variable to $PokemonTemp in script PField_Metadata to
    # remember which pokemon and how many of that kind were killed in a row
    #===============================================================================
    class PokemonTemp
      attr_accessor :catchcombo # [chain length, species]
    end
    
    #===============================================================================
    # adding a new event handler on Battle end to update the catchchain (where the
    # pokemon-kill-chain is saved)
    #===============================================================================
    Events.onWildBattleEnd+=proc {|sender,e|
       species=e[0]
       result=e[2]
       $PokemonTemp.catchcombo = [0,0] if !$PokemonTemp.catchcombo
       if $PokemonTemp.catchcombo[1]!=species
         $PokemonTemp.catchcombo=[0,species]
       end
       if result==1 && species==$PokemonTemp.catchcombo[1]
         $PokemonTemp.catchcombo[0]+=1
         #Kernel.pbMessage(_INTL("You killed {1} {2}",$PokemonTemp.catchcombo[0],$PokemonTemp.catchcombo[1]))
       end
    }
    
    
              #########################################################
              #                                                       #
              #      2. PART: SPAWNING THE OVERWORLD ENCOUNTER        #
              #                                                       #
              #########################################################
    #===============================================================================
    # We override the original method "pbOnStepTaken" it was originally used for
    # random encounter battles
    #===============================================================================
    
    def Kernel.pbOnStepTaken(eventTriggered) 
       if $game_switches[OVERWORLD_ENCOUNTER_SWITCH]==false
        if $game_player.move_route_forcing || pbMapInterpreterRunning? || !$Trainer
          Events.onStepTakenFieldMovement.trigger(nil,$game_player)
        return
        end
      $PokemonGlobal.stepcount = 0 if !$PokemonGlobal.stepcount
      $PokemonGlobal.stepcount += 1
      $PokemonGlobal.stepcount &= 0x7FFFFFFF
      repel = ($PokemonGlobal.repel>0)
      
      Events.onStepTaken.trigger(nil)
    #  Events.onStepTakenFieldMovement.trigger(nil,$game_player)
      handled = [nil]
      Events.onStepTakenTransferPossible.trigger(nil,handled)
      return if handled[0]
      if !eventTriggered
        pbBattleOnStepTaken(repel)
      end
    end
      else 
      #Should it be possible to search for pokemon nearby?
      if $game_player.move_route_forcing || pbMapInterpreterRunning? || !$Trainer
        Events.onStepTakenFieldMovement.trigger(nil,$game_player)
        return
      end
      $PokemonGlobal.stepcount = 0 if !$PokemonGlobal.stepcount
      $PokemonGlobal.stepcount += 1
      $PokemonGlobal.stepcount &= 0x7FFFFFFF
      repel = ($PokemonGlobal.repel>0)
      Events.onStepTaken.trigger(nil)
      handled = [nil]
      Events.onStepTakenTransferPossible.trigger(nil,handled)
      return if handled[0]
      if !eventTriggered
        #we choose the tile on which the pokemon appears
        pos = pbChooseTileOnStepTaken
        return if !pos
        #we choose the random encounter
        encounter = pbChooseEncounter(pos[0],pos[1],repel)
        return if !encounter
        #we generate an random encounter overworld event
        pbPlaceEncounter(pos[0],pos[1],encounter)
      end
      end
    
    
    
    
    #===============================================================================
    # new method pbChooseTileOnStepTaken to choose the tile on which the pkmn spawns 
    #===============================================================================
    def pbChooseTileOnStepTaken
      # Choose 1 random tile from 1 random ring around the player
      i = rand(4)
      r = rand((i+1)*8)
      x = $game_player.x
      y = $game_player.y
      if r<=(i+1)*2
        x = $game_player.x-i-1+r
        y = $game_player.y-i-1
      elsif r<=(i+1)*6-2
        x = [$game_player.x+i+1,$game_player.x-i-1][r%2]
        y = $game_player.y-i+((r-1-(i+1)*2)/2).floor
      else
        x = $game_player.x-i+r-(i+1)*6
        y = $game_player.y+i+1
      end
      #check if it is possible to encounter here
      return if x<0 || x>=$game_map.width || y<0 || y>=$game_map.height #check if the tile is on the map
      #check if it's a valid grass, water or cave etc. tile
      return if PBTerrain.isIce?($game_map.terrain_tag(x,y))
      return if PBTerrain.isLedge?($game_map.terrain_tag(x,y))
      return if PBTerrain.isWaterfall?($game_map.terrain_tag(x,y))
      return if PBTerrain.isRock?($game_map.terrain_tag(x,y))
      if RESTRICTENCOUNTERSTOPLAYERMOVEMENT
        return if !PBTerrain.isWater?($game_map.terrain_tag(x,y)) && 
                  $PokemonGlobal && $PokemonGlobal.surfing
        return if PBTerrain.isWater?($game_map.terrain_tag(x,y)) && 
                  !($PokemonGlobal && $PokemonGlobal.surfing)
      end
      return [x,y]
    end
    
    #===============================================================================
    # defining new method pbChooseEncounter to choose the pokemon on the tile (x,y)
    #===============================================================================
    def pbChooseEncounter(x,y,repel=false)
      return if $Trainer.ablePokemonCount==0   #check if trainer has pokemon
      encounterType = $PokemonEncounters.pbEncounterTypeOnTile(x,y)
      $PokemonTemp.encounterType = encounterType
      return if encounterType<0 #check if there are encounters
      return if !$PokemonEncounters.isEncounterPossibleHereOnTile?(x,y)
      for event in $game_map.events.values
        if event.x==x && event.y==y
          return
        end
      end
      encounter = $PokemonEncounters.pbGenerateEncounter(encounterType)
      encounter = EncounterModifier.trigger(encounter)
      if !$PokemonEncounters.pbCanEncounter?(encounter,repel)
        $PokemonTemp.forceSingleBattle = false
        EncounterModifier.triggerEncounterEnd()
        return
      end
      return encounter
    end
    
    
    
    #===============================================================================
    # defining new method pbPlaceEncounter to add/place and visualise the pokemon
    # "encounter" on the overworld-tile (x,y)
    #===============================================================================
    def pbPlaceEncounter(x,y,encounter)
      # Show grass rustling animations
      $scene.spriteset.addUserAnimation(RUSTLE_NORMAL_ANIMATION_ID,x,y,true,1)
      # Play the pokemon cry of encounter
      pbPlayCryOnOverworld(encounter[0])
      # place event with random movement with overworld sprite
      # We define the event, which has the sprite of the pokemon and activates the wildBattle on touch
      if !$MapFactory
        $game_map.spawnEvent(x,y,encounter)
      else
        mapId = $game_map.map_id
        spawnMap = $MapFactory.getMap(mapId)
        spawnMap.spawnEvent(x,y,encounter)
      end
      # For roaming encounters we have to do the following:
      if $PokemonTemp.nowRoaming == true && 
         $PokemonTemp.roamerIndex != nil &&
         $PokemonGlobal.roamEncounter != nil
        $PokemonGlobal.roamEncounter = nil
        $PokemonGlobal.roamedAlready = true
      end
      $PokemonTemp.forceSingleBattle = false
      EncounterModifier.triggerEncounterEnd()
    end
    
    #===============================================================================
    # adding new Methods pbEncounterTypeOnTile and isEncounterPossibleHereOnTile?
    # in Class PokemonEncounters in Script PField_Encounters
    #===============================================================================
    class PokemonEncounters
      def pbEncounterTypeOnTile(x,y)
        if PBTerrain.isJustWater?($game_map.terrain_tag(x,y))
          return EncounterTypes::Water
        elsif self.isCave?
          return EncounterTypes::Cave
        elsif self.isGrass?
          time = pbGetTimeNow
          enctype = EncounterTypes::Land
          enctype = EncounterTypes::LandNight if self.hasEncounter?(EncounterTypes::LandNight) && PBDayNight.isNight?(time)
          enctype = EncounterTypes::LandDay if self.hasEncounter?(EncounterTypes::LandDay) && PBDayNight.isDay?(time)
          enctype = EncounterTypes::LandMorning if self.hasEncounter?(EncounterTypes::LandMorning) && PBDayNight.isMorning?(time)
          if pbInBugContest? && self.hasEncounter?(EncounterTypes::BugContest)
            enctype = EncounterTypes::BugContest
          end
          return enctype
        end
        return -1
      end
      
      def isEncounterPossibleHereOnTile?(x,y)
        if PBTerrain.isJustWater?($game_map.terrain_tag(x,y))
          return true
        elsif self.isCave?
          return true
        elsif self.isGrass?
          return PBTerrain.isGrass?($game_map.terrain_tag(x,y))
        end
        return false
      end
    end
    
    #===============================================================================
    # new Method spawnEvent in Class Game_Map in Script Game_Map
    #===============================================================================
    class Game_Map
      def spawnEvent(x,y,encounter)
        #------------------------------------------------------------------
        # generating a new event
        event = RPG::Event.new(x,y)
        # naming the event "vanishingEncounter" for PART 3 
        event.name = "vanishingEncounter"
        #setting the nessassary properties
        key_id = (@events.keys.max || -1) + 1
        event.id = key_id
        event.x = x
        event.y = y
        #event.pages[0].graphic.tile_id = 0
        if encounter[0] < 10
          character_name = "00"+encounter[0].to_s
        elsif encounter[0] < 100
          character_name = "0"+encounter[0].to_s
        else
          character_name = encounter[0].to_s
        end
        # use shiny-sprite if probability & killcombo is high or shiny-switch is on
        $PokemonTemp.catchcombo=[0,0] if !$PokemonTemp.catchcombo
        if $game_switches[SHINY_WILD_POKEMON_SWITCH]==true
            character_name = character_name+"s"
            shinysprite=true
        elsif ($PokemonTemp.catchcombo[0]>=CHAINLENGTH && $PokemonTemp.catchcombo[1]==encounter[0])
          if rand(SHINYPROBABILITY)<$PokemonTemp.catchcombo[0]
            character_name = character_name+"s"
            shinysprite=true
          end
        end
        event.pages[0].graphic.character_name = character_name
        event.pages[0].move_type = 1
        event.pages[0].trigger = 2
        #------------------------------------------------------------------
        # we add the event commands to the event of the overworld encounter
        event.pages[0].list[0].code = 355
        event.pages[0].list[0].indent = 0
        if $PokemonGlobal.roamEncounter!=nil
          #[i,species,poke[1],poke[4]]
          parameter1 = $PokemonGlobal.roamEncounter[1].to_s
          parameter2 = $PokemonGlobal.roamEncounter[2].to_s
          parameter3 = $PokemonGlobal.roamEncounter[3].to_s
          $PokemonGlobal.roamEncounter[4] != nil ? (parameter4 = '"'+$PokemonGlobal.roamEncounter[4].to_s+'"') : (parameter4 = "nil")
          parameter = " $PokemonGlobal.roamEncounter = ["+parameter1+","+parameter2+","+parameter3+","+parameter4+"] "
        else
          parameter = " $PokemonGlobal.roamEncounter = nil "
        end
        event.pages[0].list[0].parameters = [parameter]
        event.pages[0].list[1] = RPG::EventCommand.new
        #
        event.pages[0].list[1].code = 355
        event.pages[0].list[1].indent = 0
        if $PokemonTemp.nowRoaming!=nil
          parameter =" $PokemonTemp.nowRoaming = "+$PokemonTemp.nowRoaming.to_s
        else
          parameter =" $PokemonTemp.nowRoaming = nil "
        end
        event.pages[0].list[1].parameters = [parameter]
        event.pages[0].list[2] = RPG::EventCommand.new
        #
        event.pages[0].list[2].code = 355
        event.pages[0].list[2].indent = 0
        if $PokemonTemp.roamerIndex!=nil
          parameter = " $PokemonTemp.roamerIndex = "+$PokemonTemp.roamerIndex.to_s
        else
          parameter = " $PokemonTemp.roamerIndex = nil "
        end
        event.pages[0].list[2].parameters = [parameter]
        event.pages[0].list[3] = RPG::EventCommand.new
        #
        event.pages[0].list[3].code = 355
        event.pages[0].list[3].indent = 0
        if $PokemonGlobal.nextBattleBGM!=nil
          parameter = " $PokemonGlobal.nextBattleBGM = "+PokemonGlobal.nextBattleBGM.to_s
        else
          parameter = " $PokemonGlobal.nextBattleBGM = nil "    
        end
        event.pages[0].list[3].parameters = [parameter]
        event.pages[0].list[4] = RPG::EventCommand.new
        #
        event.pages[0].list[4].code = 355
        event.pages[0].list[4].indent = 0
        if $PokemonTemp.forceSingleBattle!=nil
          parameter = " $PokemonTemp.forceSingleBattle = "+$PokemonTemp.forceSingleBattle.to_s
        else
          parameter = " $PokemonTemp.forceSingleBattle = nil "
        end
        event.pages[0].list[4].parameters = [parameter]
        event.pages[0].list[5] = RPG::EventCommand.new
        #
        event.pages[0].list[5].code = 355
        event.pages[0].list[5].indent = 0
        if $PokemonTemp.encounterType!=nil
          parameter = " $PokemonTemp.encounterType = "+$PokemonTemp.encounterType.to_s
        else
          parameter = " $PokemonTemp.encounterType = nil "
        end
        event.pages[0].list[5].parameters = [parameter]
        event.pages[0].list[6] = RPG::EventCommand.new
        #
        # setting shiny switch on if sprite is a shiny-sprite
        oldShinySwitchStatus=$game_switches[SHINY_WILD_POKEMON_SWITCH]
        if shinysprite == true
          parameter = " $game_switches["+SHINY_WILD_POKEMON_SWITCH.to_s+"]=true"
        else
          parameter = " $game_switches["+SHINY_WILD_POKEMON_SWITCH.to_s+"]=false"
        end
        event.pages[0].list[6].code = 355
        event.pages[0].list[6].indent = 0
        event.pages[0].list[6].parameters = [parameter]
        event.pages[0].list[7] = RPG::EventCommand.new
        #
        #pbSingleOrDoubleWildBattle(encounter[0],encounter[1])
        event.pages[0].list[7].code = 355
        event.pages[0].list[7].indent = 0
        parameter = " pbSingleOrDoubleWildBattle("+encounter[0].to_s+","+encounter[1].to_s+", $game_map.events["+key_id.to_s+"].map.map_id, $game_map.events["+key_id.to_s+"].x, $game_map.events["+key_id.to_s+"].y)"
        event.pages[0].list[7].parameters = [parameter]
        event.pages[0].list[8] = RPG::EventCommand.new
        #
        # setting shiny switch back to previous state
        parameter=" $game_switches["+SHINY_WILD_POKEMON_SWITCH.to_s+"]="+oldShinySwitchStatus.to_s
        event.pages[0].list[8].code = 355
        event.pages[0].list[8].indent = 0
        event.pages[0].list[8].parameters = [parameter]
        event.pages[0].list[9] = RPG::EventCommand.new
        #
        event.pages[0].list[9].code = 355
        event.pages[0].list[9].indent = 0
        event.pages[0].list[9].parameters = ["$PokemonTemp.encounterType = -1"]
        event.pages[0].list[10] = RPG::EventCommand.new
        #
        event.pages[0].list[10].code = 355
        event.pages[0].list[10].indent = 0
        event.pages[0].list[10].parameters = ["$PokemonTemp.forceSingleBattle = false"]
        event.pages[0].list[11] = RPG::EventCommand.new
        #
        event.pages[0].list[11].code = 355
        event.pages[0].list[11].indent = 0
        event.pages[0].list[11].parameters = ["EncounterModifier.triggerEncounterEnd()"]
        event.pages[0].list[12] = RPG::EventCommand.new
        #
        event.pages[0].list[12].code = 355
        event.pages[0].list[12].indent = 0
        event.pages[0].list[12].parameters = ["$game_map.events.delete("+key_id.to_s+")"]
        event.pages[0].list[13] = RPG::EventCommand.new
        #
        event.pages[0].list[13].code = 355
        event.pages[0].list[13].indent = 0
        event.pages[0].list[13].parameters = ["$scene.disposeSpritesets"]
        event.pages[0].list[14] = RPG::EventCommand.new
        #
        event.pages[0].list[14].code = 355
        event.pages[0].list[14].indent = 0
        event.pages[0].list[14].parameters = ["$scene.createSpritesets"]
        event.pages[0].list[15] = RPG::EventCommand.new
        #------------------------------------------------------------------
        # creating and adding the Game_Event
        gameEvent = Game_Event.new(@map_id, event,self)
        key_id = (@events.keys.max || -1) + 1
        gameEvent.id = key_id
        gameEvent.moveto(x,y)
        @events[key_id] = gameEvent
        #updating the sprites (copied from transferPlayer in Scene_Map)
        $scene.disposeSpritesets
        $scene.createSpritesets
      end
    end
    
    #===============================================================================
    # adding new Method pbSingleOrDoubleWildBattle to reduce the code in spawnEvent
    #===============================================================================
    def pbSingleOrDoubleWildBattle(species,level,map_id,x,y)
      if $MapFactory
        terrainTag = $MapFactory.getTerrainTag(map_id,x,y)
      else
        terrainTag = $game_map.terrain_tag(x,y)
      end
      if !$PokemonTemp.forceSingleBattle && ($PokemonGlobal.partner ||
          ($Trainer.ablePokemonCount>1 &&
          PBTerrain.isDoubleWildBattle?(terrainTag) &&
          rand(100)<30))
        encounter2 = $PokemonEncounters.pbEncounteredPokemon($PokemonTemp.encounterType)
        encounter2 = EncounterModifier.trigger(encounter2)
        pbDoubleWildBattle(species,level,encounter2[0],encounter2[1])
      else
        pbWildBattle(species,level)
      end
    end
    
    
    #===============================================================================
    # adding new method PBTerrain.isRock? to module PBTerrain in script PBTerrain
    # to check if the terrainTag "tag" is rock
    #===============================================================================
    module PBTerrain
      def PBTerrain.isRock?(tag)
        return tag==PBTerrain::Rock
      end
    end
    
    #===============================================================================
    # adding new method pbPlayCryOnOverworld to load/play Pokémon cry files 
    # SPECIAL THANKS TO "Ambient Pokémon Cries" - by Vendily
    # actually it's not used, but that code helped to include the pkmn cries faster
    #===============================================================================
    def pbPlayCryOnOverworld(pokemon,volume=90,pitch=nil)
      return if !pokemon
      if pokemon.is_a?(Numeric)
        pbPlayCrySpecies(pokemon,0,volume,pitch)
      elsif !pokemon.egg?
        if pokemon.respond_to?("chatter") && pokemon.chatter
          pokemon.chatter.play
        else
          pkmnwav = pbCryFile(pokemon)
          if pkmnwav
            pbBGSPlay(RPG::AudioFile.new(pkmnwav,volume,
               (pitch) ? pitch : (pokemon.hp*25/pokemon.totalhp)+75)) rescue nil
          end
        end
      end
    end
    
    
              #########################################################
              #                                                       #
              #      3. PART: VANISHING OF OVERWORLD ENCOUNTER        #
              #                                                       #
              #########################################################
    #===============================================================================
    # adding a new variable stepCount and replacing the method increase_steps
    # in class Game_Event in script Game_Event to count the steps of
    # overworld encounter and to make them disappear after taking more then
    # STEPSBEFOREVANISHING steps
    #===============================================================================
    class Game_Event < Game_Character
      attr_accessor :event
      attr_accessor :stepCount #counts the steps of an overworld encounter
      
      alias original_increase_steps increase_steps
      def increase_steps
        if self.name=="vanishingEncounter" && @stepCount && @stepCount>=STEPSBEFOREVANISHING
          if $game_map.events.has_key?(@id) and $game_map.events[@id]==self
            $game_map.events.delete(@id)
          else
            if $MapFactory
              for map in $MapFactory.maps
                if map.events.has_key?(@id) and map.events[@id]==self
                  map.events.delete(@id)
                  break
                end
              end
            else
              #Kernel.pbMessage("Actually, this should not be possible")
            end
          end
          $scene.disposeSpritesets
          $scene.createSpritesets
        else
          @stepCount=0 if (!@stepCount || @stepCount<0)
          @stepCount+=1
          original_increase_steps
        end
      end
    end
     

    Diegou18

    Forever Chandelure lover.
    75
    Posts
    6
    Years
    • Seen Aug 16, 2021
    I tried it this way, but I only got both types of encounters to work ... But not one or the other ...

    Spoiler:

    You should remove the end before "else" and add one more at the final of the def. Be careful.
     
    Last edited:
    308
    Posts
    4
    Years
  • There is a way to let overworld encounter appear only if a switch (denoted by OVERWORLD_ENCOUNTER_SWITCH) is activated. Simply replace the method "Kernel.pbOnStepTaken(eventTriggered)" in my script above by the following:

    Code:
    def Kernel.pbOnStepTaken(eventTriggered)
      #Should it be possible to search for pokemon nearby?
      if $game_player.move_route_forcing || pbMapInterpreterRunning? || !$Trainer
        Events.onStepTakenFieldMovement.trigger(nil,$game_player)
        return
      end
      $PokemonGlobal.stepcount = 0 if !$PokemonGlobal.stepcount
      $PokemonGlobal.stepcount += 1
      $PokemonGlobal.stepcount &= 0x7FFFFFFF
      repel = ($PokemonGlobal.repel>0)
      Events.onStepTaken.trigger(nil)
      handled = [nil]
      Events.onStepTakenTransferPossible.trigger(nil,handled)
      return if handled[0]
      if !eventTriggered
        if $game_switches[OVERWORLD_ENCOUNTER_SWITCH]==false
          #STANDARD WILDBATTLE
          pbBattleOnStepTaken(repel)
        else  
          #OVERWORLD ENCOUNTERS
          #we choose the tile on which the pokemon appears
          pos = pbChooseTileOnStepTaken
          return if !pos
          #we choose the random encounter
          encounter,gender,form = pbChooseEncounter(pos[0],pos[1],repel)
          return if !encounter
          #we generate an random encounter overworld event
          pbPlaceEncounter(pos[0],pos[1],encounter,gender,form)
        end
      end
    end

    Make sure to also include something like the following in the settings section of my script:

    Code:
    OVERWORLD_ENCOUNTER_SWITCH = 97 # choose your preferred $game_switch

    Edit: Updated for version 1.2.
     
    Last edited:
    163
    Posts
    7
    Years
    • Seen May 3, 2024
    There is a way to let overworld encounter appear only if a switch (denoted by OVERWORLD_ENCOUNTER_SWITCH) is activated. Simply replace the method "Kernel.pbOnStepTaken(eventTriggered)" in my script above by the following:

    Code:
    def Kernel.pbOnStepTaken(eventTriggered) 
      if $game_player.move_route_forcing || pbMapInterpreterRunning? || !$Trainer
        Events.onStepTakenFieldMovement.trigger(nil,$game_player)
        return
      end
      $PokemonGlobal.stepcount = 0 if !$PokemonGlobal.stepcount
      $PokemonGlobal.stepcount += 1
      $PokemonGlobal.stepcount &= 0x7FFFFFFF
      repel = ($PokemonGlobal.repel>0)
      Events.onStepTaken.trigger(nil)
    #  Events.onStepTakenFieldMovement.trigger(nil,$game_player)
      handled = [nil]
      Events.onStepTakenTransferPossible.trigger(nil,handled)
      return if handled[0]
      if !eventTriggered
        if $game_switches[OVERWORLD_ENCOUNTER_SWITCH]==false
          #STANDARD WILDBATTLE
          pbBattleOnStepTaken(repel)
        else  
          #OVERWORLD ENCOUNTERS
          #we choose the tile on which the pokemon appears
          pos = pbChooseTileOnStepTaken
          return if !pos
          #we choose the random encounter
          encounter = pbChooseEncounter(pos[0],pos[1],repel)
          return if !encounter
          #we generate an random encounter overworld event
          pbPlaceEncounter(pos[0],pos[1],encounter)
        end
      end
    end

    I tested it and it worked.

    It worked! Thank you so much for your amazing work!
     

    Zeak6464

    Zeak #3205 - Discord
    1,101
    Posts
    11
    Years
  • Love the Script !
    I used it to make a Randomize !
    unknown.png
     

    WolfPP

    Spriter/ Pixel Artist
    1,309
    Posts
    5
    Years
  • For those who are dedicated to implementing / drawing Sprite OW for each pokémon, what you did was a brilliant job!

    Thanks for sharing!
     
    62
    Posts
    6
    Years
    • Seen Aug 11, 2022
    Can we do both wild encounters?
    Normal Encounters set and Overworld Encounters.

    This script is awesome.
     

    Zeak6464

    Zeak #3205 - Discord
    1,101
    Posts
    11
    Years
  • How did you randomize it?!

    Had to encounter[0] = rand(890)+1 if $game_switches[227]

    above these lines !
    Code:
        if encounter[0] < 10
          character_name = "00"+encounter[0].to_s
        elsif encounter[0] < 100
          character_name = "0"+encounter[0].to_s 
        else
          character_name = encounter[0].to_s
        end
     
    Last edited:
    308
    Posts
    4
    Years
  • Can we do both wild encounters?
    Normal Encounters set and Overworld Encounters.

    This script is awesome.

    If you want overworld encounters and the thrilling excitement of instant wild battles at the same time, then you have to do the following:

    1) Add a new parameter to the settings. This parameter represents the propability of gaining an instant battle. It is an integer given in thousanth, i. e. 0 means 0% and 1000 means 100%. Feel free to find the best ratio for you.
    Code:
    INSTANT_WILD_BATTLE_PROPABILITY = 100 # Propability of gaining an instant battle in thousanth, i. e. 0,1,2,...,1000

    2) Replace the method "Kernel.pbOnStepTaken(eventTriggered)" in my script in post 1 above by
    Code:
    def Kernel.pbOnStepTaken(eventTriggered) 
      if $game_player.move_route_forcing || pbMapInterpreterRunning? || !$Trainer
        Events.onStepTakenFieldMovement.trigger(nil,$game_player)
        return
      end
      $PokemonGlobal.stepcount = 0 if !$PokemonGlobal.stepcount
      $PokemonGlobal.stepcount += 1
      $PokemonGlobal.stepcount &= 0x7FFFFFFF
      repel = ($PokemonGlobal.repel>0)
      Events.onStepTaken.trigger(nil)
    #  Events.onStepTakenFieldMovement.trigger(nil,$game_player)
      handled = [nil]
      Events.onStepTakenTransferPossible.trigger(nil,handled)
      return if handled[0]
      if !eventTriggered
        if rand(1000)<INSTANT_WILD_BATTLE_PROPABILITY
          #STANDARD WILDBATTLE
          pbBattleOnStepTaken(repel)
        else  
          #OVERWORLD ENCOUNTERS
          #we choose the tile on which the pokemon appears
          pos = pbChooseTileOnStepTaken
          return if !pos
          #we choose the random encounter
          encounter,gender,form = pbChooseEncounter(pos[0],pos[1],repel)
          return if !encounter
          #we generate an random encounter overworld event
          pbPlaceEncounter(pos[0],pos[1],encounter,gender,form)
        end
      end
    end

    I haven't tested it, yet. Feel free to let us know if it works the desired way.

    Edit: updated the code for version 1.2
     
    Last edited:
    62
    Posts
    6
    Years
    • Seen Aug 11, 2022
    If you want overworld encounters and the thrilling excitement of instant wild battles at the same time, then you have to do the following:

    1) Add a new parameter to the settings. This parameter represents the propability of gaining an instant battle. It is an integer given in thousanth, i. e. 0 means 0% and 1000 means 100%. Feel free to find the best ratio for you.
    Code:
    INSTANT_WILD_BATTLE_PROPABILITY = 100 # Propability of gaining an instant battle in thousanth, i. e. 0,1,2,...,1000

    2) Replace the method "Kernel.pbOnStepTaken(eventTriggered)" in my script in post 1 above by
    Code:
    def Kernel.pbOnStepTaken(eventTriggered) 
      if $game_player.move_route_forcing || pbMapInterpreterRunning? || !$Trainer
        Events.onStepTakenFieldMovement.trigger(nil,$game_player)
        return
      end
      $PokemonGlobal.stepcount = 0 if !$PokemonGlobal.stepcount
      $PokemonGlobal.stepcount += 1
      $PokemonGlobal.stepcount &= 0x7FFFFFFF
      repel = ($PokemonGlobal.repel>0)
      Events.onStepTaken.trigger(nil)
    #  Events.onStepTakenFieldMovement.trigger(nil,$game_player)
      handled = [nil]
      Events.onStepTakenTransferPossible.trigger(nil,handled)
      return if handled[0]
      if !eventTriggered
        if rand(1000)<INSTANT_WILD_BATTLE_PROPABILITY
          #STANDARD WILDBATTLE
          pbBattleOnStepTaken(repel)
        else  
          #OVERWORLD ENCOUNTERS
          #we choose the tile on which the pokemon appears
          pos = pbChooseTileOnStepTaken
          return if !pos
          #we choose the random encounter
          encounter = pbChooseEncounter(pos[0],pos[1],repel)
          return if !encounter
          #we generate an random encounter overworld event
          pbPlaceEncounter(pos[0],pos[1],encounter)
        end
      end
    end

    I haven't tested it, yet. Feel free to let us know if it works the desired way.

    Thank you!
     
    Last edited:
    37
    Posts
    8
    Years
    • Seen Apr 28, 2024
    My progress didn't work...

    ---------------------------

    Exception: NoMethodError
    Message: undefined method `isIce?' for PBTerrain:Module
    Visable Pokemon:163:in `pbChooseTileOnStepTaken'
    Visable Pokemon:131:in `pbOnStepTaken'
    Game_Player:484:in `update_old'
    Walk_Run:78:in `update'
    Scene_Map:104:in `update'
    Scene_Map:101:in `loop'
    Scene_Map:114:in `update'
    Scene_Map:68:in `main'
    Scene_Map:65:in `loop'
    Scene_Map:72:in `main'
     
    308
    Posts
    4
    Years
  • My progress didn't work...

    ---------------------------

    Exception: NoMethodError
    Message: undefined method `isIce?' for PBTerrain:Module
    Visable Pokemon:163:in `pbChooseTileOnStepTaken'
    Visable Pokemon:131:in `pbOnStepTaken'
    Game_Player:484:in `update_old'
    Walk_Run:78:in `update'
    Scene_Map:104:in `update'
    Scene_Map:101:in `loop'
    Scene_Map:114:in `update'
    Scene_Map:68:in `main'
    Scene_Map:65:in `loop'
    Scene_Map:72:in `main'

    Try adding the following code:
    Code:
    module PBTerrain
      Ice             = 12
    
      def PBTerrain.isIce?(tag)
        return tag==PBTerrain::Ice
      end
    end

    It's recommanded to include the tag "Ice = 12" and the whole method "PBTerrain.isIce?(tag)" in the already existing module "PBTerrain", which you can find in the script section "PBTerrain". But anyway, it's also fine to simply copy the code above and paste it at the end of the visible overworld encounter script. What version of Pokemon essentials do you use? Normally, I thought that the code above is already included in Pokemon essentials 17.
     
    Last edited:

    WolfPP

    Spriter/ Pixel Artist
    1,309
    Posts
    5
    Years
  • If you want the Wild Pokémon has step animation/ Stop Animation (animated like follower pokémon from HGSS) just add 'event.pages[0].step_anime = true' below 'event.pages[0].trigger = 2':
    Code:
        event.pages[0].graphic.character_name = character_name
        event.pages[0].move_type = 1
        event.pages[0].trigger = 2
        event.pages[0].step_anime = true
        #------------------------------------------------------------------
        # we add the event commands to the event of the overworld encounter

    Also I tested now and... Why give me a little bit lag? Is it possible to "fix" that? Or only if I change my laptop/hardware? :o

    Again, amazing script! Congratz!
     
    308
    Posts
    4
    Years
  • Also I tested now and... Why give me a little bit lag? Is it possible to "fix" that? Or only if I change my laptop/hardware? :o

    Again, amazing script! Congratz!

    After spawning and despawning of the overworld encounters we have to update the spriteset. Therefor, I used

    Code:
        $scene.disposeSpritesets
        $scene.createSpritesets

    in the method "increase_steps" and in "spawnEvent(x,y,encounter)". I would say that this way of updating the sprites causes your lag. If you or anyone else finds a better solution for updating the spriteset (which probabily exists) we can reduce some lag. Any suggests are welcome.
     
    Back
    Top