Luka S.J.

March 18th, 2011, 3:44 AM

Are you making your Pokemon game with RMXP and P.Essentials? Do you have loads of rebattles with the same trainer, where the trainer might have the same Pokemon, but they'd just be a different level? Or do you want to be able to rebattle a trainer, and have their Pokemon become stronger or weaker without creating a new PBS entry? There is a very simple solution for you, and it goes like this. Go to PokemonUtilities script and anywhere (outside a def of course) place the following code:

def pbLevelModifier(type,factor=1)

@levels=[]

i=0

($Trainer.party.length).times do

@levels.push($Trainer.party[i].level)

i+=1

end

@maxlevel=@levels.max

@sum=$Trainer.party[0].level

i=1

($Trainer.party.length-1).times do

@sum+=$Trainer.party[i].level

i+=1

end

@averagelevel=@sum/($Trainer.party.length)

if type=="max"

level=@maxlevel*factor

elsif type=="avg"

level=@averagelevel*factor

end

return level

end

The way you would use this is as follows: When creating a wild Pokemon Battle

pbWildBattle(species, pbLevelModifier(type,factor))

Where type should either be "max" (to find the highest party level) or "avg" (to find the average party level). Quotation marks around the types are needed! The factor value is optional if wanting to multiply the returned level by the factor percentage (where 0.01 is 1% and 1.00 is 100%)

If you'd like to place it within trainer battles, you'll have to go into PokemonTrainers, and replace

level=poke[1]

by

if $game_switches[X]==true

level=pbLevelModifier(type,factor)

else

level=poke[1]

end

Where the switch X would be your trigger for level calculations. You can play around with the scripts to adjust it any way you want, but this is just a very basic method to return either the maximum level, or the average level.

def pbLevelModifier(type,factor=1)

@levels=[]

i=0

($Trainer.party.length).times do

@levels.push($Trainer.party[i].level)

i+=1

end

@maxlevel=@levels.max

@sum=$Trainer.party[0].level

i=1

($Trainer.party.length-1).times do

@sum+=$Trainer.party[i].level

i+=1

end

@averagelevel=@sum/($Trainer.party.length)

if type=="max"

level=@maxlevel*factor

elsif type=="avg"

level=@averagelevel*factor

end

return level

end

The way you would use this is as follows: When creating a wild Pokemon Battle

pbWildBattle(species, pbLevelModifier(type,factor))

Where type should either be "max" (to find the highest party level) or "avg" (to find the average party level). Quotation marks around the types are needed! The factor value is optional if wanting to multiply the returned level by the factor percentage (where 0.01 is 1% and 1.00 is 100%)

If you'd like to place it within trainer battles, you'll have to go into PokemonTrainers, and replace

level=poke[1]

by

if $game_switches[X]==true

level=pbLevelModifier(type,factor)

else

level=poke[1]

end

Where the switch X would be your trigger for level calculations. You can play around with the scripts to adjust it any way you want, but this is just a very basic method to return either the maximum level, or the average level.