• 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] Triggering a form change when using a move of certain type?

  • 10
    Posts
    4
    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
     
  • 1,403
    Posts
    10
    Years
    • Seen Apr 29, 2024
    I don't think thismove is defined in pbCheckForm, and so thismove.nil? is always true?
     
  • 10
    Posts
    4
    Years
    • Seen Feb 29, 2020
    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?
     
  • 1,403
    Posts
    10
    Years
    • Seen Apr 29, 2024
    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.
     
  • 10
    Posts
    4
    Years
    • Seen Feb 29, 2020
    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.
     
  • 1,403
    Posts
    10
    Years
    • Seen Apr 29, 2024
    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!
     
  • 10
    Posts
    4
    Years
    • Seen Feb 29, 2020
    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?
     
  • 1,403
    Posts
    10
    Years
    • Seen Apr 29, 2024
    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.
     
  • 10
    Posts
    4
    Years
    • Seen Feb 29, 2020
    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