FANDOM


EventEncounter

An event describing a wild battle with a Deoxys.

This article describes how to begin a wild Pokémon encounter on demand. These are typically used for non-roaming legendary encounters, and for any other Pokémon you battle after interacting with it in the overworld (e.g. Voltorb that look like Item balls).

Wild battles caused by an event

Event encounters are typically those where the Pokémon to be battled appears as a sprite in the overworld, and interacting with that sprite leads to a wild encounter with that Pokémon. It can also be used to set up traps (whose events will have a blank graphic and will activate upon Player Touch).

The main part of the event is the following line of code:

pbWildBattle(PBSpecies::species,level,result,escape,canlose)

"result" is a Global Variable number in which the outcome of the battle will be recorded (1=won, 2=lost, 3=run, 4=caught, 5=draw). "escape" is whether the player can flee from the battle (TRUE if not defined). "canlose" is whether the game continues even if the player loses the battle (with the player's party fully healed) (FALSE if not defined). These last three parameters are optional.

The event consists of two pages:

  • Page 1 - Contains a call to pbWildBattle.
  • Page 2 - Blank, and depends on the event's Self Switch A being ON.

In most cases, the encounter can only be done once, which means that after the battle, regardless of the outcome, the event should go to page 2. Simply set the event's Self Switch A to ON immediately after the battle.

If the event Pokémon will only disappear because of certain battle outcomes (e.g. because of a win, capture or flee, but not because of a loss), then you will need to save the battle's result to a variable as described above. After the call to pbWildBattle, instead of simply setting the event's Self Switch, you should create one or more Conditional Branches which check the saved outcome value, and do things accordingly.

Double wild battles

These events are set up in the same way as single event encounters. The only difference is the code used to start the battle:

pbDoubleWildBattle(PBSpecies::species,level,PBSpecies::species,level,result,escape,canlose)

This works in the same way as pbWildBattle, except a second species is also defined.

Examples

pbWildBattle(PBSpecies::KECLEON,20)

This triggers an encounter with a Level 20 Kecleon. The outcome of the battle is not recorded anywhere, and the player can flee from the battle.

pbDoubleWildBattle(PBSpecies::PIKACHU,21,PBSpecies::CLEFAIRY,17)

This triggers a double wild encounter with a Level 21 Pikachu and a Level 17 Clefairy. The outcome of the battle is not recorded anywhere, and the player can flee from the battle.

pbWildBattle(PBSpecies::MEWTWO,70,1,false,true)

This triggers an encounter with a Level 70 Mewtwo. The outcome of the battle is stored in Global Variable 1, and the player cannot run from the battle. If the player loses the battle against Mewtwo, their party will be fully healed instead of them blacking out.

Modifying the Pokémon

It is possible to modify many attributes of a wild Pokémon encountered via an event (e.g. make it shiny, choose its gender, change its stats, moveset, etc.). See the article Editing a Pokémon for information on which attributes can be changed. The method described below is the best way of editing a wild Pokémon encountered in an event encounter.

Firstly, define a Global Switch that will cause one of these modifications (e.g. making the Pokémon shiny). Then, in the script section PokemonEncounterModifiers (which exists specifically for this kind of code), enter something like the following:

Events.onWildPokemonCreate+=proc {|sender,e|
  pokemon=e[0]
  if $game_switches[31]
    pokemon.makeShiny
  end
}

This example will cause all wild Pokémon to be shiny, as long as Global Switch 31 is ON when the encounter occurs. For event encounters, the modification(s) to be applied should depend on a Global Switch, as it can easily be toggled ON and OFF in the same event that triggers the battle.

Once that has been set up, in the event that triggers the battle, turn Global Switch 31 ON immediately before the call to pbWildBattle and OFF immediately afterwards, like so:

@>Control Switches: [0031: Shiny wild Pokémon] = ON
@>Script: pbWildBattle(PBSpecies::GYARADOS,30)
@>Control Switches: [0031: Shiny wild Pokémon] = OFF

It is important that the Switch be turned OFF again immediately afterwards, because if it isn't, future wild encounters will also be shiny (or have whatever modifications you chose).

Tips

  • You can combine an event encounter with a time-sensitive event, in order to have a Pokémon that only appears at certain times.
    • Alternatively, the Pokémon could return some time after it was battled, ready for re-battling. Typically, this would only be done if the battle was lost or fled from (and not if the Pokémon was defeated or captured) - take advantage of the ability to store the outcome of the battle in order to achieve this.
  • Set traps for the player by springing wild Pokémon encounters on them in specific places (an example in the games is the Team Rocket HQ under Mahogany Town). Simply don't give the event a sprite, and have it trigger when stepped on rather than interacted with.
  • You could make the Pokémon begin roaming if the battle is lost or fled.
  • Invent certain battle conditions that depend on a Global Switch being ON (e.g. all Poké Balls used will always fail, or the weather randomly changes every turn), and turn that Switch ON just before the battle (and OFF again afterwards, of course). In this way, you can customise certain wild encounters to make them unique/harder.
  • Have the Pokémon drop something if it is defeated. Edit page 2 of the event accordingly to turn the event into an item ball.
  • Allow the battle to take place only if the player has a certain Key Item (e.g. the Devon Scope for invisible Kecleon), and have the event be unresponsive and simply block the player's progress otherwise.

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.