• 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] How to make a move trigger a form change?

3
Posts
6
Years
  • Age 29
  • Seen Mar 30, 2018
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:


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.
 
Last edited:
188
Posts
9
Years
  • Age 39
  • Seen Jan 21, 2024
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.
 
13
Posts
6
Years
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.
 
Last edited:
188
Posts
9
Years
  • Age 39
  • Seen Jan 21, 2024
I don't understand what you're asking. The Transform move is located at PokeBattle_MoveEffects, function code 0x069.
 
13
Posts
6
Years
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
 
Last edited:
188
Posts
9
Years
  • Age 39
  • Seen Jan 21, 2024
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
    }
    [COLOR="Red"]if (PBMoveData.new(moveid).function==0x69 ||
       user.hasWorkingAbility(:IMPOSTER)) &&
       user && target [COLOR="green"]# Transform[/COLOR]
      [COLOR="Green"]# Change form to transformed version[/COLOR]
      if isConst?(user.species,PBSpecies,:DITTO)
        user.form=target.species
        user.pbUpdate
      else[/COLOR]
        pbChangePokemon(user,target.pokemon)
      [COLOR="red"]end[/COLOR]
    end
  end
You'll meed to make a Ditto placeholder form at whichever number the Ditto species is assigned to avoid bugs.
 
Last edited:
13
Posts
6
Years
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
    }
    [COLOR="Red"]if (PBMoveData.new(moveid).function==0x69 ||
       user.hasWorkingAbility(:IMPOSTER)) &&
       user && target [COLOR="green"]# Transform[/COLOR]
      [COLOR="Green"]# Change form to transformed version[/COLOR]
      if isConst?(user.species,PBSpecies,:DITTO)
        user.form=target.species
        user.pbUpdate
      else[/COLOR]
        pbChangePokemon(user,target.pokemon)
      [COLOR="red"]end[/COLOR]
    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
 
Last edited:
188
Posts
9
Years
  • Age 39
  • Seen Jan 21, 2024
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)
      [COLOR="Red"]user.form+=30 if isConst?(user.species,PBSpecies,:DITTO)[/COLOR]
    end
  end
This allows Ditto to change to the same form as its target.
 
13
Posts
6
Years
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)
      [COLOR="Red"]user.form+=30 if isConst?(user.species,PBSpecies,:DITTO)[/COLOR]
    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.
 
188
Posts
9
Years
  • Age 39
  • Seen Jan 21, 2024
Okay, try cutting the line in red from pbAnimation and make the following change to pbChangePokemon.
Code:
  def pbChangePokemon(attacker,pokemon)
    pkmn=@sprites["pokemon#{attacker.index}"]
    shadow=@sprites["shadow#{attacker.index}"]
    [email protected]?(attacker.index)
    [COLOR="red"]if isConst?(attacker.species,PBSpecies,:DITTO)
      pkmn.setPokemonBitmap(pokemon.form+30,back)
    else[/COLOR]
      pkmn.setPokemonBitmap(pokemon,back)
    [COLOR="red"]end[/COLOR]
    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.
 
13
Posts
6
Years
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)"
 
188
Posts
9
Years
  • Age 39
  • Seen Jan 21, 2024
Yeah, it's meant to be if isConst?(attacker.pokemon.species,PBSpecies,:DITTO).
 
Back
Top