FANDOM


Turn HM moves to items
This tutorial was written by -FL-. Please give credit.

This tutorial is related to the following pages:

Click here for more tutorials!


This tutorial explains how to turn HMs and/or other moves that work outside of battle to items. First, in PokemonHiddenMoves script section comment the 'HiddenMoveHandlers::CanUseMove' proc (all the code, inclusive the '})'). Change the line 'if $DEBUG || movefinder' (there's one for each move that can be used outside menu) to 'if $DEBUG || $PokemonBag.pbQuantity(PBItems::YOURITEMINTERNALNAME)>0'. Before this line, add line 'movefinder=nil' for won't show pokémon name and animation. There's a item example for item.txt PBS:

601,SURFBOARD,Surfboard,Surfboards,8,0,"Insert description here.",0,0,6

Adding the move in the "Use" item command

At this point, the item is already working except the "Use" command. This command is almost unnecessary for some moves like Cut and Surf, but is vital for others like Fly and Flash.

In item PBS data change the '0,0,6' to '2,0,6'. Copy the content of 'HiddenMoveHandlers::CanUseMove' proc (the code between the first line and the '})') and put between a method who start in the first line like 'def canUseMoveSurf?' and ends with 'end'. Do the same with 'HiddenMoveHandlers::UseMove' and name the method something like 'def useMoveSurf'. For this last one remember to change pokemon.name to $Trainer.name, pbHiddenMoveAnimation(pokemon) to pbHiddenMoveAnimation(nil) and PBMoves.getName(move) to the move name (e. g. "Surf"). In PokemonItemEffects script section, add the two item handlers:

ItemHandlers::UseFromBag.add(:YOURITEMINTERNALNAME,proc{|item|
   next canUseMoveSurf? ? 2 : 0
})

ItemHandlers::UseInField.add(:YOURITEMINTERNALNAME,proc{|item|
   useMoveSurf if canUseMoveSurf?
})

I suggest to change the text like "used Surf" to "used Surfboard". Mark HIDDENMOVESCOUNTBADGES as true and all badges to 0 to remove the badge requirements.

Example

I will made an example of the adding in the "use" item command using a knife item for Cut. First, I changed the seventh value to 2.

602,KNIFE,Knife,Knifes,8,0,"Cut down thin trees.",2,0,6

I copied the two HiddenMoveHandlers below (these are in base Essentials):

HiddenMoveHandlers::CanUseMove.add(:CUT,proc{|move,pkmn|
   if !$DEBUG &&
      !(HIDDENMOVESCOUNTBADGES ? $Trainer.numbadges>=BADGEFORCUT : $Trainer.badges[BADGEFORCUT])
     Kernel.pbMessage(_INTL("Sorry, a new Badge is required."))
     return false
   end
   facingEvent=$game_player.pbFacingEvent
   if !facingEvent || facingEvent.name!="Tree"
     Kernel.pbMessage(_INTL("Can't use that here."))
     return false
   end
   return true
})

HiddenMoveHandlers::UseMove.add(:CUT,proc{|move,pokemon|
   if !pbHiddenMoveAnimation(nil)
     Kernel.pbMessage(_INTL("{1} used {2}!",$Trainer.name,"Cut"))
   end
   facingEvent=$game_player.pbFacingEvent
   if facingEvent
     facingEvent.erase
     $PokemonMap.addErasedEvent(facingEvent.id)
   end
   return true
})

For making the two methods below. I added after the handlers:

def canUseMoveCut?
   if !$DEBUG &&
      !(HIDDENMOVESCOUNTBADGES ? $Trainer.numbadges>=BADGEFORCUT : $Trainer.badges[BADGEFORCUT])
     Kernel.pbMessage(_INTL("Sorry, a new Badge is required."))
     return false
   end
   facingEvent=$game_player.pbFacingEvent
   if !facingEvent || facingEvent.name!="Tree"
     Kernel.pbMessage(_INTL("Can't use that here."))
     return false
   end
   return true
end

def useMoveCut
   if !pbHiddenMoveAnimation(nil)
     Kernel.pbMessage(_INTL("{1} used {2}!",$Trainer.name,"Cut"))
   end
   facingEvent=$game_player.pbFacingEvent
   if facingEvent
     facingEvent.erase
     $PokemonMap.addErasedEvent(facingEvent.id)
   end
   return true
end

And I added at PokemonItemEffects script section:

ItemHandlers::UseFromBag.add(:KNIFE,proc{|item|
   next canUseMoveCut? ? 2 : 0
})

ItemHandlers::UseInField.add(:KNIFE,proc{|item|
   useMoveCut if canUseMoveCut?
})

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.