• 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] Editing Pokémon in a Double Battle Event Encounter [SOLVED]

7
Posts
7
Years
    • Seen Mar 1, 2017
    I'm a scripting super-newbie who's been doing my best to self-teach, and reaching out for help when I need it, and now's one of those times I could use a quick lesson.

    My end goal is to have an Event Encounter that is a double battle, with one wild Pokémon always being male and the other always being female.

    Looking at the "Modifying the Pokémon" section of the Essentials Wiki's Event Encounters page, I understand the concept of creating a switch and editing the PField_EncounterModifiers section of the script. What I need assistance with is how to make one thing happen to one Pokémon, and a different thing happen to the other.

    I tried the following:
    Code:
    Events.onWildPokemonCreate+=proc {|sender,e|
       pokemon=e[0]
       if $game_switches[61]
         pokemon1.makeMale
         pokemon2.makeFemale
       end
    }

    The error message I get when the event runs is as follows:
    Spoiler:


    The part of the error message reading "Message: Section104:20undefined local variable or method `pokemon1' for nil:NilClass" makes me figure that it's my naming of "pokemon1" and "pokemon2" that's incorrect, but I'm not sure where to find the proper way to refer to them.

    Any help would be appreciated. Thanks!
     
    Last edited:
    7
    Posts
    7
    Years
    • Seen Mar 1, 2017
    Thanks, Rot8er_ConeX. I should've known it wouldn't be that easy!

    Is there any chance it would be as simple as adding new comma-separated sections to def pbWildBattle and def pbDoubleWildBattle in the PField_Field script section? For instance, changing
    Code:
    def pbDoubleWildBattle(species1,level1,species2,level2,variable=nil,canescape=true,canlose=false)
    to
    Code:
    def pbDoubleWildBattle(species1,level1,[COLOR="Red"]gender1,[/COLOR]species2,level2,[COLOR="red"]gender2,[/COLOR]variable=nil,canescape=true,canlose=false)

    Or would I need to add other new pieces to the script to make changes like that work?
     
    824
    Posts
    8
    Years
  • Thanks, Rot8er_ConeX. I should've known it wouldn't be that easy!

    Is there any chance it would be as simple as adding new comma-separated sections to def pbWildBattle and def pbDoubleWildBattle in the PField_Field script section? For instance, changing
    Code:
    def pbDoubleWildBattle(species1,level1,species2,level2,variable=nil,canescape=true,canlose=false)
    to
    Code:
    def pbDoubleWildBattle(species1,level1,[COLOR="Red"]gender1,[/COLOR]species2,level2,[COLOR="red"]gender2,[/COLOR]variable=nil,canescape=true,canlose=false)

    Or would I need to add other new pieces to the script to make changes like that work?

    Do not add new arguments. Doing so means you would need to find every instance of the pbDoubleWildBattle function and edit it as well.

    However, since you found that function, might I suggest placing this below line 954:
    Code:
      if $game_switches[61]
        genwildpoke.makeMale
        genwildpoke2.makeFemale
      end
     
    7
    Posts
    7
    Years
    • Seen Mar 1, 2017
    Do not add new arguments. Doing so means you would need to find every instance of the pbDoubleWildBattle function and edit it as well.

    However, since you found that function, might I suggest placing this below line 954:
    Code:
      if $game_switches[61]
        genwildpoke.makeMale
        genwildpoke2.makeFemale
      end

    Hmm... I tried it and got an error message:

    Code:
    Exception: NameError
    
    Message: Section098:957:in `pbDoubleWildBattle'undefined local variable or method `genwildpoke' for #<Interpreter:0x9e57f60>

    (I did learn the term "argument" instead of "comma-separated section", though, so that's something! Can you tell how new I am to this?)
     
    824
    Posts
    8
    Years
  • Hmm... I tried it and got an error message:

    Code:
    Exception: NameError
    
    Message: Section098:957:in `pbDoubleWildBattle'undefined local variable or method `genwildpoke' for #<Interpreter:0x9e57f60>

    (I did learn the term "argument" instead of "comma-separated section", though, so that's something! Can you tell how new I am to this?)

    Hmm...what's your pbDoubleWildBattle look like? And could you highlight line 957?
     
    7
    Posts
    7
    Years
    • Seen Mar 1, 2017
    Spoiler:

    I put lines 956-959 in red; they're the ones you suggested adding. 957 specifically is genwildpoke.makeMale.

    By the way, thank you so much for taking the time to work through this with me. It's a lot more than I would have expected, and I'm very appreciative.
     
    824
    Posts
    8
    Years
  • Spoiler:

    I put lines 956-959 in red; they're the ones you suggested adding. 957 specifically is genwildpoke.makeMale.

    By the way, thank you so much for taking the time to work through this with me. It's a lot more than I would have expected, and I'm very appreciative.

    Okay. Take the two lines below the red, and move them up above the red. That should fix the problem
     
    7
    Posts
    7
    Years
    • Seen Mar 1, 2017
    I haven't tested it enough to know for sure that it's not just the natural probability of the Pokémon gender, but it didn't give an error message, and I tried switching it to have the first one female and the second one male, and they indeed swapped places in the battle, so I'm calling this a success.

    Thank you so much for your help! I've added a comment to these lines in the script crediting you.
     
    Back
    Top