Oh thanks, i can use the others item but fly not.Essentials v16 is not supported.
Do you think that in 16.2 it can be done differently just for that object?
Oh thanks, i can use the others item but fly not.Essentials v16 is not supported.
It's easy to make this script v18 compatibile. Remove every instance ifThis might sound arrogant because I don't know how to script at all, but will we see an update anytime soon?
Kernel.
in the script.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.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...
#==============================================================================#
# 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
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
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.Hi, is there a version of these HMs for v19.1? I've tried using both v17 and v18 and neither work.
#==============================================================================#
# 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
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.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:#==============================================================================# # 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.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:#==============================================================================# # 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
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.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.
ItemHandlers::UseFromBag
part change the return false
to next 0
ItemHandlers::UseFromBag
part change the return false if
to next 0 if
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?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:#==============================================================================# # 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