• 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
  • * Visible Overworld Wild Encounters Version 18.0.8 for PEv18 and PEv18.1 - by derFischae (Credits if used please) *

    UPDATED TO VERSION 18.0.8 FOR POKEMON ESSENTIALS V18. ADDED BUG FIX FOR POKEMON ESSENTIALS V18.1. This script is for Pokémon Essentials v18 and v18.1.

    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
    • you can have instant wild battle and overworld spawning at the same time and set the propability of that by default
      and change it ingame and store it with a $game_variable
    • In caves, pokemon don't spawn on impassable Rock-Tiles, which have the Tile-ID 4
    • You can check during the events @@OnWildPokemonCreate, @@OnStartBattle, ... if you are battling a spawned pokemon with the global variable $PokemonGlobal.battlingSpawnedPokemon
    • You can check during the event @@OnWildPokemonCreate if the pokemon is created for spawning on the map or created for a different reason with the Global variable $PokemonGlobal.creatingSpawningPokemon
    • If you want to add a procedure that modifies a pokemon only for spawning but not before battling then you can use the Event @@OnWildPokemonCreateForSpawning.

    INSTALLATION: It is as simple as it can be.
    1. You need sprites for the overworld pokemon in your \Graphics\Characters folder named by there number 001.png, 002.png, ..., For instance you can use Gen 1-7 OV SPrites or whatever you want for your fakemon.
      If you want to use shiny overworld sprites for shiny encounters, then make sure to also have the corresponding shiny versions in your \Graphics\Characters folder named by 001s.png, 002s.png, ....
      If you want to use alternative forms as overworld sprites, then make sure that you also have a sprite for each alternative form, e. g. for Unown 201_1.png, 201s_1.png, 201_2.png, 201s_2.png, ... Please note that Scatterbug has 18 alternative forms in Pokemon Essentials. But you will only see one form depending on your trainerID. So, you also have to include 664_1.png, ..., 664_19.png and 664s_1.png, ..., 664s_19.png. Same needs to be done for Pokemon Spewpa with number 665 and Vivillon with number 666.
      If you want to use female forms as overworld sprites, then make sure that you also have a female sprite for each pokemon named 001f.png, 001fs.png, 002f.png, 002fs.png, ... (excluding genderless pokemon of course)
    2. Insert a new file in the script editor above main, name it Overworld_Encounters and copy this code below into it.
    3. Install the bug fix below if you are using Pokemon Essentials V18.1.
    4. Set the properties for your pleasure in the properties section of the script. Most of you don't need to change anything.
    5. If you want, then you can install add-ons or modifications for the script from below.
    6. If you want then you can also install the script always in bush and in water to obtain that the overworld encounter don't stand on water anymore but sink in. You can find it at https://www.pokecommunity.com/showthread.php?p=10109060

    HERE IS THE CODE OF THE VISIBLE OVERWORLD WILD ENCOUNTER SCRIPT
    Spoiler:


    THE BUG FIX FOR POKEMON ESSENTIALS V18.1
    Spoiler:



    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 whether the overworld sprite of an shiny encounter is always the standard sprite or is the corrensponding shiny overworld sprite in parameter
      USESHINYSPRITES
    4. You can choose whether the sprite of your overworld encounter is always the standard sprite or can be an alternative form in parameter
      USEALTFORMS
    5. You can choose whether the sprites depend on the gender of the encounter or are always neutral in parameter
      USEFEMALESPRITES
    6. You can choose whether the overworld encounters have a stop/ step-animation similar to following pokemon in the parameter
      USESTOPANIMATION
    7. You can choose how many overworld encounters are agressive and run to the player in the parameter
      AGGRESSIVEENCOUNTERPROBABILITY
    8. You can choose the move-speed and move-frequenzy of normal and aggressive encounters in parameters
      ENCMOVESPEED, ENCMOVEFREQ, AGGRENCMOVESPEED, AGGRENCMOVEFREQ
    9. You can have normal and overworld encountering at the same time. You can set the default propability in percentage in the parameter
      INSTANT_WILD_BATTLE_PROPABILITY
    10. The actual propability of normal to overworld encountering during game is stored in
      $game_variables[OVERWORLD_ENCOUNTER_VARIABLE]
      and you can change its value during playtime.
    11. If you want to change the ID of the $game_variable that saves the current propability of normal to overworld encountering, then you can change it in parameter
      OVERWORLD_ENCOUNTER_VARIABLE
      Make sure that no other script uses and overrides the value of the game_variable with that ID.
    12. If you have impassable tiles in a cave, where you don't want pokemon to spawn there. Then choose the Tile-ID 4 for that tile in the tile-editor.

    ADD-ONS OF THIS SCRIPT: In the post https://www.pokecommunity.com/showthread.php?t=429019 you will also find add-ons, including
    • Vendilys Rescue Chain and JoelMatthews Add-Ons for Vendilys Rescue Chain,
      See https://www.pokecommunity.com/showthread.php?t=415524 and
      https://www.pokecommunity.com/showthread.php?t=422513 for original scripts
      Spoiler:
    • Let's go shiny hunting by chaining a pokemon,
      updated version for PEv18 and PEv18.1 by lemiho19:
      https://www.pokecommunity.com/threads/visible-overworld-wild-encounter.429019/post-10805311
      old version from PEv17.1 (also compatible upto PEv18.1):
      Spoiler:

      inspired by Diego Mertens original script https://www.pokecommunity.com/showthread.php?p=10011513
    • Automatic Spawning
      Spoiler:
    • Randomised spawning
      Spoiler:
    • all overworld encounters are shinys
      Spoiler:
    • instructions on how to make your own Add-On or to modify an already existing script to make it work with the visible overworld wild encounter script. This includes modifying a pokemon on spawning but not on battling again, by using the events OnStartBattle, OnWildPokemonCreate and OnWildPokemonCreateForSpawning
      Spoiler:
    • Joltiks Level Balance, see https://www.pokecommunity.com/showthread.php?t=409828 for original post
      Spoiler:

    MODIFICATIONS OF THIS SCRIPT FOR PEv17.2: There are various modifications of this script for Pokemon Essentials v17.2. at https://www.pokecommunity.com/showthread.php?p=10202528#post10202528 , including
    • adding shiny sparkle animation to spawned overworld shinys, especially useful if you want to sign out the shiny encounters on the map without using overworld shiny sprites
    • removing grass rustle animation on water and in caves
    • instructions on how to change the movement of the overworld encounter
    • "aggressive encounters" only get aggressive when you are 2 tiles away from them, and not before
    • forbidding pokemon to spawn on specific terrain tiles in caves
    • adding new encounter types, eg. desert, shallow water
    • instructions on how to have different encounters for overworld spawning and original encountering on the same map - like in Pokemon Sword/Shield, tested with PEv18
    • error solutions
    But I don't know jet, which one still work with Pokemon Essentials v18. And probably there are some bugs due to the update to PEv18. Feel free to test it with PEv18 and to post your bugs.

    CHANGELOG
    Spoiler:
     
    Last edited:
    465
    Posts
    7
    Years
    • Seen May 9, 2024
    seems that updates are steamrolling out :)
    One ig occassional issue i had with the old versions and the current downscaled one, and maybe its a 17 to 16 thing but,

    Spoiler:


    I get this, basically it repeats the step counter as intended but sometimes on launch if i move too soon it causes this (prior to any encounters loading ofc)

    did try and search the thread for any solutions/someone else mentioning it but the search function is a bit annoying/tempormental (atleast for me) so sorry if you've discussed it or like last time im just blind.
     
    308
    Posts
    4
    Years
  • seems that updates are steamrolling out :)
    One ig occassional issue i had with the old versions and the current downscaled one, and maybe its a 17 to 16 thing but,

    Spoiler:


    I get this, basically it repeats the step counter as intended but sometimes on launch if i move too soon it causes this (prior to any encounters loading ofc)

    did try and search the thread for any solutions/someone else mentioning it but the search function is a bit annoying/tempormental (atleast for me) so sorry if you've discussed it or like last time im just blind.

    This issue was already discussed. Probably it appears when restarting the testplay by pressing F12 without closing the last game. Here I quote the solution for you.

    The method "original_increase_steps" links to the allready defined method "increase_steps". This method is not defined in the visible overworld wild encounter script. It is defined in Pokemon Essentials or could be overwritten by any other script you installed. If you use f12 without closing the test window, then the game memory will not be cleared. This leads to the problem that the method "original_increase_steps" does not link to the original method "increase_steps" anymore, but to the later defined method "increase_steps" in the visible overworld wild encounter script. This behaviour leads to the stack overflow after using f12 without closing the window and, by the way, can occure in any arbitrary script which uses the "alias" command. That's why I do not recommand to use f12 without closing the window.

    However, if you want to continue with your workflow and use f12, then you can do so by modifying the code in the following way:
    Go find the following code in the visible overworld wild encounter script (it is the snippet where your errors occure)
    Code:
      alias original_increase_steps increase_steps
      def increase_steps
        if self.name=="vanishingEncounter" && @stepCount && @stepCount>=STEPSBEFOREVANISHING
          removeThisEventfromMap
        else
          @stepCount=0 if (!@stepCount || @stepCount<0)
          @stepCount+=1
          original_increase_steps
        end
      end
    and replace it by
    Code:
    def increase_steps
        if self.name=="vanishingEncounter" && @stepCount && @stepCount>=STEPSBEFOREVANISHING
          removeThisEventfromMap
        else
          @stepCount=0 if (!@stepCount || @stepCount<0)
          @stepCount+=1
          @stop_count = 0
          triggerLeaveTile()
        end
      end
    It will work, I tested it. However, if you use any other script that overwrites the Method "increase_steps" of Class "Game_Character" in Script section "Game_Character", then this new code above will neglect that changes of that other script and could lead to compatibly problems. The original code above will not due to the alias command.

    You're welcome.
     
    465
    Posts
    7
    Years
    • Seen May 9, 2024
    This issue was already discussed. Probably it appears when restarting the testplay by pressing F12 without closing the last game. Here I quote the solution for you.

    Okay i just didnt want it to be caused to players, sorry for repeating something again xP but cleared it up for me thanks ^^.
     
    465
    Posts
    7
    Years
    • Seen May 9, 2024
    Pardon, I didn't understand that. What does that mean?


    No problem. You're welcome.

    Even if your error was triggered by another reason, you can simply replace the code as described in the post above and the issue will be gone.

    as in players of the game get the error on start up occasionally, but if its f12 then they could get it.

    and yea i'll look into it just need to check things that use increase_steps.
     
    465
    Posts
    7
    Years
    • Seen May 9, 2024
    So back again, already something i showed to you ages ago in the script with in v16 the overworlds being over fogs, and even priority tiles, not sure with the latter, but the former seems definetly like a viewpoint.z related thing (i know viewpoint was reworked in v17 which probably explains it) and maybe the viewpoint also connects to the priority of tiles. not sure exactly where to look but where does the viewpoint of the OW's come from if you recall (e.g. if it calls to a part i can reference)

    more of a v16 issue than a major issue for newer versions (and with v18 out now less people will need a v16 but) would also help with the downscale version.
     
    308
    Posts
    4
    Years
  • So back again, already something i showed to you ages ago in the script with in v16 the overworlds being over fogs, and even priority tiles, not sure with the latter, but the former seems definetly like a viewpoint.z related thing (i know viewpoint was reworked in v17 which probably explains it) and maybe the viewpoint also connects to the priority of tiles. not sure exactly where to look but where does the viewpoint of the OW's come from if you recall (e.g. if it calls to a part i can reference)

    more of a v16 issue than a major issue for newer versions (and with v18 out now less people will need a v16 but) would also help with the downscale version.

    As far as I understood, there are 3 parameters concerning the location of Game_Event/Game_Character, that is screen_x,screen_y and screen_z.
    A Sprite_Character uses screen_z of its corresponding Game_Character for example to determine if the sprite needs to be placed above a priority-tile or below.
    In v17.2, screen_z(height = 0) is computed from x and y, the @allways_on_top-flag, tile-priorities and so on. You don't set it to a specific value. That's why I did nothing with the z-component of spawning overworld pokemon in the script.
    Maybe in screen_z you can find a way to solve the v16 issue concerning fog-layers,

    Have you tested the same situation, but instead of a spawned Overworld Pokemon you placed an event on the map with the sprite of that pokemon. Does it also look odd?
     
    465
    Posts
    7
    Years
    • Seen May 9, 2024
    As far as I understood, there are 3 parameters concerning the location of Game_Event/Game_Character, that is screen_x,screen_y and screen_z.
    A Sprite_Character uses screen_z of its corresponding Game_Character for example to determine if the sprite needs to be placed above a priority-tile or below.
    In v17.2, screen_z(height = 0) is computed from x and y, the @allways_on_top-flag, tile-priorities and so on. You don't set it to a specific value. That's why I did nothing with the z-component of spawning overworld pokemon in the script.
    Maybe in screen_z you can find a way to solve the v16 issue concerning fog-layers,

    Have you tested the same situation, but instead of a spawned Overworld Pokemon you placed an event on the map with the sprite of that pokemon. Does it also look odd?

    Odd only difference (and even when screen_z is called) is the always on top check (instead of being an if and a end its just return if) and theres no surfbase one. so not sure. unless its somehow making it always on top for some reason?

    edit: even with testing with updating certain sections to v17 like the character parts or map parts, or even making a new viewport for the overworlds to reference (and even changing its Z from 100 to 0) but still sits on top, so... cant find a way to force always on top off in a script fashion (Atleast in this script)

    Seems followers doesnt have this issue but kinda renders the same, but since it references an event maybe stuff like always on top is checked and if its off then its works or smth(?)
     
    Last edited:
    308
    Posts
    4
    Years
  • Odd only difference (and even when screen_z is called) is the always on top check (instead of being an if and a end its just return if) and theres no surfbase one. so not sure. unless its somehow making it always on top for some reason?

    edit: even with testing with updating certain sections to v17 like the character parts or map parts, or even making a new viewport for the overworlds to reference (and even changing its Z from 100 to 0) but still sits on top, so... cant find a way to force always on top off in a script fashion (Atleast in this script)

    Seems followers doesnt have this issue but kinda renders the same, but since it references an event maybe stuff like always on top is checked and if its off then its works or smth(?)

    You can compare the update method in Sprite_Character. A Sprite_Character contains the parameters self.x, self.y and self.z, which are updated using screen_x, screen_y and screen_z in the update function. Maybe, there is the difference.

    Or the difference comes from the the way how the fog gets its z-value in v16 and v17. But I don't know there to look at for fog.

    EDIT: I changed screen_z such that it always returns 999. The spawned pokemon are still below the fog-graphic I used for testing.
    EDIT2: And without changing the code, manually placed events with always_on_top-flag are under the fog in v17.
    EDIT3: In v17, events with an screen_z value of 2999 or lower will be under the fog. If the screen_z value is 3000 or higher, then the sprite is over the fog.
    EDIT4: I changed [email protected]_z(@ch) to self.z=0 in the update method of Sprite_Character. Then the player sprite was under the map-tiles and all other events were under the fog.
    I changed [email protected]_z(@ch) to self.z=1 in the update method of Sprite_Character. Then all sprites were over the map-tiles and under the fog.
    I changed [email protected]_z(@ch) to self.z=9999 in the update method of Sprite_Character. Then all sprites were over the fog.
     
    Last edited:
    465
    Posts
    7
    Years
    • Seen May 9, 2024
    You can compare the update method in Sprite_Character. A Sprite_Character contains the parameters self.x, self.y and self.z, which are updated using screen_x, screen_y and screen_z in the update function. Maybe, there is the difference.

    Or the difference comes from the the way how the fog gets its z-value in v16 and v17. But I don't know there to look at for fog.

    EDIT: I changed screen_z such that it always returns 999. The spawned pokemon are still below the fog-graphic I used for testing.
    EDIT2: And without changing the code, manually placed events with always_on_top-flag are under the fog in v17.

    Yea the stuff there is almost identical minus how it gets ch and cw, but its still identical just more accurately done in v17 (and i already tested with v17's sprite_character so)

    (since its not a big issue, its not game breaking, may just be either deal with it, hopefully find a fix soon, or upgrade)

    and its also not just fog, but was a graphic "hud" was being overlapped, by the overworlds until i made it really really high or it loaded after (since it would lay ontop)

    its less of the issue of fogs but it ignoring priority and stuff (and even above events it shouldnt be e.g. acting as always on top) but i feel their connected.

    even tried adding a moveroute to turn always on top off but no luck.... definetly a viewport thing so might need to figure out what changed or where viewport is defined.

    even messing with screen_z myself nothing fixes it so i dont feel its that but still viewport, which sucks cuz whatever i do nothing fixes it (only time it changes is if i make it -1 but thats -1 so...)

    edit: just saw your final edit; tested myself, while some stuff went funky at self.z=0 (shadows mainly) they were still over the priority. seems definetly that its not screen_z which helps but not at the same time.
     
    Last edited:
    308
    Posts
    4
    Years
  • Yea the stuff there is almost identical minus how it gets ch and cw, but its still identical just more accurately done in v17 (and i already tested with v17's sprite_character so)

    (since its not a big issue, its not game breaking, may just be either deal with it, hopefully find a fix soon, or upgrade)

    and its also not just fog, but was a graphic "hud" was being overlapped, by the overworlds until i made it really really high or it loaded after (since it would lay ontop)

    its less of the issue of fogs but it ignoring priority and stuff (and even above events it shouldnt be e.g. acting as always on top) but i feel their connected.

    even tried adding a moveroute to turn always on top off but no luck.... definetly a viewport thing so might need to figure out what changed or where viewport is defined.

    even messing with screen_z myself nothing fixes it so i dont feel its that but still viewport, which sucks cuz whatever i do nothing fixes it (only time it changes is if i make it -1 but thats -1 so...)

    edit: just saw your final edit; tested myself, while some stuff went funky at self.z=0 (shadows mainly) they were still over the priority. seems definetly that its not screen_z which helps but not at the same time.

    I found "@fog.z = 3000" inmethod initialize in class Spriteset_Map in script section Spriteset_Map. Maybe there you can find something different.
     
    465
    Posts
    7
    Years
    • Seen May 9, 2024
    I found "@fog.z = 3000" inmethod initialize in class Spriteset_Map in script section Spriteset_Map. Maybe there you can find something different.

    definetly feels the right way and it is slightly altered (e.g. panoramas being seperate to other viewports and reworking the order) however altering it by itself causes errors, but that feels where the issue lies (still confuses me how tho)
     
    13
    Posts
    8
    Years
    • Seen Mar 22, 2024
    Hello friend! Thanks for your solution, I "fixed" this long time ago by deleting two chunks of code at the end of the script. The ones with the comment about "reducing lag" or something like that. I don't know what was wrong about the sprite disposal but this brute solution worked for my. Anyway, thanks for your solution. Also sorry for my english 👌😁.
     

    DarrylBD99

    Content Creator and Game Developer
    321
    Posts
    4
    Years
  • - Automatic Spawning
    Spoiler:

    When I added it into my game and start a new save, it gives me this error. Visible Overworld Wild Encounter Also just to clarify, I did install the Overworld Encounters Script.
     
    308
    Posts
    4
    Years
  • When I added it into my game and start a new save, it gives me this error. View attachment 93396 Also just to clarify, I did install the Overworld Encounters Script.

    I updated the code. Please try this instead. Simply, copy and paste.
    Code:
    #===============================================================================
    # Add-On for automatic spawning without making a step * by derFischae
    #===============================================================================
    
    # This is an add-on for the visible overworld wild encounter script.
    # It adds automatic pokemon spawning to the script.
    
    # FEATURES INCLUDED:
    # Choose whether pokemon spawn automatically or only while moving the player
    
    # INSTALLATION:
    # Copy this code and
    # Paste it at the bottom of your visible wild overworld encounter script
    
    # PROPERTIES:
    # You can choose whether pokemon can spawn automatically or only while the 
    # player is moving and you can set the spawning frequency in the parameter
    #     AUTOSPAWNSPEED
    # in the settings below
    
    #===============================================================================
    # Settings
    #===============================================================================
    AUTOSPAWNSPEED = 60 # default 60
    #You can set the speed of automatic pokemon spawning, i.e. the ability of pokemon
    # to spawn automatically even without even moving the player.
    #0   - means that pokemon only spawn while the player is moving
    #>0  - means automatic spawning is activated, the closer to 0 the faster the spawning
    
    #===============================================================================
    # Overriding the update method of the class Game_Map in script section Game_Map
    #===============================================================================
    class Game_Map
      
      alias original_update update
      def update
        original_update
        return unless $Trainer
        return if $PokemonGlobal.repel>0
        repel = ($PokemonGlobal.repel>0)
        $framecounter = 0 if !$framecounter 
        $framecounter = $framecounter + 1
        return unless $framecounter == AUTOSPAWNSPEED
        $framecounter = 0
        if $game_variables[OVERWORLD_ENCOUNTER_VARIABLE] == 0
          if INSTANT_WILD_BATTLE_PROPABILITY > 0 && INSTANT_WILD_BATTLE_PROPABILITY < 100
            $game_variables[OVERWORLD_ENCOUNTER_VARIABLE] = INSTANT_WILD_BATTLE_PROPABILITY
          elsif INSTANT_WILD_BATTLE_PROPABILITY >= 100
            $game_variables[OVERWORLD_ENCOUNTER_VARIABLE] = 100
          else
            $game_variables[OVERWORLD_ENCOUNTER_VARIABLE] = -1
          end
        end
        return if $game_variables[OVERWORLD_ENCOUNTER_VARIABLE]>0 && ($game_variables[OVERWORLD_ENCOUNTER_VARIABLE]>=100 || rand(100) < $game_variables[OVERWORLD_ENCOUNTER_VARIABLE])
        #OVERWORLD ENCOUNTERS
        #we choose the tile on which the pokemon appears
        pos = pbChooseTileOnStepTaken
        return if !pos
        #we choose the random encounter
        encounter,gender,form,isShiny = pbChooseEncounter(pos[0],pos[1],repel)
        return if !encounter
        #we generate an random encounter overworld event
        pbPlaceEncounter(pos[0],pos[1],encounter,gender,form,isShiny)
      end
    end
     
    Back
    Top