Deoxysomega314
And Egg
- 16
- Posts
- 13
- Years
- North Carolina
- Seen Nov 16, 2016
So I'm following a combination of this and this, and I'm following the methods to a T, but I can't seem to get the new encounter methods to pop up in the Editor, and anytime I try to add some Pokemon with the new encounter method in the text file, I get this error and it's really starting to frustrate me because I feel like I'm missing something obvious. (I'm not adept at coding in any sense of the word).
All I'm trying to do is have a separate kind of grass (Long Grass), so it's not like it's a really detailed encounter method or anything. I just want to add a little more variety to my game.
I'm naming the method "MetalFloor" for right now because one of the tutorials has it named that and I didn't want to change anything out of fear of messing up.
If it helps, here is my PBTerrain script.
And my PField_Encounters script as well.
Spoiler:
---------------------------
Pokemon Essentials
---------------------------
Exception: RuntimeError
Message: Undefined encounter type MetalFloor, expected one of the following:
["Land", "Cave", "Water", "RockSmash", "OldRod", "GoodRod", "SuperRod", "HeadbuttLow", "HeadbuttHigh", "LandMorning", "LandDay", "LandNight", "BugContest"]
File PBS/encounters.txt, line 541
MetalFloor
Compiler:2621:in `pbCompileEncounters'
Compiler:4116:in `pbCompileAllData'
Compiler:4212
I'm naming the method "MetalFloor" for right now because one of the tutorials has it named that and I didn't want to change anything out of fear of messing up.
If it helps, here is my PBTerrain script.
Spoiler:
Code:
#===============================================================================
# Terrain tags
#===============================================================================
module PBTerrain
Ledge = 1
Grass = 2
Sand = 3
Rock = 4
DeepWater = 5
StillWater = 6
Water = 7
Waterfall = 8
WaterfallCrest = 9
TallGrass = 10
UnderwaterGrass = 11
Ice = 12
Neutral = 13
SootGrass = 14
Bridge = 15
Puddle = 16
MetalFloor = 17
def PBTerrain.isSurfable?(tag)
return PBTerrain.isWater?(tag)
end
def PBTerrain.isWater?(tag)
return tag==PBTerrain::Water ||
tag==PBTerrain::StillWater ||
tag==PBTerrain::DeepWater ||
tag==PBTerrain::WaterfallCrest ||
tag==PBTerrain::Waterfall
end
def PBTerrain.isPassableWater?(tag)
return tag==PBTerrain::Water ||
tag==PBTerrain::StillWater ||
tag==PBTerrain::DeepWater ||
tag==PBTerrain::WaterfallCrest
end
def PBTerrain.isJustWater?(tag)
return tag==PBTerrain::Water ||
tag==PBTerrain::StillWater ||
tag==PBTerrain::DeepWater
end
def pbisMetalFloorTag?(tag)
return tag==PBTerrain::MetalFloor
end
def PBTerrain.isGrass?(tag)
return tag==PBTerrain::Grass ||
tag==PBTerrain::TallGrass ||
tag==PBTerrain::UnderwaterGrass ||
tag==PBTerrain::SootGrass
end
def PBTerrain.isJustGrass?(tag) # The Poké Radar only works in these tiles
return tag==PBTerrain::Grass ||
tag==PBTerrain::SootGrass
end
def PBTerrain.isLedge?(tag)
return tag==PBTerrain::Ledge
end
def PBTerrain.isIce?(tag)
return tag==PBTerrain::Ice
end
def PBTerrain.isBridge?(tag)
return tag==PBTerrain::Bridge
end
def PBTerrain.hasReflections?(tag)
return tag==PBTerrain::StillWater ||
tag==PBTerrain::Puddle
end
def PBTerrain.onlyWalk?(tag)
return tag==PBTerrain::TallGrass ||
tag==PBTerrain::Ice
end
end
Spoiler:
Code:
module EncounterTypes
Land = 0
Cave = 1
Water = 2
RockSmash = 3
OldRod = 4
GoodRod = 5
SuperRod = 6
HeadbuttLow = 7
HeadbuttHigh = 8
LandMorning = 9
LandDay = 10
LandNight = 11
BugContest = 12
MetalFloor = 13
Names=[
"Land",
"Cave",
"Water",
"RockSmash",
"OldRod",
"GoodRod",
"SuperRod",
"HeadbuttLow",
"HeadbuttHigh",
"LandMorning",
"LandDay",
"LandNight",
"BugContest",
"MetalFloor"
]
EnctypeChances=[
[20,20,10,10,10,10,5,5,4,4,1,1],
[20,20,10,10,10,10,5,5,4,4,1,1],
[60,30,5,4,1],
[60,30,5,4,1],
[70,30],
[60,20,20],
[40,40,15,4,1],
[30,25,20,10,5,5,4,1],
[30,25,20,10,5,5,4,1],
[20,20,10,10,10,10,5,5,4,4,1,1],
[20,20,10,10,10,10,5,5,4,4,1,1],
[20,20,10,10,10,10,5,5,4,4,1,1],
[20,20,10,10,10,10,5,5,4,4,1,1],
[20,20,10,10,10,10,5,5,4,4,1,1]
]
EnctypeDensities=[25,10,10,0,0,0,0,0,0,25,25,25,25,10,10]
EnctypeCompileDens=[1,2,3,0,0,0,0,0,0,1,1,1,1,2,2]
end
class PokemonEncounters
def initialize
@enctypes=[]
@density=nil
end
def stepcount
return @stepcount
end
def clearStepCount
@stepcount=0
end
def hasEncounter?(enc)
return false if @density==nil || enc<0
return @enctypes[enc] ? true : false
end
def isCave?
return false if @density==nil
return @enctypes[EncounterTypes::Cave] ? true : false
end
def isMetalFloor?
return false if @density==nil
return @enctypes[EncounterTypes::MetalFloor] ? true : false
end
def isGrass?
return false if @density==nil
return (@enctypes[EncounterTypes::Land] ||
@enctypes[EncounterTypes::LandMorning] ||
@enctypes[EncounterTypes::LandDay] ||
@enctypes[EncounterTypes::LandNight] ||
@enctypes[EncounterTypes::BugContest]) ? true : false
end
def isRegularGrass?
return false if @density==nil
return (@enctypes[EncounterTypes::Land] ||
@enctypes[EncounterTypes::LandMorning] ||
@enctypes[EncounterTypes::LandDay] ||
@enctypes[EncounterTypes::LandNight]) ? true : false
end
def isWater?
return false if @density==nil
return @enctypes[EncounterTypes::Water] ? true : false
end
def pbEncounterType
if $PokemonGlobal && $PokemonGlobal.surfing
return EncounterTypes::Water
elsif self.isCave?
return EncounterTypes::Cave
elsif self.isMetalFloor?
return EncounterTypes::MetalFloor
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 isEncounterPossibleHere?
if $PokemonGlobal && $PokemonGlobal.surfing
return true
elsif PBTerrain.isIce?(pbGetTerrainTag($game_player))
return false
elsif self.isCave?
return true
elsif self.isMetalFloor?
return pbGetTerrainTag($game_player)==PBTerrain::MetalFloor
elsif self.isGrass?
return PBTerrain.isGrass?($game_map.terrain_tag($game_player.x,$game_player.y))
end
return false
end
def setup(mapID)
@density=nil
@stepcount=0
@enctypes=[]
begin
data=load_data("Data/encounters.dat")
if data.is_a?(Hash) && data[mapID]
@density=data[mapID][0]
@enctypes=data[mapID][1]
else
@density=nil
@enctypes=[]
end
rescue
@density=nil
@enctypes=[]
end
end
def pbMapHasEncounter?(mapID,enctype)
data=load_data("Data/encounters.dat")
if data.is_a?(Hash) && data[mapID]
enctypes=data[mapID][1]
density=data[mapID][0]
else
return false
end
return false if density==nil || enctype<0
return enctypes[enctype] ? true : false
end
def pbMapEncounter(mapID,enctype)
if enctype<0 || enctype>EncounterTypes::EnctypeChances.length
raise ArgumentError.new(_INTL("Encounter type out of range"))
end
data=load_data("Data/encounters.dat")
if data.is_a?(Hash) && data[mapID]
enctypes=data[mapID][1]
else
return nil
end
return nil if enctypes[enctype]==nil
chances=EncounterTypes::EnctypeChances[enctype]
chancetotal=0
chances.each {|a| chancetotal+=a}
rnd=rand(chancetotal)
chosenpkmn=0
chance=0
for i in 0...chances.length
chance+=chances[i]
if rnd<chance
chosenpkmn=i
break
end
end
encounter=enctypes[enctype][chosenpkmn]
level=encounter[1]+rand(1+encounter[2]-encounter[1])
return [encounter[0],level]
end
def pbEncounteredPokemon(enctype,tries=1)
if enctype<0 || enctype>EncounterTypes::EnctypeChances.length
raise ArgumentError.new(_INTL("Encounter type out of range"))
end
return nil if @enctypes[enctype]==nil
encounters=@enctypes[enctype]
chances=EncounterTypes::EnctypeChances[enctype]
firstpoke=$Trainer.firstParty
if firstpoke && !firstpoke.isEgg? && rand(2)==0
if isConst?(firstpoke.ability,PBAbilities,:STATIC)
newencs=[]; newchances=[]
dexdata=pbOpenDexData
for i in 0...encounters.length
pbDexDataOffset(dexdata,encounters[i][0],8)
t1=dexdata.fgetb
t2=dexdata.fgetb
if isConst?(t1,PBTypes,:ELECTRIC) || isConst?(t2,PBTypes,:ELECTRIC)
newencs.push(encounters[i])
newchances.push(chances[i])
end
end
dexdata.close
if newencs.length>0
encounters=newencs
chances=newchances
end
end
if isConst?(firstpoke.ability,PBAbilities,:MAGNETPULL)
newencs=[]; newchances=[]
dexdata=pbOpenDexData
for i in 0...encounters.length
pbDexDataOffset(dexdata,encounters[i][0],8)
t1=dexdata.fgetb
t2=dexdata.fgetb
if isConst?(t1,PBTypes,:STEEL) || isConst?(t2,PBTypes,:STEEL)
newencs.push(encounters[i])
newchances.push(chances[i])
end
end
dexdata.close
if newencs.length>0
encounters=newencs
chances=newchances
end
end
end
chancetotal=0
chances.each {|a| chancetotal+=a}
rnd=0
tries.times do
r=rand(chancetotal)
rnd=r if rnd<r
end
chosenpkmn=0
chance=0
for i in 0...chances.length
chance+=chances[i]
if rnd<chance
chosenpkmn=i
break
end
end
encounter=encounters[chosenpkmn]
return nil if !encounter
level=encounter[1]+rand(1+encounter[2]-encounter[1])
if $Trainer.firstParty && !$Trainer.firstParty.isEgg? &&
(isConst?($Trainer.firstParty.ability,PBAbilities,:HUSTLE) ||
isConst?($Trainer.firstParty.ability,PBAbilities,:VITALSPIRIT) ||
isConst?($Trainer.firstParty.ability,PBAbilities,:PRESSURE)) &&
rand(2)==0
level2=encounter[1]+rand(1+encounter[2]-encounter[1])
level=[level,level2].max
end
if $PokemonMap.blackFluteUsed && USENEWBATTLEMECHANICS
level=[level+1+rand(3),PBExperience::MAXLEVEL].min
elsif $PokemonMap.whiteFluteUsed && USENEWBATTLEMECHANICS
level=[level-1-rand(3),1].max
end
return [encounter[0],level]
end
def pbCanEncounter?(encounter)
return false if $game_system.encounter_disabled
return false if !encounter || !$Trainer
return false if $DEBUG && Input.press?(Input::CTRL)
if !pbPokeRadarOnShakingGrass
return false if $PokemonGlobal.repel>0 && $Trainer.ablePokemonCount>0 &&
encounter[1]<=$Trainer.ablePokemonParty[0].level
end
return true
end
def pbGenerateEncounter(enctype)
if enctype<0 || enctype>EncounterTypes::EnctypeChances.length
raise ArgumentError.new(_INTL("Encounter type out of range"))
end
return nil if @density==nil
return nil if @density[enctype]==0 || !@density[enctype]
return nil if @enctypes[enctype]==nil
@stepcount+=1
return nil if @stepcount<=3 # Check three steps after battle ends
encount=@density[enctype]*16
if $PokemonGlobal.bicycle
encount=(encount*0.8)
end
if $PokemonMap.blackFluteUsed && !USENEWBATTLEMECHANICS
encount=(encount/2)
elsif $PokemonMap.whiteFluteUsed && !USENEWBATTLEMECHANICS
encount=(encount*1.5)
end
firstpoke=$Trainer.firstParty
if firstpoke && !firstpoke.isEgg?
if isConst?(firstpoke.item,PBItems,:CLEANSETAG)
encount=(encount*2/3)
elsif isConst?(firstpoke.item,PBItems,:PUREINCENSE)
encount=(encount*2/3)
else # Ignore ability effects if an item effect applies
if isConst?(firstpoke.ability,PBAbilities,:STENCH)
encount=(encount/2)
elsif isConst?(firstpoke.ability,PBAbilities,:WHITESMOKE)
encount=(encount/2)
elsif isConst?(firstpoke.ability,PBAbilities,:QUICKFEET)
encount=(encount/2)
elsif isConst?(firstpoke.ability,PBAbilities,:SNOWCLOAK) &&
($game_screen.weather_type==PBFieldWeather::Snow ||
$game_screen.weather_type==PBFieldWeather::Blizzard)
encount=(encount/2)
elsif isConst?(firstpoke.ability,PBAbilities,:SANDVEIL) &&
$game_screen.weather_type==PBFieldWeather::Sandstorm
encount=(encount/2)
elsif isConst?(firstpoke.ability,PBAbilities,:SWARM)
encount=(encount*1.5)
elsif isConst?(firstpoke.ability,PBAbilities,:ILLUMINATE)
encount=(encount*2)
elsif isConst?(firstpoke.ability,PBAbilities,:ARENATRAP)
encount=(encount*2)
elsif isConst?(firstpoke.ability,PBAbilities,:NOGUARD)
encount=(encount*2)
end
end
end
return nil if rand(180*16)>=encount
encpoke=pbEncounteredPokemon(enctype)
if encpoke && firstpoke && !firstpoke.isEgg?
if isConst?(firstpoke.ability,PBAbilities,:INTIMIDATE) ||
isConst?(firstpoke.ability,PBAbilities,:KEENEYE)
if encpoke[1]<=firstpoke.level-5 && rand(2)==0
encpoke=nil
end
end
end
return encpoke
end
end
Last edited by a moderator: