v18.1 Changing Forms/Moves on the fly?

This thread pertains to v18.1 of Pokémon Essentials.

Rua

Rookie
Member
Joined
Jan 11, 2021
Posts
4
Age
26
Hi guys,

I am working on a system that allows you to change Forms using an item which have opposite types to the original Pokémon. For example, swapping Bulbasaur to a Fire Type. This works as I intended and I can swap between both Forms through the item.The problem which I am wrapping my head around is how I can change all the moves of that Pokémon to reflect the new Fire type moves which I have defined in pokemonforms.txt.

When I use the item on the Bulbasaur, it retains moves such as Vine Whip which I don't want. I have looked at the Rotom Form change in Pokemon_Forms, but just don't have the scripting knowledge to replace whatever Grass/Other moves the Bulbasaur currently has with the moves that the new form can have. I would maybe like the moves to be wiped and then a move tutor window to populate the 4 slots with moves that only the new form as well.

This would then have to work in reverse as well. The below is what I currently have for an Onix. But all this does is add BubbleBeam when the form is swapped.

Onix FormSet:
MultipleForms.register(:ONIX,{
  "onSetForm" => proc { |pkmn,form,oldForm|
    formMoves = [
       :BUBBLEBEAM,   # Void
    ]
    idxMoveToReplace = -1
    pkmn.moves.each_with_index do |move,i|
      next if !move
      formMoves.each do |newMove|
        next if !isConst?(move.id,PBMoves,newMove)
        idxMoveToReplace = i
        break
      end
      break if idxMoveToReplace>=0
    end
    if form==0
      if idxMoveToReplace>=0
        moveName = PBMoves.getName(pkmn.moves[idxMoveToReplace].id)
        pkmn.pbDeleteMoveAtIndex(idxMoveToReplace)
        pbMessage(_INTL("{1} forgot {2}...",pkmn.name,moveName))
        pkmn.pbLearnMove(:BUBBLEBEAM) if pkmn.numMoves==0
      end
    else
      newMove = getConst(PBMoves,formMoves[form-1])
      if idxMoveToReplace>=0
        oldMoveName = PBMoves.getName(pkmn.moves[idxMoveToReplace].id)
        if newMove && newMove>0
          newMoveName = PBMoves.getName(newMove)
          pkmn.moves[idxMoveToReplace].id = newMove
          pbMessage(_INTL("1,\\wt[16] 2, and\\wt[16]...\\wt[16] ...\\wt[16] ... Ta-da!\\se[Battle ball drop]\1"))
          pbMessage(_INTL("{1} forgot how to use {2}.\\nAnd...\1",pkmn.name,oldMoveName))
          pbMessage(_INTL("\\se[]{1} learned {2}!\\se[Pkmn move learnt]",pkmn.name,newMoveName))
        else
          pkmn.pbDeleteMoveAtIndex(idxMoveToReplace)
          pbMessage(_INTL("{1} forgot {2}...",pkmn.name,oldMoveName))
          pkmn.pbLearnMove(:BUBBLEBEAM) if pkmn.numMoves==0
        end
      elsif newMove && newMove>0
        pbLearnMove(pkmn,newMove,true)
      end
    end
    }
  })

Thanks so much for any help!
 

ThatWelshOne_

Eevee User
Member
Joined
Sep 29, 2020
Posts
137
From what I can understand, you just want to reset the moves when your Pokémon changes form? All you need for that is pkmn.resetMoves. Obviously, this would wipe any learned TMs and so on. Unless you're talking about replacing a specific move if the Pokémon knows it upon switching forms?
 

Rua

Rookie
Member
Joined
Jan 11, 2021
Posts
4
Age
26
Yes I actually got it working with a combination of resetting the moves and starting a Move Relearner scene. Not sure if that is best strategy. Does reset moves only delete the moves or will it add 4 moves from the new forms movepool?
 

TechSkylander1518

Wiki Dweeb
Member
Joined
Mar 24, 2017
Posts
662
Yes I actually got it working with a combination of resetting the moves and starting a Move Relearner scene. Not sure if that is best strategy. Does reset moves only delete the moves or will it add 4 moves from the new forms movepool?
It'll add the last 4 moves it would have learned via level up! (There's no script call that'll just delete all moves without replacing them with anything, that'd lead to errors)
 
Top