Essentials Docs Wiki

The Essentials wiki has moved and is now at: Essentials Engine wiki

This wiki will no longer be updated.

READ MORE

Essentials Docs Wiki
Register
(Created page with "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 use...")
Tag: Visual edit
 
Maruno (talk | contribs)
mNo edit summary
Line 1: Line 1:
  +
{{for|creating obstacles that can be overcome by using moves on them|Obstacles}}
This article describes how to '''use moves outside of battle'''.
+
This page 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 ==
 
== Using moves outside battle ==
The script section '''PField_FieldMoves''' handles the use of moves outside battle.
 
   
 
The [[script section]] '''PField_FieldMoves''' 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).
 
  +
 
The [[script section]] '''Settings''' contains a variable that determines whether HMs require a given number of [[Pokémon Gym|Gym Badges]] in order to be unlocked, or whether they need specific Badges. It also has a number for each move, which is either the number of Badges required or the specific Badge required (where badge 0 is the first Badge, 1 is the second Badge, etc.) in order to be able to use that move outside battle.
   
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.
+
There are three main ways to use a move outside battle: interacting with an event or tile, selecting the move from the [[party]] screen, or selecting the move from the [[Ready menu]]. The first method uses different scripts from the other two. 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 ==
  +
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).
+
Interacting with an event is the easiest way to use a move outside battle. The event should, when interacted with, call a method that describes the effect (including checking for whether they are able to use the move for it, e.g. whether they have the [[Pokémon Gym|Gym Badge(s)]] to allow it).
   
 
The moves that can be used in this way are:
 
The moves that can be used in this way are:
  +
 
* Cut - interact with a small tree.
 
* Cut - interact with a small tree.
 
* Headbutt - interact with a tree.
 
* Headbutt - interact with a tree.
 
* Rock Smash - interact with a cracked rock.
 
* Rock Smash - interact with a cracked rock.
 
* Strength - interact with a boulder.
 
* Strength - interact with a boulder.
See the article Obstacles for details of how to set up events for these objects.
 
   
 
