your script is wonderful, does it work with alternative forms?
I mean, when testing the script using pokemon with multiple forms, only the default form appeared, shellos is an example.
# use shiny-sprite if probability & killcombo is high or shiny-switch is on
$PokemonTemp.catchcombo=[0,0] if !$PokemonTemp.catchcombo
if $game_switches[SHINY_WILD_POKEMON_SWITCH]==true
character_name = character_name+"s"
shinysprite=true
elsif ($PokemonTemp.catchcombo[0]>=CHAINLENGTH && $PokemonTemp.catchcombo[1]==encounter[0])
if rand(SHINYPROBABILITY)<$PokemonTemp.catchcombo[0]
character_name = character_name+"s"
shinysprite=true
end
end
Also I tested now and... Why give me a little bit lag? Is it possible to "fix" that? Or only if I change my laptop/hardware? :o
Again, amazing script! Congratz!
After spawning and despawning of the overworld encounters we have to update the spriteset. Therefor, I used
$scene.disposeSpritesets
$scene.createSpritesets
in the method "increase_steps" and in "spawnEvent(x,y,encounter)". I would say that this way of updating the sprites causes your lag. If you or anyone else finds a better solution for updating the spriteset (which probabily exists) we can reduce some lag. Any suggests are welcome.
#===============================================================================
# * Visible Overworld Encounters - by derFischae (Credits if used please) *
#===============================================================================
# This script is for Pokémon Essentials 17.
# As in Pokemon Let's go Pikachu/Eevee or Pokemon Shild and Sword
# random encounters pop up on the overworld,
# they move around and you can start the battle
# with them simply by moving to the pokemon.
# Clearly, you also can omit the battle by circling around them.
#
#
# FEATURES INCLUDED:
# - see the pokemon on the overworld before going into battle
# - no forced battling against random encounters
# - plays the pokemon cry while spawning
# - Choose whether encounters occure on all terrains or only on
# the terrain of the player
# - if you kill the same species in a row, then you increase
# the chance of spawning a shiny of that species
#
# INSTALLATION:
# Installation as simple as it can be.
# Step 1) You need sprites for the overworld pokemon in your \Graphics\Characters
# folder named by there number 001.png, 002.png, ...,
# with the corresponding shiny versions 001s.png, 002s.png, ....
# For instance you can use Gen 1-7 OV SPrites or whatever you want for
# your fakemon
# Step 2) Insert a new file in the script editor above main,
# name it Overworld_Random_Encounters and copy this code into it.
#
# PROPERTIES:
# 1) If you want to have water encounters only while surfing,
# you also have to change the value of the
# upcoming parameter RESTRICTENCOUNTERSTOPLAYERMOVEMENT to
# RESTRICTENCOUNTERSTOPLAYERMOVEMENT = true
# 2) You can choose how many steps the encounter moves before vanishing
# in parameter
# STEPSBEFOREVANISHING
# 3) You can choose how many encounters you have to kill to obtain the increased
# Shiny-Chance in parameter
# CHAINLENGTH
# and the increased Shiny-Chance in parameter
# SHINYPROBABILITY
#
# NOTE: I have not checked Roaming Encounters. Feel free to test it.
#===============================================================================
# Settings
#===============================================================================
RESTRICTENCOUNTERSTOPLAYERMOVEMENT = false
#true - means that water encounters are popping up
# if and only if player is surfing
# (perhaps decreases encounter rate)
#false - means that all encounter types can pop up
# close to the player (as long as there is a suitable tile)
CHAINLENGTH = 10 # default 10
# number describes how many pokemon of the same species
# you have to kill in a row to increase shiny propability
SHINYPROBABILITY = 100 # default 100 --> 10%
# increasing this value decreases the probability of spawning a shiny
STEPSBEFOREVANISHING = 6 # default 10
# STEPSBEFOREVANISHING is the number of steps a wild Encounter goes
# before vanishing on the map.
#===============================================================================
# THE SCRIPT
#===============================================================================
#########################################################
# #
# 1. PART: THE CATCHCOMBO #
# #
#########################################################
#===============================================================================
# adding a new instance variable to $PokemonTemp in script PField_Metadata to
# remember which pokemon and how many of that kind were killed in a row
#===============================================================================
class PokemonTemp
attr_accessor :catchcombo # [chain length, species]
end
#===============================================================================
# adding a new event handler on Battle end to update the catchchain (where the
# pokemon-kill-chain is saved)
#===============================================================================
Events.onWildBattleEnd+=proc {|sender,e|
species=e[0]
result=e[2]
$PokemonTemp.catchcombo = [0,0] if !$PokemonTemp.catchcombo
if $PokemonTemp.catchcombo[1]!=species
$PokemonTemp.catchcombo=[0,species]
end
if result==1 && species==$PokemonTemp.catchcombo[1]
$PokemonTemp.catchcombo[0]+=1
#Kernel.pbMessage(_INTL("You killed {1} {2}",$PokemonTemp.catchcombo[0],$PokemonTemp.catchcombo[1]))
end
}
#########################################################
# #
# 2. PART: SPAWNING THE OVERWORLD ENCOUNTER #
# #
#########################################################
#===============================================================================
# We override the original method "pbOnStepTaken" it was originally used for
# random encounter battles
#===============================================================================
def Kernel.pbOnStepTaken(eventTriggered)
#Should it be possible to search for pokemon nearby?
if $game_player.move_route_forcing || pbMapInterpreterRunning? || !$Trainer
Events.onStepTakenFieldMovement.trigger(nil,$game_player)
return
end
$PokemonGlobal.stepcount = 0 if !$PokemonGlobal.stepcount
$PokemonGlobal.stepcount += 1
$PokemonGlobal.stepcount &= 0x7FFFFFFF
repel = ($PokemonGlobal.repel>0)
Events.onStepTaken.trigger(nil)
handled = [nil]
Events.onStepTakenTransferPossible.trigger(nil,handled)
return if handled[0]
if !eventTriggered
#we choose the tile on which the pokemon appears
pos = pbChooseTileOnStepTaken
return if !pos
#we choose the random encounter
encounter = pbChooseEncounter(pos[0],pos[1],repel)
return if !encounter
#we generate an random encounter overworld event
pbPlaceEncounter(pos[0],pos[1],encounter)
end
end
#===============================================================================
# new method pbChooseTileOnStepTaken to choose the tile on which the pkmn spawns
#===============================================================================
def pbChooseTileOnStepTaken
# Choose 1 random tile from 1 random ring around the player
i = rand(4)
r = rand((i+1)*8)
x = $game_player.x
y = $game_player.y
if r<=(i+1)*2
x = $game_player.x-i-1+r
y = $game_player.y-i-1
elsif r<=(i+1)*6-2
x = [$game_player.x+i+1,$game_player.x-i-1][r%2]
y = $game_player.y-i+((r-1-(i+1)*2)/2).floor
else
x = $game_player.x-i+r-(i+1)*6
y = $game_player.y+i+1
end
#check if it is possible to encounter here
return if x<0 || x>=$game_map.width || y<0 || y>=$game_map.height #check if the tile is on the map
#check if it's a valid grass, water or cave etc. tile
return if PBTerrain.isIce?($game_map.terrain_tag(x,y))
return if PBTerrain.isLedge?($game_map.terrain_tag(x,y))
return if PBTerrain.isWaterfall?($game_map.terrain_tag(x,y))
return if PBTerrain.isRock?($game_map.terrain_tag(x,y))
if RESTRICTENCOUNTERSTOPLAYERMOVEMENT
return if !PBTerrain.isWater?($game_map.terrain_tag(x,y)) &&
$PokemonGlobal && $PokemonGlobal.surfing
return if PBTerrain.isWater?($game_map.terrain_tag(x,y)) &&
!($PokemonGlobal && $PokemonGlobal.surfing)
end
return [x,y]
end
#===============================================================================
# defining new method pbChooseEncounter to choose the pokemon on the tile (x,y)
#===============================================================================
def pbChooseEncounter(x,y,repel=false)
return if $Trainer.ablePokemonCount==0 #check if trainer has pokemon
encounterType = $PokemonEncounters.pbEncounterTypeOnTile(x,y)
$PokemonTemp.encounterType = encounterType
return if encounterType<0 #check if there are encounters
return if !$PokemonEncounters.isEncounterPossibleHereOnTile?(x,y)
for event in $game_map.events.values
if event.x==x && event.y==y
return
end
end
encounter = $PokemonEncounters.pbGenerateEncounter(encounterType)
encounter = EncounterModifier.trigger(encounter)
if !$PokemonEncounters.pbCanEncounter?(encounter,repel)
$PokemonTemp.forceSingleBattle = false
EncounterModifier.triggerEncounterEnd()
return
end
return encounter
end
#===============================================================================
# defining new method pbPlaceEncounter to add/place and visualise the pokemon
# "encounter" on the overworld-tile (x,y)
#===============================================================================
def pbPlaceEncounter(x,y,encounter)
# place event with random movement with overworld sprite
# We define the event, which has the sprite of the pokemon and activates the wildBattle on touch
if !$MapFactory
$game_map.spawnEvent(x,y,encounter)
else
mapId = $game_map.map_id
spawnMap = $MapFactory.getMap(mapId)
#Kernel.pbMessage(_INTL("{1}",spawnMap.map_id))
spawnMap.spawnEvent(x,y,encounter)
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.nowRoaming == true &&
$PokemonTemp.roamerIndex != nil &&
$PokemonGlobal.roamEncounter != nil
$PokemonGlobal.roamEncounter = nil
$PokemonGlobal.roamedAlready = true
end
$PokemonTemp.forceSingleBattle = false
EncounterModifier.triggerEncounterEnd()
end
#===============================================================================
# adding new Methods pbEncounterTypeOnTile and isEncounterPossibleHereOnTile?
# in Class PokemonEncounters in Script PField_Encounters
#===============================================================================
class PokemonEncounters
def pbEncounterTypeOnTile(x,y)
if PBTerrain.isJustWater?($game_map.terrain_tag(x,y))
return EncounterTypes::Water
elsif self.isCave?
return EncounterTypes::Cave
elsif self.isGrass?
time = pbGetTimeNow
enctype = EncounterTypes::Land
enctype = EncounterTypes::LandNight if self.hasEncounter?(EncounterTypes::LandNight) && PBDayNight.isNight?(time)
enctype = EncounterTypes::LandDay if self.hasEncounter?(EncounterTypes::LandDay) && PBDayNight.isDay?(time)
enctype = EncounterTypes::LandMorning if self.hasEncounter?(EncounterTypes::LandMorning) && PBDayNight.isMorning?(time)
if pbInBugContest? && self.hasEncounter?(EncounterTypes::BugContest)
enctype = EncounterTypes::BugContest
end
return enctype
end
return -1
end
def isEncounterPossibleHereOnTile?(x,y)
if PBTerrain.isJustWater?($game_map.terrain_tag(x,y))
return true
elsif self.isCave?
return true
elsif self.isGrass?
return PBTerrain.isGrass?($game_map.terrain_tag(x,y))
end
return false
end
end
#===============================================================================
# new Method spawnEvent in Class Game_Map in Script Game_Map
#===============================================================================
class Game_Map
def spawnEvent(x,y,encounter)
#------------------------------------------------------------------
# generating a new event
event = RPG::Event.new(x,y)
# naming the event "vanishingEncounter" for PART 3
event.name = "vanishingEncounter"
#setting the nessassary properties
key_id = (@events.keys.max || -1) + 1
event.id = key_id
event.x = x
event.y = y
#event.pages[0].graphic.tile_id = 0
if encounter[0] < 10
character_name = "00"+encounter[0].to_s
elsif encounter[0] < 100
character_name = "0"+encounter[0].to_s
else
character_name = encounter[0].to_s
end
# use shiny-sprite if probability & killcombo is high or shiny-switch is on
$PokemonTemp.catchcombo=[0,0] if !$PokemonTemp.catchcombo
if $game_switches[SHINY_WILD_POKEMON_SWITCH]==true
character_name = character_name+"s"
shinysprite=true
elsif ($PokemonTemp.catchcombo[0]>=CHAINLENGTH && $PokemonTemp.catchcombo[1]==encounter[0])
if rand(SHINYPROBABILITY)<$PokemonTemp.catchcombo[0]
character_name = character_name+"s"
shinysprite=true
end
end
event.pages[0].graphic.character_name = character_name
event.pages[0].move_type = 1
event.pages[0].trigger = 2
#------------------------------------------------------------------
# we add the event commands to the event of the overworld encounter
event.pages[0].list[0].code = 355
event.pages[0].list[0].indent = 0
if $PokemonGlobal.roamEncounter!=nil
#[i,species,poke[1],poke[4]]
parameter1 = $PokemonGlobal.roamEncounter[1].to_s
parameter2 = $PokemonGlobal.roamEncounter[2].to_s
parameter3 = $PokemonGlobal.roamEncounter[3].to_s
$PokemonGlobal.roamEncounter[4] != nil ? (parameter4 = '"'+$PokemonGlobal.roamEncounter[4].to_s+'"') : (parameter4 = "nil")
parameter = " $PokemonGlobal.roamEncounter = ["+parameter1+","+parameter2+","+parameter3+","+parameter4+"] "
else
parameter = " $PokemonGlobal.roamEncounter = nil "
end
event.pages[0].list[0].parameters = [parameter]
event.pages[0].list[1] = RPG::EventCommand.new
#
event.pages[0].list[1].code = 355
event.pages[0].list[1].indent = 0
if $PokemonTemp.nowRoaming!=nil
parameter =" $PokemonTemp.nowRoaming = "+$PokemonTemp.nowRoaming.to_s
else
parameter =" $PokemonTemp.nowRoaming = nil "
end
event.pages[0].list[1].parameters = [parameter]
event.pages[0].list[2] = RPG::EventCommand.new
#
event.pages[0].list[2].code = 355
event.pages[0].list[2].indent = 0
if $PokemonTemp.roamerIndex!=nil
parameter = " $PokemonTemp.roamerIndex = "+$PokemonTemp.roamerIndex.to_s
else
parameter = " $PokemonTemp.roamerIndex = nil "
end
event.pages[0].list[2].parameters = [parameter]
event.pages[0].list[3] = RPG::EventCommand.new
#
event.pages[0].list[3].code = 355
event.pages[0].list[3].indent = 0
if $PokemonGlobal.nextBattleBGM!=nil
parameter = " $PokemonGlobal.nextBattleBGM = "+PokemonGlobal.nextBattleBGM.to_s
else
parameter = " $PokemonGlobal.nextBattleBGM = nil "
end
event.pages[0].list[3].parameters = [parameter]
event.pages[0].list[4] = RPG::EventCommand.new
#
event.pages[0].list[4].code = 355
event.pages[0].list[4].indent = 0
if $PokemonTemp.forceSingleBattle!=nil
parameter = " $PokemonTemp.forceSingleBattle = "+$PokemonTemp.forceSingleBattle.to_s
else
parameter = " $PokemonTemp.forceSingleBattle = nil "
end
event.pages[0].list[4].parameters = [parameter]
event.pages[0].list[5] = RPG::EventCommand.new
#
event.pages[0].list[5].code = 355
event.pages[0].list[5].indent = 0
if $PokemonTemp.encounterType!=nil
parameter = " $PokemonTemp.encounterType = "+$PokemonTemp.encounterType.to_s
else
parameter = " $PokemonTemp.encounterType = nil "
end
event.pages[0].list[5].parameters = [parameter]
event.pages[0].list[6] = RPG::EventCommand.new
#
# setting shiny switch on if sprite is a shiny-sprite
oldShinySwitchStatus=$game_switches[SHINY_WILD_POKEMON_SWITCH]
if shinysprite == true
parameter = " $game_switches["+SHINY_WILD_POKEMON_SWITCH.to_s+"]=true"
else
parameter = " $game_switches["+SHINY_WILD_POKEMON_SWITCH.to_s+"]=false"
end
event.pages[0].list[6].code = 355
event.pages[0].list[6].indent = 0
event.pages[0].list[6].parameters = [parameter]
event.pages[0].list[7] = RPG::EventCommand.new
#
#pbSingleOrDoubleWildBattle(encounter[0],encounter[1])
event.pages[0].list[7].code = 355
event.pages[0].list[7].indent = 0
parameter = " pbSingleOrDoubleWildBattle("+encounter[0].to_s+","+encounter[1].to_s+", $game_map.events["+key_id.to_s+"].map.map_id, $game_map.events["+key_id.to_s+"].x, $game_map.events["+key_id.to_s+"].y)"
event.pages[0].list[7].parameters = [parameter]
event.pages[0].list[8] = RPG::EventCommand.new
#
# setting shiny switch back to previous state
parameter=" $game_switches["+SHINY_WILD_POKEMON_SWITCH.to_s+"]="+oldShinySwitchStatus.to_s
event.pages[0].list[8].code = 355
event.pages[0].list[8].indent = 0
event.pages[0].list[8].parameters = [parameter]
event.pages[0].list[9] = RPG::EventCommand.new
#
event.pages[0].list[9].code = 355
event.pages[0].list[9].indent = 0
event.pages[0].list[9].parameters = ["$PokemonTemp.encounterType = -1"]
event.pages[0].list[10] = RPG::EventCommand.new
#
event.pages[0].list[10].code = 355
event.pages[0].list[10].indent = 0
event.pages[0].list[10].parameters = ["$PokemonTemp.forceSingleBattle = false"]
event.pages[0].list[11] = RPG::EventCommand.new
#
event.pages[0].list[11].code = 355
event.pages[0].list[11].indent = 0
event.pages[0].list[11].parameters = ["EncounterModifier.triggerEncounterEnd()"]
event.pages[0].list[12] = RPG::EventCommand.new
#
event.pages[0].list[12].code = 355
event.pages[0].list[12].indent = 0
event.pages[0].list[12].parameters = ["$game_map.events.delete("+key_id.to_s+")"]
event.pages[0].list[13] = RPG::EventCommand.new
#
event.pages[0].list[13].code = 355
event.pages[0].list[13].indent = 0
event.pages[0].list[13].parameters = ["$scene.disposeSpritesets"]
event.pages[0].list[14] = RPG::EventCommand.new
#
event.pages[0].list[14].code = 355
event.pages[0].list[14].indent = 0
event.pages[0].list[14].parameters = ["$scene.createSpritesets"]
event.pages[0].list[15] = RPG::EventCommand.new
#------------------------------------------------------------------
# creating and adding the Game_Event
gameEvent = Game_Event.new(@map_id, event,self)
key_id = (@events.keys.max || -1) + 1
gameEvent.id = key_id
gameEvent.moveto(x,y)
@events[key_id] = gameEvent
#-------------------------------------------------------------------------
#updating the sprites
sprite = Sprite_Character.new(Spriteset_Map.viewport,@events[key_id])
$scene.spritesets[self.map_id].character_sprites.push(sprite)
end
end
#===============================================================================
# adding new Method pbSingleOrDoubleWildBattle to reduce the code in spawnEvent
#===============================================================================
def pbSingleOrDoubleWildBattle(species,level,map_id,x,y)
if $MapFactory
terrainTag = $MapFactory.getTerrainTag(map_id,x,y)
else
terrainTag = $game_map.terrain_tag(x,y)
end
if !$PokemonTemp.forceSingleBattle && ($PokemonGlobal.partner ||
($Trainer.ablePokemonCount>1 &&
PBTerrain.isDoubleWildBattle?(terrainTag) &&
rand(100)<30))
encounter2 = $PokemonEncounters.pbEncounteredPokemon($PokemonTemp.encounterType)
encounter2 = EncounterModifier.trigger(encounter2)
pbDoubleWildBattle(species,level,encounter2[0],encounter2[1])
else
pbWildBattle(species,level)
end
end
#===============================================================================
# adding new method PBTerrain.isRock? to module PBTerrain in script PBTerrain
# to check if the terrainTag "tag" is rock
#===============================================================================
module PBTerrain
def PBTerrain.isRock?(tag)
return tag==PBTerrain::Rock
end
end
#===============================================================================
# adding new method pbPlayCryOnOverworld to load/play Pokémon cry files
# SPECIAL THANKS TO "Ambient Pokémon Cries" - by Vendily
# actually it's not used, but that code helped to include the pkmn cries faster
#===============================================================================
def pbPlayCryOnOverworld(pokemon,volume=90,pitch=nil)
return if !pokemon
if pokemon.is_a?(Numeric)
pbPlayCrySpecies(pokemon,0,volume,pitch)
elsif !pokemon.egg?
if pokemon.respond_to?("chatter") && pokemon.chatter
pokemon.chatter.play
else
pkmnwav = pbCryFile(pokemon)
if pkmnwav
pbBGSPlay(RPG::AudioFile.new(pkmnwav,volume,
(pitch) ? pitch : (pokemon.hp*25/pokemon.totalhp)+75)) rescue nil
end
end
end
end
#===============================================================================
# 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
#########################################################
# #
# 3. PART: VANISHING OF OVERWORLD ENCOUNTER #
# #
#########################################################
#===============================================================================
# adding a new variable stepCount and replacing the method increase_steps
# in class Game_Event in script Game_Event to count the steps of
# overworld encounter and to make them disappear after taking more then
# STEPSBEFOREVANISHING steps
#===============================================================================
class Game_Event < Game_Character
attr_accessor :event
attr_accessor :stepCount #counts the steps of an overworld encounter
alias original_increase_steps increase_steps
def increase_steps
if self.name=="vanishingEncounter" && @stepCount && @stepCount>=STEPSBEFOREVANISHING
if $game_map.events.has_key?(@id) and $game_map.events[@id]==self
#-------------------------------------------------------------------------
# added to reduce lag by derFischae
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
#-------------------------------------------------------------------------
# added to reduce lag by derFischae
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
#-------------------------------------------------------------------------
# added some code above to reduce lag by derFischae
# Original Code was
#$scene.disposeSpritesets
#$scene.createSpritesets
#-------------------------------------------------------------------------
else
@stepCount=0 if (!@stepCount || @stepCount<0)
@stepCount+=1
original_increase_steps
end
end
end
Am mobile right now but did you improve the code to check the sprite OW when form>0?As mentioned above there is some lag coming from the way how the character_sprites are updated. However, I changed some code to reduce this lag. you can find the new code in the following spoiler section:
I mean, when testing the script using pokemon with multiple forms, only the default form appeared, shellos is an example.
Zeak and I are talking about it in PokeCommunity Discord. Join with us! :DAs mentioned above there is some lag coming from the way how the character_sprites are updated. However, I changed some code to reduce this lag. you can find the new code in the following spoiler section:
As mentioned above there is some lag coming from the way how the character_sprites are updated. However, I changed some code to reduce this lag. you can find the new code in the following spoiler section:
Spoiler:
Code:#=============================================================================== # * Visible Overworld Encounters - by derFischae (Credits if used please) * #=============================================================================== # This script is for Pokémon Essentials 17. # As in Pokemon Let's go Pikachu/Eevee or Pokemon Shild and Sword # random encounters pop up on the overworld, # they move around and you can start the battle # with them simply by moving to the pokemon. # Clearly, you also can omit the battle by circling around them. # # # FEATURES INCLUDED: # - see the pokemon on the overworld before going into battle # - no forced battling against random encounters # - plays the pokemon cry while spawning # - Choose whether encounters occure on all terrains or only on # the terrain of the player # - if you kill the same species in a row, then you increase # the chance of spawning a shiny of that species # # INSTALLATION: # Installation as simple as it can be. # Step 1) You need sprites for the overworld pokemon in your \Graphics\Characters # folder named by there number 001.png, 002.png, ..., # with the corresponding shiny versions 001s.png, 002s.png, .... # For instance you can use Gen 1-7 OV SPrites or whatever you want for # your fakemon # Step 2) Insert a new file in the script editor above main, # name it Overworld_Random_Encounters and copy this code into it. # # PROPERTIES: # 1) If you want to have water encounters only while surfing, # you also have to change the value of the # upcoming parameter RESTRICTENCOUNTERSTOPLAYERMOVEMENT to # RESTRICTENCOUNTERSTOPLAYERMOVEMENT = true # 2) You can choose how many steps the encounter moves before vanishing # in parameter # STEPSBEFOREVANISHING # 3) You can choose how many encounters you have to kill to obtain the increased # Shiny-Chance in parameter # CHAINLENGTH # and the increased Shiny-Chance in parameter # SHINYPROBABILITY # # NOTE: I have not checked Roaming Encounters. Feel free to test it. #=============================================================================== # Settings #=============================================================================== RESTRICTENCOUNTERSTOPLAYERMOVEMENT = false #true - means that water encounters are popping up # if and only if player is surfing # (perhaps decreases encounter rate) #false - means that all encounter types can pop up # close to the player (as long as there is a suitable tile) CHAINLENGTH = 10 # default 10 # number describes how many pokemon of the same species # you have to kill in a row to increase shiny propability SHINYPROBABILITY = 100 # default 100 --> 10% # increasing this value decreases the probability of spawning a shiny STEPSBEFOREVANISHING = 6 # default 10 # STEPSBEFOREVANISHING is the number of steps a wild Encounter goes # before vanishing on the map. #=============================================================================== # THE SCRIPT #=============================================================================== ######################################################### # # # 1. PART: THE CATCHCOMBO # # # ######################################################### #=============================================================================== # adding a new instance variable to $PokemonTemp in script PField_Metadata to # remember which pokemon and how many of that kind were killed in a row #=============================================================================== class PokemonTemp attr_accessor :catchcombo # [chain length, species] end #=============================================================================== # adding a new event handler on Battle end to update the catchchain (where the # pokemon-kill-chain is saved) #=============================================================================== Events.onWildBattleEnd+=proc {|sender,e| species=e[0] result=e[2] $PokemonTemp.catchcombo = [0,0] if !$PokemonTemp.catchcombo if $PokemonTemp.catchcombo[1]!=species $PokemonTemp.catchcombo=[0,species] end if result==1 && species==$PokemonTemp.catchcombo[1] $PokemonTemp.catchcombo[0]+=1 #Kernel.pbMessage(_INTL("You killed {1} {2}",$PokemonTemp.catchcombo[0],$PokemonTemp.catchcombo[1])) end } ######################################################### # # # 2. PART: SPAWNING THE OVERWORLD ENCOUNTER # # # ######################################################### #=============================================================================== # We override the original method "pbOnStepTaken" it was originally used for # random encounter battles #=============================================================================== def Kernel.pbOnStepTaken(eventTriggered) #Should it be possible to search for pokemon nearby? if $game_player.move_route_forcing || pbMapInterpreterRunning? || !$Trainer Events.onStepTakenFieldMovement.trigger(nil,$game_player) return end $PokemonGlobal.stepcount = 0 if !$PokemonGlobal.stepcount $PokemonGlobal.stepcount += 1 $PokemonGlobal.stepcount &= 0x7FFFFFFF repel = ($PokemonGlobal.repel>0) Events.onStepTaken.trigger(nil) handled = [nil] Events.onStepTakenTransferPossible.trigger(nil,handled) return if handled[0] if !eventTriggered #we choose the tile on which the pokemon appears pos = pbChooseTileOnStepTaken return if !pos #we choose the random encounter encounter = pbChooseEncounter(pos[0],pos[1],repel) return if !encounter #we generate an random encounter overworld event pbPlaceEncounter(pos[0],pos[1],encounter) end end #=============================================================================== # new method pbChooseTileOnStepTaken to choose the tile on which the pkmn spawns #=============================================================================== def pbChooseTileOnStepTaken # Choose 1 random tile from 1 random ring around the player i = rand(4) r = rand((i+1)*8) x = $game_player.x y = $game_player.y if r<=(i+1)*2 x = $game_player.x-i-1+r y = $game_player.y-i-1 elsif r<=(i+1)*6-2 x = [$game_player.x+i+1,$game_player.x-i-1][r%2] y = $game_player.y-i+((r-1-(i+1)*2)/2).floor else x = $game_player.x-i+r-(i+1)*6 y = $game_player.y+i+1 end #check if it is possible to encounter here return if x<0 || x>=$game_map.width || y<0 || y>=$game_map.height #check if the tile is on the map #check if it's a valid grass, water or cave etc. tile return if PBTerrain.isIce?($game_map.terrain_tag(x,y)) return if PBTerrain.isLedge?($game_map.terrain_tag(x,y)) return if PBTerrain.isWaterfall?($game_map.terrain_tag(x,y)) return if PBTerrain.isRock?($game_map.terrain_tag(x,y)) if RESTRICTENCOUNTERSTOPLAYERMOVEMENT return if !PBTerrain.isWater?($game_map.terrain_tag(x,y)) && $PokemonGlobal && $PokemonGlobal.surfing return if PBTerrain.isWater?($game_map.terrain_tag(x,y)) && !($PokemonGlobal && $PokemonGlobal.surfing) end return [x,y] end #=============================================================================== # defining new method pbChooseEncounter to choose the pokemon on the tile (x,y) #=============================================================================== def pbChooseEncounter(x,y,repel=false) return if $Trainer.ablePokemonCount==0 #check if trainer has pokemon encounterType = $PokemonEncounters.pbEncounterTypeOnTile(x,y) $PokemonTemp.encounterType = encounterType return if encounterType<0 #check if there are encounters return if !$PokemonEncounters.isEncounterPossibleHereOnTile?(x,y) for event in $game_map.events.values if event.x==x && event.y==y return end end encounter = $PokemonEncounters.pbGenerateEncounter(encounterType) encounter = EncounterModifier.trigger(encounter) if !$PokemonEncounters.pbCanEncounter?(encounter,repel) $PokemonTemp.forceSingleBattle = false EncounterModifier.triggerEncounterEnd() return end return encounter end #=============================================================================== # defining new method pbPlaceEncounter to add/place and visualise the pokemon # "encounter" on the overworld-tile (x,y) #=============================================================================== def pbPlaceEncounter(x,y,encounter) # place event with random movement with overworld sprite # We define the event, which has the sprite of the pokemon and activates the wildBattle on touch if !$MapFactory $game_map.spawnEvent(x,y,encounter) else mapId = $game_map.map_id spawnMap = $MapFactory.getMap(mapId) #Kernel.pbMessage(_INTL("{1}",spawnMap.map_id)) spawnMap.spawnEvent(x,y,encounter) 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.nowRoaming == true && $PokemonTemp.roamerIndex != nil && $PokemonGlobal.roamEncounter != nil $PokemonGlobal.roamEncounter = nil $PokemonGlobal.roamedAlready = true end $PokemonTemp.forceSingleBattle = false EncounterModifier.triggerEncounterEnd() end #=============================================================================== # adding new Methods pbEncounterTypeOnTile and isEncounterPossibleHereOnTile? # in Class PokemonEncounters in Script PField_Encounters #=============================================================================== class PokemonEncounters def pbEncounterTypeOnTile(x,y) if PBTerrain.isJustWater?($game_map.terrain_tag(x,y)) return EncounterTypes::Water elsif self.isCave? return EncounterTypes::Cave elsif self.isGrass? time = pbGetTimeNow enctype = EncounterTypes::Land enctype = EncounterTypes::LandNight if self.hasEncounter?(EncounterTypes::LandNight) && PBDayNight.isNight?(time) enctype = EncounterTypes::LandDay if self.hasEncounter?(EncounterTypes::LandDay) && PBDayNight.isDay?(time) enctype = EncounterTypes::LandMorning if self.hasEncounter?(EncounterTypes::LandMorning) && PBDayNight.isMorning?(time) if pbInBugContest? && self.hasEncounter?(EncounterTypes::BugContest) enctype = EncounterTypes::BugContest end return enctype end return -1 end def isEncounterPossibleHereOnTile?(x,y) if PBTerrain.isJustWater?($game_map.terrain_tag(x,y)) return true elsif self.isCave? return true elsif self.isGrass? return PBTerrain.isGrass?($game_map.terrain_tag(x,y)) end return false end end #=============================================================================== # new Method spawnEvent in Class Game_Map in Script Game_Map #=============================================================================== class Game_Map def spawnEvent(x,y,encounter) #------------------------------------------------------------------ # generating a new event event = RPG::Event.new(x,y) # naming the event "vanishingEncounter" for PART 3 event.name = "vanishingEncounter" #setting the nessassary properties key_id = (@events.keys.max || -1) + 1 event.id = key_id event.x = x event.y = y #event.pages[0].graphic.tile_id = 0 if encounter[0] < 10 character_name = "00"+encounter[0].to_s elsif encounter[0] < 100 character_name = "0"+encounter[0].to_s else character_name = encounter[0].to_s end # use shiny-sprite if probability & killcombo is high or shiny-switch is on $PokemonTemp.catchcombo=[0,0] if !$PokemonTemp.catchcombo if $game_switches[SHINY_WILD_POKEMON_SWITCH]==true character_name = character_name+"s" shinysprite=true elsif ($PokemonTemp.catchcombo[0]>=CHAINLENGTH && $PokemonTemp.catchcombo[1]==encounter[0]) if rand(SHINYPROBABILITY)<$PokemonTemp.catchcombo[0] character_name = character_name+"s" shinysprite=true end end event.pages[0].graphic.character_name = character_name event.pages[0].move_type = 1 event.pages[0].trigger = 2 #------------------------------------------------------------------ # we add the event commands to the event of the overworld encounter event.pages[0].list[0].code = 355 event.pages[0].list[0].indent = 0 if $PokemonGlobal.roamEncounter!=nil #[i,species,poke[1],poke[4]] parameter1 = $PokemonGlobal.roamEncounter[1].to_s parameter2 = $PokemonGlobal.roamEncounter[2].to_s parameter3 = $PokemonGlobal.roamEncounter[3].to_s $PokemonGlobal.roamEncounter[4] != nil ? (parameter4 = '"'+$PokemonGlobal.roamEncounter[4].to_s+'"') : (parameter4 = "nil") parameter = " $PokemonGlobal.roamEncounter = ["+parameter1+","+parameter2+","+parameter3+","+parameter4+"] " else parameter = " $PokemonGlobal.roamEncounter = nil " end event.pages[0].list[0].parameters = [parameter] event.pages[0].list[1] = RPG::EventCommand.new # event.pages[0].list[1].code = 355 event.pages[0].list[1].indent = 0 if $PokemonTemp.nowRoaming!=nil parameter =" $PokemonTemp.nowRoaming = "+$PokemonTemp.nowRoaming.to_s else parameter =" $PokemonTemp.nowRoaming = nil " end event.pages[0].list[1].parameters = [parameter] event.pages[0].list[2] = RPG::EventCommand.new # event.pages[0].list[2].code = 355 event.pages[0].list[2].indent = 0 if $PokemonTemp.roamerIndex!=nil parameter = " $PokemonTemp.roamerIndex = "+$PokemonTemp.roamerIndex.to_s else parameter = " $PokemonTemp.roamerIndex = nil " end event.pages[0].list[2].parameters = [parameter] event.pages[0].list[3] = RPG::EventCommand.new # event.pages[0].list[3].code = 355 event.pages[0].list[3].indent = 0 if $PokemonGlobal.nextBattleBGM!=nil parameter = " $PokemonGlobal.nextBattleBGM = "+PokemonGlobal.nextBattleBGM.to_s else parameter = " $PokemonGlobal.nextBattleBGM = nil " end event.pages[0].list[3].parameters = [parameter] event.pages[0].list[4] = RPG::EventCommand.new # event.pages[0].list[4].code = 355 event.pages[0].list[4].indent = 0 if $PokemonTemp.forceSingleBattle!=nil parameter = " $PokemonTemp.forceSingleBattle = "+$PokemonTemp.forceSingleBattle.to_s else parameter = " $PokemonTemp.forceSingleBattle = nil " end event.pages[0].list[4].parameters = [parameter] event.pages[0].list[5] = RPG::EventCommand.new # event.pages[0].list[5].code = 355 event.pages[0].list[5].indent = 0 if $PokemonTemp.encounterType!=nil parameter = " $PokemonTemp.encounterType = "+$PokemonTemp.encounterType.to_s else parameter = " $PokemonTemp.encounterType = nil " end event.pages[0].list[5].parameters = [parameter] event.pages[0].list[6] = RPG::EventCommand.new # # setting shiny switch on if sprite is a shiny-sprite oldShinySwitchStatus=$game_switches[SHINY_WILD_POKEMON_SWITCH] if shinysprite == true parameter = " $game_switches["+SHINY_WILD_POKEMON_SWITCH.to_s+"]=true" else parameter = " $game_switches["+SHINY_WILD_POKEMON_SWITCH.to_s+"]=false" end event.pages[0].list[6].code = 355 event.pages[0].list[6].indent = 0 event.pages[0].list[6].parameters = [parameter] event.pages[0].list[7] = RPG::EventCommand.new # #pbSingleOrDoubleWildBattle(encounter[0],encounter[1]) event.pages[0].list[7].code = 355 event.pages[0].list[7].indent = 0 parameter = " pbSingleOrDoubleWildBattle("+encounter[0].to_s+","+encounter[1].to_s+", $game_map.events["+key_id.to_s+"].map.map_id, $game_map.events["+key_id.to_s+"].x, $game_map.events["+key_id.to_s+"].y)" event.pages[0].list[7].parameters = [parameter] event.pages[0].list[8] = RPG::EventCommand.new # # setting shiny switch back to previous state parameter=" $game_switches["+SHINY_WILD_POKEMON_SWITCH.to_s+"]="+oldShinySwitchStatus.to_s event.pages[0].list[8].code = 355 event.pages[0].list[8].indent = 0 event.pages[0].list[8].parameters = [parameter] event.pages[0].list[9] = RPG::EventCommand.new # event.pages[0].list[9].code = 355 event.pages[0].list[9].indent = 0 event.pages[0].list[9].parameters = ["$PokemonTemp.encounterType = -1"] event.pages[0].list[10] = RPG::EventCommand.new # event.pages[0].list[10].code = 355 event.pages[0].list[10].indent = 0 event.pages[0].list[10].parameters = ["$PokemonTemp.forceSingleBattle = false"] event.pages[0].list[11] = RPG::EventCommand.new # event.pages[0].list[11].code = 355 event.pages[0].list[11].indent = 0 event.pages[0].list[11].parameters = ["EncounterModifier.triggerEncounterEnd()"] event.pages[0].list[12] = RPG::EventCommand.new # event.pages[0].list[12].code = 355 event.pages[0].list[12].indent = 0 event.pages[0].list[12].parameters = ["$game_map.events.delete("+key_id.to_s+")"] event.pages[0].list[13] = RPG::EventCommand.new # event.pages[0].list[13].code = 355 event.pages[0].list[13].indent = 0 event.pages[0].list[13].parameters = ["$scene.disposeSpritesets"] event.pages[0].list[14] = RPG::EventCommand.new # event.pages[0].list[14].code = 355 event.pages[0].list[14].indent = 0 event.pages[0].list[14].parameters = ["$scene.createSpritesets"] event.pages[0].list[15] = RPG::EventCommand.new #------------------------------------------------------------------ # creating and adding the Game_Event gameEvent = Game_Event.new(@map_id, event,self) key_id = (@events.keys.max || -1) + 1 gameEvent.id = key_id gameEvent.moveto(x,y) @events[key_id] = gameEvent #------------------------------------------------------------------------- #updating the sprites sprite = Sprite_Character.new(Spriteset_Map.viewport,@events[key_id]) $scene.spritesets[self.map_id].character_sprites.push(sprite) end end #=============================================================================== # adding new Method pbSingleOrDoubleWildBattle to reduce the code in spawnEvent #=============================================================================== def pbSingleOrDoubleWildBattle(species,level,map_id,x,y) if $MapFactory terrainTag = $MapFactory.getTerrainTag(map_id,x,y) else terrainTag = $game_map.terrain_tag(x,y) end if !$PokemonTemp.forceSingleBattle && ($PokemonGlobal.partner || ($Trainer.ablePokemonCount>1 && PBTerrain.isDoubleWildBattle?(terrainTag) && rand(100)<30)) encounter2 = $PokemonEncounters.pbEncounteredPokemon($PokemonTemp.encounterType) encounter2 = EncounterModifier.trigger(encounter2) pbDoubleWildBattle(species,level,encounter2[0],encounter2[1]) else pbWildBattle(species,level) end end #=============================================================================== # adding new method PBTerrain.isRock? to module PBTerrain in script PBTerrain # to check if the terrainTag "tag" is rock #=============================================================================== module PBTerrain def PBTerrain.isRock?(tag) return tag==PBTerrain::Rock end end #=============================================================================== # adding new method pbPlayCryOnOverworld to load/play Pokémon cry files # SPECIAL THANKS TO "Ambient Pokémon Cries" - by Vendily # actually it's not used, but that code helped to include the pkmn cries faster #=============================================================================== def pbPlayCryOnOverworld(pokemon,volume=90,pitch=nil) return if !pokemon if pokemon.is_a?(Numeric) pbPlayCrySpecies(pokemon,0,volume,pitch) elsif !pokemon.egg? if pokemon.respond_to?("chatter") && pokemon.chatter pokemon.chatter.play else pkmnwav = pbCryFile(pokemon) if pkmnwav pbBGSPlay(RPG::AudioFile.new(pkmnwav,volume, (pitch) ? pitch : (pokemon.hp*25/pokemon.totalhp)+75)) rescue nil end end end end #=============================================================================== # 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 ######################################################### # # # 3. PART: VANISHING OF OVERWORLD ENCOUNTER # # # ######################################################### #=============================================================================== # adding a new variable stepCount and replacing the method increase_steps # in class Game_Event in script Game_Event to count the steps of # overworld encounter and to make them disappear after taking more then # STEPSBEFOREVANISHING steps #=============================================================================== class Game_Event < Game_Character attr_accessor :event attr_accessor :stepCount #counts the steps of an overworld encounter alias original_increase_steps increase_steps def increase_steps if self.name=="vanishingEncounter" && @stepCount && @stepCount>=STEPSBEFOREVANISHING if $game_map.events.has_key?(@id) and $game_map.events[@id]==self #------------------------------------------------------------------------- # added to reduce lag by derFischae 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 #------------------------------------------------------------------------- # added to reduce lag by derFischae 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 #------------------------------------------------------------------------- # added some code above to reduce lag by derFischae # Original Code was #$scene.disposeSpritesets #$scene.createSpritesets #------------------------------------------------------------------------- else @stepCount=0 if (!@stepCount || @stepCount<0) @stepCount+=1 original_increase_steps end end end
[Pokémon Essentials version 17.2]
Exception: NoMethodError
Message: undefined method `spritesets' for #<Scene_Map:0x8c51888>
:438:in `spawnEvent'
:215:in `pbPlaceEncounter'
:137:in `pbOnStepTaken'
Game_Player:461:in `update_old'
Game_Player_Visuals:71:in `update'
Scene_Map:164:in `update'
Scene_Map:161:in `loop'
Scene_Map:170:in `update'
Scene_Map:234:in `main'
Scene_Map:231:in `loop'
Scene_Map:236:in `main'
Main:49:in `mainFunctionDebug'
Main:27:in `mainFunction'
Main:27:in `pbCriticalCode'
Main:27:in `mainFunction'
Main:59
Main:58:in `loop'
Main:67
Unfortunately your last script give us an error:
class Scene_Map
attr_reader :spritesets
end
I mean, when testing the script using pokemon with multiple forms, only the default form appeared, shellos is an example.
Okay, I understand. Infact, you can already battle different forms of a pokemon. Shellos is a bad example for that since the form of shellos depends on the region. But if you take for instance unown then you can infact battle against different forms. However, the overworld sprite does not coincide with the form in battle. This will take some time to find a work around.
If anyone knows how to get the form of a pokemon in the script or how to set up the form of a pokemon for instance in the method pbWildBattle defined in Script PField_Battles please let us know. It will save us some time.
#===============================================================================
# * Visible Overworld Encounters - by derFischae (Credits if used please) *
#===============================================================================
# This script is for Pokémon Essentials 17.
# As in Pokemon Let's go Pikachu/Eevee or Pokemon Shild and Sword
# random encounters pop up on the overworld,
# they move around and you can start the battle
# with them simply by moving to the pokemon.
# Clearly, you also can omit the battle by circling around them.
#
#
# FEATURES INCLUDED:
# - see the pokemon on the overworld before going into battle
# - no forced battling against random encounters
# - plays the pokemon cry while spawning
# - Choose whether encounters occure on all terrains or only on
# the terrain of the player
# - if you kill the same species in a row, then you increase
# the chance of spawning a shiny of that species
#
# INSTALLATION:
# Installation as simple as it can be.
# Step 1) You need sprites for the overworld pokemon in your \Graphics\Characters
# folder named by there number 001.png, 002.png, ...,
# with the corresponding shiny versions 001s.png, 002s.png, ....
# For instance you can use Gen 1-7 OV SPrites or whatever you want for
# your fakemon
# Step 2) Insert a new file in the script editor above main,
# name it Overworld_Random_Encounters and copy this code into it.
#
# PROPERTIES:
# 1) If you want to have water encounters only while surfing,
# you also have to change the value of the
# upcoming parameter RESTRICTENCOUNTERSTOPLAYERMOVEMENT to
# RESTRICTENCOUNTERSTOPLAYERMOVEMENT = true
# 2) You can choose how many steps the encounter moves before vanishing
# in parameter
# STEPSBEFOREVANISHING
# 3) You can choose how many encounters you have to kill to obtain the increased
# Shiny-Chance in parameter
# CHAINLENGTH
# and the increased Shiny-Chance in parameter
# SHINYPROBABILITY
#
# NOTE: I have not checked Roaming Encounters. Feel free to test it.
#===============================================================================
# Settings
#===============================================================================
RESTRICTENCOUNTERSTOPLAYERMOVEMENT = false
#true - means that water encounters are popping up
# if and only if player is surfing
# (perhaps decreases encounter rate)
#false - means that all encounter types can pop up
# close to the player (as long as there is a suitable tile)
CHAINLENGTH = 10 # default 10
# number describes how many pokemon of the same species
# you have to kill in a row to increase shiny propability
SHINYPROBABILITY = 100 # default 100 --> 10%
# increasing this value decreases the probability of spawning a shiny
STEPSBEFOREVANISHING = 6 # default 10
# STEPSBEFOREVANISHING is the number of steps a wild Encounter goes
# before vanishing on the map.
#===============================================================================
# THE SCRIPT
#===============================================================================
#########################################################
# #
# 1. PART: THE CATCHCOMBO #
# #
#########################################################
#===============================================================================
# adding a new instance variable to $PokemonTemp in script PField_Metadata to
# remember which pokemon and how many of that kind were killed in a row
#===============================================================================
class PokemonTemp
attr_accessor :catchcombo # [chain length, species]
end
#===============================================================================
# adding a new event handler on Battle end to update the catchchain (where the
# pokemon-kill-chain is saved)
#===============================================================================
Events.onWildBattleEnd+=proc {|sender,e|
species=e[0]
result=e[2]
$PokemonTemp.catchcombo = [0,0] if !$PokemonTemp.catchcombo
if $PokemonTemp.catchcombo[1]!=species
$PokemonTemp.catchcombo=[0,species]
end
if result==1 && species==$PokemonTemp.catchcombo[1]
$PokemonTemp.catchcombo[0]+=1
#Kernel.pbMessage(_INTL("You killed {1} {2}",$PokemonTemp.catchcombo[0],$PokemonTemp.catchcombo[1]))
end
}
#########################################################
# #
# 2. PART: SPAWNING THE OVERWORLD ENCOUNTER #
# #
#########################################################
#===============================================================================
# We override the original method "pbOnStepTaken" in Script PField_Field it was
# originally used for random encounter battles
#===============================================================================
def Kernel.pbOnStepTaken(eventTriggered)
#Should it be possible to search for pokemon nearby?
if $game_player.move_route_forcing || pbMapInterpreterRunning? || !$Trainer
Events.onStepTakenFieldMovement.trigger(nil,$game_player)
return
end
$PokemonGlobal.stepcount = 0 if !$PokemonGlobal.stepcount
$PokemonGlobal.stepcount += 1
$PokemonGlobal.stepcount &= 0x7FFFFFFF
repel = ($PokemonGlobal.repel>0)
Events.onStepTaken.trigger(nil)
handled = [nil]
Events.onStepTakenTransferPossible.trigger(nil,handled)
return if handled[0]
if !eventTriggered
#we choose the tile on which the pokemon appears
pos = pbChooseTileOnStepTaken
return if !pos
#we choose the random encounter
encounter,form = pbChooseEncounter(pos[0],pos[1],repel)
return if !encounter
#we generate an random encounter overworld event
pbPlaceEncounter(pos[0],pos[1],encounter,form)
end
end
#===============================================================================
# new method pbChooseTileOnStepTaken to choose the tile on which the pkmn spawns
#===============================================================================
def pbChooseTileOnStepTaken
# Choose 1 random tile from 1 random ring around the player
i = rand(4)
r = rand((i+1)*8)
x = $game_player.x
y = $game_player.y
if r<=(i+1)*2
x = $game_player.x-i-1+r
y = $game_player.y-i-1
elsif r<=(i+1)*6-2
x = [$game_player.x+i+1,$game_player.x-i-1][r%2]
y = $game_player.y-i+((r-1-(i+1)*2)/2).floor
else
x = $game_player.x-i+r-(i+1)*6
y = $game_player.y+i+1
end
#check if it is possible to encounter here
return if x<0 || x>=$game_map.width || y<0 || y>=$game_map.height #check if the tile is on the map
#check if it's a valid grass, water or cave etc. tile
return if PBTerrain.isIce?($game_map.terrain_tag(x,y))
return if PBTerrain.isLedge?($game_map.terrain_tag(x,y))
return if PBTerrain.isWaterfall?($game_map.terrain_tag(x,y))
return if PBTerrain.isRock?($game_map.terrain_tag(x,y))
if RESTRICTENCOUNTERSTOPLAYERMOVEMENT
return if !PBTerrain.isWater?($game_map.terrain_tag(x,y)) &&
$PokemonGlobal && $PokemonGlobal.surfing
return if PBTerrain.isWater?($game_map.terrain_tag(x,y)) &&
!($PokemonGlobal && $PokemonGlobal.surfing)
end
return [x,y]
end
#===============================================================================
# defining new method pbChooseEncounter to choose the pokemon on the tile (x,y)
#===============================================================================
def pbChooseEncounter(x,y,repel=false)
return if $Trainer.ablePokemonCount==0 #check if trainer has pokemon
encounterType = $PokemonEncounters.pbEncounterTypeOnTile(x,y)
$PokemonTemp.encounterType = encounterType
return if encounterType<0 #check if there are encounters
return if !$PokemonEncounters.isEncounterPossibleHereOnTile?(x,y)
for event in $game_map.events.values
if event.x==x && event.y==y
return
end
end
encounter = $PokemonEncounters.pbGenerateEncounter(encounterType)
encounter = EncounterModifier.trigger(encounter)
if !$PokemonEncounters.pbCanEncounter?(encounter,repel)
$PokemonTemp.forceSingleBattle = false
EncounterModifier.triggerEncounterEnd()
return
end
#-----------------------------------------
# added to include forms by derFischae
#1. solution:
genwildpoke = pbGenerateWildPokemon(encounter[0],encounter[1])
form = genwildpoke.form
#2. solution
#sp=@@formSpecies[pokemon.species]
#sp=PokeBattle_Pokemon.formSpecies[pokemon.species]
#form = sp["getFormOnCreation"].call(encounter[0]) if sp && sp["getFormOnCreation"]
# end of changes
#-----------------------------------------
return encounter,form
end
#===============================================================================
# defining new method pbPlaceEncounter to add/place and visualise the pokemon
# "encounter" on the overworld-tile (x,y)
#===============================================================================
def pbPlaceEncounter(x,y,encounter,form = 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,form)
else
mapId = $game_map.map_id
spawnMap = $MapFactory.getMap(mapId)
#Kernel.pbMessage(_INTL("{1}",spawnMap.map_id))
spawnMap.spawnEvent(x,y,encounter,form)
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.nowRoaming == true &&
$PokemonTemp.roamerIndex != nil &&
$PokemonGlobal.roamEncounter != nil
$PokemonGlobal.roamEncounter = nil
$PokemonGlobal.roamedAlready = true
end
$PokemonTemp.forceSingleBattle = false
EncounterModifier.triggerEncounterEnd()
end
#===============================================================================
# adding new Methods pbEncounterTypeOnTile and isEncounterPossibleHereOnTile?
# in Class PokemonEncounters in Script PField_Encounters
#===============================================================================
class PokemonEncounters
def pbEncounterTypeOnTile(x,y)
if PBTerrain.isJustWater?($game_map.terrain_tag(x,y))
return EncounterTypes::Water
elsif self.isCave?
return EncounterTypes::Cave
elsif self.isGrass?
time = pbGetTimeNow
enctype = EncounterTypes::Land
enctype = EncounterTypes::LandNight if self.hasEncounter?(EncounterTypes::LandNight) && PBDayNight.isNight?(time)
enctype = EncounterTypes::LandDay if self.hasEncounter?(EncounterTypes::LandDay) && PBDayNight.isDay?(time)
enctype = EncounterTypes::LandMorning if self.hasEncounter?(EncounterTypes::LandMorning) && PBDayNight.isMorning?(time)
if pbInBugContest? && self.hasEncounter?(EncounterTypes::BugContest)
enctype = EncounterTypes::BugContest
end
return enctype
end
return -1
end
def isEncounterPossibleHereOnTile?(x,y)
if PBTerrain.isJustWater?($game_map.terrain_tag(x,y))
return true
elsif self.isCave?
return true
elsif self.isGrass?
return PBTerrain.isGrass?($game_map.terrain_tag(x,y))
end
return false
end
end
#===============================================================================
# new Method spawnEvent in Class Game_Map in Script Game_Map
#===============================================================================
class Game_Map
def spawnEvent(x,y,encounter,form)
#Kernel.pbMessage(_INTL("{1}",form))
#------------------------------------------------------------------
# generating a new event
event = RPG::Event.new(x,y)
# naming the event "vanishingEncounter" for PART 3
event.name = "vanishingEncounter"
#setting the nessassary properties
key_id = (@events.keys.max || -1) + 1
event.id = key_id
event.x = x
event.y = y
#event.pages[0].graphic.tile_id = 0
if encounter[0] < 10
character_name = "00"+encounter[0].to_s
elsif encounter[0] < 100
character_name = "0"+encounter[0].to_s
else
character_name = encounter[0].to_s
end
# use shiny-sprite if probability & killcombo is high or shiny-switch is on
$PokemonTemp.catchcombo=[0,0] if !$PokemonTemp.catchcombo
if $game_switches[SHINY_WILD_POKEMON_SWITCH]==true
character_name = character_name+"s"
shinysprite=true
elsif ($PokemonTemp.catchcombo[0]>=CHAINLENGTH && $PokemonTemp.catchcombo[1]==encounter[0])
if rand(SHINYPROBABILITY)<$PokemonTemp.catchcombo[0]
character_name = character_name+"s"
shinysprite=true
end
end
# use sprite of alternative form
if form!=nil and form!=0
character_name = character_name+"_"+form.to_s
end
event.pages[0].graphic.character_name = character_name
event.pages[0].move_type = 1
event.pages[0].trigger = 2
#------------------------------------------------------------------
# we add the event commands to the event of the overworld encounter
event.pages[0].list[0].code = 355
event.pages[0].list[0].indent = 0
if $PokemonGlobal.roamEncounter!=nil
#[i,species,poke[1],poke[4]]
parameter1 = $PokemonGlobal.roamEncounter[1].to_s
parameter2 = $PokemonGlobal.roamEncounter[2].to_s
parameter3 = $PokemonGlobal.roamEncounter[3].to_s
$PokemonGlobal.roamEncounter[4] != nil ? (parameter4 = '"'+$PokemonGlobal.roamEncounter[4].to_s+'"') : (parameter4 = "nil")
parameter = " $PokemonGlobal.roamEncounter = ["+parameter1+","+parameter2+","+parameter3+","+parameter4+"] "
else
parameter = " $PokemonGlobal.roamEncounter = nil "
end
event.pages[0].list[0].parameters = [parameter]
event.pages[0].list[1] = RPG::EventCommand.new
#
event.pages[0].list[1].code = 355
event.pages[0].list[1].indent = 0
if $PokemonTemp.nowRoaming!=nil
parameter =" $PokemonTemp.nowRoaming = "+$PokemonTemp.nowRoaming.to_s
else
parameter =" $PokemonTemp.nowRoaming = nil "
end
event.pages[0].list[1].parameters = [parameter]
event.pages[0].list[2] = RPG::EventCommand.new
#
event.pages[0].list[2].code = 355
event.pages[0].list[2].indent = 0
if $PokemonTemp.roamerIndex!=nil
parameter = " $PokemonTemp.roamerIndex = "+$PokemonTemp.roamerIndex.to_s
else
parameter = " $PokemonTemp.roamerIndex = nil "
end
event.pages[0].list[2].parameters = [parameter]
event.pages[0].list[3] = RPG::EventCommand.new
#
event.pages[0].list[3].code = 355
event.pages[0].list[3].indent = 0
if $PokemonGlobal.nextBattleBGM!=nil
parameter = " $PokemonGlobal.nextBattleBGM = "+PokemonGlobal.nextBattleBGM.to_s
else
parameter = " $PokemonGlobal.nextBattleBGM = nil "
end
event.pages[0].list[3].parameters = [parameter]
event.pages[0].list[4] = RPG::EventCommand.new
#
event.pages[0].list[4].code = 355
event.pages[0].list[4].indent = 0
if $PokemonTemp.forceSingleBattle!=nil
parameter = " $PokemonTemp.forceSingleBattle = "+$PokemonTemp.forceSingleBattle.to_s
else
parameter = " $PokemonTemp.forceSingleBattle = nil "
end
event.pages[0].list[4].parameters = [parameter]
event.pages[0].list[5] = RPG::EventCommand.new
#
event.pages[0].list[5].code = 355
event.pages[0].list[5].indent = 0
if $PokemonTemp.encounterType!=nil
parameter = " $PokemonTemp.encounterType = "+$PokemonTemp.encounterType.to_s
else
parameter = " $PokemonTemp.encounterType = nil "
end
event.pages[0].list[5].parameters = [parameter]
event.pages[0].list[6] = RPG::EventCommand.new
#
# setting shiny switch on if sprite is a shiny-sprite
oldShinySwitchStatus=$game_switches[SHINY_WILD_POKEMON_SWITCH]
if shinysprite == true
parameter = " $game_switches["+SHINY_WILD_POKEMON_SWITCH.to_s+"]=true"
else
parameter = " $game_switches["+SHINY_WILD_POKEMON_SWITCH.to_s+"]=false"
end
event.pages[0].list[6].code = 355
event.pages[0].list[6].indent = 0
event.pages[0].list[6].parameters = [parameter]
event.pages[0].list[7] = RPG::EventCommand.new
#
#pbSingleOrDoubleWildBattle(encounter[0],encounter[1])
event.pages[0].list[7].code = 355
event.pages[0].list[7].indent = 0
parameter = " pbSingleOrDoubleWildBattle("+encounter[0].to_s+","+encounter[1].to_s+", $game_map.events["+key_id.to_s+"].map.map_id, $game_map.events["+key_id.to_s+"].x, $game_map.events["+key_id.to_s+"].y,"+form.to_s+")"
event.pages[0].list[7].parameters = [parameter]
event.pages[0].list[8] = RPG::EventCommand.new
#
# setting shiny switch back to previous state
parameter=" $game_switches["+SHINY_WILD_POKEMON_SWITCH.to_s+"]="+oldShinySwitchStatus.to_s
event.pages[0].list[8].code = 355
event.pages[0].list[8].indent = 0
event.pages[0].list[8].parameters = [parameter]
event.pages[0].list[9] = RPG::EventCommand.new
#
event.pages[0].list[9].code = 355
event.pages[0].list[9].indent = 0
event.pages[0].list[9].parameters = ["$PokemonTemp.encounterType = -1"]
event.pages[0].list[10] = RPG::EventCommand.new
#
event.pages[0].list[10].code = 355
event.pages[0].list[10].indent = 0
event.pages[0].list[10].parameters = ["$PokemonTemp.forceSingleBattle = false"]
event.pages[0].list[11] = RPG::EventCommand.new
#
event.pages[0].list[11].code = 355
event.pages[0].list[11].indent = 0
event.pages[0].list[11].parameters = ["EncounterModifier.triggerEncounterEnd()"]
event.pages[0].list[12] = RPG::EventCommand.new
#
event.pages[0].list[12].code = 355
event.pages[0].list[12].indent = 0
event.pages[0].list[12].parameters = ["$game_map.events.delete("+key_id.to_s+")"]
event.pages[0].list[13] = RPG::EventCommand.new
#
event.pages[0].list[13].code = 355
event.pages[0].list[13].indent = 0
event.pages[0].list[13].parameters = ["$scene.disposeSpritesets"]
event.pages[0].list[14] = RPG::EventCommand.new
#
event.pages[0].list[14].code = 355
event.pages[0].list[14].indent = 0
event.pages[0].list[14].parameters = ["$scene.createSpritesets"]
event.pages[0].list[15] = RPG::EventCommand.new
#------------------------------------------------------------------
# creating and adding the Game_Event
gameEvent = Game_Event.new(@map_id, event,self)
key_id = (@events.keys.max || -1) + 1
gameEvent.id = key_id
gameEvent.moveto(x,y)
@events[key_id] = gameEvent
#-------------------------------------------------------------------------
#updating the sprites
sprite = Sprite_Character.new(Spriteset_Map.viewport,@events[key_id])
$scene.spritesets[self.map_id].character_sprites.push(sprite)
end
end
#===============================================================================
# adding new Method pbSingleOrDoubleWildBattle to reduce the code in spawnEvent
#===============================================================================
def pbSingleOrDoubleWildBattle(species,level,map_id,x,y,form = nil)
if $MapFactory
terrainTag = $MapFactory.getTerrainTag(map_id,x,y)
else
terrainTag = $game_map.terrain_tag(x,y)
end
if !$PokemonTemp.forceSingleBattle && ($PokemonGlobal.partner ||
($Trainer.ablePokemonCount>1 &&
PBTerrain.isDoubleWildBattle?(terrainTag) &&
rand(100)<30))
encounter2 = $PokemonEncounters.pbEncounteredPokemon($PokemonTemp.encounterType)
encounter2 = EncounterModifier.trigger(encounter2)
pbDoubleWildBattle(species,level,encounter2[0],encounter2[1],nil,true,false,form,nil)
else
pbWildBattle(species,level,nil,true,false,form)
end
end
#===============================================================================
# overriding Method pbWildBattle in Script PField_Battles
# to include alternate forms of the wild pokemon
#===============================================================================
def pbWildBattle(species,level,variable=nil,canescape=true,canlose=false,form = nil)
if (Input.press?(Input::CTRL) && $DEBUG) || $Trainer.pokemonCount==0
if $Trainer.pokemonCount>0
Kernel.pbMessage(_INTL("SKIPPING BATTLE..."))
end
pbSet(variable,1)
$PokemonGlobal.nextBattleBGM = nil
$PokemonGlobal.nextBattleME = nil
$PokemonGlobal.nextBattleBack = nil
return true
end
if species.is_a?(String) || species.is_a?(Symbol)
species = getID(PBSpecies,species)
end
handled = [nil]
Events.onWildBattleOverride.trigger(nil,species,level,handled)
return handled[0] if handled[0]!=nil
currentlevels = []
for i in $Trainer.party
currentlevels.push(i.level)
end
genwildpoke = pbGenerateWildPokemon(species,level)
#-----------------------------------------------------------------------------
#added by derFischae to set the form
genwildpoke.form = form if form!=nil and form>0
# 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.
#-----------------------------------------------------------------------------
Events.onStartBattle.trigger(nil,genwildpoke)
scene = pbNewBattleScene
battle = PokeBattle_Battle.new(scene,$Trainer.party,[genwildpoke],$Trainer,nil)
battle.internalbattle = true
battle.cantescape = !canescape
pbPrepareBattle(battle)
decision = 0
pbBattleAnimation(pbGetWildBattleBGM(species),0,[genwildpoke]) {
pbSceneStandby {
decision = battle.pbStartBattle(canlose)
}
pbAfterBattle(decision,canlose)
}
Input.update
pbSet(variable,decision)
Events.onWildBattleEnd.trigger(nil,species,level,decision)
return (decision!=2)
end
#===============================================================================
# overriding Method pbDoubleWildBattle in Script PField_Battles
# to include alternate forms of the wild pokemon in double battles
#===============================================================================
def pbDoubleWildBattle(species1,level1,species2,level2,form1 = nil,form2 = nil)
if (Input.press?(Input::CTRL) && $DEBUG) || $Trainer.pokemonCount==0
if $Trainer.pokemonCount>0
Kernel.pbMessage(_INTL("SKIPPING BATTLE..."))
end
pbSet(variable,1)
$PokemonGlobal.nextBattleBGM = nil
$PokemonGlobal.nextBattleME = nil
$PokemonGlobal.nextBattleBack = nil
return true
end
if species1.is_a?(String) || species1.is_a?(Symbol)
species1 = getID(PBSpecies,species1)
end
if species2.is_a?(String) || species2.is_a?(Symbol)
species2 = getID(PBSpecies,species2)
end
currentlevels = []
for i in $Trainer.party
currentlevels.push(i.level)
end
genwildpoke = pbGenerateWildPokemon(species1,level1)
genwildpoke2 = pbGenerateWildPokemon(species2,level2)
#-----------------------------------------------------------------------------
#added by derFischae to set the form
genwildpoke.form = form1 if form1!=nil and form1>0
genwildpoke2.form = form2 if form2!=nil and form2>0
# 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.
#-----------------------------------------------------------------------------
Events.onStartBattle.trigger(nil,genwildpoke)
scene = pbNewBattleScene
if $PokemonGlobal.partner
othertrainer = PokeBattle_Trainer.new($PokemonGlobal.partner[1],$PokemonGlobal.partner[0])
othertrainer.id = $PokemonGlobal.partner[2]
othertrainer.party = $PokemonGlobal.partner[3]
combinedParty = []
for i in 0...$Trainer.party.length
combinedParty[i] = $Trainer.party[i]
end
for i in 0...othertrainer.party.length
combinedParty[6+i] = othertrainer.party[i]
end
battle = PokeBattle_Battle.new(scene,combinedParty,[genwildpoke,genwildpoke2],[$Trainer,othertrainer],nil)
battle.fullparty1 = true
else
battle = PokeBattle_Battle.new(scene,$Trainer.party,[genwildpoke,genwildpoke2],$Trainer,nil)
battle.fullparty1 = false
end
battle.internalbattle = true
battle.doublebattle = battle.pbDoubleBattleAllowed?()
battle.cantescape = !canescape
pbPrepareBattle(battle)
decision = 0
pbBattleAnimation(pbGetWildBattleBGM(species1),2,[genwildpoke,genwildpoke2]) {
pbSceneStandby {
decision = battle.pbStartBattle(canlose)
}
pbAfterBattle(decision,canlose)
}
Input.update
pbSet(variable,decision)
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
#########################################################
# #
# 3. PART: VANISHING OF OVERWORLD ENCOUNTER #
# #
#########################################################
#===============================================================================
# adding a new variable stepCount and replacing the method increase_steps
# in class Game_Event in script Game_Event to count the steps of
# overworld encounter and to make them disappear after taking more then
# STEPSBEFOREVANISHING steps
#===============================================================================
class Game_Event < Game_Character
attr_accessor :event
attr_accessor :stepCount #counts the steps of an overworld encounter
alias original_increase_steps increase_steps
def increase_steps
if self.name=="vanishingEncounter" && @stepCount && @stepCount>=STEPSBEFOREVANISHING
if $game_map.events.has_key?(@id) and $game_map.events[@id]==self
#-------------------------------------------------------------------------
# added to reduce lag by derFischae
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
#-------------------------------------------------------------------------
# added to reduce lag by derFischae
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
#-------------------------------------------------------------------------
# added some code above to reduce lag by derFischae
# Original Code was
#$scene.disposeSpritesets
#$scene.createSpritesets
#-------------------------------------------------------------------------
else
@stepCount=0 if (!@stepCount || @stepCount<0)
@stepCount+=1
original_increase_steps
end
end
end
Nice script. But, can you make it compatible with WOLFPP TallGrass Script? Here: https://www.pokecommunity.com/threads/421411
I'm using his script and when i go to the tallgrass, it's kinda glitchy to the eye of the player. XD
And it works fine with pokeradar. Another thing, with this script, we only battle the overworld pokemon that pops up from the grass instead walking in the grass?
---------------------------
Pokemon Essentials
---------------------------
[Pokémon Essentials version 17.2]
Exception: RuntimeError
Message: Script error within event 11 (coords 27,14), map 5 (Route 1):
Exception: SyntaxError
Message: (eval):1:in `pbExecuteScript'compile error
(eval):1: syntax error
$PokemonGlobal.roamEncounter = [244,40,,nil]
^
***Full script:
$PokemonGlobal.roamEncounter = [244,40,,nil]
$PokemonTemp.nowRoaming = true
$PokemonTemp.roamerIndex = 3
$PokemonGlobal.nextBattleBGM = nil
$PokemonTemp.forceSingleBattle = true
$PokemonTemp.encounterType = 0
$game_switches[31]=false
pbSingleOrDoubleWildBattle(244,40, $game_map.events[11].map.map_id, $game_map.events[11].x, $game_map.events[11].y,0)
$game_switches[31]=false
$PokemonTemp.encounterType = -1
$PokemonTemp.forceSingleBattle = false
EncounterModifier.triggerEncounterEnd()
$game_map.events.delete(11)
$scene.disposeSpritesets
$scene.createSpritesets
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:163:in `update'
Scene_Map:161:in `loop'
Scene_Map:170:in `update'
Scene_Map:234:in `main'
Scene_Map:231:in `loop'
Scene_Map:236:in `main'
Main:49:in `mainFunctionDebug'
Main:27:in `mainFunction'
Main:27:in `pbCriticalCode'
Main:27:in `mainFunction'
Main:59
Main:58:in `loop'
Main:67
RoamingSpecies = [
[:LATIAS, 30, 53, 0, "Battle roaming"],
[:LATIOS, 30, 53, 0, "Battle roaming"],
[:KYOGRE, 40, 54, 2, nil, {
2 => [21,31],
21 => [2,31,69],
31 => [2,21,69],
69 => [21,31]
}],
[:ENTEI, 40, 55, 1, nil, {
5 => [5]
}]
]
When roaming, Entei appears normally but if I try to battle against, give me this error:
Same but with the default latios
#[i,species,poke[1],poke[4]]
parameter1 = $PokemonGlobal.roamEncounter[1].to_s
parameter2 = $PokemonGlobal.roamEncounter[2].to_s
parameter3 = $PokemonGlobal.roamEncounter[3].to_s
$PokemonGlobal.roamEncounter[4] != nil ? (parameter4 = '"'+$PokemonGlobal.roamEncounter[4].to_s+'"') : (parameter4 = "nil")
#[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")
#===============================================================================
# * Visible Overworld Encounters V1.2 - by derFischae (Credits if used please) *
#===============================================================================
#
# UPDATED TO VERSION 1.2
#
# This script is for Pokémon Essentials 17.
# As in Pokemon Let's go Pikachu/Eevee or Pokemon Shild and Sword
# random encounters pop up on the overworld,
# they move around and you can start the battle
# with them simply by moving to the pokemon.
# Clearly, you also can omit the battle by circling around them.
#
#
# FEATURES INCLUDED:
# - see the pokemon on the overworld before going into battle
# - no forced battling against random encounters
# - plays the pokemon cry while spawning
# - Choose whether encounters occure on all terrains or only on
# the terrain of the player
# - if you kill the same species in a row, then you increase
# the chance of spawning a shiny of that species
#
# 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
#
# 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
# You can choose whether the sprite of your overworld encounter
# is always the standard form 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
#
# NOTE: I have not checked Roaming Encounters. Feel free to test it.
#
# THANKS to Zeak6464, WolfPP and Vendily for giving me some hints about forms
# and gender on discord
# SPECIAL THANKS to BulbasaurLvl5 for bringing me to pokemon essentials and the
# super productive time
#===============================================================================
# Settings
#===============================================================================
RESTRICTENCOUNTERSTOPLAYERMOVEMENT = false
#true - means that water encounters are popping up
# if and only if player is surfing
# (perhaps decreases encounter rate)
#false - means that all encounter types can pop up
# close to the player (as long as there is a suitable tile)
CHAINLENGTH = 10 # default 10
# number describes how many pokemon of the same species
# you have to kill in a row to increase shiny propability
SHINYPROBABILITY = 100 # default 100 --> 10%
# increasing this value decreases the probability of spawning a shiny
STEPSBEFOREVANISHING = 6 # default 10
# STEPSBEFOREVANISHING is the number of steps a wild Encounter goes
# before vanishing on the map.
USEALTFORMS = true # default false
#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 false
#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
#===============================================================================
# THE SCRIPT
#===============================================================================
#########################################################
# #
# 1. PART: THE CATCHCOMBO #
# #
#########################################################
#===============================================================================
# adding a new instance variable to $PokemonTemp in script PField_Metadata to
# remember which pokemon and how many of that kind were killed in a row
#===============================================================================
class PokemonTemp
attr_accessor :catchcombo # [chain length, species]
end
#===============================================================================
# adding a new event handler on Battle end to update the catchchain (where the
# pokemon-kill-chain is saved)
#===============================================================================
Events.onWildBattleEnd+=proc {|sender,e|
species=e[0]
result=e[2]
$PokemonTemp.catchcombo = [0,0] if !$PokemonTemp.catchcombo
if $PokemonTemp.catchcombo[1]!=species
$PokemonTemp.catchcombo=[0,species]
end
if result==1 && species==$PokemonTemp.catchcombo[1]
$PokemonTemp.catchcombo[0]+=1
#Kernel.pbMessage(_INTL("You killed {1} {2}",$PokemonTemp.catchcombo[0],$PokemonTemp.catchcombo[1]))
end
}
#########################################################
# #
# 2. PART: SPAWNING THE OVERWORLD ENCOUNTER #
# #
#########################################################
#===============================================================================
# We override the original method "pbOnStepTaken" in Script PField_Field it was
# originally used for random encounter battles
#===============================================================================
def Kernel.pbOnStepTaken(eventTriggered)
#Should it be possible to search for pokemon nearby?
if $game_player.move_route_forcing || pbMapInterpreterRunning? || !$Trainer
Events.onStepTakenFieldMovement.trigger(nil,$game_player)
return
end
$PokemonGlobal.stepcount = 0 if !$PokemonGlobal.stepcount
$PokemonGlobal.stepcount += 1
$PokemonGlobal.stepcount &= 0x7FFFFFFF
repel = ($PokemonGlobal.repel>0)
Events.onStepTaken.trigger(nil)
handled = [nil]
Events.onStepTakenTransferPossible.trigger(nil,handled)
return if handled[0]
if !eventTriggered
#we choose the tile on which the pokemon appears
pos = pbChooseTileOnStepTaken
return if !pos
#we choose the random encounter
encounter,gender,form = pbChooseEncounter(pos[0],pos[1],repel)
return if !encounter
#we generate an random encounter overworld event
pbPlaceEncounter(pos[0],pos[1],encounter,gender,form)
end
end
#===============================================================================
# new method pbChooseTileOnStepTaken to choose the tile on which the pkmn spawns
#===============================================================================
def pbChooseTileOnStepTaken
# Choose 1 random tile from 1 random ring around the player
i = rand(4)
r = rand((i+1)*8)
x = $game_player.x
y = $game_player.y
if r<=(i+1)*2
x = $game_player.x-i-1+r
y = $game_player.y-i-1
elsif r<=(i+1)*6-2
x = [$game_player.x+i+1,$game_player.x-i-1][r%2]
y = $game_player.y-i+((r-1-(i+1)*2)/2).floor
else
x = $game_player.x-i+r-(i+1)*6
y = $game_player.y+i+1
end
#check if it is possible to encounter here
return if x<0 || x>=$game_map.width || y<0 || y>=$game_map.height #check if the tile is on the map
#check if it's a valid grass, water or cave etc. tile
return if PBTerrain.isIce?($game_map.terrain_tag(x,y))
return if PBTerrain.isLedge?($game_map.terrain_tag(x,y))
return if PBTerrain.isWaterfall?($game_map.terrain_tag(x,y))
return if PBTerrain.isRock?($game_map.terrain_tag(x,y))
if RESTRICTENCOUNTERSTOPLAYERMOVEMENT
return if !PBTerrain.isWater?($game_map.terrain_tag(x,y)) &&
$PokemonGlobal && $PokemonGlobal.surfing
return if PBTerrain.isWater?($game_map.terrain_tag(x,y)) &&
!($PokemonGlobal && $PokemonGlobal.surfing)
end
return [x,y]
end
#===============================================================================
# defining new method pbChooseEncounter to choose the pokemon on the tile (x,y)
#===============================================================================
def pbChooseEncounter(x,y,repel=false)
return if $Trainer.ablePokemonCount==0 #check if trainer has pokemon
encounterType = $PokemonEncounters.pbEncounterTypeOnTile(x,y)
$PokemonTemp.encounterType = encounterType
return if encounterType<0 #check if there are encounters
return if !$PokemonEncounters.isEncounterPossibleHereOnTile?(x,y)
for event in $game_map.events.values
if event.x==x && event.y==y
return
end
end
encounter = $PokemonEncounters.pbGenerateEncounter(encounterType)
encounter = EncounterModifier.trigger(encounter)
if !$PokemonEncounters.pbCanEncounter?(encounter,repel)
$PokemonTemp.forceSingleBattle = false
EncounterModifier.triggerEncounterEnd()
return
end
#-----------------------------------------
# added to include forms by derFischae
form = nil
gender = nil
if USEALTFORMS == true or USEFEMALESPRITES == true
genwildpoke = pbGenerateWildPokemon(encounter[0],encounter[1])
gender = genwildpoke.gender if USEFEMALESPRITES==true
form = genwildpoke.form if USEALTFORMS == true
end
#-----------------------------------------
return encounter,gender,form
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)
# 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)
else
mapId = $game_map.map_id
spawnMap = $MapFactory.getMap(mapId)
#Kernel.pbMessage(_INTL("{1}",spawnMap.map_id))
spawnMap.spawnEvent(x,y,encounter,gender,form)
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.nowRoaming == true &&
$PokemonTemp.roamerIndex != nil &&
$PokemonGlobal.roamEncounter != nil
$PokemonGlobal.roamEncounter = nil
$PokemonGlobal.roamedAlready = true
end
$PokemonTemp.forceSingleBattle = false
EncounterModifier.triggerEncounterEnd()
end
#===============================================================================
# adding new Methods pbEncounterTypeOnTile and isEncounterPossibleHereOnTile?
# in Class PokemonEncounters in Script PField_Encounters
#===============================================================================
class PokemonEncounters
def pbEncounterTypeOnTile(x,y)
if PBTerrain.isJustWater?($game_map.terrain_tag(x,y))
return EncounterTypes::Water
elsif self.isCave?
return EncounterTypes::Cave
elsif self.isGrass?
time = pbGetTimeNow
enctype = EncounterTypes::Land
enctype = EncounterTypes::LandNight if self.hasEncounter?(EncounterTypes::LandNight) && PBDayNight.isNight?(time)
enctype = EncounterTypes::LandDay if self.hasEncounter?(EncounterTypes::LandDay) && PBDayNight.isDay?(time)
enctype = EncounterTypes::LandMorning if self.hasEncounter?(EncounterTypes::LandMorning) && PBDayNight.isMorning?(time)
if pbInBugContest? && self.hasEncounter?(EncounterTypes::BugContest)
enctype = EncounterTypes::BugContest
end
return enctype
end
return -1
end
def isEncounterPossibleHereOnTile?(x,y)
if PBTerrain.isJustWater?($game_map.terrain_tag(x,y))
return true
elsif self.isCave?
return true
elsif self.isGrass?
return PBTerrain.isGrass?($game_map.terrain_tag(x,y))
end
return false
end
end
#===============================================================================
# new Method spawnEvent in Class Game_Map in Script Game_Map
#===============================================================================
class Game_Map
def spawnEvent(x,y,encounter,gender = nil,form = nil)
#Kernel.pbMessage(_INTL("{1}",form))
#------------------------------------------------------------------
# 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
$PokemonTemp.catchcombo=[0,0] if !$PokemonTemp.catchcombo
if $game_switches[SHINY_WILD_POKEMON_SWITCH]==true
character_name = character_name+"s"
shinysprite=true
elsif ($PokemonTemp.catchcombo[0]>=CHAINLENGTH && $PokemonTemp.catchcombo[1]==encounter[0])
if rand(SHINYPROBABILITY)<$PokemonTemp.catchcombo[0]
character_name = character_name+"s"
shinysprite=true
end
end
# use sprite of alternative form
if USEALTFORMS==true and form!=nil and form!=0
character_name = character_name+"_"+form.to_s
end
event.pages[0].graphic.character_name = character_name
event.pages[0].move_type = 1
event.pages[0].trigger = 2
#------------------------------------------------------------------
# we add the event commands to the event of the overworld encounter
event.pages[0].list[0].code = 355
event.pages[0].list[0].indent = 0
if $PokemonGlobal.roamEncounter!=nil
#[i,species,poke[1],poke[4]]
parameter1 = $PokemonGlobal.roamEncounter[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
event.pages[0].list[0].parameters = [parameter]
event.pages[0].list[1] = RPG::EventCommand.new
#
event.pages[0].list[1].code = 355
event.pages[0].list[1].indent = 0
if $PokemonTemp.nowRoaming!=nil
parameter =" $PokemonTemp.nowRoaming = "+$PokemonTemp.nowRoaming.to_s
else
parameter =" $PokemonTemp.nowRoaming = nil "
end
event.pages[0].list[1].parameters = [parameter]
event.pages[0].list[2] = RPG::EventCommand.new
#
event.pages[0].list[2].code = 355
event.pages[0].list[2].indent = 0
if $PokemonTemp.roamerIndex!=nil
parameter = " $PokemonTemp.roamerIndex = "+$PokemonTemp.roamerIndex.to_s
else
parameter = " $PokemonTemp.roamerIndex = nil "
end
event.pages[0].list[2].parameters = [parameter]
event.pages[0].list[3] = RPG::EventCommand.new
#
event.pages[0].list[3].code = 355
event.pages[0].list[3].indent = 0
if $PokemonGlobal.nextBattleBGM!=nil
parameter = " $PokemonGlobal.nextBattleBGM = "+PokemonGlobal.nextBattleBGM.to_s
else
parameter = " $PokemonGlobal.nextBattleBGM = nil "
end
event.pages[0].list[3].parameters = [parameter]
event.pages[0].list[4] = RPG::EventCommand.new
#
event.pages[0].list[4].code = 355
event.pages[0].list[4].indent = 0
if $PokemonTemp.forceSingleBattle!=nil
parameter = " $PokemonTemp.forceSingleBattle = "+$PokemonTemp.forceSingleBattle.to_s
else
parameter = " $PokemonTemp.forceSingleBattle = nil "
end
event.pages[0].list[4].parameters = [parameter]
event.pages[0].list[5] = RPG::EventCommand.new
#
event.pages[0].list[5].code = 355
event.pages[0].list[5].indent = 0
if $PokemonTemp.encounterType!=nil
parameter = " $PokemonTemp.encounterType = "+$PokemonTemp.encounterType.to_s
else
parameter = " $PokemonTemp.encounterType = nil "
end
event.pages[0].list[5].parameters = [parameter]
event.pages[0].list[6] = RPG::EventCommand.new
#
# setting shiny switch on if sprite is a shiny-sprite
oldShinySwitchStatus=$game_switches[SHINY_WILD_POKEMON_SWITCH]
if shinysprite == true
parameter = " $game_switches["+SHINY_WILD_POKEMON_SWITCH.to_s+"]=true"
else
parameter = " $game_switches["+SHINY_WILD_POKEMON_SWITCH.to_s+"]=false"
end
event.pages[0].list[6].code = 355
event.pages[0].list[6].indent = 0
event.pages[0].list[6].parameters = [parameter]
event.pages[0].list[7] = RPG::EventCommand.new
#
#pbSingleOrDoubleWildBattle(encounter[0],encounter[1])
gender = "nil" if gender==nil
form = "nil" if form==nil
event.pages[0].list[7].code = 355
event.pages[0].list[7].indent = 0
parameter = " pbSingleOrDoubleWildBattle("+encounter[0].to_s+","+encounter[1].to_s+", $game_map.events["+key_id.to_s+"].map.map_id, $game_map.events["+key_id.to_s+"].x, $game_map.events["+key_id.to_s+"].y,"+gender.to_s+","+form.to_s+")"
event.pages[0].list[7].parameters = [parameter]
event.pages[0].list[8] = RPG::EventCommand.new
#
# setting shiny switch back to previous state
parameter=" $game_switches["+SHINY_WILD_POKEMON_SWITCH.to_s+"]="+oldShinySwitchStatus.to_s
event.pages[0].list[8].code = 355
event.pages[0].list[8].indent = 0
event.pages[0].list[8].parameters = [parameter]
event.pages[0].list[9] = RPG::EventCommand.new
#
event.pages[0].list[9].code = 355
event.pages[0].list[9].indent = 0
event.pages[0].list[9].parameters = ["$PokemonTemp.encounterType = -1"]
event.pages[0].list[10] = RPG::EventCommand.new
#
event.pages[0].list[10].code = 355
event.pages[0].list[10].indent = 0
event.pages[0].list[10].parameters = ["$PokemonTemp.forceSingleBattle = false"]
event.pages[0].list[11] = RPG::EventCommand.new
#
event.pages[0].list[11].code = 355
event.pages[0].list[11].indent = 0
event.pages[0].list[11].parameters = ["EncounterModifier.triggerEncounterEnd()"]
event.pages[0].list[12] = RPG::EventCommand.new
#
event.pages[0].list[12].code = 355
event.pages[0].list[12].indent = 0
event.pages[0].list[12].parameters = ["$game_map.events.delete("+key_id.to_s+")"]
event.pages[0].list[13] = RPG::EventCommand.new
#
event.pages[0].list[13].code = 355
event.pages[0].list[13].indent = 0
event.pages[0].list[13].parameters = ["$scene.disposeSpritesets"]
event.pages[0].list[14] = RPG::EventCommand.new
#
event.pages[0].list[14].code = 355
event.pages[0].list[14].indent = 0
event.pages[0].list[14].parameters = ["$scene.createSpritesets"]
event.pages[0].list[15] = RPG::EventCommand.new
#------------------------------------------------------------------
# creating and adding the Game_Event
gameEvent = Game_Event.new(@map_id, event,self)
key_id = (@events.keys.max || -1) + 1
gameEvent.id = key_id
gameEvent.moveto(x,y)
@events[key_id] = gameEvent
#-------------------------------------------------------------------------
#updating the sprites
sprite = Sprite_Character.new(Spriteset_Map.viewport,@events[key_id])
$scene.spritesets[self.map_id].character_sprites.push(sprite)
end
end
#===============================================================================
# adding new Method pbSingleOrDoubleWildBattle to reduce the code in spawnEvent
#===============================================================================
def pbSingleOrDoubleWildBattle(species,level,map_id,x,y,gender = nil,form = nil)
if $MapFactory
terrainTag = $MapFactory.getTerrainTag(map_id,x,y)
else
terrainTag = $game_map.terrain_tag(x,y)
end
if !$PokemonTemp.forceSingleBattle && ($PokemonGlobal.partner ||
($Trainer.ablePokemonCount>1 &&
PBTerrain.isDoubleWildBattle?(terrainTag) &&
rand(100)<30))
encounter2 = $PokemonEncounters.pbEncounteredPokemon($PokemonTemp.encounterType)
encounter2 = EncounterModifier.trigger(encounter2)
pbDoubleWildBattle(species,level,encounter2[0],encounter2[1],nil,true,false,gender,form,nil,nil)
else
pbWildBattle(species,level,nil,true,false,gender,form)
end
end
#===============================================================================
# overriding Method pbWildBattle in Script PField_Battles
# to include alternate forms of the wild pokemon
#===============================================================================
def pbWildBattle(species,level,variable=nil,canescape=true,canlose=false,gender = nil,form = nil)
if (Input.press?(Input::CTRL) && $DEBUG) || $Trainer.pokemonCount==0
if $Trainer.pokemonCount>0
Kernel.pbMessage(_INTL("SKIPPING BATTLE..."))
end
pbSet(variable,1)
$PokemonGlobal.nextBattleBGM = nil
$PokemonGlobal.nextBattleME = nil
$PokemonGlobal.nextBattleBack = nil
return true
end
if species.is_a?(String) || species.is_a?(Symbol)
species = getID(PBSpecies,species)
end
handled = [nil]
Events.onWildBattleOverride.trigger(nil,species,level,handled)
return handled[0] if handled[0]!=nil
currentlevels = []
for i in $Trainer.party
currentlevels.push(i.level)
end
genwildpoke = pbGenerateWildPokemon(species,level)
#-----------------------------------------------------------------------------
#added by derFischae to set the form
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
# 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.
#-----------------------------------------------------------------------------
Events.onStartBattle.trigger(nil,genwildpoke)
scene = pbNewBattleScene
battle = PokeBattle_Battle.new(scene,$Trainer.party,[genwildpoke],$Trainer,nil)
battle.internalbattle = true
battle.cantescape = !canescape
pbPrepareBattle(battle)
decision = 0
pbBattleAnimation(pbGetWildBattleBGM(species),0,[genwildpoke]) {
pbSceneStandby {
decision = battle.pbStartBattle(canlose)
}
pbAfterBattle(decision,canlose)
}
Input.update
pbSet(variable,decision)
Events.onWildBattleEnd.trigger(nil,species,level,decision)
return (decision!=2)
end
#===============================================================================
# overriding Method pbDoubleWildBattle in Script PField_Battles
# to include alternate forms of the wild pokemon in double battles
#===============================================================================
def pbDoubleWildBattle(species1,level1,species2,level2,variable=nil,canescape=true,canlose=false,gender1 = nil,form1 = nil,gender2 = nil,form2 = nil)
if (Input.press?(Input::CTRL) && $DEBUG) || $Trainer.pokemonCount==0
if $Trainer.pokemonCount>0
Kernel.pbMessage(_INTL("SKIPPING BATTLE..."))
end
pbSet(variable,1)
$PokemonGlobal.nextBattleBGM = nil
$PokemonGlobal.nextBattleME = nil
$PokemonGlobal.nextBattleBack = nil
return true
end
if species1.is_a?(String) || species1.is_a?(Symbol)
species1 = getID(PBSpecies,species1)
end
if species2.is_a?(String) || species2.is_a?(Symbol)
species2 = getID(PBSpecies,species2)
end
currentlevels = []
for i in $Trainer.party
currentlevels.push(i.level)
end
genwildpoke = pbGenerateWildPokemon(species1,level1)
genwildpoke2 = pbGenerateWildPokemon(species2,level2)
#-----------------------------------------------------------------------------
#added by derFischae to set the form
# 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.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.resetMoves
end
#-----------------------------------------------------------------------------
Events.onStartBattle.trigger(nil,genwildpoke)
scene = pbNewBattleScene
if $PokemonGlobal.partner
othertrainer = PokeBattle_Trainer.new($PokemonGlobal.partner[1],$PokemonGlobal.partner[0])
othertrainer.id = $PokemonGlobal.partner[2]
othertrainer.party = $PokemonGlobal.partner[3]
combinedParty = []
for i in 0...$Trainer.party.length
combinedParty[i] = $Trainer.party[i]
end
for i in 0...othertrainer.party.length
combinedParty[6+i] = othertrainer.party[i]
end
battle = PokeBattle_Battle.new(scene,combinedParty,[genwildpoke,genwildpoke2],[$Trainer,othertrainer],nil)
battle.fullparty1 = true
else
battle = PokeBattle_Battle.new(scene,$Trainer.party,[genwildpoke,genwildpoke2],$Trainer,nil)
battle.fullparty1 = false
end
battle.internalbattle = true
battle.doublebattle = battle.pbDoubleBattleAllowed?()
battle.cantescape = !canescape
pbPrepareBattle(battle)
decision = 0
pbBattleAnimation(pbGetWildBattleBGM(species1),2,[genwildpoke,genwildpoke2]) {
pbSceneStandby {
decision = battle.pbStartBattle(canlose)
}
pbAfterBattle(decision,canlose)
}
Input.update
pbSet(variable,decision)
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
#########################################################
# #
# 3. PART: VANISHING OF OVERWORLD ENCOUNTER #
# #
#########################################################
#===============================================================================
# adding a new variable stepCount and replacing the method increase_steps
# in class Game_Event in script Game_Event to count the steps of
# overworld encounter and to make them disappear after taking more then
# STEPSBEFOREVANISHING steps
#===============================================================================
class Game_Event < Game_Character
attr_accessor :event
attr_accessor :stepCount #counts the steps of an overworld encounter
alias original_increase_steps increase_steps
def increase_steps
if self.name=="vanishingEncounter" && @stepCount && @stepCount>=STEPSBEFOREVANISHING
if $game_map.events.has_key?(@id) and $game_map.events[@id]==self
#-------------------------------------------------------------------------
# added to reduce lag by derFischae
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
#-------------------------------------------------------------------------
# added to reduce lag by derFischae
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
#-------------------------------------------------------------------------
# added some code above to reduce lag by derFischae
# Original Code was
#$scene.disposeSpritesets
#$scene.createSpritesets
#-------------------------------------------------------------------------
else
@stepCount=0 if (!@stepCount || @stepCount<0)
@stepCount+=1
original_increase_steps
end
end
end
When you are with trainer partners: The game crashes when you "talk" to the overworld pokemon, which it will transforms automatically in wild double battles. In other words. Your script crashes in double battles against wild pokemon.
def pbDoubleWildBattle(species1,level1,species2,level2,gender1,form1 = nil,gender2 = nil,form2 = nil)
def pbDoubleWildBattle(species1,level1,species2,level2,variable=nil,canescape=true,canlose=false,gender1 = nil,form1 = nil,gender2 = nil,form2 = nil)
#===============================================================================
# * Visible Overworld Encounters V1.3 - by derFischae (Credits if used please) *
#===============================================================================
#
# UPDATED TO VERSION 1.3
#
# This script is for Pokémon Essentials 17.
# As in Pokemon Let's go Pikachu/Eevee or Pokemon Shild and Sword
# random encounters pop up on the overworld,
# they move around and you can start the battle
# with them simply by moving to the pokemon.
# Clearly, you also can omit the battle by circling around them.
#
#
# FEATURES INCLUDED:
# - see the pokemon on the overworld before going into battle
# - no forced battling against random encounters
# - plays the pokemon cry while spawning
# - Choose whether encounters occure on all terrains or only on
# the terrain of the player
# - if you kill the same species in a row, then you increase
# the chance of spawning a shiny of that species
#
# 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
#
# 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
# You can choose whether the sprite of your overworld encounter
# is always the standard form 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
#
# NOTE: I have not checked Roaming Encounters. Feel free to test it.
#
# THANKS to Zeak6464, WolfPP and Vendily for giving me some hints about forms
# and gender on discord
# SPECIAL THANKS to BulbasaurLvl5 for bringing me to pokemon essentials and the
# super productive time
#===============================================================================
# Settings
#===============================================================================
RESTRICTENCOUNTERSTOPLAYERMOVEMENT = false
#true - means that water encounters are popping up
# if and only if player is surfing
# (perhaps decreases encounter rate)
#false - means that all encounter types can pop up
# close to the player (as long as there is a suitable tile)
CHAINLENGTH = 10 # default 10
# number describes how many pokemon of the same species
# you have to kill in a row to increase shiny propability
SHINYPROBABILITY = 100 # default 100 --> 10%
# increasing this value decreases the probability of spawning a shiny
STEPSBEFOREVANISHING = 6 # default 10
# STEPSBEFOREVANISHING is the number of steps a wild Encounter goes
# before vanishing on the map.
USEALTFORMS = true # default false
#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 false
#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
#===============================================================================
# THE SCRIPT
#===============================================================================
#########################################################
# #
# 1. PART: THE CATCHCOMBO #
# #
#########################################################
#===============================================================================
# adding a new instance variable to $PokemonTemp in script PField_Metadata to
# remember which pokemon and how many of that kind were killed in a row
#===============================================================================
class PokemonTemp
attr_accessor :catchcombo # [chain length, species]
end
#===============================================================================
# adding a new event handler on Battle end to update the catchchain (where the
# pokemon-kill-chain is saved)
#===============================================================================
Events.onWildBattleEnd+=proc {|sender,e|
species=e[0]
result=e[2]
$PokemonTemp.catchcombo = [0,0] if !$PokemonTemp.catchcombo
if $PokemonTemp.catchcombo[1]!=species
$PokemonTemp.catchcombo=[0,species]
end
if result==1 && species==$PokemonTemp.catchcombo[1]
$PokemonTemp.catchcombo[0]+=1
#Kernel.pbMessage(_INTL("You killed {1} {2}",$PokemonTemp.catchcombo[0],$PokemonTemp.catchcombo[1]))
end
}
#########################################################
# #
# 2. PART: SPAWNING THE OVERWORLD ENCOUNTER #
# #
#########################################################
#===============================================================================
# We override the original method "pbOnStepTaken" in Script PField_Field it was
# originally used for random encounter battles
#===============================================================================
def Kernel.pbOnStepTaken(eventTriggered)
#Should it be possible to search for pokemon nearby?
if $game_player.move_route_forcing || pbMapInterpreterRunning? || !$Trainer
Events.onStepTakenFieldMovement.trigger(nil,$game_player)
return
end
$PokemonGlobal.stepcount = 0 if !$PokemonGlobal.stepcount
$PokemonGlobal.stepcount += 1
$PokemonGlobal.stepcount &= 0x7FFFFFFF
repel = ($PokemonGlobal.repel>0)
Events.onStepTaken.trigger(nil)
handled = [nil]
Events.onStepTakenTransferPossible.trigger(nil,handled)
return if handled[0]
if !eventTriggered
#we choose the tile on which the pokemon appears
pos = pbChooseTileOnStepTaken
return if !pos
#we choose the random encounter
encounter,gender,form = pbChooseEncounter(pos[0],pos[1],repel)
return if !encounter
#we generate an random encounter overworld event
pbPlaceEncounter(pos[0],pos[1],encounter,gender,form)
end
end
#===============================================================================
# new method pbChooseTileOnStepTaken to choose the tile on which the pkmn spawns
#===============================================================================
def pbChooseTileOnStepTaken
# Choose 1 random tile from 1 random ring around the player
i = rand(4)
r = rand((i+1)*8)
x = $game_player.x
y = $game_player.y
if r<=(i+1)*2
x = $game_player.x-i-1+r
y = $game_player.y-i-1
elsif r<=(i+1)*6-2
x = [$game_player.x+i+1,$game_player.x-i-1][r%2]
y = $game_player.y-i+((r-1-(i+1)*2)/2).floor
else
x = $game_player.x-i+r-(i+1)*6
y = $game_player.y+i+1
end
#check if it is possible to encounter here
return if x<0 || x>=$game_map.width || y<0 || y>=$game_map.height #check if the tile is on the map
#check if it's a valid grass, water or cave etc. tile
return if PBTerrain.isIce?($game_map.terrain_tag(x,y))
return if PBTerrain.isLedge?($game_map.terrain_tag(x,y))
return if PBTerrain.isWaterfall?($game_map.terrain_tag(x,y))
return if PBTerrain.isRock?($game_map.terrain_tag(x,y))
if RESTRICTENCOUNTERSTOPLAYERMOVEMENT
return if !PBTerrain.isWater?($game_map.terrain_tag(x,y)) &&
$PokemonGlobal && $PokemonGlobal.surfing
return if PBTerrain.isWater?($game_map.terrain_tag(x,y)) &&
!($PokemonGlobal && $PokemonGlobal.surfing)
end
return [x,y]
end
#===============================================================================
# defining new method pbChooseEncounter to choose the pokemon on the tile (x,y)
#===============================================================================
def pbChooseEncounter(x,y,repel=false)
return if $Trainer.ablePokemonCount==0 #check if trainer has pokemon
encounterType = $PokemonEncounters.pbEncounterTypeOnTile(x,y)
$PokemonTemp.encounterType = encounterType
return if encounterType<0 #check if there are encounters
return if !$PokemonEncounters.isEncounterPossibleHereOnTile?(x,y)
for event in $game_map.events.values
if event.x==x && event.y==y
return
end
end
encounter = $PokemonEncounters.pbGenerateEncounter(encounterType)
encounter = EncounterModifier.trigger(encounter)
if !$PokemonEncounters.pbCanEncounter?(encounter,repel)
$PokemonTemp.forceSingleBattle = false
EncounterModifier.triggerEncounterEnd()
return
end
#-----------------------------------------
# added to include forms by derFischae
form = nil
gender = nil
if USEALTFORMS == true or USEFEMALESPRITES == true
genwildpoke = pbGenerateWildPokemon(encounter[0],encounter[1])
gender = genwildpoke.gender if USEFEMALESPRITES==true
form = genwildpoke.form if USEALTFORMS == true
end
#-----------------------------------------
return encounter,gender,form
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)
# 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)
else
mapId = $game_map.map_id
spawnMap = $MapFactory.getMap(mapId)
#Kernel.pbMessage(_INTL("{1}",spawnMap.map_id))
spawnMap.spawnEvent(x,y,encounter,gender,form)
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.nowRoaming == true &&
$PokemonTemp.roamerIndex != nil &&
$PokemonGlobal.roamEncounter != nil
$PokemonGlobal.roamEncounter = nil
$PokemonGlobal.roamedAlready = true
end
$PokemonTemp.forceSingleBattle = false
EncounterModifier.triggerEncounterEnd()
end
#===============================================================================
# adding new Methods pbEncounterTypeOnTile and isEncounterPossibleHereOnTile?
# in Class PokemonEncounters in Script PField_Encounters
#===============================================================================
class PokemonEncounters
def pbEncounterTypeOnTile(x,y)
if PBTerrain.isJustWater?($game_map.terrain_tag(x,y))
return EncounterTypes::Water
elsif self.isCave?
return EncounterTypes::Cave
elsif self.isGrass?
time = pbGetTimeNow
enctype = EncounterTypes::Land
enctype = EncounterTypes::LandNight if self.hasEncounter?(EncounterTypes::LandNight) && PBDayNight.isNight?(time)
enctype = EncounterTypes::LandDay if self.hasEncounter?(EncounterTypes::LandDay) && PBDayNight.isDay?(time)
enctype = EncounterTypes::LandMorning if self.hasEncounter?(EncounterTypes::LandMorning) && PBDayNight.isMorning?(time)
if pbInBugContest? && self.hasEncounter?(EncounterTypes::BugContest)
enctype = EncounterTypes::BugContest
end
return enctype
end
return -1
end
def isEncounterPossibleHereOnTile?(x,y)
if PBTerrain.isJustWater?($game_map.terrain_tag(x,y))
return true
elsif self.isCave?
return true
elsif self.isGrass?
return PBTerrain.isGrass?($game_map.terrain_tag(x,y))
end
return false
end
end
#===============================================================================
# new Method spawnEvent in Class Game_Map in Script Game_Map
#===============================================================================
class Game_Map
def spawnEvent(x,y,encounter,gender = nil,form = nil)
#Kernel.pbMessage(_INTL("{1}",form))
#------------------------------------------------------------------
# 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
$PokemonTemp.catchcombo=[0,0] if !$PokemonTemp.catchcombo
if $game_switches[SHINY_WILD_POKEMON_SWITCH]==true
character_name = character_name+"s"
shinysprite=true
elsif ($PokemonTemp.catchcombo[0]>=CHAINLENGTH && $PokemonTemp.catchcombo[1]==encounter[0])
if rand(SHINYPROBABILITY)<$PokemonTemp.catchcombo[0]
character_name = character_name+"s"
shinysprite=true
end
end
# use sprite of alternative form
if USEALTFORMS==true and form!=nil and form!=0
character_name = character_name+"_"+form.to_s
end
event.pages[0].graphic.character_name = character_name
event.pages[0].move_type = 1
event.pages[0].trigger = 2
#------------------------------------------------------------------
# we add the event commands to the event of the overworld encounter
event.pages[0].list[0].code = 355
event.pages[0].list[0].indent = 0
if $PokemonGlobal.roamEncounter!=nil
#[i,species,poke[1],poke[4]]
parameter1 = $PokemonGlobal.roamEncounter[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
event.pages[0].list[0].parameters = [parameter]
event.pages[0].list[1] = RPG::EventCommand.new
#
event.pages[0].list[1].code = 355
event.pages[0].list[1].indent = 0
if $PokemonTemp.nowRoaming!=nil
parameter =" $PokemonTemp.nowRoaming = "+$PokemonTemp.nowRoaming.to_s
else
parameter =" $PokemonTemp.nowRoaming = nil "
end
event.pages[0].list[1].parameters = [parameter]
event.pages[0].list[2] = RPG::EventCommand.new
#
event.pages[0].list[2].code = 355
event.pages[0].list[2].indent = 0
if $PokemonTemp.roamerIndex!=nil
parameter = " $PokemonTemp.roamerIndex = "+$PokemonTemp.roamerIndex.to_s
else
parameter = " $PokemonTemp.roamerIndex = nil "
end
event.pages[0].list[2].parameters = [parameter]
event.pages[0].list[3] = RPG::EventCommand.new
#
event.pages[0].list[3].code = 355
event.pages[0].list[3].indent = 0
if $PokemonGlobal.nextBattleBGM!=nil
parameter = " $PokemonGlobal.nextBattleBGM = "+PokemonGlobal.nextBattleBGM.to_s
else
parameter = " $PokemonGlobal.nextBattleBGM = nil "
end
event.pages[0].list[3].parameters = [parameter]
event.pages[0].list[4] = RPG::EventCommand.new
#
event.pages[0].list[4].code = 355
event.pages[0].list[4].indent = 0
if $PokemonTemp.forceSingleBattle!=nil
parameter = " $PokemonTemp.forceSingleBattle = "+$PokemonTemp.forceSingleBattle.to_s
else
parameter = " $PokemonTemp.forceSingleBattle = nil "
end
event.pages[0].list[4].parameters = [parameter]
event.pages[0].list[5] = RPG::EventCommand.new
#
event.pages[0].list[5].code = 355
event.pages[0].list[5].indent = 0
if $PokemonTemp.encounterType!=nil
parameter = " $PokemonTemp.encounterType = "+$PokemonTemp.encounterType.to_s
else
parameter = " $PokemonTemp.encounterType = nil "
end
event.pages[0].list[5].parameters = [parameter]
event.pages[0].list[6] = RPG::EventCommand.new
#
# setting shiny switch on if sprite is a shiny-sprite
oldShinySwitchStatus=$game_switches[SHINY_WILD_POKEMON_SWITCH]
if shinysprite == true
parameter = " $game_switches["+SHINY_WILD_POKEMON_SWITCH.to_s+"]=true"
else
parameter = " $game_switches["+SHINY_WILD_POKEMON_SWITCH.to_s+"]=false"
end
event.pages[0].list[6].code = 355
event.pages[0].list[6].indent = 0
event.pages[0].list[6].parameters = [parameter]
event.pages[0].list[7] = RPG::EventCommand.new
#
#pbSingleOrDoubleWildBattle(encounter[0],encounter[1])
gender = "nil" if gender==nil
form = "nil" if form==nil
event.pages[0].list[7].code = 355
event.pages[0].list[7].indent = 0
parameter = " pbSingleOrDoubleWildBattle("+encounter[0].to_s+","+encounter[1].to_s+", $game_map.events["+key_id.to_s+"].map.map_id, $game_map.events["+key_id.to_s+"].x, $game_map.events["+key_id.to_s+"].y,"+gender.to_s+","+form.to_s+")"
event.pages[0].list[7].parameters = [parameter]
event.pages[0].list[8] = RPG::EventCommand.new
#
# setting shiny switch back to previous state
parameter=" $game_switches["+SHINY_WILD_POKEMON_SWITCH.to_s+"]="+oldShinySwitchStatus.to_s
event.pages[0].list[8].code = 355
event.pages[0].list[8].indent = 0
event.pages[0].list[8].parameters = [parameter]
event.pages[0].list[9] = RPG::EventCommand.new
#
event.pages[0].list[9].code = 355
event.pages[0].list[9].indent = 0
event.pages[0].list[9].parameters = ["$PokemonTemp.encounterType = -1"]
event.pages[0].list[10] = RPG::EventCommand.new
#
event.pages[0].list[10].code = 355
event.pages[0].list[10].indent = 0
event.pages[0].list[10].parameters = ["$PokemonTemp.forceSingleBattle = false"]
event.pages[0].list[11] = RPG::EventCommand.new
#
event.pages[0].list[11].code = 355
event.pages[0].list[11].indent = 0
event.pages[0].list[11].parameters = ["EncounterModifier.triggerEncounterEnd()"]
event.pages[0].list[12] = RPG::EventCommand.new
#
event.pages[0].list[12].code = 355
event.pages[0].list[12].indent = 0
event.pages[0].list[12].parameters = ["$game_map.events.delete("+key_id.to_s+")"]
event.pages[0].list[13] = RPG::EventCommand.new
#
event.pages[0].list[13].code = 355
event.pages[0].list[13].indent = 0
event.pages[0].list[13].parameters = ["$scene.disposeSpritesets"]
event.pages[0].list[14] = RPG::EventCommand.new
#
event.pages[0].list[14].code = 355
event.pages[0].list[14].indent = 0
event.pages[0].list[14].parameters = ["$scene.createSpritesets"]
event.pages[0].list[15] = RPG::EventCommand.new
#------------------------------------------------------------------
# creating and adding the Game_Event
gameEvent = Game_Event.new(@map_id, event,self)
key_id = (@events.keys.max || -1) + 1
gameEvent.id = key_id
gameEvent.moveto(x,y)
@events[key_id] = gameEvent
#-------------------------------------------------------------------------
#updating the sprites
sprite = Sprite_Character.new(Spriteset_Map.viewport,@events[key_id])
$scene.spritesets[self.map_id].character_sprites.push(sprite)
end
end
#===============================================================================
# adding new Method pbSingleOrDoubleWildBattle to reduce the code in spawnEvent
#===============================================================================
def pbSingleOrDoubleWildBattle(species,level,map_id,x,y,gender = nil,form = nil)
if $MapFactory
terrainTag = $MapFactory.getTerrainTag(map_id,x,y)
else
terrainTag = $game_map.terrain_tag(x,y)
end
if !$PokemonTemp.forceSingleBattle && ($PokemonGlobal.partner ||
($Trainer.ablePokemonCount>1 &&
PBTerrain.isDoubleWildBattle?(terrainTag) &&
rand(100)<30))
encounter2 = $PokemonEncounters.pbEncounteredPokemon($PokemonTemp.encounterType)
encounter2 = EncounterModifier.trigger(encounter2)
pbDoubleWildBattle(species,level,encounter2[0],encounter2[1],nil,true,false,gender,form,nil,nil)
else
pbWildBattle(species,level,nil,true,false,gender,form)
end
end
#===============================================================================
# overriding Method pbWildBattle in Script PField_Battles
# to include alternate forms of the wild pokemon
#===============================================================================
def pbWildBattle(species,level,variable=nil,canescape=true,canlose=false,gender = nil,form = nil)
if (Input.press?(Input::CTRL) && $DEBUG) || $Trainer.pokemonCount==0
if $Trainer.pokemonCount>0
Kernel.pbMessage(_INTL("SKIPPING BATTLE..."))
end
pbSet(variable,1)
$PokemonGlobal.nextBattleBGM = nil
$PokemonGlobal.nextBattleME = nil
$PokemonGlobal.nextBattleBack = nil
return true
end
if species.is_a?(String) || species.is_a?(Symbol)
species = getID(PBSpecies,species)
end
handled = [nil]
Events.onWildBattleOverride.trigger(nil,species,level,handled)
return handled[0] if handled[0]!=nil
currentlevels = []
for i in $Trainer.party
currentlevels.push(i.level)
end
genwildpoke = pbGenerateWildPokemon(species,level)
#-----------------------------------------------------------------------------
#added by derFischae to set the form
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
# 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.
#-----------------------------------------------------------------------------
Events.onStartBattle.trigger(nil,genwildpoke)
scene = pbNewBattleScene
battle = PokeBattle_Battle.new(scene,$Trainer.party,[genwildpoke],$Trainer,nil)
battle.internalbattle = true
battle.cantescape = !canescape
pbPrepareBattle(battle)
decision = 0
pbBattleAnimation(pbGetWildBattleBGM(species),0,[genwildpoke]) {
pbSceneStandby {
decision = battle.pbStartBattle(canlose)
}
pbAfterBattle(decision,canlose)
}
Input.update
pbSet(variable,decision)
Events.onWildBattleEnd.trigger(nil,species,level,decision)
return (decision!=2)
end
#===============================================================================
# overriding Method pbDoubleWildBattle in Script PField_Battles
# to include alternate forms of the wild pokemon in double battles
#===============================================================================
def pbDoubleWildBattle(species1,level1,species2,level2,variable=nil,canescape=true,canlose=false,gender1 = nil,form1 = nil,gender2 = nil,form2 = nil)
if (Input.press?(Input::CTRL) && $DEBUG) || $Trainer.pokemonCount==0
if $Trainer.pokemonCount>0
Kernel.pbMessage(_INTL("SKIPPING BATTLE..."))
end
pbSet(variable,1)
$PokemonGlobal.nextBattleBGM = nil
$PokemonGlobal.nextBattleME = nil
$PokemonGlobal.nextBattleBack = nil
return true
end
if species1.is_a?(String) || species1.is_a?(Symbol)
species1 = getID(PBSpecies,species1)
end
if species2.is_a?(String) || species2.is_a?(Symbol)
species2 = getID(PBSpecies,species2)
end
currentlevels = []
for i in $Trainer.party
currentlevels.push(i.level)
end
genwildpoke = pbGenerateWildPokemon(species1,level1)
genwildpoke2 = pbGenerateWildPokemon(species2,level2)
#-----------------------------------------------------------------------------
#added by derFischae to set the form
# 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.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.resetMoves
end
#-----------------------------------------------------------------------------
Events.onStartBattle.trigger(nil,genwildpoke)
scene = pbNewBattleScene
if $PokemonGlobal.partner
othertrainer = PokeBattle_Trainer.new($PokemonGlobal.partner[1],$PokemonGlobal.partner[0])
othertrainer.id = $PokemonGlobal.partner[2]
othertrainer.party = $PokemonGlobal.partner[3]
combinedParty = []
for i in 0...$Trainer.party.length
combinedParty[i] = $Trainer.party[i]
end
for i in 0...othertrainer.party.length
combinedParty[6+i] = othertrainer.party[i]
end
battle = PokeBattle_Battle.new(scene,combinedParty,[genwildpoke,genwildpoke2],[$Trainer,othertrainer],nil)
battle.fullparty1 = true
else
battle = PokeBattle_Battle.new(scene,$Trainer.party,[genwildpoke,genwildpoke2],$Trainer,nil)
battle.fullparty1 = false
end
battle.internalbattle = true
battle.doublebattle = battle.pbDoubleBattleAllowed?()
battle.cantescape = !canescape
pbPrepareBattle(battle)
decision = 0
pbBattleAnimation(pbGetWildBattleBGM(species1),2,[genwildpoke,genwildpoke2]) {
pbSceneStandby {
decision = battle.pbStartBattle(canlose)
}
pbAfterBattle(decision,canlose)
}
Input.update
pbSet(variable,decision)
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
#########################################################
# #
# 3. PART: VANISHING OF OVERWORLD ENCOUNTER #
# #
#########################################################
#===============================================================================
# adding a new variable stepCount and replacing the method increase_steps
# in class Game_Event in script Game_Event to count the steps of
# overworld encounter and to make them disappear after taking more then
# STEPSBEFOREVANISHING steps
#===============================================================================
class Game_Event < Game_Character
attr_accessor :event
attr_accessor :stepCount #counts the steps of an overworld encounter
alias original_increase_steps increase_steps
def increase_steps
if self.name=="vanishingEncounter" && @stepCount && @stepCount>=STEPSBEFOREVANISHING
if $game_map.events.has_key?(@id) and $game_map.events[@id]==self
#-------------------------------------------------------------------------
# added to reduce lag by derFischae
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
#-------------------------------------------------------------------------
# added to reduce lag by derFischae
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
#-------------------------------------------------------------------------
# added some code above to reduce lag by derFischae
# Original Code was
#$scene.disposeSpritesets
#$scene.createSpritesets
#-------------------------------------------------------------------------
else
@stepCount=0 if (!@stepCount || @stepCount<0)
@stepCount+=1
original_increase_steps
end
end
end
I would like to make an exception for the legendary Pokémon.
I wish they would not appear in overworld mode but only in the grass.
And I'd like that during the double encounters, there is only one Pokémon and not two.
To make it more realist.
(I use this method because I have both type of wild encounter in my game. Normal encounter and overworlds encounter as you mentioned in INSTANT_WILD_BATTLE_PROPABILITY
Thanks in advance and I continue to enjoy your awesome scripts.