A script with some code that allows you to have a lot more control over encounters.
- You Get To Pick The Probability Of Pokemon Appearing Not Only Each Individual Map, But Also Each Encounter Type
- You Get To Choose Which Levels Each Pokemon Appears At, Just Like In Normal Encounters
- For Any You Do Not Fill Out, The Standard Encounters Will Be There Instead
- Code Written With Speed In Mind, Being As Efficient As Possible To Avoid Lag
- No Graphics Involved. Simply Add The Script Above Main And Do One Small Thing.
- Really Cool Anyway!
Script's here! :
- You Get To Pick The Probability Of Pokemon Appearing Not Only Each Individual Map, But Also Each Encounter Type
- You Get To Choose Which Levels Each Pokemon Appears At, Just Like In Normal Encounters
- For Any You Do Not Fill Out, The Standard Encounters Will Be There Instead
- Code Written With Speed In Mind, Being As Efficient As Possible To Avoid Lag
- No Graphics Involved. Simply Add The Script Above Main And Do One Small Thing.
- Really Cool Anyway!
Script's here! :
Code:
#===============================================================================
# Cool Pokemon Encounters
# by Swdfm
#===============================================================================
#
# To use, do the following:
# - On Script PField_Field,
# delete or comment out all of def bBattleOnStepTaken(repel=false)
# - On the PBS file, you must still fill in the data, but you
# can fill it with what you want. eg. RATTATA, 1 the whole time.
#
#===============================================================================
ENCOUNTERMAPS = 13 #Change This To An Empty Game Variable Of Your Choosing
ENCOUNTERSWITCH = 7 #Change This To An Empty Game Switch Of Your Choosing
LEVELVARIANCE = 2 #The Range Of Levels Of Which Pokemon Appear
#eg. At a MINLEVEL of 5,
# A LEVELVARIANCE of 2 would give Level 5-7
# A LEVELVARIANCE of 4 would give Level 5-9 etc.
#There is an equal chance of each level appearing
def pbEncountersArray
#Fill This Array With Your Chosen Encounters
#The Probability Is Ratio Based, And Does Not Need To Add Up To 100
return [
[1, #MAPID
[EncounterTypes::Land,:RATTATA,10,2,:PIDGEY,20,3,:CATERPIE,10,5,],
#ENCOUNTERTYPE,SPECIES,PROBABILITY,MINLEVEL,SPECIES,PROBABILITY,MINLEVEL ETC.
[EncounterTypes::Water,:MAGIKARP,5,2,:GOLDEEN,20,10,:GOLDUCK,15,7]
],[2,
[EncounterTypes::Cave,:GEODUDE,40,2,:ZUBAT,20,3]
]
]
end
#===============================================================================
#
# No Need To Edit Past Here, Really!
#
#===============================================================================
def pbCalculateEncPokemon(array)
#Actual Formula To Determine Which Pokemon To Pick, Once Encounter Type Has
# Been Discovered
leng=(array.length/3)-1
pokearray=[]
probarray=[]
levelarray=[]
for i in 0...leng
pokearray.push(array[(3*i)+1])
probarray.push(array[(3*i)+2])
levelarray.push(array[(3*i)+3])
end
hundrednum=0
for i in probarray
hundrednum+=i
end
random=rand(hundrednum)
choice=0
hundrednum=0
hundrednum+=probarray[choice]
while hundrednum<random
hundrednum+=probarray[choice]
choice+=1
end
return [pokearray[choice],levelarray[choice]]
end
def pbDrawMapArray
#This Produces An Array Of Any Maps With Encounters
#This Speeds Things Up
array=[]
for i in pbEncountersArray
array.push(i[0])
end
$game_switches[ENCOUNTERSWITCH]=true
$game_variables[ENCOUNTERMAPS]=array
end
def pbWhereInMapArray?(map)
#This Checks That The Map In Question Is In The Encounters Array
#It Then Returns Where In The Produced Array (from pbDrawMapArray) The Map Is
#Also For Speed
pbDrawMapArray if !$game_switches[ENCOUNTERSWITCH]
ret=false
ret=true if pbGet(ENCOUNTERMAPS).include?(map)
if ret
for i in 0...pbGet(ENCOUNTERMAPS).length
return i if pbGet(ENCOUNTERMAPS)[i]==map
end
end
return -1
end
#A Revised Version Of The Original Code
def pbBattleOnStepTaken(repel=false)
return if $Trainer.ablePokemonCount==0
encounterType = $PokemonEncounters.pbEncounterType
return if encounterType<0
return if !$PokemonEncounters.isEncounterPossibleHere?
encounter = $PokemonEncounters.pbGenerateEncounter(encounterType)
encounter = EncounterModifier.trigger(encounter)
encounter = pbSwdfmEncounters(encounter,encounterType)
if $PokemonEncounters.pbCanEncounter?(encounter,repel)
$PokemonTemp.encounterType = encounterType
if !$PokemonTemp.forceSingleBattle && ($PokemonGlobal.partner ||
($Trainer.ablePokemonCount>1 && PBTerrain.isDoubleWildBattle?(pbGetTerrainTag) && rand(100)<30))
encounter2 = $PokemonEncounters.pbEncounteredPokemon(encounterType)
encounter2 = EncounterModifier.trigger(encounter2)
encounter2 = pbSwdfmEncounters(encounter2,encounterType)
pbDoubleWildBattle(encounter[0],encounter[1],encounter2[0],encounter2[1])
else
pbWildBattle(encounter[0],encounter[1])
end
$PokemonTemp.encounterType = -1
end
$PokemonTemp.forceSingleBattle = false
EncounterModifier.triggerEncounterEnd()
end
def pbSwdfmEncounters(encounter,encounterType)
#Changes Encounters To The Ones On The Table, If It Applies
arraypos=pbWhereInMapArray?($game_map.map_id)
return encounter if arraypos==-1
maparray=pbEncountersArray[arraypos]
leng=maparray.length-1
chosenone=-1
for i in 1...leng
chosenone=i if maparray[i][0]==encounterType
end
return encounter if chosenone==-1
encounter=pbCalculateEncPokemon(maparray[chosenone])
encounter[1]+=rand(LEVELVARIANCE)
encounter[1]=PBExperience::MAXLEVEL if encounter[1]>PBExperience::MAXLEVEL
return encounter
end