• 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] HM Moves As held items

17
Posts
3
Years
    • Seen Feb 6, 2023
    Working with pokemon essentials v18 .1

    In my game you need to be able to use the stock hm moves as is, Cut, Surf,Fly,Rocksmash however when you get to a certain point in the game based on the number of badges, an npc "the charm speccialist" will offer to make a charm for you, eg: Cut Charm, Surf Charm, Fly Charm, Rock Smash Charm. I've got this all set out already as an event. essentially the pokemon will be able to use the hm move in the field (not in battle) without losing a move slot. in my game pokemon can forget HM moves so these can be frgotten once youve progressed enough into the game to acquire the charms.

    so the question becomes, how to alter the field moves script to allow for checking for an held item as well as continue to check if the Pokemon has the move.

    eg:
    if pokemon has the item and can learn the move related to the item but does not have the move allow it to use move in the overworld.
    else check it has the move and use it.

    I've tried to add this myself but keep getting errors.

    I've tried to add the check using:- pkmn.hasItem?(:CUTCHARM) and it just doesnt do anything.

    Any help or a point to somthing else that can help is welcome, I will just ask peopel to remember to be nice as I've gotten "snotty" replies off people because they now how to do somthing and think it should be obvious how to do it. remember that is always the case for everyone.

    thanks in advance for any replies.
     

    JulyArt

    New Developer
    70
    Posts
    3
    Years
    • Seen Dec 17, 2021
    I feel like this would be way simpler to edit how the current 'Fly, Rock Smash' are activated. e.g. When we select a Pokemon within the Pokemon Party Screen, it'll show options "Summary, Held Item, etc" , how does it do this? This is what I think you should edit.

    Then all you have to do, is add an 'or' operator to whatever condition it is right now. That condition is probably simple like "Does it currently know the move Fly?" if so show Fly option.

    Now we know where we want to edit, but we don't know one of the reference 'new condition' yet besides 'held item', we also need to check if the selected PKMN can learn fly. So now navigate to how 'TM and HM works'. and try to find out how TM and HM determines if a PKMN can learn that move. edit#1 (there shouldn't be any PKMN that can naturally learn Fly through leveling and not being able to learn Fly through HM, although if there is, this method won't pick that up. For those special pokemons since the numbers are so low, you'd just add the "or if specie = _____" )

    Currently, the game 'Fly' option is likely "If PKMN has Fly in its current move list, show option Fly" you'll need to add "or (if PKMN is holding held item = Fly Charm AND PKMN can learn Fly)

    I haven't looked at the code to see how the element reference one another, but using this logic with your skills, you'd likely be able to get it done.
     
    17
    Posts
    3
    Years
    • Seen Feb 6, 2023
    not really sure how to do it still, the only thing I'v found is this:

    elsif pbCanUseHiddenMove?(pkmn,pkmn.moves.id)
    if pbConfirmUseHiddenMove(pkmn,pkmn.moves.id)
    @scene.pbEndScene
    if isConst?(pkmn.moves.id,PBMoves,:FLY)
    scene = PokemonRegionMap_Scene.new(-1,false)
    screen = PokemonRegionMapScreen.new(scene)
    ret = screen.pbStartFlyScreen

    this is calling the fuctions which i wasnt able to add the pkmn.hasItem?(:CUTCHARM) check to.
    wouldnt i still then have to call the move handlers in wich case theyd return false as the pokemon wouldnt have the move in its current moves.
     
    17
    Posts
    3
    Years
    • Seen Feb 6, 2023
    anyone who can tell me what im doing wrong would be great, prepare for very janky code.

    def pbCut
    move = getID(PBMoves,:CUT)
    movefinder = pbCheckMove(move)
    heldItem = pbCheckHeldItem(:CUTITEM)
    canUse = pbCheckCanLearnMove(move)
    pokeName = pbGetName(move)
    if heldItem == true
    if canUse == true
    if !pbCheckHiddenMoveBadge(BADGE_FOR_CUT,false) || (!$DEBUG)
    pbMessage(_INTL("This tree looks like it can be cut down."))
    return false
    end
    pbMessage(_INTL("This tree looks like it can be cut down!\1"))
    if pbConfirmMessage(_INTL("Would you like to cut it?"))
    speciesname = (PokeName) ? PokeName.name : $Trainer.name
    pbMessage(_INTL("{1} used {2}!",speciesname,PBMoves.getName(move)))
    pbHiddenMoveAnimation(movefinder)
    return true
    end
    end
    end


    error message:-

    ---------------------------
    Pokemon Snow And Spirit
    ---------------------------
    [Pokémon Essentials version 18.1]

    Exception: RuntimeError

    Message: Script error within event 21 (coords 19,18), map 6 (Valcosville):

    Exception: NoMethodError

    Message: PSystem_PokemonUtilities:413:in `pbCheckHeldItem'undefined method `<=' for :CUTITEM:Symbol



    ***Full script:

    Kernel.pbCut



    Backtrace:

    Interpreter:197:in `pbExecuteScript'

    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'

    Interpreter:102:in `loop'

    Interpreter:158: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 `update'

    Scene_Map:160:in `loop'

    Scene_Map:169:in `update'

    Scene_Map:229:in `main'



    This exception was logged in

    C:\Users\USERNAME\Saved Games\Pokemon Snow And Spirit\errorlog.txt.

    Press Ctrl+C to copy this message to the clipboard.
    ---------------------------
    OK
    ---------------------------
     
    1,407
    Posts
    10
    Years
    • Seen today
    anyone who can tell me what im doing wrong would be great, prepare for very janky code.

    def pbCut
    move = getID(PBMoves,:CUT)
    movefinder = pbCheckMove(move)
    heldItem = pbCheckHeldItem(:CUTITEM)
    canUse = pbCheckCanLearnMove(move)
    pokeName = pbGetName(move)
    if heldItem == true
    if canUse == true
    if !pbCheckHiddenMoveBadge(BADGE_FOR_CUT,false) || (!$DEBUG)
    pbMessage(_INTL("This tree looks like it can be cut down."))
    return false
    end
    pbMessage(_INTL("This tree looks like it can be cut down!\1"))
    if pbConfirmMessage(_INTL("Would you like to cut it?"))
    speciesname = (PokeName) ? PokeName.name : $Trainer.name
    pbMessage(_INTL("{1} used {2}!",speciesname,PBMoves.getName(move)))
    pbHiddenMoveAnimation(movefinder)
    return true
    end
    end
    end


    error message:-

    ---------------------------
    Pokemon Snow And Spirit
    ---------------------------
    [Pokémon Essentials version 18.1]

    Exception: RuntimeError

    Message: Script error within event 21 (coords 19,18), map 6 (Valcosville):

    Exception: NoMethodError

    Message: PSystem_PokemonUtilities:413:in `pbCheckHeldItem'undefined method `<=' for :CUTITEM:Symbol



    ***Full script:

    Kernel.pbCut



    Backtrace:

    Interpreter:197:in `pbExecuteScript'

    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'

    Interpreter:102:in `loop'

    Interpreter:158: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 `update'

    Scene_Map:160:in `loop'

    Scene_Map:169:in `update'

    Scene_Map:229:in `main'



    This exception was logged in

    C:\Users\USERNAME\Saved Games\Pokemon Snow And Spirit\errorlog.txt.

    Press Ctrl+C to copy this message to the clipboard.
    ---------------------------
    OK
    ---------------------------

    I don't really follow your code, but I feel like you're making this far more complicated than it needs to be. I was able to get what you're attempting to make working by simply doing this:

    Paste this somewhere in PSystem_PokemonUtilities
    Code:
    def pbCheckHeldItem(item)
      item = getID(PBItems,item)
      return nil if !item || item<=0
      for i in $Trainer.pokemonParty
        return i if i.item==item
      end
      return nil
    end

    Then in pbCut, change the line movefinder = pbCheckMove(move) to this instead:
    Code:
    movefinder = (pbCheckMove(move) || pbCheckHeldItem(:CUTCHARM))
    That's it.

    Obviously, replace CUTCHARM with whatever your item is, and then just replicate this for each field move.

    When used in the field, the game will prioritize Pokemon in the party that have the move Cut, but if none exist, it will then check for Pokemon with the Cut Charm instead.
     
    17
    Posts
    3
    Years
    • Seen Feb 6, 2023
    I alredy have this in pokemon utilites def pbCheckHeldItem(item) yours looks more elegent for sure but also mine works. so im going with if it isnt broke dont fix it.

    I did manage to get it working for CUT, ROCK SMASH,DIVE,SURF with the code I had but my problem is FLY,

    like I mentioned I dont want just any pokemon to hold the charm and be able to use its respective move. so i do a check if the pokemon can learn a move pbcheck move only return if the pokemon has the move which would make the charm pointless.

    I need to be able to give a pokemon the fly charm and have fly appear in the party menu for the pokemon if they can use the move fly but dont have it. also for quickness to be able to press tab and have the fly option with the same peramiters eg: if pokemon has held item and can learn fly then use fly elseIf pokemon knows fly then use fly

    any hints would be fab
     
    1,407
    Posts
    10
    Years
    • Seen today
    I alredy have this in pokemon utilites def pbCheckHeldItem(item) yours looks more elegent for sure but also mine works. so im going with if it isnt broke dont fix it.

    I did manage to get it working for CUT, ROCK SMASH,DIVE,SURF with the code I had but my problem is FLY,

    like I mentioned I dont want just any pokemon to hold the charm and be able to use its respective move. so i do a check if the pokemon can learn a move pbcheck move only return if the pokemon has the move which would make the charm pointless.

    I need to be able to give a pokemon the fly charm and have fly appear in the party menu for the pokemon if they can use the move fly but dont have it. also for quickness to be able to press tab and have the fly option with the same peramiters eg: if pokemon has held item and can learn fly then use fly elseIf pokemon knows fly then use fly

    any hints would be fab

    Oh, if you want the move to appear in the party menu while holding the item, then that's a whole different story and will require a bunch of edits in the Party screen. I've done this before when adding new party commands when creating the Birthsign script.

    Off the top of my head, you'll have to find the line
    Code:
    cmdMoves   = [-1,-1,-1,-1]
    And then add an entry for each field move you're attempting to add via held item. So for example
    Code:
    cmdCut      = -1
    cmdStrength = -1
    cmdSurf     = -1
    Etc, etc...

    Then, you'll have to add the command text for each entry a few lines down, above this:
    Code:
    commands[cmdSwitch = commands.length]       = _INTL("Switch") if @party.length>1
    Each of your entries should look something like this:
    Code:
    commands[cmdCut = commands.length]       = [_INTL("Cut"),1] if pkmn.hasItem?(:CUTCHARM)

    Then further down still, you'll have to add what each of these new commands do when selected, above this:
    Code:
    elsif cmdMail>=0 && command==cmdMail
    Each of your entries should look something like this:
    Code:
    elsif cmdCut>=0 && command==cmdCut
            move = getID(PBMoves,:CUT)
            if pbCanUseHiddenMove?(pkmn,move)
              if pbConfirmUseHiddenMove(pkmn,move)
                @scene.pbEndScene
                return [pkmn,move]
              end
            end

    For Fly in particular, you'll need a completely different code:
    Code:
    elsif cmdFly>=0 && command==cmdFly
            move = getID(PBMoves,:FLY)
            if pbCanUseHiddenMove?(pkmn,move)
              if pbConfirmUseHiddenMove(pkmn,move)
                @scene.pbEndScene
                scene = PokemonRegionMap_Scene.new(-1,false)
                screen = PokemonRegionMapScreen.new(scene)
                ret = screen.pbStartFlyScreen
                if ret
                  $PokemonTemp.flydata=ret
                  return [pkmn,move]
                end
              end
            end

    And that *should* do it. Any of the code you implemented in PField_FieldMoves should no longer be necessary after this, because for all intents and purposes the Pokemon will just be treated as if it has that field move while the item is held.
     
    17
    Posts
    3
    Years
    • Seen Feb 6, 2023
    that fantastic, i now can use fly from the party menu. is there a way to add this commad to the tap ready menu? with similar checks, if can learn fly from hm but hasnt yet and has held item:cutitem add command to ready menu

    thanks again.
     
    1,407
    Posts
    10
    Years
    • Seen today
    that fantastic, i now can use fly from the party menu. is there a way to add this commad to the tap ready menu? with similar checks, if can learn fly from hm but hasnt yet and has held item:cutitem add command to ready menu

    thanks again.

    Idk, I've never used that menu or even looked at that code tbh.
     
    17
    Posts
    3
    Years
    • Seen Feb 6, 2023
    any idea why im getting this:

    ---------------------------
    Pokemon Snow And Spirit
    ---------------------------
    [Pokémon Essentials version 18.1]

    Exception: NoMethodError

    Message: undefined method `x=' for nil:NilClass



    Backtrace:

    MessageConfig:135:in `pbBottomLeftLines'

    PScreen_Party:563:in `pbSetHelpText'

    PScreen_Party:1115:in `pbPokemonScreen'

    PScreen_Party:1114:in `loop'

    PScreen_Party:1345:in `pbPokemonScreen'

    PScreen_PauseMenu:178:in `pbStartPokemonMenu'

    PScreen_PauseMenu:175:in `pbFadeOutIn'

    PScreen_PauseMenu:180:in `pbStartPokemonMenu'

    PScreen_PauseMenu:144:in `loop'

    PScreen_PauseMenu:274:in `pbStartPokemonMenu'



    This exception was logged in

    C:\Users\USERNAME\Saved Games\Pokemon Snow And Spirit\errorlog.txt.

    Press Ctrl+C to copy this message to the clipboard.
    ---------------------------
    OK
    ---------------------------

    I tested last night the changes to add the fly to the party screen pokemon commands and you can fly but if you click cancel without chosing a fly location and retun to pause menu i get this error
     
    17
    Posts
    3
    Years
    • Seen Feb 6, 2023
    figured it out was missing a line to start the party screen menu

    elsif cmdFly>=0 && command==cmdFly
    move = getID(PBMoves,:FLY)
    if pbCanUseHiddenMove?(pkmn,move)
    if pbConfirmUseHiddenMove(pkmn,move)
    @scene.pbEndScene
    scene = PokemonRegionMap_Scene.new(-1,false)
    screen = PokemonRegionMapScreen.new(scene)
    ret = screen.pbStartFlyScreen
    if ret
    $PokemonTemp.flydata=ret
    return [pkmn,move]
    end
    ##### missing line
    @scene.pbStartScene(@party,
    (@party.length>1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel."))
    end
     
    Back
    Top