• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Our weekly protagonist poll is now up! Vote for your favorite Conquest protagonist in the poll by clicking here.
  • 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

That would be a very easy way of solving the roaming legendaries error

I thought that there is no error for roaming encounters anymore since version 1.3. Please check that you have the newest version of this script. And if you find an error then please let me know here to fix it.

UPDATE: You were right. Roaming Encounters still generated a crash. I updated the script to version 1.5. Now with version 1.5, roaming encounters work properly. I tested it.
 
Last edited:
removed my last comment about v17 to v16 scaling, that all works fine.

if you want a v16 port i can willingly send it so people can use it (will need to remove my extra checks but wont be hard)

still testing here and there with it though.

edit:
So is there any way to put up the spawn chance? i am using the wild grass ecnounter addon thing, so not sure if thats messing up with it.
like i have the instant wild battle probablity at 450 but does that number even effect the spawn rates? like at one point i had alot of spawns at 600 but most timnes none or like 2.
not expecting hundreds but is there any way to increase it? ive put up the steps before vanishing but does any setting or actual part effect the rate? just wondering.

if not that, is there any way to properly seperate the overworld spawns and encounters? thus they appear around you, the spawning seems a bit... tempemental, sometimes spawns out of grass (when player is out of grass not the spawns) but othertimes not meaning i get no spawns (like walked through my map and saw like 4 total)
 
Last edited:
removed my last comment about v17 to v16 scaling, that all works fine.

if you want a v16 port i can willingly send it so people can use it (will need to remove my extra checks but wont be hard)

still testing here and there with it though.

I guess it would be nice to present your downscaled version of the overworld encounter script prominently for all who still use Pokemon essentials v16. If you send it to me, then I will add it to the first post. So everyone, who is interested, can find it immediately.

So is there any way to put up the spawn chance? i am using the wild grass encounter addon thing, so not sure if thats messing up with it.
like i have the instant wild battle probablity at 450 but does that number even effect the spawn rates? like at one point i had alot of spawns at 600 but most timnes none or like 2.
not expecting hundreds but is there any way to increase it? ive put up the steps before vanishing but does any setting or actual part effect the rate? just wondering.

if not that, is there any way to properly seperate the overworld spawns and encounters? thus they appear around you, the spawning seems a bit... tempemental, sometimes spawns out of grass (when player is out of grass not the spawns) but othertimes not meaning i get no spawns (like walked through my map and saw like 4 total)

Of course, there is a way to put up the spawn chance. Well, I don't know how the wild grass encounter addon thing works, but in Pokemon Essentials, you increase or decrease the encounter range in the debug menu or in the PBS file "encounters.txt". And, in fact, this normal behaviour still works with overworld encounters.

However, there is another factor concerning overworld encounters. How much grass is in range of the player? As you already noticed, overworld encounters spawn in grass, but the player does not have to be in the grass at that moment. (That's the same behaviour as in Pokemon shild/sword or Let's go Eevee/Pikachu.) The overworld encounter script chooses randomly a tile in range of the player. But only if this tile is grass (without an npc or player on it), then the encounter spawns there. Thus, a map with lots of grass will have more spawning encounters then a map with the same encounter range in "encounter.txt" but less grass. More precisely, let x denote the sum of all grass tiles (without an npc or player on it) in the 8 times 8 square around the player. And let p be the probability of an wild battle which you set in the wild grass encounter addon thing but in percent. Then the probability of spawning a pokemon equals p*x/63.

For short, increasing the encounter range will increase the probability of spawning of overworld encounters. This should also work with the wild grass encounter addon thing. Moreover, more grass in range will also force a higher spawning rate.
 
About the little lag to spawn a pokémon, did you check how klein studio coded to do Phenomenon's script? Download his pack and check there if not, maybe can help you/ us to make a better code to put less lag to spawn:

https://pokemonfangames.com/resource/pokemon-essentials-bw/

I took a closer look on the phenomenon script by KleinStudio. This is a nice piece of code. However, I don't see much to optimize the runtime. By the way, I can't notice a lag generated by this overworld encounter script anymore, since version 1.6. But to be more precise, updating the spriteset was already done with the same methods or with even less computationally intensive methods than in the phenomenos script. Another thing is the following: In the phenomenons script, a new spawned phenomenon is stored in a new introduced list of phenomenons. So, there is an easy access to the phonomenons. But actually this also causes that phenomenos will not be treated as game-events. This is totally fine for the phenomenos. But if you want to add an overworld encounter, then this encounter must be treaten as an event, since it has to move, it has to still be there after changing the map or after a battle with a different encounter and of course after saving. That's why the impementation of the phenomenons script is not suitable for overworld encounters and why it will not decrease lag, which doesn't seem to be relevant anymore anyway.

