- 7
- Posts
- 8
- Years
- Seen Nov 19, 2020
I'm using an essentials script made by umbreon and modified by me to randomize the pokemon roughly around the same strength
It seems to randomize trainers and triggered battles just fine but I crash with an error when using pbAddPokemon, the original unmodified script crashes as well though with a different error (something along the lines of pokemon 721 being invalid)
edit: it crashes even with the switch turned off, so that inner loop isn't even touched and it still crashes. Just confused as too why
Code:
Here's the error
Edit: Thanks to whoever changed the title, original may have been a little vague
It seems to randomize trainers and triggered battles just fine but I crash with an error when using pbAddPokemon, the original unmodified script crashes as well though with a different error (something along the lines of pokemon 721 being invalid)
edit: it crashes even with the switch turned off, so that inner loop isn't even touched and it still crashes. Just confused as too why
Code:
Code:
module RandomizedChallenge
Switch = 36 # switch ID to randomize a pokemon, if it's on then ALL
# pokemon will be randomized. No exceptions.
#
Range = 0.05 # Percentage of difference between the stats use 0.05 format
end
######################### End of settings, edit below at your own risk
class PokeBattle_Pokemon
alias randomized_init initialize
def initialize(species,level,player=nil,withMoves=true)
statTotal = getBaseStatTotal(species)
if $game_switches && $game_switches[RandomizedChallenge::Switch]
generatedMon = rand(PBSpecies.maxValue - 1) + 1
randTotal = getBaseStatTotal(generatedMon)
while (randTotal+225) <= (statTotal+225)*(1-RandomizedChallenge::Range) || (randTotal+225) >= (statTotal+225)*(1+RandomizedChallenge::Range)
generatedMon = rand(PBSpecies.maxValue - 1) + 1
randTotal = getBaseStatTotal(generatedMon)
if randTotal == 236
randTotal *= 2;
end
end
randomized_init(generatedMon, level, player, withMoves)
end
end
end
def getBaseStatTotal(species)
dexdata=pbOpenDexData
pbDexDataOffset(dexdata,species,10)
bs=[
dexdata.fgetb, # HP
dexdata.fgetb, # Attack
dexdata.fgetb, # Defense
dexdata.fgetb, # Speed
dexdata.fgetb, # Special Attack
dexdata.fgetb # Special Defense
]
dexdata.close
return bs.inject{|sum,x| sum + x }
end
Here's the error
Code:
---------------------------
Pokemon Essentials Gen 6
---------------------------
Exception: RuntimeError
Message: Script error within event 2, map 33 (Canvas Town):
Exception: TypeError
Message: Section041:559:in `[]'no implicit conversion from nil to integer
***Full script:
pbAddPokemon(:PIKACHU,20)
Interpreter:243:in `pbExecuteScript'
Intl_Messages:559:in `get'
Intl_Messages:669:in `get'
Intl_Messages:706:in `pbGetMessage'
PBSpecies:724:in `getName'
PSystem_Utilities:1742:in `pbAddPokemon'
(eval):1:in `pbExecuteScript'
Interpreter:1606:in `eval'
Interpreter:243:in `pbExecuteScript'
Interpreter:1606:in `command_355'
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:103:in `update'
Scene_Map:101:in `loop'
Scene_Map:114:in `update'
Scene_Map:68:in `main'
This exception was logged in
C:\Users\Krig\Saved Games/Pokemon Essentials Gen 6/errorlog.txt.
Press Ctrl+C to copy this message to the clipboard.
---------------------------
OK
---------------------------
Edit: Thanks to whoever changed the title, original may have been a little vague
Last edited: