- 318
- Posts
- 5
- Years
- Germany
- Seen Apr 28, 2025
* 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:
INSTALLATION: It is as simple as it can be.
HERE IS THE CODE OF THE VISIBLE OVERWORLD WILD ENCOUNTER SCRIPT
THE BUG FIX FOR POKEMON ESSENTIALS V18.1
In Pokemon Essentials V18.1, it was introduced that normal wild encounter can encounter on turning the direction of your player. These encounters are always normal encounters. So, if you don't want these normal encounters then you have multiple ways to remove or correct that.
Open the script editor and go to the script section "PField_Field". Search for the following code snippet
and
PROPERTIES:
ADD-ONS OF THIS SCRIPT: In the post https://www.pokecommunity.com/showthread.php?t=429019 you will also find add-ons, including
MODIFICATIONS OF THIS SCRIPT FOR PEv17.2: There are various modifications of this script for Pokemon Essentials v17.2. at https://www.pokecommunity.com/posts/10202528/ , including
CHANGELOG
NEW FEATURES IN VERSION 18.0.7 FOR PEv18:
- tiny bug fix for $PokemonTemp.encounterType
NEW FEATURES IN VERSION 18.0.7 FOR PEv18:
- removed a bug concerning changing the standard form when goining into battle
NEW FEATURES IN VERSION 18.0.6 FOR PEv18:
- (hopefully) removed a rare bug concerning character_sprites
NEW FEATURES IN VERSION 2.0.5 FOR PEv18:
- removed bug that makes all water encounter vanish
NEW FEATURES IN VERSION 2.0.4 FOR PEv18:
- encounters don't spawn on impassable tiles in caves
NEW FEATURES IN VERSION 2.0.3 FOR PEv18:
- Poke Radar works as usual
NEW FEATURES IN VERSION 2.0.2 FOR PEv18:
- added new global variable $PokemonGlobal.creatingSpawningPokemon to check during the event @@OnWildPokemonCreate if the pokemon is created for spawning on the map or created for a different reason
UPSCALED FEATURES FROM VERSION 2.0.1 FOR PEv17.2:
- less lag
- supports sprites for alternative forms of pokemon
- supports sprites for female/male/genderless pokemon
- bug fixes for roaming encounter and double battles
- more options in settings
- roaming encounters working correctly
- more lag reduction
- included automatic spawning of pokemon, i.e. spawning without having to move the player
- included vendilys rescue chain, i. e. if pokemon of the same species family spawn in a row and will be battled in a row, then you increase the chance of spawning
an evolved pokemon of that species family. Link: https://www.pokecommunity.com/showthread.php?t=415524
- removed bug occuring after fainting against wild overworld encounter
- for script-developers, shortened the spawnEvent method for better readablitiy
- removed bugs from version 1.9
- added shapes of overworld encounter for rescue chain users
- supports spawning of alternate forms while chaining
- if overworld sprites for alternative, female or shiny forms are missing,
then the standard sprite will be displayed instead of an invisible event
- bug fix for shiny encounters
- respecting shiny state for normal encounters when using overworld and normal encounters at the same time
- easier chaining concerning Vendilys Rescue chain, i.e. no more resetting of the chain when spawning of a pokemon of different family but when fighting with a pokemon of different family
- Added new Event @@OnPokemonCreateForSpawning which only triggers on spawning
- Added new global variable $PokemonGlobal.battlingSpawnedShiny to check if an active battle is against a spawned pokemon.
- removed bug to make the new features in version 1.11 work
- reorganised and thin out the code to organise code as add-ons
- removed Vendilys Rescue Chain, Let's Go Shiny Hunting and automatic spawning as hard coded feature and provide it as Add-Ons instead
- Now, using overworld and normal encounters at the same time is a standard feature
- autospawning will not trigger instant battles anymore
- removed a bug that came from reorganising the code in original code and add-ons concerning Let's go shiny hunting add-on
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.
- 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) - Insert a new file in the script editor above main, name it Overworld_Encounters and copy this code below into it.
- Install the bug fix below if you are using Pokemon Essentials V18.1.
- Set the properties for your pleasure in the properties section of the script. Most of you don't need to change anything.
- If you want, then you can install add-ons or modifications for the script from below.
- 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:
Code:
#===============================================================================
# * Visible Overworld Wild Encounters V18.0.8 for PEv18 - by derFischae (Credits if used please) *
#===============================================================================
#
# UPDATED TO VERSION 18.0.8.
#
# 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.
#
# This script is for Pokémon Essentials v18 and v18.1 (for short PEv18).
#
# 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.
#
# 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
# - Let's go chiny hunting by chaining a pokemon, inspired by Diego Mertens script
# https://www.pokecommunity.com/showthread.php?p=10011513
# - Automatic Spawning
# - randomized spawning
# - always shiny spawning
# - 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
# - Joltiks Level Balance, see https://www.pokecommunity.com/showthread.php?t=409828 for original post
#
# 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?t=429019
# 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
# - "agressive 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
# - 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 PEv18.1 and to post your bugs.
#
# NEW FEATURES FROM VERSION 18.0.8 FOR PEv18:
# - tiny bug fix for $PokemonTemp.encounterType
#
# NEW FEATURES FROM VERSION 18.0.7 FOR PEv18:
# - removed a bug concerning changing the standard form when goining into battle
#
# NEW FEATURES FROM VERSION 18.0.6 FOR PEv18:
# - (hopefully) removed a rare crash concerning character_sprites
#
# NEW FEATURES FROM VERSION 2.0.5 FOR PEv18:
# - removed bug that makes all water encounter vanish
#
# NEW FEATURES FROM VERSION 2.0.4 FOR PEv18:
# - encounters dont spawn on impassable tiles in caves
#
# NEW FEATURES FROM VERSION 2.0.3 FOR PEv18:
# - poke radar works as usual
#
# NEW FEATURES FROM VERSION 2.0.2 FOR PEv18:
# - added new global variable $PokemonGlobal.creatingSpawningPokemon to check during the event @@OnWildPokemonCreate if the pokemon is created for spawning on the map or created for a different reason
#
# UPSCALED FEATURES FROM VERSION 2.0.1 FOR PEv17.2:
# - less lag
# - supports sprites for alternative forms of pokemon
# - supports sprites for female/male/genderless pokemon
# - bug fixes for roaming encounter and double battles
# - more options in settings
# - roaming encounters working correctly
# - more lag reduction
# - included automatic spawning of pokemon, i.e. spawning without having to move the player
# - included vendilys rescue chain, i. e. if pokemon of the same species family spawn in a row and will be battled in a row, then you increase the chance of spawning
# an evolved pokemon of that species family. Link: https://www.pokecommunity.com/showthread.php?t=415524
# - removed bug occuring after fainting against wild overworld encounter
# - for script-developers, shortened the spawnEvent method for better readablitiy
# - removed bugs from version 1.9
# - added shapes of overworld encounter for rescue chain users
# - supports spawning of alternate forms while chaining
# - if overworld sprites for alternative, female or shiny forms are missing,
# then the standard sprite will be displayed instead of an invisible event
# - bug fix for shiny encounters
# - respecting shiny state for normal encounters when using overworld and normal encounters at the same time
# - easier chaining concerning Vendilys Rescue chain, i.e. no more resetting of the chain when spawning of a pokemon of different family but when fighting with a pokemon of different family
# - Added new Event @@OnPokemonCreateForSpawning which only triggers on spawning
# - Added new global variable $PokemonGlobal.battlingSpawnedShiny to check if an active battle is against a spawned pokemon.
# - removed bug to make the new features in version 1.11 work
# - reorganised and thin out the code to organise code as add-ons
# - removed Vendilys Rescue Chain, Let's Go Shiny Hunting and automatic spawning as hard coded feature and provide it as Add-Ons instead
# - Now, using overworld and normal encounters at the same time is a standard feature
# - autospawning will not trigger instant battles anymore
# - removed a bug that came from reorganising the code in original code and add-ons concerning Let's go shiny hunting add-on
#
# 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, ...,
# 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)
# Step 2) Insert a new file in the script editor above main,
# name it Overworld_Encounters and copy this code into it.
# Step 3) Install the bug fix below if you are using Pokemon Essentials V18.1.
# Step 4) Set the properties for your pleasure in the properties section of the script. Most of you don't need to change anything.
# Step 5) If you want, then you can install add-ons or modifications for the script from the Pokecommunity thread https://www.pokecommunity.com/showthread.php?p=10203908#post10203908
# Step 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
#
# 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.
#===============================================================================
# Settings
#===============================================================================
OVERWORLD_ENCOUNTER_VARIABLE = 26 # default is an ID which is not used anywhere else
# This parameter stores the ID of the $game_variable which holds the propability
# of normal to overworld encountering.
# Make sure that no other script uses the $game_variable with this ID,
# except for the visible overworld wild encounter script itself and its add-ons.
#
# The $game_variable with the ID equal to OVERWORLD_ENCOUNTER_VARIABLE is used
# to store the propability of an instant (normal) wild battle.
# You can modify the value of that $game_variable during game or with events as usual. It is similar to use
# game switches. See the Pokemon Essentials manual for more informations.
# The propability is stored the following way
# $game_variables[OVERWORLD_ENCOUNTER_VARIABLE] = 0
# - the propability of instant battle to spawning will be equal to the value
# of INSTANT_WILD_BATTLE_PROPABILITY in percentage, see below
# $game_variables[OVERWORLD_ENCOUNTER_VARIABLE] < 0
# - means only overworld encounters, no instant battles
# $game_variables[OVERWORLD_ENCOUNTER_VARIABLE] > 0 and < 100
# - means overworld encounters and normal encounters at the same time,
# where the value equals the propability of normal encounters in percentage
# $game_variables[OVERWORLD_ENCOUNTER_VARIABLE] >= 100
# - means only normal encounters and instant battles as usual, no overworld spawning
INSTANT_WILD_BATTLE_PROPABILITY = 0 # default 0.
# It will be used when starting the game the first time. Changing this value later on will not affect the propability anymore.
# However, you can still change the propability stored in the $game_variable with ID above during runtime.
# This parameter holds the DEFAULT propability of normal to overworld encountering.
# The propability is stored in percentage with possible values 0,1,2,...,100.
# <= 0 - means only overworld encounters, no instant battles
# > 0 and < 100 - means overworld encounters and normal encounters at the same time.
# >= 100 - means only normal encounters and instant battles as usual, no overworld spawning
# You can still change the propability stored in the $game_variable with ID above during runtime.
# But if you don't change the propability ingame, then it will be this INSTANT_WILD_BATTLE_PROPABILITY
# Note that, if $game_variables[OVERWORLD_ENCOUNTER_VARIABLE] = 0 then the propability stored in that $game_variable will be reset to
# the value of INSTANT_WILD_BATTLE_PROPABILITY, unless this is also 0.
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)
STEPSBEFOREVANISHING = 6 # default 10
# STEPSBEFOREVANISHING is the number of steps a wild Encounter goes
# before vanishing on the map.
USESHINYSPRITES = true # default true
#false - means that you don't use shiny sprites for your overworld encounter
#true - means that a shiny encounter will have a its special shiny overworld sprite
# make sure that you have the shiny sprites named with an "s" (e.g. 001s.png)
# for the shiny forms in your \Graphics\Characters folder
USEALTFORMS = true # default true
#false - means that you don't use alternative forms for your overworld sprite
#true - means that the sprite of overworld encounter varies by the form of that pokemon
# make sure that you have the sprites with the right name
# for your alternative forms in your \Graphics\Characters folder
USEFEMALESPRITES = true # default true
#false - means that you use always a neutral overworld sprite
#true - means that female pokemon have there own female overworld sprite
# make sure that you have the sprites with the right name 001f.png,
# 001fs.png, ... for the female forms in your \Graphics\Characters folder
USESTOPANIMATION = true # default true
#false - means that overworld encounters don't have a stop- animation
#true - means that overworld encounters have a stop- animation similar as
# following pokemon
ENCMOVESPEED = 3 # default 3
# this is the movement speed (compare to autonomous movement of events) of an overworld encounter
#1 - means lowest movement
#6 - means highest movement
ENCMOVEFREQ = 3 # default 3
# this is the movement frequenzy (compare to autonomous movement of events) of an overworld encounter
#1 - means lowest movement
#6 - means highest movement
AGGRESSIVEENCOUNTERPROBABILITY = 20 # default 20
#this is the probability in percent of spawning of an agressive encounter
#0 - means that there are no aggressive encounters
#100 - means that all encounter are aggressive
AGGRENCMOVESPEED = 3 # default 3
# this is the movement speed (compare to autonomous movement of events) of an aggressive encounter
#1 - means lowest movement
#6 - means highest movement
AGGRENCMOVEFREQ = 5 # default 5
# this is the movement frequenzy (compare to autonomous movement of events) of an aggressive encounter
#1 - means lowest movement
#6 - means highest movement
#===============================================================================
# THE SCRIPT
#===============================================================================
#########################################################
# #
# 1. PART: SPAWNING THE OVERWORLD ENCOUNTER #
# #
#########################################################
#===============================================================================
# We override the original method "pbOnStepTaken" in Script PField_Field it was
# originally used for random encounter battles
#===============================================================================
def 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 && !$game_temp.in_menu
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
if ($game_variables[OVERWORLD_ENCOUNTER_VARIABLE]>0 && ($game_variables[OVERWORLD_ENCOUNTER_VARIABLE]>=100 || rand(100) < $game_variables[OVERWORLD_ENCOUNTER_VARIABLE])) || pbPokeRadarOnShakingGrass
#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,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
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] if PBTerrain.isWater?($game_map.terrain_tag(x,y))
#check if tile is passable
for i in [2, 1, 0]
tile_id = $game_map.data[x, y, i]
terrain = $game_map.terrain_tags[tile_id]
passage = $game_map.passages[tile_id]
if terrain!=PBTerrain::Neutral
if passage & 0x0f == 0x0f
return
elsif $game_map.priorities[tile_id] == 0
break
end
end
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)
return if encounterType<0 #check if there are encounters
return if !$PokemonEncounters.isEncounterPossibleHereOnTile?(x,y)
$PokemonTemp.encounterType = encounterType
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
form = nil
gender = nil
$PokemonGlobal.creatingSpawningPokemon = true
pokemon = pbGenerateWildPokemon(encounter[0],encounter[1])
# trigger event on spawning of pokemon
Events.onWildPokemonCreateForSpawning.trigger(nil,pokemon)
$PokemonGlobal.creatingSpawningPokemon = false
encounter = [pokemon.species,pokemon.level]
gender = pokemon.gender if USEFEMALESPRITES==true
form = pokemon.form if USEALTFORMS == true
form = 0 if USEALTFORMS == true and form==nil
isShiny = pokemon.isShiny?
return encounter,gender,form,isShiny
end
#===============================================================================
# defining new method pbPlaceEncounter to add/place and visualise the pokemon
# "encounter" on the overworld-tile (x,y)
#===============================================================================
def pbPlaceEncounter(x,y,encounter,gender = nil,form = nil,isShiny = nil)
# 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,gender,form,isShiny)
else
mapId = $game_map.map_id
spawnMap = $MapFactory.getMap(mapId)
spawnMap.spawnEvent(x,y,encounter,gender,form,isShiny)
end
# Show grass rustling animations
$scene.spriteset.addUserAnimation(RUSTLE_NORMAL_ANIMATION_ID,x,y,true,1)
# Play the pokemon cry of encounter
pbPlayCryOnOverworld(encounter[0])
# For roaming encounters we have to do the following:
if $PokemonTemp.roamerIndex != nil &&
$PokemonGlobal.roamEncounter != nil
$PokemonGlobal.roamEncounter = nil
$PokemonGlobal.roamedAlready = true
end
$PokemonTemp.encounterType = -1
$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,gender = nil,form = nil, isShiny = nil)
#------------------------------------------------------------------
# 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 sprite of female pokemon
character_name = character_name+"f" if USEFEMALESPRITES == true and gender==1 and pbResolveBitmap("Graphics/Characters/"+character_name+"f")
# use shiny-sprite if probability & killcombo is high or shiny-switch is on
shinysprite = nil
if isShiny==true
character_name = character_name+"s" if USESHINYSPRITES == true and pbResolveBitmap("Graphics/Characters/"+character_name+"s")
shinysprite = true
end
# use sprite of alternative form
if USEALTFORMS==true and form!=nil and form!=0
character_name = character_name+"_"+form.to_s if pbResolveBitmap("Graphics/Characters/"+character_name+"_"+form.to_s)
end
event.pages[0].graphic.character_name = character_name
# we configure the movement of the overworld encounter
if rand(100) < AGGRESSIVEENCOUNTERPROBABILITY
event.pages[0].move_type = 3
event.pages[0].move_speed = AGGRENCMOVESPEED
event.pages[0].move_frequency = AGGRENCMOVEFREQ
event.pages[0].move_route.list[0].code = 10
event.pages[0].move_route.list[1] = RPG::MoveCommand.new
else
event.pages[0].move_type = 1
event.pages[0].move_speed = ENCMOVESPEED
event.pages[0].move_frequency = ENCMOVEFREQ
end
event.pages[0].step_anime = true if USESTOPANIMATION
event.pages[0].trigger = 2
#------------------------------------------------------------------
# we add the event commands to the event of the overworld encounter
# set roamer
if $PokemonGlobal.roamEncounter!=nil
#[i,species,poke[1],poke[4]]
parameter1 = $PokemonGlobal.roamEncounter[0].to_s
parameter2 = $PokemonGlobal.roamEncounter[1].to_s
parameter3 = $PokemonGlobal.roamEncounter[2].to_s
$PokemonGlobal.roamEncounter[3] != nil ? (parameter4 = '"'+$PokemonGlobal.roamEncounter[3].to_s+'"') : (parameter4 = "nil")
parameter = " $PokemonGlobal.roamEncounter = ["+parameter1+","+parameter2+","+parameter3+","+parameter4+"] "
else
parameter = " $PokemonGlobal.roamEncounter = nil "
end
pbPushScript(event.pages[0].list,sprintf(parameter))
parameter = ($PokemonTemp.roamerIndex!=nil) ? " $PokemonTemp.roamerIndex = "+$PokemonTemp.roamerIndex.to_s : " $PokemonTemp.roamerIndex = nil "
pbPushScript(event.pages[0].list,sprintf(parameter))
#parameter = ($PokemonGlobal.nextBattleBGM!=nil) ? " $PokemonGlobal.nextBattleBGM = '"+$PokemonGlobal.nextBattleBGM.to_s+"'" : " $PokemonGlobal.nextBattleBGM = nil "
#pbPushScript(event.pages[0].list,sprintf(parameter))
parameter = ($PokemonTemp.forceSingleBattle!=nil) ? " $PokemonTemp.forceSingleBattle = "+$PokemonTemp.forceSingleBattle.to_s : " $PokemonTemp.forceSingleBattle = nil "
pbPushScript(event.pages[0].list,sprintf(parameter))
parameter = ($PokemonTemp.encounterType!=nil) ? " $PokemonTemp.encounterType = "+$PokemonTemp.encounterType.to_s : " $PokemonTemp.encounterType = nil "
pbPushScript(event.pages[0].list,sprintf(parameter))
# setting $PokemonGlobal.battlingSpawnedPokemon = true
pbPushScript(event.pages[0].list,sprintf(" $PokemonGlobal.battlingSpawnedPokemon = true"))
#pbSingleOrDoubleWildBattle(encounter[0],encounter[1])
gender = "nil" if gender==nil
form = "nil" if form==nil
shinysprite = "nil" if shinysprite==nil
pbPushScript(event.pages[0].list,sprintf(" 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,"+gender.to_s+","+form.to_s+","+shinysprite.to_s+")"))
# setting $PokemonGlobal.battlingSpawnedPokemon = false
pbPushScript(event.pages[0].list,sprintf(" $PokemonGlobal.battlingSpawnedPokemon = false"))
if !$MapFactory
parameter = "$game_map.removeThisEventfromMap(#{key_id})"
else
mapId = $game_map.map_id
parameter = "$MapFactory.getMap("+mapId.to_s+").removeThisEventfromMap(#{key_id})"
end
pbPushScript(event.pages[0].list,sprintf(parameter))
pbPushEnd(event.pages[0].list)
#------------------------------------------------------------------
# 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
sprite = Sprite_Character.new(Spriteset_Map.viewport,@events[key_id])
$scene.spritesets[self.map_id]=Spriteset_Map.new(self) if $scene.spritesets[self.map_id]==nil
$scene.spritesets[self.map_id].character_sprites.push(sprite)
# alternatively: updating the sprites (old and slow but working):
#$scene.disposeSpritesets
#$scene.createSpritesets
end
end
#===============================================================================
# adding new Method pbSingleOrDoubleWildBattle to reduce the code in spawnEvent
#===============================================================================
def pbSingleOrDoubleWildBattle(species,level,map_id,x,y,gender = nil,form = nil,shinysprite = nil)
if $MapFactory
terrainTag = $MapFactory.getTerrainTag(map_id,x,y)
else
terrainTag = $game_map.terrain_tag(x,y)
end
if !$PokemonTemp.forceSingleBattle && !pbInSafari? && ($PokemonGlobal.partner ||
($Trainer.ablePokemonCount>1 && PBTerrain.isDoubleWildBattle?(pbGetTerrainTag) && rand(100)<30))
encounter2 = $PokemonEncounters.pbEncounteredPokemon($PokemonTemp.encounterType)
encounter2 = EncounterModifier.trigger(encounter2)
pbDoubleWildBattle(species,level,encounter2[0],encounter2[1],nil,true,false,gender,form,shinysprite,nil,nil,nil)
else
pbWildBattle(species,level,nil,true,false,gender,form,shinysprite)
end
$PokemonTemp.encounterType = -1
$PokemonTemp.forceSingleBattle = false
EncounterModifier.triggerEncounterEnd
end
#===============================================================================
# overriding Method pbWildBattleCore in Script PField_Battles
# to include alternate forms of the wild pokemon
#===============================================================================
def pbWildBattleCore(*args)
outcomeVar = $PokemonTemp.battleRules["outcomeVar"] || 1
canLose = $PokemonTemp.battleRules["canLose"] || false
# Skip battle if the player has no able Pokémon, or if holding Ctrl in Debug mode
if $Trainer.ablePokemonCount==0 || ($DEBUG && Input.press?(Input::CTRL))
pbMessage(_INTL("SKIPPING BATTLE...")) if $Trainer.pokemonCount>0
pbSet(outcomeVar,1) # Treat it as a win
$PokemonTemp.clearBattleRules
$PokemonGlobal.nextBattleBGM = nil
$PokemonGlobal.nextBattleME = nil
$PokemonGlobal.nextBattleCaptureME = nil
$PokemonGlobal.nextBattleBack = nil
return 1 # Treat it as a win
end
# Record information about party Pokémon to be used at the end of battle (e.g.
# comparing levels for an evolution check)
Events.onStartBattle.trigger(nil)
# Generate wild Pokémon based on the species and level
foeParty = []
sp = nil
for arg in args
if arg.is_a?(PokeBattle_Pokemon)
foeParty.push(arg)
elsif arg.is_a?(Array)
species = getID(PBSpecies,arg[0])
pkmn = pbGenerateWildPokemon(species,arg[1])
#-----------------------------------------------------------------------------
#added by derFischae to set the gender, form and shinyflag
if arg.length()==5
gender = arg[2]
pkmn.setGender(gender) if USEFEMALESPRITES==true and gender!=nil and gender>=0 and gender<3
form = arg[3]
pkmn.form = form if USEALTFORMS==true and form!=nil and form>=0
pkmn.resetMoves
shinyflag = arg[4]
pkmn.shinyflag = shinyflag if shinyflag!=nil
end
# well actually it is not okay to test if form>0, we should also test if form
# is smaller than the maximal form, but for now I keep it that way.
#-----------------------------------------------------------------------------
foeParty.push(pkmn)
elsif sp
species = getID(PBSpecies,sp)
pkmn = pbGenerateWildPokemon(species,arg)
foeParty.push(pkmn)
sp = nil
else
sp = arg
end
end
raise _INTL("Expected a level after being given {1}, but one wasn't found.",sp) if sp
# Calculate who the trainers and their party are
playerTrainers = [$Trainer]
playerParty = $Trainer.party
playerPartyStarts = [0]
if $PokemonGlobal.partner && !$PokemonTemp.battleRules["noPartner"] && foeParty.length>1
ally = PokeBattle_Trainer.new($PokemonGlobal.partner[1],$PokemonGlobal.partner[0])
ally.id = $PokemonGlobal.partner[2]
ally.party = $PokemonGlobal.partner[3]
playerTrainers.push(ally)
playerParty = []
$Trainer.party.each { |pkmn| playerParty.push(pkmn) }
playerPartyStarts.push(playerParty.length)
ally.party.each { |pkmn| playerParty.push(pkmn) }
end
# Create the battle scene (the visual side of it)
scene = pbNewBattleScene
# Create the battle class (the mechanics side of it)
battle = PokeBattle_Battle.new(scene,playerParty,foeParty,playerTrainers,nil)
battle.party1starts = playerPartyStarts
# Set various other properties in the battle class
pbPrepareBattle(battle)
$PokemonTemp.clearBattleRules
# Perform the battle itself
decision = 0
pbBattleAnimation(pbGetWildBattleBGM(foeParty),(foeParty.length==1) ? 0 : 2,foeParty) {
pbSceneStandby {
decision = battle.pbStartBattle
}
pbAfterBattle(decision,canLose)
}
Input.update
# Save the result of the battle in a Game Variable (1 by default)
# 0 - Undecided or aborted
# 1 - Player won
# 2 - Player lost
# 3 - Player or wild Pokémon ran from battle, or player forfeited the match
# 4 - Wild Pokémon was caught
# 5 - Draw
pbSet(outcomeVar,decision)
return decision
end
#===============================================================================
# overriding Method pbWildBattle in Script PField_Battles
# to include alternate forms of the wild pokemon
#===============================================================================
#-----------------------------------------------------------------------------
#added by derFischae to set the gender, form and shinyflag
#genwildpoke.setGender(gender) if USEFEMALESPRITES==true and gender!=nil and gender>=0 and gender<3
#genwildpoke.form = form if USEALTFORMS==true and form!=nil and form>0
#genwildpoke.shinyflag = shinysprite if shinysprite!=nil
# well actually it is not okay to test if form>0, we should also test if form
# is smaller than the maximal form, but for now I keep it that way.
#-----------------------------------------------------------------------------
#===============================================================================
# Standard methods that start a wild battle of various sizes
#===============================================================================
# Used when walking in tall grass, hence the additional code.
def pbWildBattle(species, level, outcomeVar=1, canRun=true, canLose=false,gender = nil,form = nil,shinysprite = nil)
species = getID(PBSpecies,species)
# Potentially call a different pbWildBattle-type method instead (for roaming
# Pokémon, Safari battles, Bug Contest battles)
handled = [nil]
Events.onWildBattleOverride.trigger(nil,species,level,handled)
return handled[0] if handled[0]!=nil
# Set some battle rules
setBattleRule("outcomeVar",outcomeVar) if outcomeVar!=1
setBattleRule("cannotRun") if !canRun
setBattleRule("canLose") if canLose
# Perform the battle
decision = pbWildBattleCore([species,level,gender,form,shinysprite])
# Used by the Poké Radar to update/break the chain
Events.onWildBattleEnd.trigger(nil,species,level,decision)
# Return false if the player lost or drew the battle, and true if any other result
return (decision!=2 && decision!=5)
end
#===============================================================================
# overriding Method pbDoubleWildBattle in Script PField_Battles
# to include alternate forms of the wild pokemon in double battles
#===============================================================================
#-----------------------------------------------------------------------------
#added by derFischae to set the gender, form and shinyflag
# well actually it is not okay to test if form>0, we should also test if form
# is smaller than the maximal form, but for now I keep it that way.
#genwildpoke.setGender(gender1) if USEFEMALESPRITES==true and gender1!=nil and gender1>=0 and gender1<3
#if USEALTFORMS==true and form1!=nil and form1>0
# genwildpoke.form = form1
# genwildpoke.shinyflag = shinysprite1 if shinysprite1!=nil
# genwildpoke.resetMoves
#end
#genwildpoke2.setGender(gender) if USEFEMALESPRITES==true and gender2!=nil and gender2>=0 and gender2<3
#if USEALTFORMS==true and form2!=nil and form2>0
# genwildpoke2.form = form2 if USEALTFORMS==true and form2!=nil and form2>0
# genwildpoke2.shinyflag = shinysprite2 if shinysprite2!=nil
# genwildpoke2.resetMoves
#end
#-----------------------------------------------------------------------------
def pbDoubleWildBattle(species1, level1, species2, level2,
outcomeVar=1, canRun=true, canLose=false,
gender1 = nil,form1 = nil,shinysprite1 = nil,gender2 = nil,form2 = nil,shinysprite2 = nil)
# Set some battle rules
setBattleRule("outcomeVar",outcomeVar) if outcomeVar!=1
setBattleRule("cannotRun") if !canRun
setBattleRule("canLose") if canLose
setBattleRule("double")
# Perform the battle
decision = pbWildBattleCore([species1,level1,gender1,form1,shinysprite1], [species2,level2,gender2,form2,shinysprite2])
# Return false if the player lost or drew the battle, and true if any other result
return (decision!=2 && decision!=5)
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
#===============================================================================
# adding a new method attr_reader to the Class Spriteset_Map in Script
# Spriteset_Map to get access to the variable @character_sprites of a
# Spriteset_Map
#===============================================================================
class Spriteset_Map
attr_reader :character_sprites
end
#===============================================================================
# adding a new method attr_reader to the Class Scene_Map in Script
# Scene_Map to get access to the Spriteset_Maps listed in the variable
# @spritesets of a Scene_Map
#===============================================================================
class Scene_Map
attr_reader :spritesets
end
#########################################################
# #
# 2. 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
removeThisEventfromMap
else
@stepCount=0 if (!@stepCount || @stepCount<0)
@stepCount+=1
original_increase_steps
end
end
def removeThisEventfromMap
if $game_map.events.has_key?(@id) and $game_map.events[@id]==self
for sprite in $scene.spritesets[$game_map.map_id].character_sprites
if sprite.character==self
$scene.spritesets[$game_map.map_id].character_sprites.delete(sprite)
sprite.dispose
break
end
end
$game_map.events.delete(@id)
else
if $MapFactory
for map in $MapFactory.maps
if map.events.has_key?(@id) and map.events[@id]==self
for sprite in $scene.spritesets[self.map_id].character_sprites
if sprite.character==self
$scene.spritesets[map.map_id].character_sprites.delete(sprite)
sprite.dispose
break
end
end
map.events.delete(@id)
break
end
end
else
Kernel.pbMessage("Actually, this should not be possible")
end
end
end
end
class Game_Map
def removeThisEventfromMap(id)
if @events.has_key?(id)
for sprite in $scene.spritesets[@map_id].character_sprites
if sprite.character == @events[id]
$scene.spritesets[@map_id].character_sprites.delete(sprite)
sprite.dispose
break
end
end
@events.delete(id)
end
end
end
#########################################################
# #
# 3. PART: ADDITIONAL FEATURES #
# #
#########################################################
#===============================================================================
# Adding Event OnWildPokemonCreateForSpawning to Module Events in Script PField_Field.
# This Event is triggered when a new pokemon spawns. Use this Event instead of OnWildPokemonCreate
# if you want to add a new procedure that modifies a pokemon on spawning
# but not on creation while going into battle with an already spawned pokemon.
#Note that OnPokemonCreate is also triggered when a pokemon is created for spawning,
#But OnPokemonCreateForSpawning is not triggered when a pokemon is created in other situations than for spawning
#===============================================================================
module Events
@@OnWildPokemonCreateForSpawning = Event.new
# Triggers whenever a wild Pokémon is created for spawning
# Parameters:
# e[0] - Pokémon being created for spawning
def self.onWildPokemonCreateForSpawning; @@OnWildPokemonCreateForSpawning; end
def self.onWildPokemonCreateForSpawning=(v); @@OnWildPokemonCreateForSpawning = v; end
end
#===============================================================================
# adds new parameter battlingSpawnedPokemon to the class PokemonGlobalMetadata
# defined in script section PField_Metadata. Also overrides initialize include that parameter there.
#===============================================================================
class PokemonGlobalMetadata
attr_accessor :battlingSpawnedPokemon
attr_accessor :creatingSpawningPokemon
alias original_initialize initialize
def initialize
battlingSpawnedPokemon = false
creatingSpawningPokemon = false
original_initialize
end
end
THE BUG FIX FOR POKEMON ESSENTIALS V18.1
Spoiler:
In Pokemon Essentials V18.1, it was introduced that normal wild encounter can encounter on turning the direction of your player. These encounters are always normal encounters. So, if you don't want these normal encounters then you have multiple ways to remove or correct that.
Open the script editor and go to the script section "PField_Field". Search for the following code snippet
Code:
# Start wild encounters while turning on the spot
Events.onChangeDirection += proc {
repel = ($PokemonGlobal.repel>0)
pbBattleOnStepTaken(repel) if !$game_temp.in_menu
}
- either remove that code (to remove that pokemon can encounter on changing the direction of your player), or
- replace it by this code snippet
Spoiler:
Code:# Start wild overworld/mixed encounters while turning on the spot Events.onChangeDirection += proc { repel = ($PokemonGlobal.repel>0) if !$game_temp.in_menu 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 if $game_variables[OVERWORLD_ENCOUNTER_VARIABLE]>0 && ($game_variables[OVERWORLD_ENCOUNTER_VARIABLE]>=100 || rand(100) < $game_variables[OVERWORLD_ENCOUNTER_VARIABLE]) #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,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 }
to replace normal wild encountering during direction changing by overworld/mixed encountering.
PROPERTIES:
- 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 - You can choose how many steps the encounter moves before vanishing in parameter
STEPSBEFOREVANISHING - 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 - You can choose whether the sprite of your overworld encounter is always the standard sprite or can be an alternative form in parameter
USEALTFORMS - You can choose whether the sprites depend on the gender of the encounter or are always neutral in parameter
USEFEMALESPRITES - You can choose whether the overworld encounters have a stop/ step-animation similar to following pokemon in the parameter
USESTOPANIMATION - You can choose how many overworld encounters are agressive and run to the player in the parameter
AGGRESSIVEENCOUNTERPROBABILITY - You can choose the move-speed and move-frequenzy of normal and aggressive encounters in parameters
ENCMOVESPEED, ENCMOVEFREQ, AGGRENCMOVESPEED, AGGRENCMOVEFREQ - 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 - 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. - 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. - 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:
This is an add-on for the visible overworld wild encounter script. It adds Vendilys Rescue Chain to the script and its add-ons by JoelMathew.
See https://www.pokecommunity.com/showthread.php?t=415524 and https://www.pokecommunity.com/showthread.php?t=422513 for original scripts
FEATURES INCLUDED: If you kill or catch the same species in a row, then you increase the chance of spawning an evolved pokemon of that species family.
Moreover, JoelMathews Add-Ons raise the chance that a chained pokemon gets maximal IVs or its hidden ability
INSTALLATION:
Step 1) Copy the code below and Paste it at the bottom of your visible wild overworld encounter script.
Step 2) If you want to use JoelMathews Add-ons, then simply copy and paste the original code at https://www.pokecommunity.com/showthread.php?t=422513
PROPERTIES: Moreover, you also have all settings of vendilys Rescue chain below.
Code:#=============================================================================== # RESCUE CHAIN - By Vendily # - edited to obtain compatibility for visible overworld encounter by derFischae #=============================================================================== # This is an add-on for the visible overworld wild encounter script. # It adds Vendilys Rescue Chain to the script. # See https://www.pokecommunity.com/showthread.php?t=415524 for original script # # FEATURES INCLUDED: # If you kill or catch the same species in a row, then you increase the chance of spawning an evolved pokemon of that species family. # # INSTALLATION: # Step 1) Copy this code and # Paste it at the bottom of your visible wild overworld encounter script # Step 2) If you want to use JoelMathews Add-ons, then simply copy and paste # the original code at https://www.pokecommunity.com/showthread.php?t=422513 # # PROPERTIES: # Moreover, you also have all settings of vendilys Rescue chain below. #=============================================================================== # Rescue Chain - By Vendily # This script makes it so that if you chain pokemon of the same evolutionary # family together, an evolved form of the species will appear. # I used no references and I completly misinterpreted a description of SOS # battles as this thing. # * Minimum length of chain before evolved forms begin to appear. With every # multiple, the chance for the evolved form or a second evolved form to appear # increases. (Default 10) # * Chance that the evolved form will even show up, 1 out of this constant. # (Default 4, for 1/4 chance, it's probably too high) # * Random number added to the minimum level this pokemon can evolve at or # the wild pokemon's current level if it evolves through item (Default 5) # * Disable this modifier while the pokeradar is being used. # I recommend leaving it as is as the pokeradar may behave strangely and the # two scripts may reset each others' chain. (Default true) # * The maps where this effect can only take place in. # * The maps where this effect will never happen. Ever. # * The switch to disable this effect. (Default -1) #=============================================================================== EVOCHAINLENGTH = 1 EVORANDCHANCE = 1 EVOLEVELWOBBLE = 5 EVOPKRADERDISABLE = true EVOMAPSWHITELIST = [] EVOMAPSBLACKLIST = [] EVODISABLESWITCH = -1 class PokemonTemp attr_accessor :rescuechain # [chain length, evo family] end Events.onWildPokemonCreate+=proc {|sender,e| if !$PokemonGlobal.battlingSpawnedPokemon next if EVOMAPSBLACKLIST.include?($game_map.map_id) next if EVOMAPSWHITELIST.length>0 && !EVOMAPSWHITELIST.include?($game_map.map_id) next if EVODISABLESWITCH>0 && $game_switches[EVODISABLESWITCH] next if EVOPKRADERDISABLE && !$PokemonTemp.pokeradar.nil? next if !$PokemonGlobal.roamEncounter.nil? pokemon=e[0] next if pokemon.nil? if !$PokemonTemp.rescuechain $PokemonTemp.rescuechain=[0,nil] end family=pbGetBabySpecies(pokemon.species) if family != $PokemonTemp.rescuechain[1] $PokemonTemp.rescuechain=[0,family] end if $PokemonTemp.rescuechain[0]>=EVOCHAINLENGTH for i in 0..($PokemonTemp.rescuechain[0]/EVOCHAINLENGTH).floor() evodata=pbGetEvolvedFormData(pokemon.species) if evodata.length>0 && rand(EVORANDCHANCE)==0 fspecies=evodata[rand(evodata.length)][2] newspecies,newform=pbGetSpeciesFromFSpecies(fspecies) level=pbGetMinimumLevel(fspecies) level=[level,pokemon.level].max level+=rand(EVOLEVELWOBBLE) pokemon.species=newspecies pokemon.form=newform pokemon.level=level pokemon.name=PBSpecies.getName(newspecies) pokemon.calcStats pokemon.resetMoves end end end end } Events.onWildBattleEnd+=proc {|sender,e| next if EVOMAPSBLACKLIST.include?($game_map.map_id) next if EVOMAPSWHITELIST.length>0 && !EVOMAPSWHITELIST.include?($game_map.map_id) next if EVODISABLESWITCH>0 && $game_switches[EVODISABLESWITCH] next if EVOPKRADERDISABLE && !$PokemonTemp.pokeradar.nil? $PokemonTemp.rescuechain = [0,nil] if !$PokemonTemp.rescuechain species=e[0] result=e[2] family=pbGetBabySpecies(species) if $PokemonTemp.rescuechain[1]!=family $PokemonTemp.rescuechain=[0,family] end if (result==1 || result == 4) && family==$PokemonTemp.rescuechain[1] $PokemonTemp.rescuechain[0]+=1 end }
- 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:
This is an add-on for the visible overworld wild encounter script. It adds shiny hunting by chaining a pokemon species to the script.
This script is motified by Diego Mertens Lets's Go Catch Combo, see https://www.pokecommunity.com/showthread.php?p=10011513
FEATURES INCLUDED: If you catch the same species in a row, then you increase the chance of spawning a shiny of that species.
INSTALLATION: Copy the code below and Paste it at the bottom of your visible wild overworld encounter script.
PROPERTIES: You can choose how many encounters you have to catch to obtain the increased Shiny-Chance in parameter
CHAINLENGTH
and the increased Shiny-Chance in parameter
SHINYPROBABILITY
in the settings section of this add-on.
REMARK: If you want that killing instead of chaining has the effect on spawning shinies then replace "result == 4" at the bottom of the shiny chining script by "result==1". And If you want that killing and chaining also that effect then replace "result == 4" by "(result==1 || result == 4)".
Code:#=============================================================================== # The Let's Go Shiny Hunting, inpired by Diego Mertens script # - to make a chained pokemon shiny #=============================================================================== # This is an add-on for the visible overworld wild encounter script. # It adds shiny hunting by chaining a pokemon species to the script. # This script is motified by Diego Mertens Lets's Go Catch Combo, see # https://www.pokecommunity.com/showthread.php?p=10011513 # FEATURES INCLUDED: # If you catch the same species in a row, then you increase the chance of # spawning a shiny of that species. # INSTALLATION: # Copy this code and # Paste it at the bottom of your visible wild overworld encounter script. # PROPERTIES: # You can choose how many encounters you have to catch to obtain the increased # Shiny-Chance in parameter # CHAINLENGTH # and the increased Shiny-Chance in parameter # SHINYPROBABILITY # in the settings below. # REMARK: # If you want that killing instead of chaining has the effect on spawning shinies then replace "result == 4" # at the bottom of the shiny chining script by "result==1". # And If you want that killing and chaining also that effect then replace "result == 4" by "(result==1 || result == 4)". #=============================================================================== # Settings #=============================================================================== CHAINLENGTH = 1 # default 10 # number describes how many pokemon of the same species # you have to catch in a row to increase shiny propability SHINYPROBABILITY = 10 # default 100 --> 10% # increasing this value decreases the probability of spawning a shiny #=============================================================================== # adding a new instance variable to $PokemonTemp in script PField_Metadata to # remember which pokemon and how many of that kind were caught in a row #=============================================================================== class PokemonTemp attr_accessor :catchcombo # [chain length, species] end #=============================================================================== # adding a new event handler on pokemon create to make pokemon shiny on spawning # and in instant battles if the chain is long enough #=============================================================================== Events.onWildPokemonCreate+=proc {|sender,e| if !$PokemonGlobal.battlingSpawnedPokemon pokemon=e[0] next if pokemon.nil? $PokemonTemp.catchcombo=[0,0] if !$PokemonTemp.catchcombo if ($PokemonTemp.catchcombo[0]>=CHAINLENGTH && $PokemonTemp.catchcombo[1]==pokemon.species) if rand(SHINYPROBABILITY)<$PokemonTemp.catchcombo[0] pokemon.makeShiny end end end } #=============================================================================== # adding a new event handler on Battle end to update the catchchain (where the # pokemon-catch-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==4 && species==$PokemonTemp.catchcombo[1] $PokemonTemp.catchcombo[0]+=1 end }
inspired by Diego Mertens original script https://www.pokecommunity.com/showthread.php?p=10011513 - Automatic Spawning
Spoiler:
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 the code below 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 section of this add-on.
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
- Randomised spawning
Spoiler:
UPDATED TO VERSION 1.01 to include randomising of forms and gender depending on randomised species.
Here is an easy Add-On. Overworld encounters will be random. Updated to Simply, add the code to the bottom of the visible overworld wild encounter script
Code:#====================================================== # Randomised Spawning v1.01 by derFischae #====================================================== # This is an Add-On for the visible overworld wild encounters script. It will randomise overworld encounters. # # Add this code to the bottom of the visible overworld wild encounter script Events.onWildPokemonCreateForSpawning+=proc{|sender,e| pokemon=e[0] pokemon.species = rand(PBSpecies.maxValue)+1 pokemon.setGender(2) pokemon.setGender(1) pokemon.setGender(0) if rand(100)<50 f = MultipleForms.call("getFormOnCreation",pokemon) if f pokemon.form = f pokemon.resetMoves end }
- all overworld encounters are shinys
Spoiler:
Here is a very easy Add-On. It makes all pokemon spawn as shinies. Simply, add the code to the bottom of the visible overworld wild encounter script
Code:Events.onWildPokemonCreateForSpawning+=proc {|sender,e| pokemon.species=e[0] pokemon.makeShiny }
- 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:
Note that, Pokemon Essentials v18 does not support modifying wild Pokemon on start Battle anymore. It is recommanded to use the event OnPokemonCreate for that instead.
lots of scripts out there work as suggested with this script. But for some scripts you might need to modify your additional scripts, such as Vendilys Rescue Chain or Joltiks Level Balance, to work properly with the visible overworld encounter script. Here I give you some instructions for that.
EVENTS AND VISIBLE OVERWORLD WILD ENCOUNTER
Concerning Wild Pokemon, there are 3 Events, which trigger before a wild overworld pokebattle.
At first, the event @@OnStartBattle triggers right before the battle.
You can add a procedure to this event, so that procedure runs when going into battle.
Note that Pokemon Essentiasl v18 does not support to modify the encountering pokemon in OnStartBattle anymore.
See the Pokemon Essentials manual if you want to read more on how to use it.
Another event is @@OnWildPokemonCreate, instructions in the Pokemon Essentials manual.
But with the visible overworld wild encounter script, the event @@OnWildPokemonCreate triggers twice, since we need to create a pokemon in two situation.
At first when the pokemon spawns to generate the pokemon species, level, shinyness, form and gender for the sprite.
And the second time it creates a pokemon is when you go into battle with an already spawned pokemon to set the ability, IVs and all the other things we need for the battle.
So, you can still use all your scripts which make use of the event @@OnwildPokemonCreate.
But it might get an odd behavior since that event triggers twice.
To get rid of that the visible wild overworld encounter script introduces a new event @@OnWildPokemonCreateForSpawning.
It can be used the same way as the event @@OnWildPokemonCreate,
but this event will only trigger when a pokemon spawns on the overworld and is not triggered in any other situations than for spawning.
If you want to add a procedure that modifies a pokemon only for spawning but not before battling then you can do it.
Simply add that procedure to the event @@OnWildPokemonCreateForSpawning.
Also make sure that the procedure only affects the species, level, alternative form, gender and shinyness of the pokemon.
All other changes of properties of the pokemon, such as the ability and the IVs, will be omitted, since they are not relevant for the sprite of the overworld encounter. (If you think, that there should be some other property changable then let me know.)
But all other properties of a pokemon can still be changed in @@OnWildPokemonCreate or @@OnStartBattle as usual.
You can have overworld encounters and events, placed by your own, which force a wild battle, which also counts somehow as a normal encounter.
Or you use overworld encounters and normal encounters at the same time. This can be done by setting the parameter INSTANT_WILD_BATTLE_PROPABILITY = 1,2,3,4,... or 99 before starting the game the first time.
Or by changing ingame the value of the $game_variable with the ID equal to OVERWORLD_ENCOUNTER_VARIABLE. Read the instructions in the settings section of the visible overworld wild encounter script for more informations.
So you might come to the point that you want to modify a pokemon or run a certain procedure in battle only for overworld encounters, only for normal encounters or for all encounters.
That's way the visible overworld wild encounter script introduces two new global variables $PokemonGlobal.battlingSpawnedPokemon and $Pokemon.creatingSpawningPokemon.
During events, such as @@OnWildPokemonCreate, you can use $PokemonGlobal.battlingSpawnedPokemon to decide if you are going into battle against an overworld encounter (true) or not (nil or false), including battling a normal encounter or not battling at all.
Similary, you can use $Pokemon.creatingSpawningPokemon in @@OnWildPokemonCreate and @@OnWildPokemonCreateForSpawning to decide if a pokemon is created to let it spawn on the map (true) or for any other reason (nil or false).
Combining both global variables makes it possible to distinguish every situation when a pokemon is created.
For example, if you want to add a procedure to the event @@OnWildPokemonCreate and want that this procedure runs only on battling with an overworld encounter use this code snippet
Code:Events.onWildPokemonCreate+=proc {|sender,e| if $PokemonGlobal.battlingSpawnedPokemon == true #The actual code of your procedure you want to run only when battling overworld encounters. end }
You can find the other if conditions and its meaning below
Code:$PokemonGlobal.battlingSpawnedPokemon == true # means procedure triggers when going into battle with already spawned pokemon !$PokemonGlobal.battlingSpawnedPokemon # means procedure triggers for instant battles and for creating For Spawning !$PokemonGlobal.battlingSpawnedPokemon and !$PokemonGlobal.creatingSpawningPokemon # means procedure triggers for instant battles $PokemonGlobal.creatingSpawningPokemon == true # means procedure triggers when a pokemon is created for spawning !$PokemonGlobal.creatingSpawningPokemon # means procedure triggers in every situation except that it is created for spawning, including instant battles and battling spawned pokemon # !$PokemonGlobal.battlingSpawnedPokemon and $PokemonGlobal.creatingSpawningPokemon == true # equals $PokemonGlobal.creatingSpawningPokemon == true # $PokemonGlobal.battlingSpawnedPokemon == true and !$PokemonGlobal.creatingSpawningPokemon # equals $PokemonGlobal.battlingSpawnedPokemon # $PokemonGlobal.battlingSpawnedPokemon == true and $PokemonGlobal.creatingSpawningPokemon == true # means that the procedure will not trigger
- Joltiks Level Balance, see https://www.pokecommunity.com/showthread.php?t=409828 for original post
Spoiler:
With Joltiks Level Balance, the encountering wild pokemon will always have a level balanced by the level of your party pokemon. Moreover, with high level, you will also encounter evolved pokemon.
Joltiks Level Balance is a script, such as many other scripts, that is not written for overworld spawning but also works fine without any modifiactions.
Basically, you can install the original version which you find at
https://www.pokecommunity.com/showthread.php?t=409828
It should not produce any odd behaviour.
But if you want to modify Joltiks Level Balance Script to be sure that it is completely compatible then you can do the following 2 steps. (You can read the instructions on how to make your own Add-On above for more informations)
Step 1) Simply search for all code in the script that is added to @@OnWildPokemonCreate by
Code:Events.onWildPokemonCreate+=proc {|sender,e| #Here is the code }
Code:Events.onWildPokemonCreateForSpawning+=proc {|sender,e| #Here is the code }
This global variable let's you restrict a procedure added to @@OnWildPokemonCreate run only on creation for battling an already spawned pokemon or not to run then.
So, you can add this code snippet
Code:Events.onWildPokemonCreate+=proc {|sender,e| if !$PokemonGlobal.battlingSpawnedPokemon #Here is the code end }
Note that Joltiks Level Balance is a good script to perform the described modifications since it only affects the species and the level of the pokemon. Although, without any modifications, Joltiks Level Balance would not generate any odd behavior. It just runs twice.
In general, make sure that the code only affects the species, level gender, alternative form and the shinyness of the pokemon. This should be the case for the script level balancing by Joltik for example.
If it also affects other parameters of the pokemon, such as the stats, then that modifications don't work anymore.
MODIFICATIONS OF THIS SCRIPT FOR PEv17.2: There are various modifications of this script for Pokemon Essentials v17.2. at https://www.pokecommunity.com/posts/10202528/ , 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
CHANGELOG
Spoiler:
NEW FEATURES IN VERSION 18.0.7 FOR PEv18:
- tiny bug fix for $PokemonTemp.encounterType
NEW FEATURES IN VERSION 18.0.7 FOR PEv18:
- removed a bug concerning changing the standard form when goining into battle
NEW FEATURES IN VERSION 18.0.6 FOR PEv18:
- (hopefully) removed a rare bug concerning character_sprites
NEW FEATURES IN VERSION 2.0.5 FOR PEv18:
- removed bug that makes all water encounter vanish
NEW FEATURES IN VERSION 2.0.4 FOR PEv18:
- encounters don't spawn on impassable tiles in caves
NEW FEATURES IN VERSION 2.0.3 FOR PEv18:
- Poke Radar works as usual
NEW FEATURES IN VERSION 2.0.2 FOR PEv18:
- added new global variable $PokemonGlobal.creatingSpawningPokemon to check during the event @@OnWildPokemonCreate if the pokemon is created for spawning on the map or created for a different reason
UPSCALED FEATURES FROM VERSION 2.0.1 FOR PEv17.2:
- less lag
- supports sprites for alternative forms of pokemon
- supports sprites for female/male/genderless pokemon
- bug fixes for roaming encounter and double battles
- more options in settings
- roaming encounters working correctly
- more lag reduction
- included automatic spawning of pokemon, i.e. spawning without having to move the player
- included vendilys rescue chain, i. e. if pokemon of the same species family spawn in a row and will be battled in a row, then you increase the chance of spawning
an evolved pokemon of that species family. Link: https://www.pokecommunity.com/showthread.php?t=415524
- removed bug occuring after fainting against wild overworld encounter
- for script-developers, shortened the spawnEvent method for better readablitiy
- removed bugs from version 1.9
- added shapes of overworld encounter for rescue chain users
- supports spawning of alternate forms while chaining
- if overworld sprites for alternative, female or shiny forms are missing,
then the standard sprite will be displayed instead of an invisible event
- bug fix for shiny encounters
- respecting shiny state for normal encounters when using overworld and normal encounters at the same time
- easier chaining concerning Vendilys Rescue chain, i.e. no more resetting of the chain when spawning of a pokemon of different family but when fighting with a pokemon of different family
- Added new Event @@OnPokemonCreateForSpawning which only triggers on spawning
- Added new global variable $PokemonGlobal.battlingSpawnedShiny to check if an active battle is against a spawned pokemon.
- removed bug to make the new features in version 1.11 work
- reorganised and thin out the code to organise code as add-ons
- removed Vendilys Rescue Chain, Let's Go Shiny Hunting and automatic spawning as hard coded feature and provide it as Add-Ons instead
- Now, using overworld and normal encounters at the same time is a standard feature
- autospawning will not trigger instant battles anymore
- removed a bug that came from reorganising the code in original code and add-ons concerning Let's go shiny hunting add-on
Last edited: