• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Dawn, Gloria, Juliana, or Summer - which Pokémon protagonist is your favorite? Let us know by voting in our poll!
  • Our friends from the Johto Times are hosting a favorite Pokémon poll - and we'd love for you to participate! Click here for information on how to vote for your favorites!
  • 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] Problem with making HM based on species

  • 13
    Posts
    12
    Years
    I wanted to view the HM list on the pokemon menu based on the learnable species moves instead of the single pokemon moveset (for example all Gyarados can surf despite not knowing it).
    I made it but only partially.

    On my team I have Lugia (that can learn fly, surf, strength, rock smash, dive, waterfall and headbutt), Dusclops (that can learn strength, rock smash and headbutt) and Chansey (strength, rock smash, soft-boiled, headbutt and sweet scent).

    The problems that I have are that Lugia can use all the moves perfectly except headbutt that does nothing, Dusclops can only use strength despite rock smash works for Lugia and Chansey can't use any moves except strength that for an unknown reason works as soft-boiled

    This is the code of the part in PScreen_Party that I modified

    Code:
          fMoves = [getID(PBMoves,:FLY),
                    getID(PBMoves,:SURF),
                    getID(PBMoves,:STRENGTH),
                    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)
                    ]
          
          pkmn = @party[pkmnid]
          commands   = []
          cmdSummary = -1
          cmdDebug   = -1
          cmdMoves   = Array.new(fMoves.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 = []
          
          if !pkmn.egg?
            
            for i in 0...fMoves.length
              if pkmn.isCompatibleWithMove?(fMoves[i])
                commands[cmdMoves[i] = commands.length] = [PBMoves.getName(fMoves[i]),1]
                usableMoves.push(fMoves[i])
              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
          
          #pkmn.moves[i].id => cmdMoves[i]
          
          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

    EDIT: I found the problem.
    After the list of compatible moves was found, the array cmdMoves was in Dusclops case [-1, -1, 2, 3, -1, -1, -1, -1, -1, 4, -1, -1] that is correct but, for example, on the commands list the third position there isn't Strength but Headbutt, so the moves in cmdMoves were in the wrong order so I simply deleted all the -1 value on the array

    So, to make all the code correct I only added

    Code:
    cmdMoves = cmdMoves.select {|v| v >= 0}

    after creating the list of compatible moves
     
    Last edited:
    I'm not sure what your problem and what you are doing. Are you saying having a list to show what HMs that poke is capable of and has learnt?
     
    Back
    Top