See the page [[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 <code>Events.onAction</code> 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|
 
 
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, when the player presses the [[Controls|"Use" button]], the game uses a procedure called <code>Events.onAction</code> 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:
facingEvent=$game_player.pbFacingEvent
 
  +
if facingEvent
 
 
Events.onAction += proc { |sender,e|
if facingEvent.name=="Boulder"
 
 
facingEvent = $game_player.pbFacingEvent
Kernel.pbStrength
 
 
if facingEvent && facingEvent.name=="Boulder"
return
 
end
+
Kernel.pbStrength
end
+
end
 
}
 
}
   
 
== Interacting with a tile ==
 
== 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:
+
Interacting with a tile means checking the [[Tilesets|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).
+
* Surf - interact with a water tile ([[Tilesets|terrain tag]]s 5, 6, 7, 8 or 9).
 
* Dive - interact with a deep water tile ([[Tilesets|terrain tag]] 5).
These interactions need a procedure called <code>Events.onAction</code>, 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.
 
 
* Waterfall - interact with a waterfall tile ([[Tilesets|terrain tag]] 8).
  +
 
These interactions need a procedure called <code>Events.onAction</code>, which checks the [[Tilesets|terrain tag]] of the tile in front of the player and calls another method that describes the actual effect of that move.
   
 
For example, the procedure for Surf is as follows:
 
For example, the procedure for Surf is as follows:
  +
Events.onAction+=proc{|sender,e|
+
Events.onAction += proc { |sender,e|
terrain=Kernel.pbFacingTerrainTag
 
 
next if $PokemonGlobal.surfing
notCliff=$game_map.passable?($game_player.x,$game_player.y,$game_player.direction)
 
 
next if pbGetMetadata($game_map.map_id,MetadataBicycleAlways)
if pbIsWaterTag?(terrain) && !$PokemonGlobal.surfing &&
 
  +
next if !PBTerrain.isSurfable?(Kernel.pbFacingTerrainTag)
 !pbGetMetadata($game_map.map_id,MetadataBicycleAlways) && notCliff
 
  +
next if !$game_map.passable?($game_player.x,$game_player.y,$game_player.direction,$game_player)
Kernel.pbSurf
+
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 <code>pbSurf</code> (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 these procedures do not check for [[Partner trainer|dependent events]] or the appropriate [[Pokémon Gym|Gym Badge(s)]] or so forth - those checks are done in <code>def Kernel.pbSurf</code> (or whichever method is called for other moves). This 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.
 
  +
 
Note that the method 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 ==
 
== 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:
+
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
 
* Chatter
 
* Dig
 
* Dig
Line 66: Line 68:
 
* Sweet Scent
 
* Sweet Scent
 
* Teleport
 
* Teleport
  +
 
The way the game decides whether a move should appear in the menu is to see whether there exists a <code>HiddenMoveHandlers::CanUseMove</code> 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 Soft-Boiled, which are dealt with separately (see below).
 
The way the game decides whether a move should appear in the menu is to see whether there exists a <code>HiddenMoveHandlers::CanUseMove</code> 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 Soft-Boiled, which are dealt with separately (see below).
   
There are two types of handler associated with using moves from the Party screen: <code>CanUseMove</code> and <code>UseMove</code>. The former does all the checks to decide whether the move can be used, and the latter carries out the move.
+
There are two types of handler associated with using moves from the [[party]] screen: <code>CanUseMove</code> and <code>UseMove</code>. 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:
 
For example, the two handlers for Surf are as follows:
  +
HiddenMoveHandlers::CanUseMove.add(:SURF,proc{|move,pkmn|
+
HiddenMoveHandlers::CanUseMove.add(:SURF,proc { |move,pkmn,showmsg|
terrain=Kernel.pbFacingTerrainTag
 
  +
next false if !pbCheckHiddenMoveBadge(BADGEFORSURF,showmsg)
notCliff=$game_map.passable?($game_player.x,$game_player.y,$game_player.direction)
 
 
if $PokemonGlobal.surfing
if !$DEBUG &&
 
 
Kernel.pbMessage(_INTL("You're already surfing.")) if showmsg
 !(HIDDENMOVESCOUNTBADGES ? $Trainer.numbadges>=BADGEFORSURF : $Trainer.badges[BADGEFORSURF])
 
 
next false
Kernel.pbMessage(_INTL("Sorry, a new Badge is required."))
 
 
end
return false
 
 
if $game_player.pbHasDependentEvents?
end
 
 
Kernel.pbMessage(_INTL("It can't be used when you have someone with you.")) if showmsg
if $PokemonGlobal.surfing
 
 
next false
Kernel.pbMessage(_INTL("You're already surfing."))
 
 
end
return false
 
 
if pbGetMetadata($game_map.map_id,MetadataBicycleAlways)
end
 
 
Kernel.pbMessage(_INTL("Let's enjoy cycling!")) if showmsg
if $game_player.pbHasDependentEvents?
 
 
next false
Kernel.pbMessage(_INTL("You can't use that if you have someone with you."))
 
 
end
return false
 
 
if !PBTerrain.isSurfable?(Kernel.pbFacingTerrainTag) ||
end
 
 
!$game_map.passable?($game_player.x,$game_player.y,$game_player.direction,$game_player)
if pbGetMetadata($game_map.map_id,MetadataBicycleAlways)
 
Kernel.pbMessage(_INTL("Let's enjoy cycling!"))
+
Kernel.pbMessage(_INTL("No surfing here!")) if showmsg
return false
+
return false
end
+
end
 
next true
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.
 
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|
+
HiddenMoveHandlers::UseMove.add(:SURF,proc { |move,pokemon|
if !pbHiddenMoveAnimation(pokemon)
 
  +
$game_temp.in_menu = false
Kernel.pbMessage(_INTL("{1} used {2}!",pokemon.name,PBMoves.getName(move)))
 
  +
Kernel.pbCancelVehicles
end
 
 
if !pbHiddenMoveAnimation(pokemon)
pbStartSurfing()
 
 
Kernel.pbMessage(_INTL("{1} used {2}!",pokemon.name,PBMoves.getName(move)))
return true
 
 
end
  +
surfbgm = pbGetMetadata(0,MetadataSurfBGM)
  +
pbCueBGM(surfbgm,0.5) if surfbgm
 
pbStartSurfing
 
next 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 (<code>pbStartSurfing</code>) is different to the one called above (<code>pbSurf</code>), 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.
 
   
 
If the player can surf, this handler performs the effect. It displays an animation (see below) and then calls a method that starts the player surfing. This method (<code>def pbStartSurfing</code>) is different to the one called above (<code>def Kernel.pbSurf</code>) 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 <code>UseMove</code> handler above and <code>pbSurf</code> call the same def (<code>pbStartSurfing</code>). This final def actually handles the start of surfing.
 
   
 
Note that, in the end, both the <code>UseMove</code> handler above and <code>def Kernel.pbSurf</code> call the same method (<code>def pbStartSurfing</code>). This final method actually handles the start of surfing.
   
  +
=== Fly ===
   
 
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.
 
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 '''PScreen_Party''' in the def <code>pbPokemonScreen</code>. The chosen Fly destination is stored in a temporary variable, and then Fly's hidden move handler is called as normal.
+
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]] '''PScreen_Party''' in <code>def pbPokemonScreen</code>. The chosen Fly destination is stored in a temporary variable, and then Fly's hidden move handler is called as normal.
   
 
=== Milk Drink and Soft-Boiled ===
 
=== Milk Drink and Soft-Boiled ===
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.
 
   
 
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 '''PScreen_Party''' in the def <code>pbPokemonScreen</code>), in addition to looking for hidden move handlers as mentioned above, the game also specifically checks whether the Pokémon knows Milk Drink or Soft-Boiled, and adds these options to the list if so.
 
  +
 
When deciding which commands should appear in the party screen menu (in the [[script section]] '''PScreen_Party''' in <code>def pbPokemonScreen</code>), in addition to looking for hidden move handlers as mentioned above, the game also specifically checks whether the Pokémon knows Milk Drink or Soft-Boiled, 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 '''PField_FieldMoves''' for these two moves.
+
The effects of these two moves also appear in that same method, 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]] '''PField_FieldMoves''' for these two moves.
   
 
== Using move animation ==
 
== Using move animation ==
[[File:UsingMoveOutsideBattle.png|thumb|220x220px]]
+
[[Image:UsingMoveOutsideBattle.png|right|256px|thumb|Animation of Gyarados using a move outside battle.]]
When the player uses a move outside battle (except Milk Drink or Soft-Boiled), an animation will be shown of the Pokémon sweeping across the screen. This animation is defined in the script section '''PField_FieldMoves''' in the def <code>pbHiddenMoveAnimation</code>.
+
When the player uses a move outside battle (except Milk Drink or Soft-Boiled), an animation will be shown of the Pokémon sweeping across the screen. This animation is defined in the script section '''PField_FieldMoves''' in <code>def pbHiddenMoveAnimation</code>.

Revision as of 14:28, 24 August 2019

For creating obstacles that can be overcome by using moves on them, see Obstacles.

This page describes how to use moves outside of battle.

Using moves outside battle

The script section PField_FieldMoves 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 has a number for each move, which is either the number of Badges required or the specific Badge required (where badge 0 is the first Badge, 1 is the second Badge, etc.) in order to be able to use that move outside battle.

There are three main ways to use a move outside battle: interacting with an event or tile, selecting the move from the party screen, or selecting the move from the Ready menu. The first method uses different scripts from the other two. 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 method that describes the effect (including checking for whether they are able to use the move for 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 page 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, when the player presses the "Use" button, 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 && facingEvent.name=="Boulder"
    Kernel.pbStrength
  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 method that describes the actual effect of that move.

For example, the procedure for Surf is as follows:

Events.onAction += proc { |sender,e|
  next if $PokemonGlobal.surfing
  next if pbGetMetadata($game_map.map_id,MetadataBicycleAlways)
  next if !PBTerrain.isSurfable?(Kernel.pbFacingTerrainTag)
  next if !$game_map.passable?($game_player.x,$game_player.y,$game_player.direction,$game_player)
  Kernel.pbSurf
}

Note that these procedures do not check for dependent events or the appropriate Gym Badge(s) or so forth - those checks are done in def Kernel.pbSurf (or whichever method is called for other moves). This 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 method 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
  • Soft-Boiled
  • 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 Soft-Boiled, 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,showmsg|
  next false if !pbCheckHiddenMoveBadge(BADGEFORSURF,showmsg)
  if $PokemonGlobal.surfing
    Kernel.pbMessage(_INTL("You're already surfing.")) if showmsg
    next false
  end
  if $game_player.pbHasDependentEvents?
    Kernel.pbMessage(_INTL("It can't be used when you have someone with you.")) if showmsg
    next false
  end
  if pbGetMetadata($game_map.map_id,MetadataBicycleAlways)
    Kernel.pbMessage(_INTL("Let's enjoy cycling!")) if showmsg
    next false
  end
  if !PBTerrain.isSurfable?(Kernel.pbFacingTerrainTag) ||
     !$game_map.passable?($game_player.x,$game_player.y,$game_player.direction,$game_player)
    Kernel.pbMessage(_INTL("No surfing here!")) if showmsg
    return false
  end
  next 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|
  $game_temp.in_menu = false
  Kernel.pbCancelVehicles
  if !pbHiddenMoveAnimation(pokemon)
    Kernel.pbMessage(_INTL("{1} used {2}!",pokemon.name,PBMoves.getName(move)))
  end
  surfbgm = pbGetMetadata(0,MetadataSurfBGM)
  pbCueBGM(surfbgm,0.5) if surfbgm
  pbStartSurfing
  next true
})

If the player can surf, this handler performs the effect. It displays an animation (see below) and then calls a method that starts the player surfing. This method (def pbStartSurfing) is different to the one called above (def Kernel.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 def Kernel.pbSurf call the same method (def pbStartSurfing). This final method actually handles the start of surfing.

Fly

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 PScreen_Party in 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 Soft-Boiled

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 PScreen_Party in 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 Soft-Boiled, and adds these options to the list if so.

The effects of these two moves also appear in that same method, 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 PField_FieldMoves 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 Soft-Boiled), an animation will be shown of the Pokémon sweeping across the screen. This animation is defined in the script section PField_FieldMoves in def pbHiddenMoveAnimation.