- 1,224
- Posts
- 11
- Years
- Omnipresence
- Seen Aug 8, 2023
Add this as a new section above the Main
Make sure to add the difficulty variable to your options (basically a copy+paste of the other options, make sure to initialize the variables. You may have to start a new game.)
On easy difficulty, it does nothing. On medium difficulty it increases trainer pokemon's levels (scaling according to their current level), and has the possibility of adding another pokemon to the trainer's party, assuming the trainer's pokemon average level 30. The pokemon it adds will be of similar BST to the average of the trainer's current mons, and it will attempt to add a similar typed pokemon if possible(most common type occurrence). On hard difficulty it is the same thing, but with slightly higher levels, no level requirement to add pokemon to the trainer's party, and it can add up to two pokemon as opposed to one.
Requires v15+
Code:
class PokeBattle_Trainer
alias diff_skill skill
def skill
ret=diff_skill
case $PokemonSystem.difficulty
when 0
#do nothing
when 1
case ret
when 0
ret+=5
when PBTrainerAI.minimumSkill...PBTrainerAI.mediumSkill
ret = PBTrainerAI.mediumSkill
when PBTrainerAI.mediumSkill...PBTrainerAI.highSkill
ret = PBTrainerAI.highSkill
else
ret = PBTrainerAI.bestSkill
end
when 2
case ret
when 0
ret = PBTrainerAI.mediumSkill
when PBTrainerAI.minimumSkill...PBTrainerAI.mediumSkill
ret = PBTrainerAI.highSkill
when PBTrainerAI.mediumSkill...PBTrainerAI.highSkill
ret = PBTrainerAI.bestSkill
else
ret = PBTrainerAI.bestSkill
end
end
return ret
end
end
Events.onTrainerPartyLoad+=proc {|sender,e|
if e[0] # Trainer data should exist to be loaded, but may not exist somehow
trainer=e[0][0] # A PokeBattle_Trainer object of the loaded trainer
items=e[0][1] # An array of the trainer's items they can use
party=e[0][2] # An array of the trainer's Pokémon
case $PokemonSystem.difficulty
when 0
#do nothing
when 1
levels=0
types=[]
stats=[]
for i in 0...party.length
types.push(party[i].type1)
types.push(party[i].type2)
bst=(party[i].baseStats).dup
bst=bst.inject{|sum,x| sum + x }
stats.push(bst)
levelchange=party[i].level/10.floor
levelchange*=2 if levelchange<3
party[i].level+=levelchange
party[i].level+=rand(3)
party[i].level=MAXIMUMLEVEL if party[i].level>MAXIMUMLEVEL
party[i].level=1 if party[i].level<1
party[i].calcStats
levels+=party[i].level
movelist=party[i].getMoveList
moves=[]
for k in 0...movelist.length
for j in 0...party[i].moves.length
if movelist[k][1]==party[i].moves[j]
moves.push(party[i].moves[j])
end
end
end
moves.uniq!
party[i].resetMoves if moves.length==3
end
levels=levels/party.length
if party.length<6 && levels>30 && rand(100)<75
#Add another strong pokemon
count = Hash.new(0)
types.each {|word| count[word] += 1}
type=(count.sort_by { |k,v| v }.last) #Type to look for
bst=(stats.inject{|sum,x| sum + x })/party.length #BST to look for
acceptable_pokes=[]
backup_pokes=[]
scn=PokemonPokedexScene.new
dex=scn.pbGetDexList #Get all pokemon in region
for i in 0...dex.length
dexdata=pbOpenDexData
pbDexDataOffset(dexdata,dex[i][0],8)
type1=dexdata.fgetb
type2=dexdata.fgetb
curstats=[
dexdata.fgetb, # HP
dexdata.fgetb, # Attack
dexdata.fgetb, # Defense
dexdata.fgetb, # Speed
dexdata.fgetb, # Special Attack
dexdata.fgetb # Special Defense
]
dexdata.close
curstats=(curstats.inject{|sum,x| sum + x })
if (-20..20).include?(bst-curstats)
if type1==type || type2==type
acceptable_pokes.push(dex[i][0]) #Pokemon's number
else
backup_pokes.push(dex[i][0])
end
end
end
#remove legendaries here, has to be specified
if acceptable_pokes.length==0
if backup_pokes.length>0
p=PokeBattle_Pokemon.new(backup_pokes[rand(backup_pokes.length)],levels,trainer)
party.push(p)
end
else
p=PokeBattle_Pokemon.new(acceptable_pokes[rand(acceptable_pokes.length)],levels,trainer)
party.push(p)
end
end
when 2
levels=0
types=[]
stats=[]
for i in 0...party.length
types.push(party[i].type1)
types.push(party[i].type2)
bst=(party[i].baseStats).dup
bst=bst.inject{|sum,x| sum + x }
stats.push(bst)
levelchange=party[i].level/10.floor
if levelchange<6
levelchange*=2
levelchange+=rand(3)
else
levelchange+=rand(5)
end
party[i].level+=levelchange
party[i].level=MAXIMUMLEVEL if party[i].level>MAXIMUMLEVEL
party[i].level=1 if party[i].level<1
party[i].calcStats
levels+=party[i].level
movelist=party[i].getMoveList
moves=[]
for k in 0...movelist.length
for j in 0...party[i].moves.length
if movelist[k][1]==party[i].moves[j]
moves.push(party[i].moves[j])
end
end
end
moves.uniq!
party[i].resetMoves if moves.length==4
end
levels=levels/party.length
if party.length<6 && rand(100)<75
#Add another strong pokemon
count = Hash.new(0)
types.each {|word| count[word] += 1}
type=(count.sort_by { |k,v| v }.last) #Type to look for
bst=(stats.inject{|sum,x| sum + x })/party.length #BST to look for
acceptable_pokes=[]
backup_pokes=[]
scn=PokemonPokedexScene.new
dex=scn.pbGetDexList #Get all pokemon in region
for i in 0...dex.length
dexdata=pbOpenDexData
pbDexDataOffset(dexdata,dex[i][0],8)
type1=dexdata.fgetb
type2=dexdata.fgetb
curstats=[
dexdata.fgetb, # HP
dexdata.fgetb, # Attack
dexdata.fgetb, # Defense
dexdata.fgetb, # Speed
dexdata.fgetb, # Special Attack
dexdata.fgetb # Special Defense
]
dexdata.close
curstats=(curstats.inject{|sum,x| sum + x })
if (-20..20).include?(bst-curstats)
if type1==type || type2==type
acceptable_pokes.push(dex[i][0]) #Pokemon's number
else
backup_pokes.push(dex[i][0])
end
end
end
#remove legendaries here, has to be specified
if acceptable_pokes.length==0
if backup_pokes.length>0
p=PokeBattle_Pokemon.new(backup_pokes[rand(backup_pokes.length)],levels,trainer)
party.push(p)
end
else
p=PokeBattle_Pokemon.new(acceptable_pokes[rand(acceptable_pokes.length)],levels,trainer)
party.push(p)
end
if party.length<6 && rand(100)<50
if acceptable_pokes.length==0
if backup_pokes.length>0
p=PokeBattle_Pokemon.new(backup_pokes[rand(backup_pokes.length)],levels,trainer)
party.push(p)
end
else
p=PokeBattle_Pokemon.new(acceptable_pokes[rand(acceptable_pokes.length)],levels,trainer)
party.push(p)
end
end
end
end
end
}
Make sure to add the difficulty variable to your options (basically a copy+paste of the other options, make sure to initialize the variables. You may have to start a new game.)
On easy difficulty, it does nothing. On medium difficulty it increases trainer pokemon's levels (scaling according to their current level), and has the possibility of adding another pokemon to the trainer's party, assuming the trainer's pokemon average level 30. The pokemon it adds will be of similar BST to the average of the trainer's current mons, and it will attempt to add a similar typed pokemon if possible(most common type occurrence). On hard difficulty it is the same thing, but with slightly higher levels, no level requirement to add pokemon to the trainer's party, and it can add up to two pokemon as opposed to one.
Requires v15+
Last edited: