• Do not use Discord to host any images you post, these links expire quickly! You can learn how to add images to your posts here.
  • Eevee Expo's webhost has been having technical issues since Nov. 20th and you might be unable to connect to our site. Staff are also facing issues connecting, so please send a DM to Cat on-site or through Discord directly for faster service!
HM Items

Resource HM Items v1.0

Ott

My crown is made from the Yellow Pages
Moderator
this scripts supports the version 18?
It's still for 17.2

LP6agZr.png
 

zlohpa

Novice
Member
Joined
Nov 21, 2020
Posts
10
This might sound arrogant because I don't know how to script at all, but will we see an update anytime soon?
 

Golisopod User

Elite Trainer
Member
Joined
May 11, 2020
Posts
319
This might sound arrogant because I don't know how to script at all, but will we see an update anytime soon?
It's easy to make this script v18 compatibile. Remove every instance if Kernel. in the script.
 

Leondrea

Trainer
Member
Joined
Jul 26, 2020
Posts
95
Marin submitted a new resource:

HM Items - Replace HMs with Items without having to do any coding. Plug-and-play.



Read more about this resource...
Marin, I have taken my time to fix your script for Essentials v.18.1, TechSkylander helped me alot and Thundaga had a fix that I used too.

I took a few days but I figured out how to make your Script compatible for Essentials v.18.1.
I've playtested everything and everything works perfectly fine and smoothly. If people want to use it -

- Just add this Script above Main:
Ruby:
Expand Collapse Copy
#==============================================================================#
#                                    HM Items                                  #
#                                    by Marin                                  #
#              Fixed to work with Essentials v.18.1 by Leondrea                #
#==============================================================================#
#                       No coding knowledge required at all.                   #
#                                                                              #
#  Because the items override the actual moves' functionality, the items have  #
#      switches to toggle them, as you see below (USING_SURF_ITEM, etc.)       #
#   If they're set to true, the items will be active and will override some    #
#                 in-field functionality of the moves themselves.              #
#==============================================================================#
#      Rock Smash, Strength and Cut all use the default Essentials events.     #
#==============================================================================#
#                    Please give credit when using this.                       #
#==============================================================================#

# Future updates may contain: Flash, Headbutt, Sweet Scent, Rock Climb.


# The internal name of the item that will trigger Surf
SURF_ITEM = :FLOATINGTIRE

# The internal name of the item that will trigger Rock Smash
ROCK_SMASH_ITEM = :PICKAXE

# The internal name of the item that will trigger Fly
FLY_ITEM = :HOTAIRBALLOON

# The internal name of the item that will trigger Strength
STRENGTH_ITEM = :STRENGTHGLOVE

# The internal name of the item that will trigger Cut
CUT_ITEM = :PRUNINGSHEAR



# When true, this overrides the old surfing mechanics.
USING_SURF_ITEM = true

# When true, this overrides the old rock smash mechanics.
USING_ROCK_SMASH_ITEM = true

# When true, this overrides the old fly mechanics.
USING_FLY_ITEM = true

# When true, this overrides the old strength mechanics.
USING_STRENGTH_ITEM = true

# When true, this overrides the old cut mechanics.
USING_CUT_ITEM = true


#==============================================================================#
# This section of code contains minor utility methods.                         #
#==============================================================================#

class Game_Map
  attr_reader :map
end

class Game_Player
  attr_writer :x
  attr_writer :y
end

class HandlerHash
  def delete(sym)
    id = fromSymbol(sym)
    @hash.delete(id) if id && @hash[id]
    symbol = toSymbol(sym)
    @hash.delete(symbol) if symbol && @hash[symbol]
  end
end

def pbSmashEvent(event)
  return unless event
  if event.name == "Tree"
    pbSEPlay("Cut", 80)
  elsif event.name == "Rock"
    pbSEPlay("Rock Smash", 80)
  end
  pbMoveRoute(event,[
     PBMoveRoute::TurnDown,
     PBMoveRoute::Wait, 2,
     PBMoveRoute::TurnLeft,
     PBMoveRoute::Wait, 2,
     PBMoveRoute::TurnRight,
     PBMoveRoute::Wait, 2,
     PBMoveRoute::TurnUp,
     PBMoveRoute::Wait, 2
  ])
  pbWait(16)
  event.erase
  $PokemonMap.addErasedEvent(event.id) if $PokemonMap
end

#==============================================================================#
# This section of the code handles the item that calls Surf.                   #
#==============================================================================#

if USING_SURF_ITEM
  HiddenMoveHandlers::CanUseMove.delete(:SURF)
  HiddenMoveHandlers::UseMove.delete(:SURF)
 
  def pbSurf
    return false if $game_player.pbHasDependentEvents?
    move = getID(PBMoves,:SURF)
     if !$PokemonBag.pbHasItem?(:FLOATINGTIRE) && !$DEBUG
      then
      pbMessage(_INTL("The water is deep blue..."))
      return false
    end
    if pbConfirmMessage(_INTL("The water is a deep blue...\nWould you like to surf on it?"))
      pbMessage(_INTL("{1} used the {2}!", $Trainer.name, PBItems.getName(getConst(PBItems,SURF_ITEM))))
      pbCancelVehicles
      surfbgm = pbGetMetadata(0,MetadataSurfBGM)
      pbCueBGM(surfbgm,0.5) if surfbgm
      pbStartSurfing
      return true
    end
    return false
  end
 
  ItemHandlers::UseInField.add(SURF_ITEM, proc do |item|
    $game_temp.in_menu = false
    pbSurf
    return true
  end)
 
  ItemHandlers::UseFromBag.add(SURF_ITEM, proc do |item|
    return false if $PokemonGlobal.surfing ||
                    pbGetMetadata($game_map.map_id,MetadataBicycleAlways) ||
                    !PBTerrain.isSurfable?(pbFacingTerrainTag) ||
                    !$game_map.passable?($game_player.x,$game_player.y,$game_player.direction,$game_player)
    return 2
  end)
end

#==============================================================================#
# This section of the code handles the item that calls Fly.                    #
#==============================================================================#

if USING_FLY_ITEM
  ItemHandlers::UseFromBag.add(FLY_ITEM, proc do |item|
    return false unless pbGetMetadata($game_map.map_id,MetadataOutdoor)
    if defined?(BetterRegionMap)
      ret = pbBetterRegionMap(nil, true, true)
    else
      ret = pbFadeOutIn(99999) do
        scene = PokemonRegionMap_Scene.new(-1, false)
        screen = PokemonRegionMapScreen.new(scene)
        next screen.pbStartFlyScreen
      end
    end
    if ret
      $PokemonTemp.flydata = ret
      return 2
    end
    return 0
  end)
 
  ItemHandlers::UseInField.add(FLY_ITEM, proc do |item|
    $game_temp.in_menu = false
    return false if !$PokemonTemp.flydata
    pbMessage(_INTL("{1} used the {2}!", $Trainer.name,PBItems.getName(getConst(PBItems,FLY_ITEM))))
    pbFadeOutIn(99999) do
       $game_temp.player_new_map_id    = $PokemonTemp.flydata[0]
       $game_temp.player_new_x         = $PokemonTemp.flydata[1]
       $game_temp.player_new_y         = $PokemonTemp.flydata[2]
       $game_temp.player_new_direction = 2
       pbCancelVehicles
       $PokemonTemp.flydata = nil
       $scene.transfer_player
       $game_map.autoplay
       $game_map.refresh
    end
    pbEraseEscapePoint
    return true
  end)
end


#==============================================================================#
# This section of the code handles the item that calls Rock Smash.             #
#==============================================================================#

if USING_ROCK_SMASH_ITEM
  HiddenMoveHandlers::CanUseMove.delete(:ROCKSMASH)
  HiddenMoveHandlers::UseMove.delete(:ROCKSMASH)
 
  ItemHandlers::UseFromBag.add(ROCK_SMASH_ITEM, proc do |item|
    if $game_player.pbFacingEvent && $game_player.pbFacingEvent.name == "Rock"
      return 2
    end
    return false
  end)
 
  ItemHandlers::UseInField.add(ROCK_SMASH_ITEM, proc do |item|
    $game_player.pbFacingEvent.start
    return true
  end)
 
  def pbRockSmash
    if !$PokemonBag.pbHasItem?(:PICKAXE) && !$DEBUG
      then
      pbMessage(_INTL("It's a cracked boulder. A certain Key Item may be able to break it."))
      return false
    end
    item = PBItems.getName(getConst(PBItems,ROCK_SMASH_ITEM))
    if pbConfirmMessage(_INTL("This rock appears to be breakable. Would you like to use the {1}?", item))
      pbMessage(_INTL("{1} used the {2}!",$Trainer.name, item))
      return true
    end
    return false
  end
end


#==============================================================================#
# This section of code handles the item that calls Strength.                   #
#==============================================================================#

if USING_STRENGTH_ITEM
  HiddenMoveHandlers::CanUseMove.delete(:STRENGTH)
  HiddenMoveHandlers::UseMove.delete(:STRENGTH)
 
  def pbStrength
    if $PokemonMap.strengthUsed
      pbMessage(_INTL("The Strength Glove made it possible to move boulders around."))
      return false
    end
    if !$PokemonBag.pbHasItem?(:STRENGTHGLOVE) && !$DEBUG
      pbMessage(_INTL("It's a big boulder, but a certain Key Item may be able to push it aside."))
      return false
    end
    if !pbHasItem?(STRENGTH_ITEM)
      pbMessage(_INTL("It's a big boulder, but a certain Key Item may be able to push it aside."))
      return false
    else
      itemname = PBItems.getName(getConst(PBItems,STRENGTH_ITEM))
      pbMessage(_INTL("It's a big boulder.\1"))
      if pbConfirmMessage(_INTL("Would you like to use the {1}?", itemname))
        pbMessage(_INTL("{1} used the {2}!",
            $Trainer.name, itemname))
        pbMessage(_INTL("The {1} made it possible to move boulders around!",itemname))
        $PokemonMap.strengthUsed = true
        return true
      end
    end
    return false
  end
 
  ItemHandlers::UseFromBag.add(STRENGTH_ITEM, proc do
    if $game_player.pbFacingEvent && $game_player.pbFacingEvent.name == "Boulder"
      return 2
    end
    return false
  end)
 
  ItemHandlers::UseInField.add(STRENGTH_ITEM, proc { pbStrength })
end


#==============================================================================#
# This section of code handles the item that calls Cut.                        #
#==============================================================================#

if USING_CUT_ITEM
  HiddenMoveHandlers::CanUseMove.delete(:CUT)
  HiddenMoveHandlers::UseMove.delete(:CUT)
 
  def pbCut
    if !$PokemonBag.pbHasItem?(:PRUNINGSHEAR) && !$DEBUG
      then
      pbMessage(_INTL("You can't pass because of a tree, but a certain Key Item may be able to cut the tree."))
      return false
    end
    pbMessage(_INTL("These tree can be cut down!\1"))
    if pbConfirmMessage(_INTL("Would you like to cut it?"))
      itemname = PBItems.getName(getConst(PBItems,CUT_ITEM))
      pbMessage(_INTL("{1} used the {2}!",$Trainer.name,itemname))
      pbSmashEvent($game_player.pbFacingEvent)
      return true
    end
    return false
  end
 
  ItemHandlers::UseFromBag.add(CUT_ITEM, proc do
    if $game_player.pbFacingEvent && $game_player.pbFacingEvent.name == "Tree"
      return 2
    end
    return false
  end)
 
  ItemHandlers::UseInField.add(CUT_ITEM, proc { $game_player.pbFacingEvent.start })
end

I've attached the graphics for the Key Items that I've used:
If you want to use them just put them inside graphics/icons and make sure the number of the items are the same in your items.txt in the pbs folder!

Then if you want to use your own graphics and your own Internal Names, you can do it. Just make sure that they are ALL CAPS, In the script for example if you want to use a machete instead of the pruning shears, just press CTRL + F and search for PRUNINGSHEAR and replace it with your internal name: MACHETE
You'll also need to change the text's inside pbMessage sometimes, in case you want to need another key item instead of the STRENGTHGLOVE

And here is how my pbs items.txt file looks like:
Ruby:
Expand Collapse Copy
634,FLOATINGTIRE,Floating Tire,Floating Tires,8,0,"A Floating Tire that lets you swim trough the water.",2,0,6,
635,HOTAIRBALLOON,Hot Air Ballon,Hot Air Balloons,8,0,"A Hot Air Ballon that takes you wherever you want to fly.",2,0,6,
636,STRENGTHGLOVE,Strength Glove,Strength Gloves,8,0,"A glove full of Strength that will give you the power to pull boulders.",2,0,6,
637,PICKAXE,Pickaxe,Pickaxes,8,0,"A Pickaxe that will let you smash rocks.",2,0,6,
638,PRUNINGSHEAR,Pruning Shear,Pruning Shears,8,0,"A pruning shear that lets you cut thorn bushes.",2,0,6

Credits go to Marin for making the original Script, for TechSkylander for helping me out and please credit me too, for fixing the script!
And thanks to Thundaga for his amazing tutorials on youtube! He had find a fix for the script to work for the old Essentials version. But I
wrote the same code as in his video and it worked: if ![imath]PokemonBag.pbHasItem?(:INTERNALNAMEOFITEM) && ![/imath]DEBUG
This helped me a lot. The rest I figured it out by myself with a lot of playtesting.
 

Attachments

  • item634.png
    item634.png
    737 bytes · Views: 162
  • item635.png
    item635.png
    1.5 KB · Views: 178
  • item636.png
    item636.png
    478 bytes · Views: 175
  • item637.png
    item637.png
    614 bytes · Views: 173
  • item638.png
    item638.png
    1.2 KB · Views: 171

Cross Agento

Novice
Member
Joined
Jun 27, 2021
Posts
32
Hi, is there a version of these HMs for v19.1? I've tried using both v17 and v18 and neither work.
 

Leondrea

Trainer
Member
Joined
Jul 26, 2020
Posts
95
Hi, is there a version of these HMs for v19.1? I've tried using both v17 and v18 and neither work.
I don't know, but I'll figure it out tomorrow. I'm new at scripting but I'll take a look at version 19 and how the script are handled there.
 

FeelsMoyoMan

Rookie
Member
Joined
Jul 26, 2021
Posts
8
I am using V19.1 and it obviously doesn't work. Even Leondrea's fix doesn't work anymore. So I tried to fix it.

I first started by removing every instance of Kernel, as Golisopod User said. It, unfortunately, wasn't that easy. After hours of code changes and tests I now have a working version for V19.1. I modified the original Script from Marin, so I don't know, what you have to change to make Leondrea's version work.

I said it in a different thread, I am not very familiar with Ruby. So I am pretty sure, that this isn't the best way to solve this.

This is definitely just a bandage and not a fully fleshed-out Script since the original Script is fairly old. I am, maybe, going to rework the whole thing and ad stuff like Flash, Headbutt, etc. as well, but just maybe.

Important to note is, that when you want to use Rock Smash or Cut out of the inventory, the Rock Event needs to be named "SmashRock" and the Cut Event needs to be named "CutTree". This is a quirk from the original Script and I am going to leave it like this for now.

If anything breaks, feel free to contact me, I will try my best to fix it.

Also if you want to use that Script make sure to give Marin Credit. You don't have to mention me, but I would appreciate it.

HM Items:
Expand Collapse Copy
#==============================================================================#
#                                    HM Items                                  #
#                                    by Marin                                  #
#==============================================================================#
#                       No coding knowledge required at all.                   #
#                                                                              #
#  Because the items override the actual moves' functionality, the items have  #
#      switches to toggle them, as you see below (USING_SURF_ITEM, etc.)       #
#   If they're set to true, the items will be active and will override some    #
#                 in-field functionality of the moves themselves.              #
#==============================================================================#
#      Rock Smash, Strength and Cut all use the default Essentials events.     #
#==============================================================================#
#                    Please give credit when using this.                       #
#==============================================================================#

# Future updates may contain: Flash, Headbutt, Sweet Scent, Rock Climb.


# The internal name of the item that will trigger Surf
SURF_ITEM = :SURFITEM

# The internal name of the item that will trigger Rock Smash
ROCK_SMASH_ITEM = :ROCKSMASHITEM

# The internal name of the item that will trigger Fly
FLY_ITEM = :FLYITEM

# The internal name of the item that will trigger Strength
STRENGTH_ITEM = :STRENGTHITEM

# The internal name of the item that will trigger Cut
CUT_ITEM = :CUTITEM



# When true, this overrides the old surfing mechanics.
USING_SURF_ITEM = true

# When true, this overrides the old rock smash mechanics.
USING_ROCK_SMASH_ITEM = true

# When true, this overrides the old fly mechanics.
USING_FLY_ITEM = true

# When true, this overrides the old strength mechanics.
USING_STRENGTH_ITEM = true

# When true, this overrides the old cut mechanics.
USING_CUT_ITEM = true


#==============================================================================#
# This section of code contains minor utility methods.                         #
#==============================================================================#

class Game_Map
  attr_reader :map
end

class Game_Player
  attr_writer :x
  attr_writer :y
end

class HandlerHash
  def delete(sym)
    id = fromSymbol(sym)
    @hash.delete(id) if id && @hash[id]
    symbol = toSymbol(sym)
    @hash.delete(symbol) if symbol && @hash[symbol]
  end
end

def pbSmashEvent(event)
  return unless event
  if event.name == "CutTree"
    pbSEPlay("Cut", 80)
  elsif event.name == "SmashRock"
    pbSEPlay("Rock Smash", 80)
  end
  pbMoveRoute(event,[
     PBMoveRoute::TurnDown,
     PBMoveRoute::Wait, 2,
     PBMoveRoute::TurnLeft,
     PBMoveRoute::Wait, 2,
     PBMoveRoute::TurnRight,
     PBMoveRoute::Wait, 2,
     PBMoveRoute::TurnUp,
     PBMoveRoute::Wait, 2
  ])
  pbWait(16)
  event.erase
  $PokemonMap.addErasedEvent(event.id) if $PokemonMap
end


#==============================================================================#
# This section of the code handles the item that calls Surf.                   #
#==============================================================================#

if USING_SURF_ITEM
 
  def pbSurf
    return false if $game_player.pbHasDependentEvents?
    move = GameData::Move.get(:SURF)
    if !$PokemonBag.pbHasItem?(:SURFITEM) && !$DEBUG
      return false
    end
    if pbConfirmMessage(_INTL("The water is a deep blue...\nWould you like to surf on it?"))
      pbMessage(_INTL("{1} used the {2}!", $Trainer.name, GameData::Item.get(SURF_ITEM).name))
      pbCancelVehicles
      surfbgm = GameData::Metadata.get.surf_BGM
      pbCueBGM(surfbgm,0.5) if surfbgm
      pbStartSurfing
      return true
    end
    return false
  end
 
  ItemHandlers::UseInField.add(SURF_ITEM, proc do |item|
    $game_temp.in_menu = false
    pbSurf
    next 1
  end)
 
  ItemHandlers::UseFromBag.add(SURF_ITEM, proc do |item|
    next 0 if $PokemonGlobal.surfing ||
                    GameData::MapMetadata.get($game_map.map_id).always_bicycle||
                    !$game_player.pbFacingTerrainTag.can_surf_freely ||
                    !$game_map.passable?($game_player.x,$game_player.y,$game_player.direction,$game_player)
    next 2
  end)
end


#==============================================================================#
# This section of the code handles the item that calls Fly.                    #
#==============================================================================#

if USING_FLY_ITEM
  ItemHandlers::UseFromBag.add(FLY_ITEM, proc do |item|
    if !GameData::MapMetadata.exists?($game_map.map_id) ||
       !GameData::MapMetadata.get($game_map.map_id).outdoor_map
      pbMessage(_INTL("Can't use that here."))
      next 0
    end
    if defined?(BetterRegionMap)
      ret = pbBetterRegionMap(nil, true, true)
    else
      ret = pbFadeOutIn(99999) do
        scene = PokemonRegionMap_Scene.new(-1, false)
        screen = PokemonRegionMapScreen.new(scene)
        next screen.pbStartFlyScreen
      end
    end
    if ret
      $PokemonTemp.flydata = ret
      next 2
    end
    next 0
  end)
 
  ItemHandlers::UseInField.add(FLY_ITEM, proc do |item|
    $game_temp.in_menu = false
    next 0 if !$PokemonTemp.flydata
    pbMessage(_INTL("{1} used the {2}!", $Trainer.name,GameData::Item.get(FLY_ITEM).name))
    pbFadeOutIn {
      $game_temp.player_new_map_id    = $PokemonTemp.flydata[0]
      $game_temp.player_new_x         = $PokemonTemp.flydata[1]
      $game_temp.player_new_y         = $PokemonTemp.flydata[2]
      $game_temp.player_new_direction = 2
      $PokemonTemp.flydata = nil
      $scene.transfer_player
      $game_map.autoplay
      $game_map.refresh
    }
    pbEraseEscapePoint
    next 1
  end)
end

#==============================================================================#
# This section of the code handles the item that calls Rock Smash.             #
#==============================================================================#

if USING_ROCK_SMASH_ITEM
 
  ItemHandlers::UseFromBag.add(ROCK_SMASH_ITEM, proc do |item|
    if $game_player.pbFacingEvent && $game_player.pbFacingEvent.name == "SmashRock"
      next 2
    end
    next 0
  end)
 
  ItemHandlers::UseInField.add(ROCK_SMASH_ITEM, proc do |item|
    $game_player.pbFacingEvent.start
    next 1
  end)
 
  def pbRockSmash
    if !$PokemonBag.pbHasItem?(ROCK_SMASH_ITEM) && !$DEBUG
      pbMessage(_INTL("It's a rugged rock, but an item may be able to smash it."))
      return false
    end
    item = GameData::Item.get(ROCK_SMASH_ITEM).name
    if pbConfirmMessage(_INTL("This rock appears to be breakable. Would you like to use the {1}?", item))
      pbMessage(_INTL("{1} used the {2}!",$Trainer.name, item))
      return true
    end
    return false
  end
end


#==============================================================================#
# This section of code handles the item that calls Strength.                   #
#==============================================================================#

if USING_STRENGTH_ITEM
 
  def pbStrength
    if $PokemonMap.strengthUsed
      pbMessage(_INTL("Strength made it possible to move boulders around."))
      return false
    end
    if !$PokemonBag.pbHasItem?(STRENGTH_ITEM) && !$DEBUG
      pbMessage(_INTL("It's a big boulder, but an item may be able to push it aside."))
      return false
    end
    itemname = GameData::Item.get(STRENGTH_ITEM).name
    pbMessage(_INTL("It's a big boulder, but an item may be able to push it aside.\1"))
    if pbConfirmMessage(_INTL("Would you like to use the {1}?", itemname))
      pbMessage(_INTL("{1} used the {2}!",
          $Trainer.name, itemname))
      pbMessage(_INTL("The {1} made it possible to move boulders around!",itemname))
      $PokemonMap.strengthUsed = true
      return true
    end
    return false
  end
 
  ItemHandlers::UseFromBag.add(STRENGTH_ITEM, proc do
    if $game_player.pbFacingEvent && $game_player.pbFacingEvent.name == "Boulder"
      next 2
    end
    next 0
  end)
 
  ItemHandlers::UseInField.add(STRENGTH_ITEM, proc { pbStrength })
end


#==============================================================================#
# This section of code handles the item that calls Cut.                        #
#==============================================================================#

if USING_CUT_ITEM
 
  def pbCut
    if !$PokemonBag.pbHasItem?(CUT_ITEM) && !$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?"))
      itemname = GameData::Item.get(CUT_ITEM).name
      pbMessage(_INTL("{1} used the {2}!",$Trainer.name,itemname))
      pbSmashEvent($game_player.pbFacingEvent)
      return true
    end
    return false
  end
 
  ItemHandlers::UseFromBag.add(CUT_ITEM, proc do
    if $game_player.pbFacingEvent && $game_player.pbFacingEvent.name == "CutTree"
      next 2
    end
    next 0
  end)
 
  ItemHandlers::UseInField.add(CUT_ITEM, proc { $game_player.pbFacingEvent.start })
end
 
Last edited:

Leondrea

Trainer
Member
Joined
Jul 26, 2020
Posts
95
I am using V19.1 and it obviously doesn't work. Even Leondrea's fix doesn't work anymore. So I tried to fix it.

I first started by removing every instance of Kernel, as Golisopod User said. It, unfortunately, wasn't that easy. After hours of code changes and tests I now have a working version for V19.1. I modified the original Script from Marin, so I don't know, what you have to change to make Leondrea's version work.

I said it in a different thread, I am not very familiar with Ruby. So I am pretty sure, that this isn't the best way to solve this.

This is definitely just a bandage and not a fully fleshed-out Script since the original Script is fairly old. I am, maybe, going to rework the whole thing and ad stuff like Flash, Headbutt, etc. as well, but just maybe.

Important to note is, that when you want to use Rock Smash or Cut out of the inventory, the Rock Event needs to be named "SmashRock" and the Cut Event needs to be named "CutTree". This is a quirk from the original Script and I am going to leave it like this for now.

If anything breaks, feel free to contact me, I will try my best to fix it.

Also if you want to use that Script make sure to give Marin Credit. You don't have to mention me, but I would appreciate it.

HM Items:
Expand Collapse Copy
#==============================================================================#
#                                    HM Items                                  #
#                                    by Marin                                  #
#==============================================================================#
#                       No coding knowledge required at all.                   #
#                                                                              #
#  Because the items override the actual moves' functionality, the items have  #
#      switches to toggle them, as you see below (USING_SURF_ITEM, etc.)       #
#   If they're set to true, the items will be active and will override some    #
#                 in-field functionality of the moves themselves.              #
#==============================================================================#
#      Rock Smash, Strength and Cut all use the default Essentials events.     #
#==============================================================================#
#                    Please give credit when using this.                       #
#==============================================================================#

# Future updates may contain: Flash, Headbutt, Sweet Scent, Rock Climb.


# The internal name of the item that will trigger Surf
SURF_ITEM = :SURFITEM

# The internal name of the item that will trigger Rock Smash
ROCK_SMASH_ITEM = :ROCKSMASHITEM

# The internal name of the item that will trigger Fly
FLY_ITEM = :FLYITEM

# The internal name of the item that will trigger Strength
STRENGTH_ITEM = :STRENGTHITEM

# The internal name of the item that will trigger Cut
CUT_ITEM = :CUTITEM



# When true, this overrides the old surfing mechanics.
USING_SURF_ITEM = true

# When true, this overrides the old rock smash mechanics.
USING_ROCK_SMASH_ITEM = true

# When true, this overrides the old fly mechanics.
USING_FLY_ITEM = true

# When true, this overrides the old strength mechanics.
USING_STRENGTH_ITEM = true

# When true, this overrides the old cut mechanics.
USING_CUT_ITEM = true


#==============================================================================#
# This section of code contains minor utility methods.                         #
#==============================================================================#

class Game_Map
  attr_reader :map
end

class Game_Player
  attr_writer :x
  attr_writer :y
end

class HandlerHash
  def delete(sym)
    id = fromSymbol(sym)
    @hash.delete(id) if id && @hash[id]
    symbol = toSymbol(sym)
    @hash.delete(symbol) if symbol && @hash[symbol]
  end
end

def pbSmashEvent(event)
  return unless event
  if event.name == "CutTree"
    pbSEPlay("Cut", 80)
  elsif event.name == "SmashRock"
    pbSEPlay("Rock Smash", 80)
  end
  pbMoveRoute(event,[
     PBMoveRoute::TurnDown,
     PBMoveRoute::Wait, 2,
     PBMoveRoute::TurnLeft,
     PBMoveRoute::Wait, 2,
     PBMoveRoute::TurnRight,
     PBMoveRoute::Wait, 2,
     PBMoveRoute::TurnUp,
     PBMoveRoute::Wait, 2
  ])
  pbWait(16)
  event.erase
  $PokemonMap.addErasedEvent(event.id) if $PokemonMap
end


#==============================================================================#
# This section of the code handles the item that calls Surf.                   #
#==============================================================================#

if USING_SURF_ITEM
 
  def pbSurf
    return false if $game_player.pbHasDependentEvents?
    move = GameData::Move.get(:SURF)
    if !$PokemonBag.pbHasItem?(:SURFITEM) && !$DEBUG
      return false
    end
    if pbConfirmMessage(_INTL("The water is a deep blue...\nWould you like to surf on it?"))
      pbMessage(_INTL("{1} used the {2}!", $Trainer.name, GameData::Item.get(SURF_ITEM).name))
      pbCancelVehicles
      surfbgm = GameData::Metadata.get.surf_BGM
      pbCueBGM(surfbgm,0.5) if surfbgm
      pbStartSurfing
      return true
    end
    return false
  end
 
  ItemHandlers::UseInField.add(SURF_ITEM, proc do |item|
    $game_temp.in_menu = false
    pbSurf
    next 1
  end)
 
  ItemHandlers::UseFromBag.add(SURF_ITEM, proc do |item|
    return false if $PokemonGlobal.surfing ||
                    GameData::MapMetadata.get($game_map.map_id).always_bicycle||
                    !$game_player.pbFacingTerrainTag.can_surf_freely ||
                    !$game_map.passable?($game_player.x,$game_player.y,$game_player.direction,$game_player)
    next 2
  end)
end


#==============================================================================#
# This section of the code handles the item that calls Fly.                    #
#==============================================================================#

if USING_FLY_ITEM
  ItemHandlers::UseFromBag.add(FLY_ITEM, proc do |item|
    if !GameData::MapMetadata.exists?($game_map.map_id) ||
       !GameData::MapMetadata.get($game_map.map_id).outdoor_map
      pbMessage(_INTL("Can't use that here."))
      next 0
    end
    if defined?(BetterRegionMap)
      ret = pbBetterRegionMap(nil, true, true)
    else
      ret = pbFadeOutIn(99999) do
        scene = PokemonRegionMap_Scene.new(-1, false)
        screen = PokemonRegionMapScreen.new(scene)
        next screen.pbStartFlyScreen
      end
    end
    if ret
      $PokemonTemp.flydata = ret
      next 2
    end
    next 0
  end)
 
  ItemHandlers::UseInField.add(FLY_ITEM, proc do |item|
    $game_temp.in_menu = false
    next 0 if !$PokemonTemp.flydata
    pbMessage(_INTL("{1} used the {2}!", $Trainer.name,GameData::Item.get(FLY_ITEM).name))
    pbFadeOutIn {
      $game_temp.player_new_map_id    = $PokemonTemp.flydata[0]
      $game_temp.player_new_x         = $PokemonTemp.flydata[1]
      $game_temp.player_new_y         = $PokemonTemp.flydata[2]
      $game_temp.player_new_direction = 2
      $PokemonTemp.flydata = nil
      $scene.transfer_player
      $game_map.autoplay
      $game_map.refresh
    }
    pbEraseEscapePoint
    next 1
  end)
end

#==============================================================================#
# This section of the code handles the item that calls Rock Smash.             #
#==============================================================================#

if USING_ROCK_SMASH_ITEM
 
  ItemHandlers::UseFromBag.add(ROCK_SMASH_ITEM, proc do |item|
    if $game_player.pbFacingEvent && $game_player.pbFacingEvent.name == "SmashRock"
      next 2
    end
    next 0
  end)
 
  ItemHandlers::UseInField.add(ROCK_SMASH_ITEM, proc do |item|
    $game_player.pbFacingEvent.start
    next 1
  end)
 
  def pbRockSmash
    if !$PokemonBag.pbHasItem?(ROCK_SMASH_ITEM) && !$DEBUG
      pbMessage(_INTL("It's a rugged rock, but an item may be able to smash it."))
      return false
    end
    item = GameData::Item.get(ROCK_SMASH_ITEM).name
    if pbConfirmMessage(_INTL("This rock appears to be breakable. Would you like to use the {1}?", item))
      pbMessage(_INTL("{1} used the {2}!",$Trainer.name, item))
      return true
    end
    return false
  end
end


#==============================================================================#
# This section of code handles the item that calls Strength.                   #
#==============================================================================#

if USING_STRENGTH_ITEM
 
  def pbStrength
    if $PokemonMap.strengthUsed
      pbMessage(_INTL("Strength made it possible to move boulders around."))
      return false
    end
    if !$PokemonBag.pbHasItem?(STRENGTH_ITEM) && !$DEBUG
      pbMessage(_INTL("It's a big boulder, but an item may be able to push it aside."))
      return false
    end
    itemname = GameData::Item.get(STRENGTH_ITEM).name
    pbMessage(_INTL("It's a big boulder, but an item may be able to push it aside.\1"))
    if pbConfirmMessage(_INTL("Would you like to use the {1}?", itemname))
      pbMessage(_INTL("{1} used the {2}!",
          $Trainer.name, itemname))
      pbMessage(_INTL("The {1} made it possible to move boulders around!",itemname))
      $PokemonMap.strengthUsed = true
      return true
    end
    return false
  end
 
  ItemHandlers::UseFromBag.add(STRENGTH_ITEM, proc do
    if $game_player.pbFacingEvent && $game_player.pbFacingEvent.name == "Boulder"
      next 2
    end
    next 0
  end)
 
  ItemHandlers::UseInField.add(STRENGTH_ITEM, proc { pbStrength })
end


#==============================================================================#
# This section of code handles the item that calls Cut.                        #
#==============================================================================#

if USING_CUT_ITEM
 
  def pbCut
    if !$PokemonBag.pbHasItem?(CUT_ITEM) && !$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?"))
      itemname = GameData::Item.get(CUT_ITEM).name
      pbMessage(_INTL("{1} used the {2}!",$Trainer.name,itemname))
      pbSmashEvent($game_player.pbFacingEvent)
      return true
    end
    return false
  end
 
  ItemHandlers::UseFromBag.add(CUT_ITEM, proc do
    if $game_player.pbFacingEvent && $game_player.pbFacingEvent.name == "CutTree"
      next 2
    end
    return 0
  end)
 
  ItemHandlers::UseInField.add(CUT_ITEM, proc { $game_player.pbFacingEvent.start })
end
Marin's Script HM_Items that I have updated to v.18.1, of course, does not work on the latest version of Essentials, because I intentionally fixed that for v.18.1, I didn't think of updating it for v.19, because I don't use it myself.

But I'm happy you want to fix Marin's code for 19.1, so other people can use it too. Sure you have to use the original code of Marin, because the one I fixed is for v.18.1. My fix works just for v.18.1, I never said it was for v.19.1
 
Last edited:

Cross Agento

Novice
Member
Joined
Jun 27, 2021
Posts
32
I am using V19.1 and it obviously doesn't work. Even Leondrea's fix doesn't work anymore. So I tried to fix it.

I first started by removing every instance of Kernel, as Golisopod User said. It, unfortunately, wasn't that easy. After hours of code changes and tests I now have a working version for V19.1. I modified the original Script from Marin, so I don't know, what you have to change to make Leondrea's version work.

I said it in a different thread, I am not very familiar with Ruby. So I am pretty sure, that this isn't the best way to solve this.

This is definitely just a bandage and not a fully fleshed-out Script since the original Script is fairly old. I am, maybe, going to rework the whole thing and ad stuff like Flash, Headbutt, etc. as well, but just maybe.

Important to note is, that when you want to use Rock Smash or Cut out of the inventory, the Rock Event needs to be named "SmashRock" and the Cut Event needs to be named "CutTree". This is a quirk from the original Script and I am going to leave it like this for now.

If anything breaks, feel free to contact me, I will try my best to fix it.

Also if you want to use that Script make sure to give Marin Credit. You don't have to mention me, but I would appreciate it.

HM Items:
Expand Collapse Copy
#==============================================================================#
#                                    HM Items                                  #
#                                    by Marin                                  #
#==============================================================================#
#                       No coding knowledge required at all.                   #
#                                                                              #
#  Because the items override the actual moves' functionality, the items have  #
#      switches to toggle them, as you see below (USING_SURF_ITEM, etc.)       #
#   If they're set to true, the items will be active and will override some    #
#                 in-field functionality of the moves themselves.              #
#==============================================================================#
#      Rock Smash, Strength and Cut all use the default Essentials events.     #
#==============================================================================#
#                    Please give credit when using this.                       #
#==============================================================================#

# Future updates may contain: Flash, Headbutt, Sweet Scent, Rock Climb.


# The internal name of the item that will trigger Surf
SURF_ITEM = :SURFITEM

# The internal name of the item that will trigger Rock Smash
ROCK_SMASH_ITEM = :ROCKSMASHITEM

# The internal name of the item that will trigger Fly
FLY_ITEM = :FLYITEM

# The internal name of the item that will trigger Strength
STRENGTH_ITEM = :STRENGTHITEM

# The internal name of the item that will trigger Cut
CUT_ITEM = :CUTITEM



# When true, this overrides the old surfing mechanics.
USING_SURF_ITEM = true

# When true, this overrides the old rock smash mechanics.
USING_ROCK_SMASH_ITEM = true

# When true, this overrides the old fly mechanics.
USING_FLY_ITEM = true

# When true, this overrides the old strength mechanics.
USING_STRENGTH_ITEM = true

# When true, this overrides the old cut mechanics.
USING_CUT_ITEM = true


#==============================================================================#
# This section of code contains minor utility methods.                         #
#==============================================================================#

class Game_Map
  attr_reader :map
end

class Game_Player
  attr_writer :x
  attr_writer :y
end

class HandlerHash
  def delete(sym)
    id = fromSymbol(sym)
    @hash.delete(id) if id && @hash[id]
    symbol = toSymbol(sym)
    @hash.delete(symbol) if symbol && @hash[symbol]
  end
end

def pbSmashEvent(event)
  return unless event
  if event.name == "CutTree"
    pbSEPlay("Cut", 80)
  elsif event.name == "SmashRock"
    pbSEPlay("Rock Smash", 80)
  end
  pbMoveRoute(event,[
     PBMoveRoute::TurnDown,
     PBMoveRoute::Wait, 2,
     PBMoveRoute::TurnLeft,
     PBMoveRoute::Wait, 2,
     PBMoveRoute::TurnRight,
     PBMoveRoute::Wait, 2,
     PBMoveRoute::TurnUp,
     PBMoveRoute::Wait, 2
  ])
  pbWait(16)
  event.erase
  $PokemonMap.addErasedEvent(event.id) if $PokemonMap
end


#==============================================================================#
# This section of the code handles the item that calls Surf.                   #
#==============================================================================#

if USING_SURF_ITEM
 
  def pbSurf
    return false if $game_player.pbHasDependentEvents?
    move = GameData::Move.get(:SURF)
    if !$PokemonBag.pbHasItem?(:SURFITEM) && !$DEBUG
      return false
    end
    if pbConfirmMessage(_INTL("The water is a deep blue...\nWould you like to surf on it?"))
      pbMessage(_INTL("{1} used the {2}!", $Trainer.name, GameData::Item.get(SURF_ITEM).name))
      pbCancelVehicles
      surfbgm = GameData::Metadata.get.surf_BGM
      pbCueBGM(surfbgm,0.5) if surfbgm
      pbStartSurfing
      return true
    end
    return false
  end
 
  ItemHandlers::UseInField.add(SURF_ITEM, proc do |item|
    $game_temp.in_menu = false
    pbSurf
    next 1
  end)
 
  ItemHandlers::UseFromBag.add(SURF_ITEM, proc do |item|
    return false if $PokemonGlobal.surfing ||
                    GameData::MapMetadata.get($game_map.map_id).always_bicycle||
                    !$game_player.pbFacingTerrainTag.can_surf_freely ||
                    !$game_map.passable?($game_player.x,$game_player.y,$game_player.direction,$game_player)
    next 2
  end)
end


#==============================================================================#
# This section of the code handles the item that calls Fly.                    #
#==============================================================================#

if USING_FLY_ITEM
  ItemHandlers::UseFromBag.add(FLY_ITEM, proc do |item|
    if !GameData::MapMetadata.exists?($game_map.map_id) ||
       !GameData::MapMetadata.get($game_map.map_id).outdoor_map
      pbMessage(_INTL("Can't use that here."))
      next 0
    end
    if defined?(BetterRegionMap)
      ret = pbBetterRegionMap(nil, true, true)
    else
      ret = pbFadeOutIn(99999) do
        scene = PokemonRegionMap_Scene.new(-1, false)
        screen = PokemonRegionMapScreen.new(scene)
        next screen.pbStartFlyScreen
      end
    end
    if ret
      $PokemonTemp.flydata = ret
      next 2
    end
    next 0
  end)
 
  ItemHandlers::UseInField.add(FLY_ITEM, proc do |item|
    $game_temp.in_menu = false
    next 0 if !$PokemonTemp.flydata
    pbMessage(_INTL("{1} used the {2}!", $Trainer.name,GameData::Item.get(FLY_ITEM).name))
    pbFadeOutIn {
      $game_temp.player_new_map_id    = $PokemonTemp.flydata[0]
      $game_temp.player_new_x         = $PokemonTemp.flydata[1]
      $game_temp.player_new_y         = $PokemonTemp.flydata[2]
      $game_temp.player_new_direction = 2
      $PokemonTemp.flydata = nil
      $scene.transfer_player
      $game_map.autoplay
      $game_map.refresh
    }
    pbEraseEscapePoint
    next 1
  end)
end

#==============================================================================#
# This section of the code handles the item that calls Rock Smash.             #
#==============================================================================#

if USING_ROCK_SMASH_ITEM
 
  ItemHandlers::UseFromBag.add(ROCK_SMASH_ITEM, proc do |item|
    if $game_player.pbFacingEvent && $game_player.pbFacingEvent.name == "SmashRock"
      next 2
    end
    next 0
  end)
 
  ItemHandlers::UseInField.add(ROCK_SMASH_ITEM, proc do |item|
    $game_player.pbFacingEvent.start
    next 1
  end)
 
  def pbRockSmash
    if !$PokemonBag.pbHasItem?(ROCK_SMASH_ITEM) && !$DEBUG
      pbMessage(_INTL("It's a rugged rock, but an item may be able to smash it."))
      return false
    end
    item = GameData::Item.get(ROCK_SMASH_ITEM).name
    if pbConfirmMessage(_INTL("This rock appears to be breakable. Would you like to use the {1}?", item))
      pbMessage(_INTL("{1} used the {2}!",$Trainer.name, item))
      return true
    end
    return false
  end
end


#==============================================================================#
# This section of code handles the item that calls Strength.                   #
#==============================================================================#

if USING_STRENGTH_ITEM
 
  def pbStrength
    if $PokemonMap.strengthUsed
      pbMessage(_INTL("Strength made it possible to move boulders around."))
      return false
    end
    if !$PokemonBag.pbHasItem?(STRENGTH_ITEM) && !$DEBUG
      pbMessage(_INTL("It's a big boulder, but an item may be able to push it aside."))
      return false
    end
    itemname = GameData::Item.get(STRENGTH_ITEM).name
    pbMessage(_INTL("It's a big boulder, but an item may be able to push it aside.\1"))
    if pbConfirmMessage(_INTL("Would you like to use the {1}?", itemname))
      pbMessage(_INTL("{1} used the {2}!",
          $Trainer.name, itemname))
      pbMessage(_INTL("The {1} made it possible to move boulders around!",itemname))
      $PokemonMap.strengthUsed = true
      return true
    end
    return false
  end
 
  ItemHandlers::UseFromBag.add(STRENGTH_ITEM, proc do
    if $game_player.pbFacingEvent && $game_player.pbFacingEvent.name == "Boulder"
      next 2
    end
    next 0
  end)
 
  ItemHandlers::UseInField.add(STRENGTH_ITEM, proc { pbStrength })
end


#==============================================================================#
# This section of code handles the item that calls Cut.                        #
#==============================================================================#

if USING_CUT_ITEM
 
  def pbCut
    if !$PokemonBag.pbHasItem?(CUT_ITEM) && !$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?"))
      itemname = GameData::Item.get(CUT_ITEM).name
      pbMessage(_INTL("{1} used the {2}!",$Trainer.name,itemname))
      pbSmashEvent($game_player.pbFacingEvent)
      return true
    end
    return false
  end
 
  ItemHandlers::UseFromBag.add(CUT_ITEM, proc do
    if $game_player.pbFacingEvent && $game_player.pbFacingEvent.name == "CutTree"
      next 2
    end
    return 0
  end)
 
  ItemHandlers::UseInField.add(CUT_ITEM, proc { $game_player.pbFacingEvent.start })
end
For the most part, this code works great! It allows this to be used and it's really nice. The only issue is, if you try to use the Cut Item in the overworld and there's no tree to cut down, it crashes the game. I'm not sure if this happens with the other items, but I'll test that out later. Sorry, I would do this code on my own, but I don't really know anything about it...Thank you in advance.
 

FeelsMoyoMan

Rookie
Member
Joined
Jul 26, 2021
Posts
8
For the most part, this code works great! It allows this to be used and it's really nice. The only issue is, if you try to use the Cut Item in the overworld and there's no tree to cut down, it crashes the game. I'm not sure if this happens with the other items, but I'll test that out later. Sorry, I would do this code on my own, but I don't really know anything about it...Thank you in advance.
This also happens with surf. I am actually currently working on a complete overhaul of the script, but there is an easy fix for now.
Go in the Cut section and in the ItemHandlers::UseFromBag part change the return false to next 0
To fix surf go to the surf section. In the ItemHandlers::UseFromBag part change the return false if to next 0 if
If you have trouble finding the section, I updated the script in my earlier post. You can just copy and paste it again.
 

Aussaye

Rookie
Member
Joined
Sep 7, 2021
Posts
7
I am using V19.1 and it obviously doesn't work. Even Leondrea's fix doesn't work anymore. So I tried to fix it.

I first started by removing every instance of Kernel, as Golisopod User said. It, unfortunately, wasn't that easy. After hours of code changes and tests I now have a working version for V19.1. I modified the original Script from Marin, so I don't know, what you have to change to make Leondrea's version work.

I said it in a different thread, I am not very familiar with Ruby. So I am pretty sure, that this isn't the best way to solve this.

This is definitely just a bandage and not a fully fleshed-out Script since the original Script is fairly old. I am, maybe, going to rework the whole thing and ad stuff like Flash, Headbutt, etc. as well, but just maybe.

Important to note is, that when you want to use Rock Smash or Cut out of the inventory, the Rock Event needs to be named "SmashRock" and the Cut Event needs to be named "CutTree". This is a quirk from the original Script and I am going to leave it like this for now.

If anything breaks, feel free to contact me, I will try my best to fix it.

Also if you want to use that Script make sure to give Marin Credit. You don't have to mention me, but I would appreciate it.

HM Items:
Expand Collapse Copy
#==============================================================================#
#                                    HM Items                                  #
#                                    by Marin                                  #
#==============================================================================#
#                       No coding knowledge required at all.                   #
#                                                                              #
#  Because the items override the actual moves' functionality, the items have  #
#      switches to toggle them, as you see below (USING_SURF_ITEM, etc.)       #
#   If they're set to true, the items will be active and will override some    #
#                 in-field functionality of the moves themselves.              #
#==============================================================================#
#      Rock Smash, Strength and Cut all use the default Essentials events.     #
#==============================================================================#
#                    Please give credit when using this.                       #
#==============================================================================#

# Future updates may contain: Flash, Headbutt, Sweet Scent, Rock Climb.


# The internal name of the item that will trigger Surf
SURF_ITEM = :SURFITEM

# The internal name of the item that will trigger Rock Smash
ROCK_SMASH_ITEM = :ROCKSMASHITEM

# The internal name of the item that will trigger Fly
FLY_ITEM = :FLYITEM

# The internal name of the item that will trigger Strength
STRENGTH_ITEM = :STRENGTHITEM

# The internal name of the item that will trigger Cut
CUT_ITEM = :CUTITEM



# When true, this overrides the old surfing mechanics.
USING_SURF_ITEM = true

# When true, this overrides the old rock smash mechanics.
USING_ROCK_SMASH_ITEM = true

# When true, this overrides the old fly mechanics.
USING_FLY_ITEM = true

# When true, this overrides the old strength mechanics.
USING_STRENGTH_ITEM = true

# When true, this overrides the old cut mechanics.
USING_CUT_ITEM = true


#==============================================================================#
# This section of code contains minor utility methods.                         #
#==============================================================================#

class Game_Map
  attr_reader :map
end

class Game_Player
  attr_writer :x
  attr_writer :y
end

class HandlerHash
  def delete(sym)
    id = fromSymbol(sym)
    @hash.delete(id) if id && @hash[id]
    symbol = toSymbol(sym)
    @hash.delete(symbol) if symbol && @hash[symbol]
  end
end

def pbSmashEvent(event)
  return unless event
  if event.name == "CutTree"
    pbSEPlay("Cut", 80)
  elsif event.name == "SmashRock"
    pbSEPlay("Rock Smash", 80)
  end
  pbMoveRoute(event,[
     PBMoveRoute::TurnDown,
     PBMoveRoute::Wait, 2,
     PBMoveRoute::TurnLeft,
     PBMoveRoute::Wait, 2,
     PBMoveRoute::TurnRight,
     PBMoveRoute::Wait, 2,
     PBMoveRoute::TurnUp,
     PBMoveRoute::Wait, 2
  ])
  pbWait(16)
  event.erase
  $PokemonMap.addErasedEvent(event.id) if $PokemonMap
end


#==============================================================================#
# This section of the code handles the item that calls Surf.                   #
#==============================================================================#

if USING_SURF_ITEM
 
  def pbSurf
    return false if $game_player.pbHasDependentEvents?
    move = GameData::Move.get(:SURF)
    if !$PokemonBag.pbHasItem?(:SURFITEM) && !$DEBUG
      return false
    end
    if pbConfirmMessage(_INTL("The water is a deep blue...\nWould you like to surf on it?"))
      pbMessage(_INTL("{1} used the {2}!", $Trainer.name, GameData::Item.get(SURF_ITEM).name))
      pbCancelVehicles
      surfbgm = GameData::Metadata.get.surf_BGM
      pbCueBGM(surfbgm,0.5) if surfbgm
      pbStartSurfing
      return true
    end
    return false
  end
 
  ItemHandlers::UseInField.add(SURF_ITEM, proc do |item|
    $game_temp.in_menu = false
    pbSurf
    next 1
  end)
 
  ItemHandlers::UseFromBag.add(SURF_ITEM, proc do |item|
    next 0 if $PokemonGlobal.surfing ||
                    GameData::MapMetadata.get($game_map.map_id).always_bicycle||
                    !$game_player.pbFacingTerrainTag.can_surf_freely ||
                    !$game_map.passable?($game_player.x,$game_player.y,$game_player.direction,$game_player)
    next 2
  end)
end


#==============================================================================#
# This section of the code handles the item that calls Fly.                    #
#==============================================================================#

if USING_FLY_ITEM
  ItemHandlers::UseFromBag.add(FLY_ITEM, proc do |item|
    if !GameData::MapMetadata.exists?($game_map.map_id) ||
       !GameData::MapMetadata.get($game_map.map_id).outdoor_map
      pbMessage(_INTL("Can't use that here."))
      next 0
    end
    if defined?(BetterRegionMap)
      ret = pbBetterRegionMap(nil, true, true)
    else
      ret = pbFadeOutIn(99999) do
        scene = PokemonRegionMap_Scene.new(-1, false)
        screen = PokemonRegionMapScreen.new(scene)
        next screen.pbStartFlyScreen
      end
    end
    if ret
      $PokemonTemp.flydata = ret
      next 2
    end
    next 0
  end)
 
  ItemHandlers::UseInField.add(FLY_ITEM, proc do |item|
    $game_temp.in_menu = false
    next 0 if !$PokemonTemp.flydata
    pbMessage(_INTL("{1} used the {2}!", $Trainer.name,GameData::Item.get(FLY_ITEM).name))
    pbFadeOutIn {
      $game_temp.player_new_map_id    = $PokemonTemp.flydata[0]
      $game_temp.player_new_x         = $PokemonTemp.flydata[1]
      $game_temp.player_new_y         = $PokemonTemp.flydata[2]
      $game_temp.player_new_direction = 2
      $PokemonTemp.flydata = nil
      $scene.transfer_player
      $game_map.autoplay
      $game_map.refresh
    }
    pbEraseEscapePoint
    next 1
  end)
end

#==============================================================================#
# This section of the code handles the item that calls Rock Smash.             #
#==============================================================================#

if USING_ROCK_SMASH_ITEM
 
  ItemHandlers::UseFromBag.add(ROCK_SMASH_ITEM, proc do |item|
    if $game_player.pbFacingEvent && $game_player.pbFacingEvent.name == "SmashRock"
      next 2
    end
    next 0
  end)
 
  ItemHandlers::UseInField.add(ROCK_SMASH_ITEM, proc do |item|
    $game_player.pbFacingEvent.start
    next 1
  end)
 
  def pbRockSmash
    if !$PokemonBag.pbHasItem?(ROCK_SMASH_ITEM) && !$DEBUG
      pbMessage(_INTL("It's a rugged rock, but an item may be able to smash it."))
      return false
    end
    item = GameData::Item.get(ROCK_SMASH_ITEM).name
    if pbConfirmMessage(_INTL("This rock appears to be breakable. Would you like to use the {1}?", item))
      pbMessage(_INTL("{1} used the {2}!",$Trainer.name, item))
      return true
    end
    return false
  end
end


#==============================================================================#
# This section of code handles the item that calls Strength.                   #
#==============================================================================#

if USING_STRENGTH_ITEM
 
  def pbStrength
    if $PokemonMap.strengthUsed
      pbMessage(_INTL("Strength made it possible to move boulders around."))
      return false
    end
    if !$PokemonBag.pbHasItem?(STRENGTH_ITEM) && !$DEBUG
      pbMessage(_INTL("It's a big boulder, but an item may be able to push it aside."))
      return false
    end
    itemname = GameData::Item.get(STRENGTH_ITEM).name
    pbMessage(_INTL("It's a big boulder, but an item may be able to push it aside.\1"))
    if pbConfirmMessage(_INTL("Would you like to use the {1}?", itemname))
      pbMessage(_INTL("{1} used the {2}!",
          $Trainer.name, itemname))
      pbMessage(_INTL("The {1} made it possible to move boulders around!",itemname))
      $PokemonMap.strengthUsed = true
      return true
    end
    return false
  end
 
  ItemHandlers::UseFromBag.add(STRENGTH_ITEM, proc do
    if $game_player.pbFacingEvent && $game_player.pbFacingEvent.name == "Boulder"
      next 2
    end
    next 0
  end)
 
  ItemHandlers::UseInField.add(STRENGTH_ITEM, proc { pbStrength })
end


#==============================================================================#
# This section of code handles the item that calls Cut.                        #
#==============================================================================#

if USING_CUT_ITEM
 
  def pbCut
    if !$PokemonBag.pbHasItem?(CUT_ITEM) && !$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?"))
      itemname = GameData::Item.get(CUT_ITEM).name
      pbMessage(_INTL("{1} used the {2}!",$Trainer.name,itemname))
      pbSmashEvent($game_player.pbFacingEvent)
      return true
    end
    return false
  end
 
  ItemHandlers::UseFromBag.add(CUT_ITEM, proc do
    if $game_player.pbFacingEvent && $game_player.pbFacingEvent.name == "CutTree"
      next 2
    end
    next 0
  end)
 
  ItemHandlers::UseInField.add(CUT_ITEM, proc { $game_player.pbFacingEvent.start })
end
Love this code btw but I have having issues with surf where interacting with the water outside of debug mode I don't get the message to surf. Have I don't something wrong? do I have to define what is and isn't water?
 
Back
Top