• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[Scripting Question] Wild pokes with specific moves

153
Posts
4
Years
  • Age 36
  • Seen Feb 4, 2020
Hello everyone it's me again!

I made this code copying the existing one so I can have a wild encounter adapting to my pokes level but with higher lvl (used for bosses). Then I wanted to add that if the encounter is a SCIZOR then it should learn some moves (because depending on the level it will be defied I'm afraid it has only bad moves).

Events.onWildPokemonCreate+=proc {|sender,e|
pokemon=e[0]
if $game_switches[89]
newlevel=pbBalancedLevel($Trainer.party) + 2 + rand(5)
newlevel=1 if newlevel<1
newlevel=PBExperience::MAXLEVEL if newlevel>PBExperience::MAXLEVEL
pokemon.level=newlevel
pokemon.calcStats
pokemon.resetMoves
end
if pokemon.species=[212]
pokemon.pbLearnMove(:VOLTTACKLE)
pokemon.pbLearnMove(:THUNDER)
pokemon.pbLearnMove(:FLAMETHROWER)
pokemon.pbLearnMove(:TACKLE)


end
}
This is the error I get:
---------------------------
Pokemon Essentials
---------------------------
[Pokémon Essentials version 17]

Exception: RuntimeError

Message: Script error within event 27 (coords 30,4), map 127 (Forêt):

Exception: TypeError

Message: MiscData:165:in `-'cannot convert Fixnum into Array

***Full script:

pbWildBattle(:SCIZOR,5,1,false,true)

Interpreter:243:in `pbExecuteScript'

MiscData:165:in `pbDexDataOffset'

PokeBattle_Pokemon:144:in `growthrate'

PokeBattle_Pokemon:123:in `level'

PokeBattle_Battler:209:in `__shadow_pbInitPokemon'

Pokemon_ShadowPokemon:525:in `pbInitPokemon'

PokeBattle_Battler:510:in `pbInitialize'

PokeBattle_Battle:2364:in `pbStartBattleCore'

PokeBattle_Battle:2340:in `pbStartBattle'

PField_Battles:98:in `pbWildBattle'



Interpreter:276:in `pbExecuteScript'

Interpreter:794:in `command_111'

Interpreter:320:in `execute_command'

Interpreter:193:in `update'

Interpreter:106:in `loop'

Interpreter:198:in `update'

Scene_Map:161:in `follow_update'

Scene_Map:159:in `loop'

Scene_Map:168:in `follow_update'

Follow:1551:in `update'


I don't understand which fix number is trying to be converted into array. Thanks in advance
 
1,680
Posts
8
Years
  • Age 23
  • Seen today
the botched line is this here
pokemon.species=[212]
instead of checking if the species is equal to 212, you've set it to an array containing 212. this breaks basically everything.
pokemon.species==212 is what you're looking for.
though you may want to move that whole if block inside the other one, else it'll always set all 212's to have the same moveset.
 
153
Posts
4
Years
  • Age 36
  • Seen Feb 4, 2020
Incredibly clear, thanks a lot.

Yes I'll move it in the other one.
 

WolfPP

Spriter/ Pixel Artist
1,309
Posts
5
Years
Well, i made this (item, ability, EV and IV included. Also, to trigger you need to put Switch Number 100 ON):
Spoiler:
 
153
Posts
4
Years
  • Age 36
  • Seen Feb 4, 2020
That is really usefull thank you.
I have a new problem with this code. I wanted to add that depending on the balanced party level the difference in level with the new encounter increases. For an unknown reason the level is not modified at all anymore. I don't understand where the error is (I don't get any error message, the level stays 5 if it's 5 in the event). (Ichecked that the switch was on using debug)
Events.onWildPokemonCreate+=proc {|sender,e|
pokemon=e[0]
if $game_switches[89]
if pbBalancedLevel($Trainer.party)<=20
newlevel=pbBalancedLevel($Trainer.party) + 5
newlevel=1 if newlevel<1
elsif pbBalancedLevel($Trainer.party)<=30
newlevel=pbBalancedLevel($Trainer.party) + 7
elsif pbBalancedLevel($Trainer.party)<=40
newlevel=pbBalancedLevel($Trainer.party) + 9
elsif pbBalancedLevel($Trainer.party)<=60
newlevel=pbBalancedLevel($Trainer.party) + 12
elsif pbBalancedLevel($Trainer.party)<=80
newlevel=pbBalancedLevel($Trainer.party) + 15
else
newlevel=pbBalancedLevel($Trainer.party) + 20
newlevel=PBExperience::MAXLEVEL if newlevel>PBExperience::MAXLEVEL
pokemon.level=newlevel
pokemon.calcStats
pokemon.resetMoves
end
if pokemon.species=212
pokemon.pbLearnMove(:METALCLAW)
pokemon.pbLearnMove(:ICEPUNCH)
pokemon.pbLearnMove(:THUNDERPUNCH)
end
end

}
 
153
Posts
4
Years
  • Age 36
  • Seen Feb 4, 2020
I fixed it with this code if someone is interested by this.

if $game_switches[89] and if pbBalancedLevel($Trainer.party)>1
newlevel=pbBalancedLevel($Trainer.party) + 1
if pbBalancedLevel($Trainer.party)>10
newlevel=pbBalancedLevel($Trainer.party) + 2
end
if pbBalancedLevel($Trainer.party)>20
newlevel=pbBalancedLevel($Trainer.party) + 4
end
if pbBalancedLevel($Trainer.party)>30
newlevel=pbBalancedLevel($Trainer.party) + 6
end
if pbBalancedLevel($Trainer.party)>40
newlevel=pbBalancedLevel($Trainer.party) + 8
end
if pbBalancedLevel($Trainer.party)>50
newlevel=pbBalancedLevel($Trainer.party) + 10
end
if pbBalancedLevel($Trainer.party)>60
newlevel=pbBalancedLevel($Trainer.party) + 12
end
if pbBalancedLevel($Trainer.party)>70
newlevel=pbBalancedLevel($Trainer.party) + 14
end
if pbBalancedLevel($Trainer.party)>80
newlevel=pbBalancedLevel($Trainer.party) + 16
end
if pbBalancedLevel($Trainer.party)>90
newlevel=pbBalancedLevel($Trainer.party) + 10
end
end
newlevel=PBExperience::MAXLEVEL if newlevel>PBExperience::MAXLEVEL
pokemon.level=newlevel

I don't know why the previous code didn't work so if someone has an idea it would make me happy :)
 

Luka S.J.

Jealous Croatian
1,270
Posts
15
Years
If you're still looking for explanation, I've added some comments and fixed up parts of your code from two posts above this one
Code:
# indenting your code will not only clean it up visually, but allow you to
# more easily identify which parts of the code belong to which block of
# logic
Events.onWildPokemonCreate += proc{|sender,e|
  pokemon = e[0]
  if $game_switches[89]
    if pbBalancedLevel($Trainer.party) <= 20
      newlevel = pbBalancedLevel($Trainer.party) + 5
      newlevel = 1 if newlevel < 1
    elsif pbBalancedLevel($Trainer.party) <= 30
      newlevel = pbBalancedLevel($Trainer.party) + 7
    elsif pbBalancedLevel($Trainer.party) <= 40
      newlevel = pbBalancedLevel($Trainer.party) + 9
    elsif pbBalancedLevel($Trainer.party) <= 60
      newlevel = pbBalancedLevel($Trainer.party) + 12
    elsif pbBalancedLevel($Trainer.party) <= 80
      newlevel = pbBalancedLevel($Trainer.party) + 15
    else
      newlevel = pbBalancedLevel($Trainer.party) + 20
    # newlevel = PBExperience::MAXLEVEL if newlevel > PBExperience::MAXLEVEL
      # the Pokemon levels and stats will only get calculated in this branch
      # of the conditional statement, hence they will not be applied if your
      # other conditions are met. You want to take this out of here
      # and apply it post the conditional branch
    # pokemon.level = newlevel
    # pokemon.calcStats
    # pokemon.resetMoves
    end
    newlevel = PBExperience::MAXLEVEL if newlevel > PBExperience::MAXLEVEL
    pokemon.level = newlevel
    pokemon.calcStats
    pokemon.resetMoves
    # as Vendily mentioned the '=' operator assigns whatever value is defined
    # on the right side to the variable on the left
  # if pokemon.species = 212
    # hence your if statement here is incorrect, as you should be checking
    # whether or not the two variables are of equal value
    # you do this with the '==' operator (don't miss out on the double equals sign)
    # so your condition should look like the following
    if pokemon.species == 212
      pokemon.pbLearnMove(:METALCLAW)
      pokemon.pbLearnMove(:ICEPUNCH)
      pokemon.pbLearnMove(:THUNDERPUNCH)
    end
  end
}
 
Last edited:
153
Posts
4
Years
  • Age 36
  • Seen Feb 4, 2020
Always looking for explanation, especially when they lead to a better understanding.
Thank you very much for your answer.
I'm happy I found this forum but sad I did a bit late. Looks like many of you retired a bit. It's even nicer of you to come back here and check on these newbie messages.
 
Back
Top