However, I found a nice function to shorten the overworld encounter script. For instance instead of
Code:
event.pages[0].list[12].code = 355
event.pages[0].list[12].indent = 0
event.pages[0].list[12].parameters = ["$game_map.events["+key_id.to_s+"].removeThisEventfromMap"]
event.pages[0].list[13] = RPG::EventCommand.new
we can simply write (probably)
Code:
pbPushScript(pages[0].list, sprintf("$game_map.events[#{key_id}].removeThisEventfromMap"))
 
For short, increasing the encounter range will increase the probability of spawning of overworld encounters. This should also work with the wild grass encounter addon thing. Moreover, more grass in range will also force a higher spawning rate.

Im assuming the encounter range in encounters.txt is the density? seeing more numbers but not a masive increase, might need to increase the radius.

guessing this:
Code:
r = rand((i+1)*8)
is that 8 radius ring? didnt want to touch it but guessing that area (pbChooseTileOnStepTaken)
is for that ring.

Not an issue just something i noticed, the events go over fog layers, let me get a sample.
[PokeCommunity.com] Visible Overworld Wild Encounter


Not a major issue as it does help them stick out in dark areas, just makes them feel out of place.

EDIT:
so the method pbEncounterTypeOnTile, can that be used elsewhere?
i have a custom script for additional encounters but it spawns the land ones on the water, how could i use the "if PBTerrain.isJustWater?($game_map.terrain_tag(x,y))" part in unison with the method to detect its on water?
 
Last edited:
Im assuming the encounter range in encounters.txt is the density? seeing more numbers but not a masive increase, might need to increase the radius.
guessing this:
Code:
r = rand((i+1)*8)
is that 8 radius ring? didnt want to touch it but guessing that area (pbChooseTileOnStepTaken)
is for that ring.

I would say decreasing the radius would increase the probability. In pbChooseTileOnStepTaken, the radius of the 8 radius ring is the number 4 in
Code:
i = rand(4)
You can replace that short line by
Code:
i = rand(RADIUS)
and add a new parameter
Code:
RADIUS = 2 # default =4
in the settings section of the overworld encounter script. Then you can test what the best radius is by changing the RADIUS in the settings.

Not an issue just something i noticed, the events go over fog layers [...] Not a major issue as it does help them stick out in dark areas, just makes them feel out of place.

Right now, I don't know where this behaviour comes from and how to fix it. Probably, it will take some time to find out.

so the method pbEncounterTypeOnTile, can that be used elsewhere?
i have a custom script for additional encounters but it spawns the land ones on the water, how could i use the "if PBTerrain.isJustWater?($game_map.terrain_tag(x,y))" part in unison with the method to detect its on water?

Clearly, I don't know how you include the additional encounters. But, it sounds like that your additional encounters are allways land encounters. Then, I would say that you can do something like that:
1.) Choose a tile, given by its coordinates (x,y) - which you already do
2.) Check if encounter is possible there:
Code:
return if !$PokemonEncounters.isEncounterPossibleHereOnTile?(x,y,encounterType)
where isEncounterPossibleHereOnTile?(x,y) is changed to
Code:
  def isEncounterPossibleHereOnTile?(x,y)
    if PBTerrain.isJustWater?($game_map.terrain_tag(x,y))
      return false
    elsif self.isCave?
      return true
    elsif self.isGrass?
      return PBTerrain.isGrass?($game_map.terrain_tag(x,y))
    end
    return false
  end

If you have different types of encounters, then you can probably do something similar as I did:

1.) Choose a tile, given by its coordinates (x,y) - which you already do
2.) Compute the encounterType of that tile (grass, water, cave)
Code:
encounterType = $PokemonEncounters.pbEncounterTypeOnTile(x,y)
3.) Check if encounter is possible there and stop if it isn't:
Code:
return if !$PokemonEncounters.isEncounterPossibleHereOnTile?(x,y)
4.) Generate the encounter depending on "encounterType". Here, your implementation of your custom script comes into play. I did something like that:
Code:
encounter = $PokemonEncounters.pbGenerateEncounter(encounterType)

I hope this answers your question.
 
I hope this answers your question.

Usually decresing makes sense, but wanted to increase it as patches of grass are further apart and slightly smaller, but did answer it.

so that check didnt work as it was external but doing a check if the encounter type was water worked, or seemed to work.

edit: that "fix" didnt work, just made it spawn all the water encounters.

only fix was restrict the overworld spawns to land or water, then it worked.
 
Last edited:
Not an issue just something i noticed, the events go over fog layers, let me get a sample. [...] Not a major issue as it does help them stick out in dark areas, just makes them feel out of place.

I tested the issue with fog-layers. As you can see in the picture below, the overworld encounters spawn under the fog-layer. So everything looks fine in Pokemon Essentials 17.2. Perhaps your issue comes from the old essentials version 16.2. Or perhaps you set the fog in a different way. I used the event command "change map settings..." --> "fog graphic".

[PokeCommunity.com] Visible Overworld Wild Encounter
 
I tested the issue with fog-layers. As you can see in the picture below, the overworld encounters spawn under the fog-layer. So everything looks fine in Pokemon Essentials 17.2. Perhaps your issue comes from the old essentials version 16.2. Or perhaps you set the fog in a different way. I used the event command "change map settings..." --> "fog graphic".

View attachment 90809

hmm odd, as in the rpgmaker deafault option or actual script changing it? might just be a v16 to v17 issue.
 
Anyway to make a special encounter table for ow spawns? Like I'm using both random and overworld, but what if i wanted to have only certain pokemon spawn overworld or certain pokemon spawn in grass like SW/SH
 
Anyway to make a special encounter table for ow spawns? Like I'm using both random and overworld, but what if i wanted to have only certain pokemon spawn overworld or certain pokemon spawn in grass like SW/SH

you most likely can, best way is to make another encounter type "overworld" lets say, and specify what ones you want in the encounter.txt and in the script change the part in "PokemonEncounters" in the script about encounter type land and replace it with the overworld encoutner type OOOR overworld encounter types (e.g. overworldnight, overworldwater etc.)
 
Thank you. Another question to anyone, how can I make the mons not move into my follower Pokemon / npc? Kinda breaks immersion
 
Thank you. Another question to anyone, how can I make the mons not move into my follower Pokemon / npc? Kinda breaks immersion

What happens if you place an event on the map using the map editor and let this event move randomly. I would guess, that this event will also move into your follower Pokemon. Please check if that holds true. If it does, then your issue does not come from this overworld encounter script, but your following pokemon script.
 
What happens if you place an event on the map using the map editor and let this event move randomly. I would guess, that this event will also move into your follower Pokemon. Please check if that holds true. If it does, then your issue does not come from this overworld encounter script, but your following pokemon script.

I will test when I get home I appreciate the help
 
While i cant confirm about moving in npcs, other events can move where the followers are, as they dont really exist. might have been fixed in later versions, but guessing not, and is just how followers work in the xp engine.
 
View attachment 90535

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

UPDATED TO VERSION 1.6. NOW INCLUDING DOWNSCALE FOR POKEMON ESSENTIALS V16.2 BY ARCHYTHEARC.

This script is for Pokémon Essentials V16.2, V17 and V17.2. Originally written for V17 and 17.2 by me and downscaled to V16.2 by ArchyTheArc.

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

NEW FEATURES IN VERSION 1.1:
- less lag
- supports sprites for alternative forms of pokemon

NEW FEATURES IN VERSION 1.2:
- supports sprites for female/male/genderless pokemon

NEW FEATURES IN VERSION 1.3:
- bug fixes for roaming encounter and double battles

NEW FEATURES IN VERSION 1.4:
- more options in settings

NEW FEATURES IN VERSION 1.5:
- roaming encounters working correctly

NEW FEATURES IN VERSION 1.6:
- did some runtime optimization, i.e. faster despawning of pokemon after battle


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.
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, ...
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)
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
4) You can choose whether the sprite of your overworld encounter is always the standard form 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

NOTE: I have not checked Roaming Encounters. Feel free to test it.

THANKS to BulbasaurLvl5 for bringing me to pokemon essentials and the super productive time

