• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Dawn, Gloria, Juliana, or Summer - which Pokémon protagonist is your favorite? Let us know by voting in our poll!
  • 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] Triggering a form change when using a move of certain type?

  • 10
    Posts
    5
    Years
    • Seen Feb 29, 2020
    Hi, I'm trying to make a custom ability that changes a pokemon's form when it uses a move of a certain type. I put this code here in pokebattle_battler, in def pbcheckform, but instead it doesn't do anything when the pokemon use the move in battle; the pokemon didn't change the form whatsoever. Can someone point out my mistake here? Thank you in advance.

    if isConst?(self.species, PBSpecies, :CUSTOMPOKEMON) && !self.isFainted?
    if isConst?(self.ability, PBAbilities, :CUSTOMABILITY)
    if self.form != 1 && !thismove.nil? && isConst?(thismove.type,PBTypes,:NORMAL)
    self.form = 1 ; transformed = true
    elsif self.form !=2 && !thismove.nil? && isConst?(thismove.type,PBTypes,:FIGHTING)
    self.form = 2 ; transformed = true
    elsif self.form !=3 && !thismove.nil? && isConst?(thismove.type,PBTypes,:GRASS)
    self.form = 3 ; transformed = true
    elsif self.form !=4 && !thismove.nil? && isConst?(thismove.type,PBTypes,:FIRE)
    self.form = 4 ; transformed = true
    elsif self.form !=5 && !thismove.nil? && isConst?(thismove.type,PBTypes,:WATER)
    self.form = 5 ; transformed = true
    elsif self.form !=6 && !thismove.nil? && isConst?(thismove.type,PBTypes,:GHOST)
    self.form = 6 ; transformed = true
    end
    end
    end
     
    I don't think thismove is defined in pbCheckForm, and so thismove.nil? is always true?
     
    Can you explain more about thismove.nil? Is always true?
    And about this code, I made it from tweaking the code used for Aegislash's form change, and it works in game so it should be defined...I think?
     
    Stance Change happens in pbUseMove, which (as the name suggests) has access to the move being used. IIRC pbCheckForm happens at the end of turn (maybe others), where there obviously isn't a current move. So you're referencing an undefined variable, and what Ruby (unhelpfully, IMO) gives you is a nil.
     
    Hm, that makes sense...thanks for explaining that to me. So with that the case, I should move the code to pbUseMove? And is there something I can fix in the code? I'm still new to this so I usually write code by taking a look at existing ones.
     
    Yeah, I think pbUseMove is the right place for your ability. I'd just stick it after Stance Change's code, since that's what you've based it on :)

    As for making it work if it doesn't already… I guess just make sure you do everything Stance Change does and you should be fine!
     
    Okay, so I modified the stance change code, and put it in pbUseMove as you advised, and nothing still happened in game.
    Then out of curiosity (and frustration) I assigned the effect to an already existing ability.
    It worked now.
    I don't really understand. Why did it only work when I assign it to an already existing ability? Did something go wrong when rpg maker was trying to compile the pbs?
     
    Hmm, yeah my guesses are 1) Essentials hasn't recompiled your abilities PBS (fix: hold Ctrl while starting a playtest), 2) You've misspelled the internal name in your PBS or scripts (i.e. there's a mismatch), or 3) Your Pokémon doesn't have that ability.
     
    Thank you Vendily, and sorry for the problem ^^

    Huh, I forgot you can force recompile with ctrl. Anyway, I've checked the pbs and the internal names many times, so I'm fairly certain I don't make a mistake there. Thank you for your help!
     
    Back
    Top