The PokéCommunity Forums Fan Games Game Development Pokémon Essentials
Custom Scripts Question How to make a move trigger a form change?

Pokémon Essentials All questions and discussion about Pokémon Essentials, the Pokémon game kit for RPG Maker XP, go in here. Also contains links to the latest downloads and the Essentials Wiki.


Reply
 
Thread Tools
  #1    
Old March 29th, 2018 (9:11 AM). Edited March 29th, 2018 by Dinklebort.
Dinklebort Dinklebort is offline
     
    Join Date: Jul 2017
    Posts: 3
    Hello there, I've been trying to figure out how to make a Pokemon change form when it uses a specific move, like how Meloetta changes forms with Relic song, but it's not working.

    Here's how my script looks in Pokebattle_Battler:
    Spoiler:

    if isConst?(self.ability,PBAbilities,:CUSTOMABILITY) &&
    isConst?(self.species,PBSpecies,:CUSTOMPOKEMON) && hp>0
    if self.form == 0 && !thismove.nil? && thismove.id == 700
    self.form=1 #Form 2
    transformed=true
    end
    end


    Yet when I use the move with the ID in question, it doesn't change forms. When I remove the "&& !thismove.nil? && thismove.id == 700 " (like how King's shield makes Aegislash go back into shield form), it automatically transforms upon entering battle. I've tried "thismovefunction =" and the likes too and it's just not working at all.

    Just to clarify, I want the transformation to be a one way thing in battle, and I already have it set up so that it reverts to the original form after battle.
    Reply With Quote

    Relevant Advertising!

      #2    
    Old March 29th, 2018 (5:02 PM).
    James Davy James Davy is offline
       
      Join Date: Oct 2014
      Gender: Male
      Posts: 119
      What you would do is remove your code from PokeBattle_Battler and add this at the end of your move's function code:
      Code:
        def pbEffectAfterHit(attacker,opponent,turneffects)
          if isConst?(@id,PBMoves,:CUSTOMMOVE)
            if isConst?(attacker.species,PBSpecies,:CUSTOMSPECIES) &&
               !attacker.effects[PBEffects::Transform] &&
               !(attacker.hasWorkingAbility(:SHEERFORCE) && self.addlEffect>0) &&
               !attacker.fainted?
              attacker.form=1
              attacker.pbUpdate(true)
              @battle.scene.pbChangePokemon(attacker,attacker.pokemon)
              @battle.pbDisplay(_INTL("{1} transformed!",attacker.pbThis))
              PBDebug.log("[Form changed] #{attacker.pbThis} changed to form #{attacker.form}")
            end
          end
        end
      This assumes you're using version 17.2.
      Reply With Quote
        #3    
      Old March 30th, 2018 (9:58 AM).
      Dinklebort Dinklebort is offline
         
        Join Date: Jul 2017
        Posts: 3
        It worked, thanks a ton!
        Reply With Quote
          #4    
        Old May 20th, 2018 (9:44 PM). Edited May 20th, 2018 by Dfox44.
        Dfox44's Avatar
        Dfox44 Dfox44 is offline
           
          Join Date: Apr 2018
          Location: Ontario,Canada
          Gender: Male
          Nature: Quiet
          Posts: 13
          Quote:
          Originally Posted by James Davy View Post
          What you would do is remove your code from PokeBattle_Battler and add this at the end of your move's function code:
          Code:
            def pbEffectAfterHit(attacker,opponent,turneffects)
              if isConst?(@id,PBMoves,:CUSTOMMOVE)
                if isConst?(attacker.species,PBSpecies,:CUSTOMSPECIES) &&
                   !attacker.effects[PBEffects::Transform] &&
                   !(attacker.hasWorkingAbility(:SHEERFORCE) && self.addlEffect>0) &&
                   !attacker.fainted?
                  attacker.form=1
                  attacker.pbUpdate(true)
                  @battle.scene.pbChangePokemon(attacker,attacker.pokemon)
                  @battle.pbDisplay(_INTL("{1} transformed!",attacker.pbThis))
                  PBDebug.log("[Form changed] #{attacker.pbThis} changed to form #{attacker.form}")
                end
              end
            end
          This assumes you're using version 17.2.
          Hey, by any change would you know how to do this in 16.2 and with the move transform and on ditto only? I would need this for multiple forms too.
          Reply With Quote
            #5    
          Old May 21st, 2018 (4:56 PM).
          James Davy James Davy is offline
             
            Join Date: Oct 2014
            Gender: Male
            Posts: 119
            I don't understand what you're asking. The Transform move is located at PokeBattle_MoveEffects, function code 0x069.
            Reply With Quote
              #6    
            Old May 21st, 2018 (5:40 PM). Edited May 21st, 2018 by Dfox44.
            Dfox44's Avatar
            Dfox44 Dfox44 is offline
               
              Join Date: Apr 2018
              Location: Ontario,Canada
              Gender: Male
              Nature: Quiet
              Posts: 13
              Quote:
              Originally Posted by James Davy View Post
              I don't understand what you're asking. The Transform move is located at PokeBattle_MoveEffects, function code 0x069.
              Sorry, I'll try wording it different. Basically a transform that can use an alternate set of graphics from a different folder that works with one specific pokemon.

              Example:
              Ditto uses transform=turns into something else(but keeps the same moves and stats it would of taken from regular transform)
              Mew uses transform=working as intended
              Reply With Quote
                #7    
              Old May 22nd, 2018 (7:17 PM). Edited May 22nd, 2018 by James Davy.
              James Davy James Davy is offline
                 
                Join Date: Oct 2014
                Gender: Male
                Posts: 119
                My best guess would be to give Ditto alternate forms based on whatever species it's transforming into. It'll involve making copies of the battler sprites and altering the copies (for example giving them a Ditto face or palette-swapping them to have similar colours to Ditto like in Gen-II). Unfortunately it won't be in a separate folder to the other battler sprites.

                On the code side of things, in PokeBattle_Scene make the following changes:
                Code:
                  def pbAnimation(moveid,user,target,hitnum=0)
                    animid=pbFindAnimation(moveid,user.index,hitnum)
                    return if !animid
                    anim=animid[0]
                    animations=load_data("Data/PkmnAnimations.rxdata")
                    pbSaveShadows {
                       if animid[1] # On opposing side and using OppMove animation
                         pbAnimationCore(animations[anim],target,user,true)
                       else         # On player's side, and/or using Move animation
                         pbAnimationCore(animations[anim],user,target)
                       end
                    }
                    if (PBMoveData.new(moveid).function==0x69 ||
                       user.hasWorkingAbility(:IMPOSTER)) &&
                       user && target # Transform
                      # Change form to transformed version
                      if isConst?(user.species,PBSpecies,:DITTO)
                        user.form=target.species
                        user.pbUpdate
                      else
                        pbChangePokemon(user,target.pokemon)
                      end
                    end
                  end
                You'll meed to make a Ditto placeholder form at whichever number the Ditto species is assigned to avoid bugs.
                Reply With Quote
                  #8    
                Old May 22nd, 2018 (8:42 PM). Edited May 22nd, 2018 by Dfox44.
                Dfox44's Avatar
                Dfox44 Dfox44 is offline
                   
                  Join Date: Apr 2018
                  Location: Ontario,Canada
                  Gender: Male
                  Nature: Quiet
                  Posts: 13
                  Quote:
                  Originally Posted by James Davy View Post
                  My best guess would be to give Ditto alternate forms based on whatever species it's transforming into. It'll involve making copies of the battler sprites and altering the copies (for example giving them a Ditto face or palette-swapping them to have similar colours to Ditto like in Gen-II). Unfortunately it won't be in a separate folder to the other battler sprites.

                  On the code side of things, in PokeBattle_Scene make the following changes:
                  Code:
                    def pbAnimation(moveid,user,target,hitnum=0)
                      animid=pbFindAnimation(moveid,user.index,hitnum)
                      return if !animid
                      anim=animid[0]
                      animations=load_data("Data/PkmnAnimations.rxdata")
                      pbSaveShadows {
                         if animid[1] # On opposing side and using OppMove animation
                           pbAnimationCore(animations[anim],target,user,true)
                         else         # On player's side, and/or using Move animation
                           pbAnimationCore(animations[anim],user,target)
                         end
                      }
                      if (PBMoveData.new(moveid).function==0x69 ||
                         user.hasWorkingAbility(:IMPOSTER)) &&
                         user && target # Transform
                        # Change form to transformed version
                        if isConst?(user.species,PBSpecies,:DITTO)
                          user.form=target.species
                          user.pbUpdate
                        else
                          pbChangePokemon(user,target.pokemon)
                        end
                      end
                    end
                  You'll meed to make a Ditto placeholder form at whichever number the Ditto species is assigned to avoid bugs.
                  Thank you! ^^ So I hate to say that it isn't working unfortunately. I am newer to scripts so i'm still learning and following tutorials when I can. Anyways so I'm testing this with pikachu so I put the picture below under form 25 in my battlers. Nothing happened. I edited the moveid to 422 which is transform for me. It transformed my pikachu after I did an attack even though the trainer that has ditto has imposter and it looks like ditto for some reason and didn't turn into pikachu. Here are the images i'm trying to use below. I'm not too sure why it's not working.
                  https://imgur.com/e7FlRvf
                  https://imgur.com/1zA9zCs
                  Reply With Quote
                    #9    
                  Old May 23rd, 2018 (4:07 AM).
                  James Davy James Davy is offline
                     
                    Join Date: Oct 2014
                    Gender: Male
                    Posts: 119
                    Admittedly I did go out on a bit of a limb, but I have a way to approach it from another angle. Instead of using alternate forms of Ditto, you can make at least one alternate form of every species and number it starting at 30 (allowing room for Unown's forms). For example, your Pikachu sprites would be named "025_30" or "025f_30" and so on. The code would be as follows:
                    Code:
                      def pbAnimation(moveid,user,target,hitnum=0)
                        animid=pbFindAnimation(moveid,user.index,hitnum)
                        return if !animid
                        anim=animid[0]
                        animations=load_data("Data/PkmnAnimations.rxdata")
                        pbSaveShadows {
                           if animid[1] # On opposing side and using OppMove animation
                             pbAnimationCore(animations[anim],target,user,true)
                           else         # On player's side, and/or using Move animation
                             pbAnimationCore(animations[anim],user,target)
                           end
                        }
                        if PBMoveData.new(moveid).function==0x69 && user && target # Transform
                          # Change form to transformed version
                          pbChangePokemon(user,target.pokemon)
                          user.form+=30 if isConst?(user.species,PBSpecies,:DITTO)
                        end
                      end
                    This allows Ditto to change to the same form as its target.
                    Reply With Quote
                      #10    
                    Old May 23rd, 2018 (9:39 AM).
                    Dfox44's Avatar
                    Dfox44 Dfox44 is offline
                       
                      Join Date: Apr 2018
                      Location: Ontario,Canada
                      Gender: Male
                      Nature: Quiet
                      Posts: 13
                      Quote:
                      Originally Posted by James Davy View Post
                      Admittedly I did go out on a bit of a limb, but I have a way to approach it from another angle. Instead of using alternate forms of Ditto, you can make at least one alternate form of every species and number it starting at 30 (allowing room for Unown's forms). For example, your Pikachu sprites would be named "025_30" or "025f_30" and so on. The code would be as follows:
                      Code:
                        def pbAnimation(moveid,user,target,hitnum=0)
                          animid=pbFindAnimation(moveid,user.index,hitnum)
                          return if !animid
                          anim=animid[0]
                          animations=load_data("Data/PkmnAnimations.rxdata")
                          pbSaveShadows {
                             if animid[1] # On opposing side and using OppMove animation
                               pbAnimationCore(animations[anim],target,user,true)
                             else         # On player's side, and/or using Move animation
                               pbAnimationCore(animations[anim],user,target)
                             end
                          }
                          if PBMoveData.new(moveid).function==0x69 && user && target # Transform
                            # Change form to transformed version
                            pbChangePokemon(user,target.pokemon)
                            user.form+=30 if isConst?(user.species,PBSpecies,:DITTO)
                          end
                        end
                      This allows Ditto to change to the same form as its target.
                      No problem! The other code seemed very promising. So unfortunately, it still doesn't seem to change and goes to a similar result for this one. It's like transform ignores the forms when it happens and it still looks like default pikachu. Unless i'm missing something else but not that I can think of.
                      Reply With Quote
                        #11    
                      Old May 23rd, 2018 (7:43 PM).
                      James Davy James Davy is offline
                         
                        Join Date: Oct 2014
                        Gender: Male
                        Posts: 119
                        Try adding user.pbUpdate after the user.form line and see if that helps.
                        Reply With Quote
                          #12    
                        Old May 24th, 2018 (11:37 AM).
                        Dfox44's Avatar
                        Dfox44 Dfox44 is offline
                           
                          Join Date: Apr 2018
                          Location: Ontario,Canada
                          Gender: Male
                          Nature: Quiet
                          Posts: 13
                          Quote:
                          Originally Posted by James Davy View Post
                          Try adding user.pbUpdate after the user.form line and see if that helps.
                          It still seems like the same result happens.
                          Reply With Quote
                            #13    
                          Old May 24th, 2018 (5:32 PM).
                          James Davy James Davy is offline
                             
                            Join Date: Oct 2014
                            Gender: Male
                            Posts: 119
                            Okay, try cutting the line in red from pbAnimation and make the following change to pbChangePokemon.
                            Code:
                              def pbChangePokemon(attacker,pokemon)
                                [email protected]["pokemon#{attacker.index}"]
                                [email protected]["shadow#{attacker.index}"]
                                [email protected]?(attacker.index)
                                if isConst?(attacker.species,PBSpecies,:DITTO)
                                  pkmn.setPokemonBitmap(pokemon.form+30,back)
                                else
                                  pkmn.setPokemonBitmap(pokemon,back)
                                end
                                pkmn.x=-pkmn.bitmap.width/2
                                pkmn.y=adjustBattleSpriteY(pkmn,pokemon.species,attacker.index)
                                if @battle.doublebattle
                                  case attacker.index
                                  when 0
                                    pkmn.x+=PokeBattle_SceneConstants::PLAYERBATTLERD1_X
                                    pkmn.y+=PokeBattle_SceneConstants::PLAYERBATTLERD1_Y
                                  when 1
                                    pkmn.x+=PokeBattle_SceneConstants::FOEBATTLERD1_X
                                    pkmn.y+=PokeBattle_SceneConstants::FOEBATTLERD1_Y
                                  when 2
                                    pkmn.x+=PokeBattle_SceneConstants::PLAYERBATTLERD2_X
                                    pkmn.y+=PokeBattle_SceneConstants::PLAYERBATTLERD2_Y
                                  when 3
                                    pkmn.x+=PokeBattle_SceneConstants::FOEBATTLERD2_X
                                    pkmn.y+=PokeBattle_SceneConstants::FOEBATTLERD2_Y
                                  end
                                else
                                  pkmn.x+=PokeBattle_SceneConstants::PLAYERBATTLER_X if attacker.index==0
                                  pkmn.y+=PokeBattle_SceneConstants::PLAYERBATTLER_Y if attacker.index==0
                                  pkmn.x+=PokeBattle_SceneConstants::FOEBATTLER_X if attacker.index==1
                                  pkmn.y+=PokeBattle_SceneConstants::FOEBATTLER_Y if attacker.index==1
                                end
                                if shadow && !back
                                  shadow.visible=showShadow?(pokemon.species)
                                end
                              end
                            It may not work, but it's worth a try.
                            Reply With Quote
                              #14    
                            Old May 24th, 2018 (9:11 PM).
                            Dfox44's Avatar
                            Dfox44 Dfox44 is offline
                               
                              Join Date: Apr 2018
                              Location: Ontario,Canada
                              Gender: Male
                              Nature: Quiet
                              Posts: 13
                              So I just got this error back from it:

                              Exception: NoMethodError
                              Message: undefined method `species' for 30:Fixnum
                              PSystem_Utilities:1089:in `pbLoadPokemonBitmap'
                              Pokemon_Sprites:119:in `setPokemonBitmap'
                              PokeBattle_Scene:2867:in `pbChangePokemon'
                              PokeBattle_Scene:2995:in `pbAnimation'
                              PokeBattle_Battle:2378:in `pbAnimation'
                              PokeBattle_Move:1307:in `pbShowAnimation'
                              PokeBattle_MoveEffects:2911:in `pbEffect'
                              PokeBattle_Battler:2728:in `pbProcessMoveAgainstTarget'
                              PokeBattle_Battler:2684:in `each'
                              PokeBattle_Battler:2684:in `pbProcessMoveAgainstTarget'

                              It's for this line it says " if isConst?(attacker.species,PBSpecies,:DITTO)"
                              Reply With Quote
                                #15    
                              Old May 25th, 2018 (4:37 PM).
                              James Davy James Davy is offline
                                 
                                Join Date: Oct 2014
                                Gender: Male
                                Posts: 119
                                Yeah, it's meant to be if isConst?(attacker.pokemon.species,PBSpecies,:DITTO).
                                Reply With Quote
                                  #16    
                                Old May 27th, 2018 (6:22 AM).
                                Dfox44's Avatar
                                Dfox44 Dfox44 is offline
                                   
                                  Join Date: Apr 2018
                                  Location: Ontario,Canada
                                  Gender: Male
                                  Nature: Quiet
                                  Posts: 13
                                  Quote:
                                  Originally Posted by James Davy View Post
                                  Yeah, it's meant to be if isConst?(attacker.pokemon.species,PBSpecies,:DITTO).
                                  Yes but I was just saying the issue is saying it's because of that even though I know that would be needed.
                                  Reply With Quote
                                  Reply

                                  Quick Reply

                                  Join the conversation!

                                  Create an account to post a reply in this thread, participate in other discussions, and more!

                                  Create a PokéCommunity Account

                                  Sponsored Links
                                  Thread Tools

                                  Posting Rules
                                  You may not post new threads
                                  You may not post replies
                                  You may not post attachments
                                  You may not edit your posts

                                  BB code is On
                                  Smilies are On
                                  [IMG] code is On
                                  HTML code is Off

                                  Forum Jump


                                  All times are GMT -8. The time now is 4:39 PM.