Male
Italy
Seen 14 Hours Ago
Posted September 25th, 2020
12 posts
8.9 Years
If you are tired of teaching Surf to your Gyarados and ruin his physical moveset this script is perfect for you.
Instead of checking the moveset of your party for any learned field move, you can instead check the compatibility with this moves.
So in this way Gyarados can freely use Surf, Strength, Rocksmash, Dive and Waterfall without wasting any move slot

- Starting point

Spoiler:

Put this code above main

#===============================================================================
# * Field moves defined by species - by Lexor
#===============================================================================
# 
# This script make the field moves (cut, fly, ...) usable by simply check
# if the Pokemon can learn that move instead of check the moveset
# 
# NOTE: You must insert non TM/HM moves like softboiled and teleport
#       in tm.txt if you want to make them usable
# 
# If you wanna add a new field move, after defined in PField_FieldMoves their
# code, add in UsableFieldMoves a new element:
#   
#   getID(PBMoves,:"INTERNAL MOVE NAME")
#
#===============================================================================

UsableFieldMoves = [getID(PBMoves,:CUT),
                    getID(PBMoves,:FLY),
                    getID(PBMoves,:SURF),
                    getID(PBMoves,:STRENGTH),
                    getID(PBMoves,:FLASH),
                    getID(PBMoves,:ROCKSMASH),
                    getID(PBMoves,:DIVE),
                    getID(PBMoves,:WATERFALL),
                    getID(PBMoves,:DIG),
                    getID(PBMoves,:SOFTBOILED),
                    getID(PBMoves,:MILKDRINK),
                    getID(PBMoves,:HEADBUTT),
                    getID(PBMoves,:TELEPORT),
                    getID(PBMoves,:SWEETSCENT)
                    ]


- Set the moves list on the Pokemon menu in the party screen

Spoiler:

In PScreen_Party change

      pkmn = @party[pkmnid]
      commands   = []
      cmdSummary = -1
      cmdDebug   = -1
      cmdMoves   = [-1,-1,-1,-1]
      cmdSwitch  = -1
      cmdMail    = -1
      cmdItem    = -1
      # Build the commands
      commands[cmdSummary = commands.length]      = _INTL("Summary")
      commands[cmdDebug = commands.length]        = _INTL("Debug") if $DEBUG
      for i in 0...pkmn.moves.length
        move = pkmn.moves[i]
        # Check for hidden moves and add any that were found
        if !pkmn.egg? && (isConst?(move.id,PBMoves,:MILKDRINK) ||
                          isConst?(move.id,PBMoves,:SOFTBOILED) ||
                          HiddenMoveHandlers.hasHandler(move.id))
          commands[cmdMoves[i] = commands.length] = [PBMoves.getName(move.id),1]
        end
      end
      commands[cmdSwitch = commands.length]       = _INTL("Switch") if @party.length>1
      if !pkmn.egg?
        if pkmn.mail
          commands[cmdMail = commands.length]     = _INTL("Mail")
        else
          commands[cmdItem = commands.length]     = _INTL("Item")
        end
      end
      commands[commands.length]                   = _INTL("Cancel")
      command = @scene.pbShowCommands(_INTL("Do what with {1}?",pkmn.name),commands)
      havecommand = false
      for i in 0...4
        if cmdMoves[i]>=0 && command==cmdMoves[i]
          havecommand = true
          if isConst?(pkmn.moves[i].id,PBMoves,:SOFTBOILED) ||
             isConst?(pkmn.moves[i].id,PBMoves,:MILKDRINK)
            amt = [(pkmn.totalhp/5).floor,1].max
            if pkmn.hp<=amt
              pbDisplay(_INTL("Not enough HP..."))
              break
            end
            @scene.pbSetHelpText(_INTL("Use on which Pokémon?"))
            oldpkmnid = pkmnid
            loop do
              @scene.pbPreSelect(oldpkmnid)
              pkmnid = @scene.pbChoosePokemon(true,pkmnid)
              break if pkmnid<0
              newpkmn = @party[pkmnid]
              movename = PBMoves.getName(pkmn.moves[i].id)
              if pkmnid==oldpkmnid
                pbDisplay(_INTL("{1} can't use {2} on itself!",pkmn.name,movename))
              elsif newpkmn.egg?
                pbDisplay(_INTL("{1} can't be used on an Egg!",movename))
              elsif newpkmn.hp==0 || newpkmn.hp==newpkmn.totalhp
                pbDisplay(_INTL("{1} can't be used on that Pokémon.",movename))
              else
                pkmn.hp -= amt
                hpgain = pbItemRestoreHP(newpkmn,amt)
                @scene.pbDisplay(_INTL("{1}'s HP was restored by {2} points.",newpkmn.name,hpgain))
                pbRefresh
              end
              break if pkmn.hp<=amt
            end
            @scene.pbSelect(oldpkmnid)
            pbRefresh
            break
          elsif pbCanUseHiddenMove?(pkmn,pkmn.moves[i].id)
            if pbConfirmUseHiddenMove(pkmn,pkmn.moves[i].id)
              @scene.pbEndScene
              if isConst?(pkmn.moves[i].id,PBMoves,:FLY)
                scene = PokemonRegionMap_Scene.new(-1,false)
                screen = PokemonRegionMapScreen.new(scene)
                ret = screen.pbStartFlyScreen
                if ret
                  $PokemonTemp.flydata=ret
                  return [pkmn,pkmn.moves[i].id]
                end
                @scene.pbStartScene(@party,
                   (@party.length>1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel."))
                break
              end
              return [pkmn,pkmn.moves[i].id]
            end
          else
            break
          end
        end
      end
With

      pkmn = @party[pkmnid]
      commands   = []
      cmdSummary = -1
      cmdDebug   = -1
      cmdMoves   = Array.new(UsableFieldMoves.length,-1)
      cmdSwitch  = -1
      cmdMail    = -1
      cmdItem    = -1
      # Build the commands
      commands[cmdSummary = commands.length]      = _INTL("Summary")
      commands[cmdDebug = commands.length]        = _INTL("Debug") if $DEBUG
      
      usableMoves = []
      count = 0
      
      if !pkmn.egg?
        
        for i in 0...UsableFieldMoves.length
          if pkmn.compatibleWithMove?(UsableFieldMoves[i])
            commands[cmdMoves[count] = commands.length] = [PBMoves.getName(UsableFieldMoves[i]),1]
            usableMoves.push(UsableFieldMoves[i])
            count += 1
          end
        end
      end
      
      commands[cmdSwitch = commands.length]       = _INTL("Switch") if @party.length>1
      if !pkmn.egg?
        if pkmn.mail
          commands[cmdMail = commands.length]     = _INTL("Mail")
        else
          commands[cmdItem = commands.length]     = _INTL("Item")
        end
      end
      commands[commands.length]                   = _INTL("Cancel")
      command = @scene.pbShowCommands(_INTL("Do what with {1}?",pkmn.name),commands)
      havecommand = false
      
      for i in 0...usableMoves.length
        if cmdMoves[i]>=0 && command==cmdMoves[i]
          havecommand = true
          if isConst?(usableMoves[i],PBMoves,:SOFTBOILED) ||
             isConst?(usableMoves[i],PBMoves,:MILKDRINK)
            amt = [(pkmn.totalhp/5).floor,1].max
            if pkmn.hp<=amt
              pbDisplay(_INTL("Not enough HP..."))
              break
            end
            @scene.pbSetHelpText(_INTL("Use on which Pokémon?"))
            oldpkmnid = pkmnid
            loop do
              @scene.pbPreSelect(oldpkmnid)
              pkmnid = @scene.pbChoosePokemon(true,pkmnid)
              break if pkmnid<0
              newpkmn = @party[pkmnid]
              movename = PBMoves.getName(usableMoves[i])
              if pkmnid==oldpkmnid
                pbDisplay(_INTL("{1} can't use {2} on itself!",pkmn.name,movename))
              elsif newpkmn.egg?
                pbDisplay(_INTL("{1} can't be used on an Egg!",movename))
              elsif newpkmn.hp==0 || newpkmn.hp==newpkmn.totalhp
                pbDisplay(_INTL("{1} can't be used on that Pokémon.",movename))
              else
                pkmn.hp -= amt
                hpgain = pbItemRestoreHP(newpkmn,amt)
                @scene.pbDisplay(_INTL("{1}'s HP was restored by {2} points.",newpkmn.name,hpgain))
                pbRefresh
              end
              break if pkmn.hp<=amt
            end
            @scene.pbSelect(oldpkmnid)
            pbRefresh
            break
          elsif pbCanUseHiddenMove?(pkmn,usableMoves[i])
            if pbConfirmUseHiddenMove(pkmn,usableMoves[i])
              @scene.pbEndScene
              if isConst?(usableMoves[i],PBMoves,:FLY)
                scene = PokemonRegionMap_Scene.new(-1,false)
                screen = PokemonRegionMapScreen.new(scene)
                ret = screen.pbStartFlyScreen
                if ret
                  $PokemonTemp.flydata=ret
                  return [pkmn,usableMoves[i]]
                end
                @scene.pbStartScene(@party,
                   (@party.length>1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel."))
                break
              end
              return [pkmn,usableMoves[i]]
            end
          else
            break
          end
        end
      end


- Change how field moves work in the overworld

Spoiler:

In PSystem_PokemonUtilities change the entirety of pbCheckMove with this code

def pbCheckMove(move)
  move = getID(PBMoves,move)
  return nil if !move || move<=0
  for i in $Trainer.pokemonParty 
    return i if i.compatibleWithMove?(move)
  end
  return nil
end


Add these in tm.txt if you wanna use softboiled, milkdrink, teleport and sweetscent

Spoiler:

[SOFTBOILED]
CLEFAIRY,CLEFABLE,CHANSEY,MEW,CLEFFA,TOGEPI,TOGETIC,BLISSEY,HAPPINY,TOGEKISS
[MILKDRINK]
MILTANK
[SWEETSCENT]
BULBASAUR,IVYSAUR,VENUSAUR,BUTTERFREE,BEEDRILL,ODDISH,GLOOM,VILEPLUME,PARAS,PARASECT,VENONAT,VENOMOTH,BELLSPROUT,WEEPINBELL,VICTREEBEL,EXEGGCUTE,EXEGGUTOR,CHANSEY,TANGELA,JYNX,MEW,CHIKORITA,BAYLEEF,MEGANIUM,LEDYBA,LEDIAN,BELLOSSOM,HOPPIP,SKIPLOOM,JUMPLUFF,SUNKERN,SUNFLORA,PINECO,FORRETRESS,SHUCKLE,TEDDIURSA,URSARING,SMOOCHUM,MILTANK,BLISSEY,CELEBI,LOTAD,LOMBRE,LUDICOLO,SURSKIT,MASQUERAIN,MAWILE,ILLUMISE,ROSELIA,TROPIUS,ROSERADE,COMBEE,VESPIQUEN,CHERUBI,CHERRIM,HAPPINY,CARNIVINE,TANGROWTH,SHAYMIN,SNIVY,SERVINE,SERPERIOR,PETILIL,LILLIGANT,MARACTUS,FOONGUS,AMOONGUSS
[TELEPORT]
ABRA,KADABRA,ALAKAZAM,MEWTWO,MEW,NATU,XATU,RALTS,KIRLIA,GARDEVOIR,CLAYDOL,DEOXYS,GALLADE,ELGYEM,BEHEEYEM


Code for v.17
Spoiler:

- Starting point

Spoiler:

Put this code above main

#===============================================================================
# * Field moves defined by species - by Lexor
#===============================================================================
# 
# This script make the field moves (cut, fly, ...) usable by simply check
# if the Pokemon can learn that move instead of check the moveset
# 
# NOTE: You must insert non TM/HM moves like softboiled and teleport
#       in tm.txt if you want to make them usable
# 
# If you wanna add a new field move, after defined in PField_FieldMoves their
# code, add in UsableFieldMoves a new element:
#   
#   getID(PBMoves,:"INTERNAL MOVE NAME")
#
#===============================================================================

UsableFieldMoves = [getID(PBMoves,:CUT),
                    getID(PBMoves,:FLY),
                    getID(PBMoves,:SURF),
                    getID(PBMoves,:STRENGTH),
                    getID(PBMoves,:FLASH),
                    getID(PBMoves,:ROCKSMASH),
                    getID(PBMoves,:DIVE),
                    getID(PBMoves,:WATERFALL),
                    getID(PBMoves,:DIG),
                    getID(PBMoves,:SOFTBOILED),
                    getID(PBMoves,:MILKDRINK),
                    getID(PBMoves,:HEADBUTT),
                    getID(PBMoves,:TELEPORT),
                    getID(PBMoves,:SWEETSCENT)
                    ]


- Set the moves list on the Pokemon menu in the party screen

Spoiler:

In PScreen_Party change

pkmn = @party[pkmnid]
      commands   = []
      cmdSummary = -1
      cmdDebug   = -1
      cmdMoves   = [-1,-1,-1,-1]
      cmdSwitch  = -1
      cmdMail    = -1
      cmdItem    = -1
      # Build the commands
      commands[cmdSummary = commands.length]      = _INTL("Summary")
      commands[cmdDebug = commands.length]        = _INTL("Debug") if $DEBUG
      for i in 0...pkmn.moves.length
        move = pkmn.moves[i]
        # Check for hidden moves and add any that were found
        if !pkmn.egg? && (isConst?(move.id,PBMoves,:MILKDRINK) ||
                          isConst?(move.id,PBMoves,:SOFTBOILED) ||
                          HiddenMoveHandlers.hasHandler(move.id))
          commands[cmdMoves[i] = commands.length] = [PBMoves.getName(move.id),1]
        end
      end
      commands[cmdSwitch = commands.length]       = _INTL("Switch") if @party.length>1
      if !pkmn.egg?
        if pkmn.mail
          commands[cmdMail = commands.length]     = _INTL("Mail")
        else
          commands[cmdItem = commands.length]     = _INTL("Item")
        end
      end
      commands[commands.length]                   = _INTL("Cancel")
      command = @scene.pbShowCommands(_INTL("Do what with {1}?",pkmn.name),commands)
      havecommand = false
      for i in 0...4
        if cmdMoves[i]>=0 && command==cmdMoves[i]
          havecommand = true
          if isConst?(pkmn.moves[i].id,PBMoves,:SOFTBOILED) ||
             isConst?(pkmn.moves[i].id,PBMoves,:MILKDRINK)
            amt = [(pkmn.totalhp/5).floor,1].max
            if pkmn.hp<=amt
              pbDisplay(_INTL("Not enough HP..."))
              break
            end
            @scene.pbSetHelpText(_INTL("Use on which Pokémon?"))
            oldpkmnid = pkmnid
            loop do
              @scene.pbPreSelect(oldpkmnid)
              pkmnid = @scene.pbChoosePokemon(true,pkmnid)
              break if pkmnid<0
              newpkmn = @party[pkmnid]
              movename = PBMoves.getName(pkmn.moves[i].id)
              if pkmnid==oldpkmnid
                pbDisplay(_INTL("{1} can't use {2} on itself!",pkmn.name,movename))
              elsif newpkmn.egg?
                pbDisplay(_INTL("{1} can't be used on an Egg!",movename))
              elsif newpkmn.hp==0 || newpkmn.hp==newpkmn.totalhp
                pbDisplay(_INTL("{1} can't be used on that Pokémon.",movename))
              else
                pkmn.hp -= amt
                hpgain = pbItemRestoreHP(newpkmn,amt)
                @scene.pbDisplay(_INTL("{1}'s HP was restored by {2} points.",newpkmn.name,hpgain))
                pbRefresh
              end
              break if pkmn.hp<=amt
            end
            @scene.pbSelect(oldpkmnid)
            pbRefresh
            break
          elsif Kernel.pbCanUseHiddenMove?(pkmn,pkmn.moves[i].id)
            if Kernel.pbConfirmUseHiddenMove(pkmn,pkmn.moves[i].id)
              @scene.pbEndScene
              if isConst?(pkmn.moves[i].id,PBMoves,:FLY)
                scene = PokemonRegionMap_Scene.new(-1,false)
                screen = PokemonRegionMapScreen.new(scene)
                ret = screen.pbStartFlyScreen
                if ret
                  $PokemonTemp.flydata=ret
                  return [pkmn,pkmn.moves[i].id]
                end
                @scene.pbStartScene(@party,
                   (@party.length>1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel."))
                break
              end
              return [pkmn,pkmn.moves[i].id]
            end
          else
            break
          end
        end
      end
With

pkmn = @party[pkmnid]
      commands   = []
      cmdSummary = -1
      cmdDebug   = -1
      cmdMoves   = Array.new(UsableFieldMoves.length,-1)
      cmdSwitch  = -1
      cmdMail    = -1
      cmdItem    = -1
      # Build the commands
      commands[cmdSummary = commands.length]      = _INTL("Summary")
      commands[cmdDebug = commands.length]        = _INTL("Debug") if $DEBUG
      
      usableMoves = []
      count = 0
      
      if !pkmn.egg?
        
        for i in 0...UsableFieldMoves.length
          if pkmn.isCompatibleWithMove?(UsableFieldMoves[i])
            commands[cmdMoves[count] = commands.length] = [PBMoves.getName(UsableFieldMoves[i]),1]
            usableMoves.push(UsableFieldMoves[i])
            count += 1
          end
        end
      end
      
      commands[cmdSwitch = commands.length]       = _INTL("Switch") if @party.length>1
      if !pkmn.egg?
        if pkmn.mail
          commands[cmdMail = commands.length]     = _INTL("Mail")
        else
          commands[cmdItem = commands.length]     = _INTL("Item")
        end
      end
      commands[commands.length]                   = _INTL("Cancel")
      command = @scene.pbShowCommands(_INTL("Do what with {1}?",pkmn.name),commands)
      havecommand = false
      
      for i in 0...usableMoves.length
        if cmdMoves[i]>=0 && command==cmdMoves[i]
          havecommand = true
          if isConst?(usableMoves[i],PBMoves,:SOFTBOILED) ||
             isConst?(usableMoves[i],PBMoves,:MILKDRINK)
            amt = [(pkmn.totalhp/5).floor,1].max
            if pkmn.hp<=amt
              pbDisplay(_INTL("Not enough HP..."))
              break
            end
            @scene.pbSetHelpText(_INTL("Use on which Pokémon?"))
            oldpkmnid = pkmnid
            loop do
              @scene.pbPreSelect(oldpkmnid)
              pkmnid = @scene.pbChoosePokemon(true,pkmnid)
              break if pkmnid<0
              newpkmn = @party[pkmnid]
              movename = PBMoves.getName(usableMoves[i])
              if pkmnid==oldpkmnid
                pbDisplay(_INTL("{1} can't use {2} on itself!",pkmn.name,movename))
              elsif newpkmn.egg?
                pbDisplay(_INTL("{1} can't be used on an Egg!",movename))
              elsif newpkmn.hp==0 || newpkmn.hp==newpkmn.totalhp
                pbDisplay(_INTL("{1} can't be used on that Pokémon.",movename))
              else
                pkmn.hp -= amt
                hpgain = pbItemRestoreHP(newpkmn,amt)
                @scene.pbDisplay(_INTL("{1}'s HP was restored by {2} points.",newpkmn.name,hpgain))
                pbRefresh
              end
              break if pkmn.hp<=amt
            end
            @scene.pbSelect(oldpkmnid)
            pbRefresh
            break
          elsif Kernel.pbCanUseHiddenMove?(pkmn,usableMoves[i])
            if Kernel.pbConfirmUseHiddenMove(pkmn,usableMoves[i])
              @scene.pbEndScene
              if isConst?(usableMoves[i],PBMoves,:FLY)
                scene = PokemonRegionMap_Scene.new(-1,false)
                screen = PokemonRegionMapScreen.new(scene)
                ret = screen.pbStartFlyScreen
                if ret
                  $PokemonTemp.flydata=ret
                  return [pkmn,usableMoves[i]]
                end
                @scene.pbStartScene(@party,
                   (@party.length>1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel."))
                break
              end
              return [pkmn,usableMoves[i]]
            end
          else
            break
          end
        end
      end


- Change how field moves work in the overworld

Spoiler:

In PSystem_PokemonUtilities change the entirety of pbCheckMove with this code

def pbCheckMove(move)
  if move.is_a?(String) || move.is_a?(Symbol)
    move = getID(PBMoves,move)
  end
  return nil if !move || move<=0
  for i in $Trainer.party
    next if i.egg?
    
    return i if i.isCompatibleWithMove?(move)
  end
  return nil
end



-- Edit 25/09/20: Added support to v.18

Vendily

Female
Seen 4 Hours Ago
Posted 6 Days Ago
1,349 posts
5.7 Years
incredible work! i was wondering if you would have any idea how to get these moves to show up on the ready menu? thanks in advance
Taking a quick look, it appears the lines you'd be interested in are in def pbUseKeyItem
probably this if $Trainer.party[j].hasMove?(move), you'll want to switch that into checking if it's compatible instead. so if $Trainer.party[j].isCompatibleWithMove?(move) should do the trick.

Vendily

Female
Seen 4 Hours Ago
Posted 6 Days Ago
1,349 posts
5.7 Years
This is awesome!
But I do have a question/suggestion. I think it would make more sense if using Dive would require an item in addition to the Pkmn Compatibility, like a scuba suit or something. How could I implement this?
Looks like you'll need to edit the HiddenMoveHandlers::CanUseMove for Dive in PField_FieldMoves. It returns false if you don't have the required badge, so all you need to do is add another line that returns false if you don't have the requisite item. !$PokemonBag.pbHasItem?(:ITEM) is the check you want.
Seen January 28th, 2021
Posted January 16th, 2021
13 posts
98 Days


help please

[Pokémon Essentials version 18.1.dev]
Exception: RuntimeError
Message: Script error within event 11 (coords 21,16), map 5 (Route 1):
Exception: NoMethodError
Message: PSystem_PokemonUtilities:382:in `pbCheckMove'undefined method `CompatibleWithMove?' for #<PokeBattle_Pokemon:0x9ad67e0>

***Full script:
pbCut

Backtrace:
Interpreter:197:in `pbExecuteScript'
PSystem_PokemonUtilities:379:in `each'
PSystem_PokemonUtilities:379:in `pbCheckMove'
PField_FieldMoves:198:in `pbCut'
(eval):1:in `pbExecuteScript'
Interpreter:658:in `eval'
Interpreter:197:in `pbExecuteScript'
Interpreter:658:in `command_111'
Interpreter:272:in `execute_command'
Interpreter:155:in `update'


Backtrace:
Interpreter:246:in `pbExecuteScript'
Interpreter:658:in `command_111'
Interpreter:272:in `execute_command'
Interpreter:155:in `update'
Interpreter:102:in `loop'
Interpreter:158:in `update'
Scene_Map:162:in `follow_update'
Scene_Map:160:in `loop'
Scene_Map:169:in `follow_update'
Follower_Main:1187:in `update'