THANKS to ArchyTheArc for downscaling to Pokemon Essentials V16.2.

* For Pokemon Essentials V17 and V17.2. *
Spoiler:


* Version 1.6 for Pokemon Essentials V16.2. Downscale by ArchyTheArc *
Spoiler:

So wild pokemon are showing up for me but when I run into one I get an error. I have Essentials 16.2 and following pokemon on too. Is the following pokemon script conflicting with this, if so can i change anything to fix this or do i have to remove following pokemon completely.


Exception: RuntimeError

Message: Script error within event 2, map 5 (Route 1):

Exception: NoMethodError

Message: Section179:575:in `pbSingleOrDoubleWildBattle'undefined method `isDoubleGrass?' for PBTerrain:Module

***Full script:

$PokemonGlobal.roamEncounter = nil
$PokemonTemp.nowRoaming = false
$PokemonTemp.roamerIndex = nil
$PokemonGlobal.nextBattleBGM = nil

$PokemonTemp.encounterType = 0
$game_switches[31]=false
pbSingleOrDoubleWildBattle(16,12, $game_map.events[2].map.map_id, $game_map.events[2].x, $game_map.events[2].y,1,0)
$game_switches[31]=false
$PokemonTemp.encounterType = -1

EncounterModifier.triggerEncounterEnd()
$game_map.events[2].removeThisEventfromMap
$game_map.events.delete(2)


Interpreter:243:in `pbExecuteScript'

(eval):8:in `pbExecuteScript'

Interpreter:1606:in `eval'

Interpreter:243:in `pbExecuteScript'

Interpreter:1606:in `command_355'

Interpreter:494:in `execute_command'

Interpreter:193:in `update'

Interpreter:106:in `loop'

Interpreter:198:in `update'

Scene_Map:103:in `follow_update'



Interpreter:276:in `pbExecuteScript'

Interpreter:1606:in `command_355'

Interpreter:494:in `execute_command'

Interpreter:193:in `update'

Interpreter:106:in `loop'

Interpreter:198:in `update'

Scene_Map:103:in `follow_update'

Scene_Map:101:in `loop'

Scene_Map:114:in `follow_update'

Follow Pokemon:1544:in `update'
 
So wild pokemon are showing up for me but when I run into one I get an error. I have Essentials 16.2 and following pokemon on too. Is the following pokemon script conflicting with this, if so can i change anything to fix this or do i have to remove following pokemon completely.

Exception: RuntimeError

Message: Script error within event 2, map 5 (Route 1):

Exception: NoMethodError

Message: Section179:575:in `pbSingleOrDoubleWildBattle'undefined method `isDoubleGrass?' for PBTerrain:Module

Thank you for your remark. At first, following Pokemon should not affect overworld encounters.

To fix your error, open the script editor and go to the script PBTerrain. There, you can find the module PBTerrain. Make sure that you have the following parameter in this module:
Code:
  TallGrass       = 10

Also make sure that you find the following method inside the module PBTerrain:
Code:
def PBTerrain.isDoubleWildBattle?(tag)
    return tag==PBTerrain::TallGrass
  end

If you find the method "PBTerrain.isDoubleWildBattle?(tag)", then you can simply replace the line
Code:
      PBTerrain.isDoubleGrass?(terrainTag) &&
inside the overworld encounter script v1.6 for PE16.2 by
Code:
      PBTerrain.isDoubleWildBattle?(terrainTag) &&

If there is no method "PBTerrain.isDoubleWildBattle?(tag)" in the module PBTerrain, then add a new method "PBTerrain.isDoubleGrass?(tag)" to that module by copying the following code inside that module:
Code:
  def PBTerrain.isDoubleGrass?(tag)
    return tag==PBTerrain::TallGrass
  end

I'm using PE17.2 and not PE16.2. So I would be thankful if you can tell me whether there is this method "PBTerrain.isDoubleWildBattle?(tag)" or not. Then I can also include the correct bug fix for version 1.6 for PE16.2 for all future users.
 
Hey, the script is so good! I was doing something similar in my game but with events with so many pages, and this look so much neat and useful. I've got a question, is there a way to modify the script so that instead of working when the player makes a step, making this working based on time? For example calling the "step function" every second in time. It would look more realistic in my opinion, so that you can stand in the same spot and the Pokémon keep on spawning and despawning.
 
Back
Top