• 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.
  • 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!
  • Scottie, Todd, Serena, Kris - which Pokémon protagonist is your favorite? Let us know by voting in our poll!
  • 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.

Trouble with turning HMs into items (specifically Surf)

  • 3
    Posts
    9
    Years
    • Seen Dec 5, 2016
    I'm new around here so I'm not sure if this is the right place to ask this but I'm trying to turn HMs into items. I'm changing surf to a raft now, and everything work except the use from bag. When I use it from the bag it uses the item, it changes to the surfing sprite, but the player doesn't jump forward into the water. He just remains on the land tile he was standing on unable to move and then it freezes, I can't move or open the pause menu or anything. I'm so confused because it works is you walk up and press the action button on the water but not from the bag. Can anyone help?

    Here's my script:
    Code:
    def Kernel.pbSurf
    if $game_player.pbHasDependentEvents?
    return false
    end
    if $DEBUG ||
    (HIDDENMOVESCOUNTBADGES ? $Trainer.numbadges>=BADGEFORSURF : $Trainer.badges[BADGEFORSURF])
    movefinder=Kernel.pbCheckMove(:SURF)
    if $DEBUG || $PokemonBag.pbQuantity(PBItems::RAFT)>0
    if Kernel.pbConfirmMessage(_INTL("The water is a deep blue, would you like to use the raft?"))
    speciesname=!movefinder ? $Trainer.name : movefinder.name
    Kernel.pbMessage(_INTL("You started rafting!",speciesname))
    
    surfbgm=pbGetMetadata(0,MetadataSurfBGM)
    if surfbgm
    pbCueBGM(surfbgm,0.5)
    end
    
    pbStartSurfing()
    return true
    end
    end
    end
    return false
    end
    
    def pbStartSurfing()
    Kernel.pbCancelVehicles
    $PokemonEncounters.clearStepCount
    $PokemonGlobal.surfing=true
    Kernel.pbUpdateVehicle
    Kernel.pbJumpToward
    Kernel.pbUpdateVehicle
    $game_player.check_event_trigger_here([1,2])
    end
    
    def pbEndSurf(xOffset,yOffset)
    return false if !$PokemonGlobal.surfing
    x=$game_player.x
    y=$game_player.y
    currentTag=$game_map.terrain_tag(x,y)
    facingTag=Kernel.pbFacingTerrainTag
    if PBTerrain.isSurfable?(currentTag) && !PBTerrain.isSurfable?(facingTag)
    if Kernel.pbJumpToward
    Kernel.pbCancelVehicles
    $game_map.autoplayAsCue
    $game_player.increase_steps
    result=$game_player.check_event_trigger_here([1,2])
    Kernel.pbOnStepTaken(result)
    end
    return true
    end
    return false
    end
    
    Events.onAction+=proc{|sender,e|
    terrain=Kernel.pbFacingTerrainTag
    notCliff=$game_map.passable?($game_player.x,$game_player.y,$game_player.direction)
    if PBTerrain.isSurfable?(terrain) && !$PokemonGlobal.surfing &&
    !pbGetMetadata($game_map.map_id,MetadataBicycleAlways) && notCliff
    Kernel.pbSurf
    return
    end
    }
    def canUseMoveSurf?
    terrain=Kernel.pbFacingTerrainTag
    notCliff=$game_map.passable?($game_player.x,$game_player.y,$game_player.direction)
    if !$DEBUG &&
    !(HIDDENMOVESCOUNTBADGES ? $Trainer.numbadges>=BADGEFORSURF : $Trainer.badges[BADGEFORSURF])
    Kernel.pbMessage(_INTL("Sorry, a new Badge is required."))
    return false
    end
    if $PokemonGlobal.surfing
    Kernel.pbMessage(_INTL("You're already rafting."))
    return false
    end
    if $game_player.pbHasDependentEvents?
    Kernel.pbMessage(_INTL("It can't be used when you have someone with you."))
    return false
    end
    if pbGetMetadata($game_map.map_id,MetadataBicycleAlways)
    Kernel.pbMessage(_INTL("Let's enjoy cycling!"))
    return false
    end
    if !PBTerrain.isSurfable?(terrain) || !notCliff
    Kernel.pbMessage(_INTL("No rafting here!"))
    return false
    end
    return true
    end
    
    def useMoveSurf
    if !pbHiddenMoveAnimation(nil)
    Kernel.pbMessage(_INTL("You started rafting!",$Trainer.name,"Surf"))
    end
    pbStartSurfing()
    return true
    end
    
    HiddenMoveHandlers::UseMove.add(:SURF,proc{|move,pokemon|
    if !pbHiddenMoveAnimation(pokemon)
    Kernel.pbMessage(_INTL("{1} used {2}!",pokemon.name,PBMoves.getName(move)))
    end
    pbStartSurfing()
    return true
    })

    Code:
    ItemHandlers::UseFromBag.add(:RAFT,proc{|item|
       next canUseMoveSurf? ? 2 : 0
    })
    
    
    ItemHandlers::UseInField.add(:RAFT,proc{|item|
    useMoveSurf if canUseMoveSurf?
    })

    Any help is very appreciated. Thank you.
     
    I think it is a bug, i am hunting for solution of this problem too.

    If you go to the script PField_HiddenMoves and comment the line 516(Kernel.pbJumpToward), it seems to work but still not correctly:

    def pbStartSurfing()
    Kernel.pbCancelVehicles
    $PokemonEncounters.clearStepCount
    $PokemonGlobal.surfing=true
    Kernel.pbUpdateVehicle
    #Kernel.pbJumpToward
    Kernel.pbUpdateVehicle
    $game_player.check_event_trigger_here([1,2])
    end
     
    Hello guys, I think I can help. I'm new with coding, with Pokemon Essentials/RGSS, but I seen this post, and thought I'd try figure out the issue. I think it's a pretty easy fix, it seems to be working for me at least.
    Hope this helps!


    Here is the full working code below.
    Code:
    #===============================================================================
    # Surf
    #===============================================================================
    def Kernel.pbSurf
    if $game_player.pbHasDependentEvents?
    return false
    end
    if $DEBUG ||
    (HIDDENMOVESCOUNTBADGES ? $Trainer.numbadges>=BADGEFORSURF : $Trainer.badges[BADGEFORSURF])
    movefinder=Kernel.pbCheckMove(:SURF)
    if $DEBUG || $PokemonBag.pbQuantity(PBItems::RAFT)>0
    if Kernel.pbConfirmMessage(_INTL("The water is a deep blue, would you like to use the raft?"))
    speciesname=!movefinder ? $Trainer.name : movefinder.name
    Kernel.pbMessage(_INTL("You started rafting!",speciesname))
    
    surfbgm=pbGetMetadata(0,MetadataSurfBGM)
    if surfbgm
    pbCueBGM(surfbgm,0.5)
    end
    
    pbStartSurfing()
    return true
    end
    end
    end
    return false
    end
    
    def pbStartSurfing()
    Kernel.pbCancelVehicles
    $PokemonEncounters.clearStepCount
    $PokemonGlobal.surfing=true
    Kernel.pbUpdateVehicle
    Kernel.pbJumpToward
    Kernel.pbUpdateVehicle
    $game_player.check_event_trigger_here([1,2])
    end
    
    def pbEndSurf(xOffset,yOffset)
    return false if !$PokemonGlobal.surfing
    x=$game_player.x
    y=$game_player.y
    currentTag=$game_map.terrain_tag(x,y)
    facingTag=Kernel.pbFacingTerrainTag
    if pbIsSurfableTag?(currentTag) && !pbIsSurfableTag?(facingTag)
    if Kernel.pbJumpToward
    Kernel.pbCancelVehicles
    $game_map.autoplayAsCue
    $game_player.increase_steps
    result=$game_player.check_event_trigger_here([1,2])
    Kernel.pbOnStepTaken(result)
    end
    return true
    end
    return false
    end
    
    Events.onAction+=proc{|sender,e|
    terrain=Kernel.pbFacingTerrainTag
    notCliff=$game_map.passable?($game_player.x,$game_player.y,$game_player.direction)
    if pbIsWaterTag?(terrain) && !$PokemonGlobal.surfing && 
    !pbGetMetadata($game_map.map_id,MetadataBicycleAlways) && notCliff
    Kernel.pbSurf
    return
    end
    }
    def canUseMoveSurf?
    terrain=Kernel.pbFacingTerrainTag
    notCliff=$game_map.passable?($game_player.x,$game_player.y,$game_player.direction)
    if !$DEBUG &&
    !(HIDDENMOVESCOUNTBADGES ? $Trainer.numbadges>=BADGEFORSURF : $Trainer.badges[BADGEFORSURF])
    Kernel.pbMessage(_INTL("Sorry, a new Badge is required."))
    return false
    end
    if $PokemonGlobal.surfing
    Kernel.pbMessage(_INTL("You're already rafting."))
    return false
    end
    if $game_player.pbHasDependentEvents?
    Kernel.pbMessage(_INTL("It can't be used when you have someone with you."))
    return false
    end
    if pbGetMetadata($game_map.map_id,MetadataBicycleAlways)
    Kernel.pbMessage(_INTL("Let's enjoy cycling!"))
    return false
    end
    #if !PBTerrain.isSurfable?(terrain) || !notCliff
    if !pbIsWaterTag?(terrain) || !notCliff
    Kernel.pbMessage(_INTL("No rafting here!"))
    return false
    end
    return true
    end
    
    def useMoveSurf
    if !pbHiddenMoveAnimation(nil)
    Kernel.pbMessage(_INTL("You started rafting!",$Trainer.name,"Surf"))
    end
    pbStartSurfing()
    return true
    end
    
    HiddenMoveHandlers::UseMove.add(:SURF,proc{|move,pokemon|
    if !pbHiddenMoveAnimation(pokemon)
    Kernel.pbMessage(_INTL("{1} used {2}!",pokemon.name,PBMoves.getName(move)))
    end
    pbStartSurfing()
    return true
    })
    Incase you want to manually change it.. (You only need to edit/fix 3 lines)

    Replace:
    Code:
    if PBTerrain.isSurfable?(currentTag) && !PBTerrain.isSurfable?(facingTag)
    With:
    Code:
      [COLOR=Red]
    if pbIsSurfableTag?(currentTag) && !pbIsSurfableTag?(facingTag)
    [/COLOR]


    Replace:
    Code:
    if PBTerrain.isSurfable?(terrain) && !$PokemonGlobal.surfing &&
    !pbGetMetadata($game_map.map_id,MetadataBicycleAlways) && notCliff

    With:
    Code:
    [COLOR=Red][COLOR=Black][COLOR=Red]
    if pbIsWaterTag?(terrain) && !$PokemonGlobal.surfing && 
    !pbGetMetadata($game_map.map_id,MetadataBicycleAlways) && notCliff
    [/COLOR][/COLOR][/COLOR]


    Replace:
    Code:
    [B][COLOR=Red][COLOR=Black]
    [/COLOR][/COLOR][/B]if !PBTerrain.isSurfable?(terrain) || !notCliff

    With:
    Code:
    [B][COLOR=Red][COLOR=Black][COLOR=Red][COLOR=Black]
    [/COLOR][/COLOR][/COLOR][/COLOR][/B][COLOR=Red]if !pbIsWaterTag?(terrain) || !notCliff[/COLOR]

     
    Weedfanatic:
    See my problem isn't in using the move. If I approach the water, press A and go through the "water is a deep blue, would you like to surf?", it works fine. Jumps forwards and surf works as it should. My problem is when I go to the key items in the bag and use the raft from there. It uses the raft and changes my sprite, but it doesn't jump forward into the water. I'm just stuck on land and cant move.

    Danilols:
    I tried that, but I don't like that the player can just raft around land after that. Just too goofy lol. So I've thrown it on the back burner for now as it does work as long as you don't use it out of the bag. Working on more important parts now, gonna troubleshoot that later.
     
    From my tutorial:
    After testing, the only adjustment was the plural field when declaring items.

    But using Surf from menu won't work in Essentials V16.1, so it won't work here too.
    The problem is some strange bug with jump that occurs when surf is called from menu.
     
    Weedfanatic:
    See my problem isn't in using the move. If I approach the water, press A and go through the "water is a deep blue, would you like to surf?", it works fine. Jumps forwards and surf works as it should. My problem is when I go to the key items in the bag and use the raft from there. It uses the raft and changes my sprite, but it doesn't jump forward into the water. I'm just stuck on land and cant move.

    Danilols:
    I tried that, but I don't like that the player can just raft around land after that. Just too goofy lol. So I've thrown it on the back burner for now as it does work as long as you don't use it out of the bag. Working on more important parts now, gonna troubleshoot that later.

    I knew what you meant. When you use the item from bag, it doesn't let you jump into the water. I got that.
    I tested your exact code with the adjustments I posted, and used the item from bag. It worked fine for me, and my player jumped into the water + displayed the normal surf sprite. Did you at least try fix the changes I posted? I'm pretty sure it's not a bug, rather old code mixed with v16 code.

    Edit: You're using V16.1?
     
    Back
    Top