Fandom

Pokémon Essentials Wiki

Using moves outside battle

229pages on
this wiki
Add New Page
Talk2 Share

This article describes how to use moves outside of battle.

See also

Obstacles

  • This article describes how to set up events and areas that these moves can be used on.

Moves

  • For how moves are defined.

Using moves outside battle

The script section PokemonHiddenMoves handles the use of moves outside battle.

The script section Settings contains a variable that determines whether HMs require a given number of Gym Badges in order to be unlocked, or whether they need specific badges. It also contains a variable relating to each move, which is either the number of badges required or the specific badge required (where badge 0 is the first badge, etc.) in order to be able to use that move outside battle (i.e. HM moves).

There are two main ways to use a move outside battle: interacting with an event or tile, or selecting the move from the party screen. These two methods use different scripts. Below are descriptions of each variation of these methods - the effects themselves are not described, as they are fairly straightforward. Note that all moves use the second method, while some also use the first method as well.

Interacting with an event

Interacting with an event is the easiest way to use a move outside battle. The event should, when interacted with, call a def that describes the effect (including checking for whether they are able to use it, e.g. whether they have the Gym Badge(s) to allow it).

The moves that can be used in this way are:

  • Cut - interact with a small tree.
  • Headbutt - interact with a tree.
  • Rock Smash - interact with a cracked rock.
  • Strength - interact with a boulder.

See the article Obstacles for details of how to set up events for these objects.

For Strength, the boulder event simply moves the boulder if the player runs into it after using Strength. To use Strength in the first place, the game uses a procedure called Events.onAction to check whether the player is facing an event called "Boulder", and if so, to ask if they want to use the move Strength. This procedure is as follows:

Events.onAction+=proc{|sender,e|
   facingEvent=$game_player.pbFacingEvent
   if facingEvent
     if facingEvent.name=="Boulder"
       Kernel.pbStrength
       return
     end
   end
}

Interacting with a tile

Interacting with a tile means checking the terrain tag of the tile immediately in front of the player. The three moves that can be used in this way are:

  • Surf - interact with a water tile (terrain tags 5, 6, 7, 8 or 9).
  • Dive - interact with a deep water tile (terrain tag 5).
  • Waterfall - interact with a waterfall tile (terrain tag 8).

These interactions need a procedure called Events.onAction, which checks the terrain tag of the tile in front of the player and calls another def that describes the actual effect of that move.

For example, the procedure for Surf is as follows:

Events.onAction+=proc{|sender,e|
   terrain=Kernel.pbFacingTerrainTag
   notCliff=$game_map.passable?($game_player.x,$game_player.y,$game_player.direction)
   if pbIsWaterTag?(terrain) && !$PokemonGlobal.surfing && 
      !pbGetMetadata($game_map.map_id,MetadataBicycleAlways) && notCliff
     Kernel.pbSurf
     return
   end
}

Note that these procedures do not check for dependent events or the appropriate Gym Badge(s) or so forth - those checks are done in pbSurf (or whichever def is called for other moves). The procedure simply checks whether the player is in the right place to be able to use the move, not whether they are actually allowed to use it.

Note that the def called here should first ask the player whether they want to use the move or not, rather than automatically use it straight away.

Using the move from the party screen

All moves that can be used outside battle should appear in the party screen menu when selecting a Pokémon. This includes all of the above moves, plus:

  • Chatter
  • Dig
  • Flash
  • Fly
  • Milk Drink
  • Softboiled
  • Sweet Scent
  • Teleport

The way the game decides whether a move should appear in the menu is to see whether there exists a HiddenMoveHandlers::CanUseMove handler for each of the Pokémon's moves. If there is, then that move will be added to the menu options (even if it can't be used). However, this does not apply to Milk Drink or Softboiled, which are dealt with separately (see below).

There are two types of handler associated with using moves from the Party screen: CanUseMove and UseMove. The former does all the checks to decide whether the move can be used, and the latter carries out the move.

For example, the two handlers for Surf are as follows:

HiddenMoveHandlers::CanUseMove.add(:SURF,proc{|move,pkmn|
   terrain=Kernel.pbFacingTerrainTag
   notCliff=$game_map.passable?($game_player.x,$game_player.y,$game_player.direction)
   if !$DEBUG &&
      !(HIDDENMOVESCOUNTBADGES ? $Trainer.numbadges>=BADGEFORSURF : $Trainer.badges[BADGEFORSURF])
     Kernel.pbMessage(_INTL("Sorry, a new Badge is required."))
     return false
   end
   if $PokemonGlobal.surfing
     Kernel.pbMessage(_INTL("You're already surfing."))
     return false
   end
   if $game_player.pbHasDependentEvents?
     Kernel.pbMessage(_INTL("You can't use that if you have someone with you."))
     return false
   end
   if pbGetMetadata($game_map.map_id,MetadataBicycleAlways)
     Kernel.pbMessage(_INTL("Let's enjoy cycling!"))
     return false
   end
   if !pbIsWaterTag?(terrain) || !notCliff
     Kernel.pbMessage(_INTL("No surfing here!"))
     return false
   end
   return true
})

This handler performs all the checks for whether the player is allowed to surf. It returns TRUE if they can.

HiddenMoveHandlers::UseMove.add(:SURF,proc{|move,pokemon|
   if !pbHiddenMoveAnimation(pokemon)
     Kernel.pbMessage(_INTL("{1} used {2}!",pokemon.name,PBMoves.getName(move)))
   end
   pbStartSurfing()
   return true
})

If the player can surf, this handler performs the effect. It displays an animation (see below) and then calls a def that starts the player surfing. This def (pbStartSurfing) is different to the one called above (pbSurf), because it assumes the player has already confirmed they want to use the move, so the game shouldn't ask the player again whether they want to use it.

Note that, in the end, both the UseMove handler above and pbSurf call the same def (pbStartSurfing). This final def actually handles the start of surfing.


Fly is a little more involved, as the move is not used straight away, but instead the player has to choose a destination to fly to. That is, the specific effect of Fly is not the same every time it is used - the destination can vary.

Before the hidden move handler for Fly is called, the game opens the region map screen so that the player can choose a destination. This is done in the script section PokemonParty in the def pbPokemonScreen. The chosen Fly destination is stored in a temporary variable, and then Fly's hidden move handler is called as normal.

Milk Drink and Softboiled

These two moves can be used outside battle, but they do not affect anything in the field like other moves do. Instead, they simply affect Pokémon in the player's party, and thus don't need the party screen to close in order to occur.

When deciding which commands should appear in the party screen menu (in the script section PokemonParty in the def pbPokemonScreen), in addition to looking for hidden move handlers as mentioned above, the game also specifically checks whether the Pokémon knows Milk Drink or Softboiled, and adds these options to the list if so.

The effects of these two moves also appear in the same def, a little further down alongside what happens when any of the other menu options (e.g. Summary, Switch) are chosen. There are no separate scripts in the script section PokemonHiddenMoves for these two moves.

Using move animation

UsingMoveOutsideBattle

Animation of Gyarados using a move outside battle.

When the player uses a move outside battle (except Milk Drink or Softboiled), an animation will be shown of the Pokémon sweeping across the screen. This animation is defined in the script section PokemonHiddenMoves in the def pbHiddenMoveAnimation.

Related tutorials

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.