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
Advertisement
For how to trigger a rematch against a trainer, see Phone.

This page describes how to have rematches with trainers. Specifically, it describes how to set up events for trainers that can be rebattled - see Phone for details on when rematches are triggered.

Setting up a trainer for rematches[]

Creating a trainer that the player can rebattle is an extension of creating a regular trainer. This page assumes that you are familiar with how to set up a regular trainer.

To modify a regular trainer so that they can be rebattled, do the following:

  • Include at least two "Battle:" comments in the trainer event (even if they all say the same thing) when using comments to create the trainer's event.
  • Create the same number of versions of the trainer as there are "Battle:" comments, in the PBS file "trainers.txt". They must be numbered in order, starting from 0 (e.g. 0, 1, 2, 3, etc.).

The number of "Battle:" comments is important, as this number determines how many different battles are set up. These different battles are each with different versions of the trainer, which is why the same number of versions of the trainer need to be created.

Any version of the trainer can be identical to another version. This is useful if you want to allow, say, three rematches against the same version of the trainer before upgrading them to a stronger team. In this case, technically the player is battling a different version each time; it's just that those versions are all the same.

You can have multiple copies of the "EndSpeech:" and "EndBattle:" comments in a trainer event. These define the appropriate messages for each battle in order. You can have fewer of these comments than you have "Battle:" comments; if so, then the last "EndSpeech:" or "EndBattle:" comment will be used over and over again in subsequent rematches (even if those matches are against different versions of the trainer).

See Phone for details on when a registered trainer becomes available for a(nother) rematch.

A trainer can only be rebattled if they are registered in the phone, as the version of that trainer to battle is one of the bits of information stored in the phone.

A trainer can be rebattled even after all of their versions have been battled. In this case, the last version of the trainer will be battled over and over again. There is no limit to the number of times a trainer can be rebattled (assuming they can be rebattled at all).


Of course, rather than using comments to set up a trainer event, you can create it from scratch using the below information and referring to the sample trainers in the example maps. However, that will be more difficult and time-consuming than simply using comments and compiling the game. You can always remove the comments afterwards and tweak the event commands in whatever way you like.

Example[]

@>Comment: Type: CAMPER
@>Comment: Name: Dave
@>Comment: Battle: Let's battle!
@>Comment: Battle: Let's battle again!
@>Comment: Battle: I'll win this time!
@>Comment: Battle: One last time!
@>Comment: EndSpeech: Wiped out!
@>Comment: EndSpeech: Wiped out again!
@>Comment: EndBattle: You won!
@>Comment: EndBattle: You won again!
@>Comment: EndBattle: You beat me for the third time!
@>Comment: EndBattle: I give up!
@>Comment: RegSpeech: Let's swap numbers!

These are all the comments that describe a trainer, Camper Dave, who can be registered in the phone and rebattled (both these facts are because there is more than one "Battle:" comment). This trainer should have four versions: one for the original battle and three for rematches (because there are four "Battle:" comments in total).

The first time Dave is battled, he will say "Let's battle!" before the battle, "Wiped out!" after he is defeated (still in the battle screen), and "You won!" if the player talks to him again after defeating him. Immediately after beating him, he will ask to be registered in the phone (saying "Let's swap numbers!").

In his first rematch, he will say "Let's battle again!" before the battle, "Wiped out again!" after he is defeated (still in the battle screen), and "You won again!" if the player talks to him again after defeating him this time.

In his second rematch, he will say the third lines in the relevant comments, except for "EndSpeech:" where he will say "Wiped out again!" again (he will keep saying that for the rest of his rematches).

After Dave has been defeated in his third rematch (i.e. all the versions of him have been defeated), he can be rebattled again, but he will be identical to how he was in his third rematch. There is no limit on the number of times he can be rebattled, but once you have run out of different versions of him, you will just battle the latest version over and over again.

Structure of trainer events[]

This section provides a more in-depth description of the trainer events, specifically what they look like after they have been compiled using the event comments.

Note that page 2 uses Self Switch B, while page 3 uses Self Switch A.

Page 1[]

The first page is the same as for any other trainer event, and handles the original battle.

The sole difference between this page and any other trainer's first page is that an additional line is included inside the battle's Conditional Branch just before Self Switch A is set to "ON". The extra line is:

@>Script: pbPhoneRegisterBattle(_I("Let me register you."), get_self, :CAMPER, "Dave", 4)

The text comes from the "RegSpeech:" comment.

This script registers the trainer in the phone, after asking the player if they want to register them. The highlighted parts are the only parts that should be changed (if you want to). They should be, in turn, the trainer's type, the trainer's name, and the total number of different versions of the trainer (including the original version).

Page 2[]

The second page is much like the first page, except in a Conditional Branch and copied a number of times over. This page handles all the rematch battles.

Each copy looks like this:

@>Conditional Branch: Script: pbPhoneBattleCount(:CAMPER,"Dave") == 1
  @>Script: pbTrainerIntro(:CAMPER)
  @>Text: Battle me now!
  @>Conditional Branch: Script: TrainerBattle.start(:CAMPER, "Dave", 1)
    @>Script: pbPhoneIncrement(:CAMPER, "Dave", 4)
    @>Control Self Switch: A =ON
    @>Control Self Switch: B =OFF
    @>Script: pbTrainerEnd
    @>
   : Branch End
  @>Exit Event Processing
  @>
 : Branch End

The only differences between each copy are the highlighted numbers - they are both the same in a given copy, and are the number of this rematch ("1" is the first rematch).

The text comes from the "Battle:" and "EndSpeech:" comments in order. Note that the first of each of the "Battle:" and "EndSpeech:" texts are skipped here - that first text is on page 1, with the original battle.

Also, the final copy has an extra tweak: the "==" just before the highlighted number in the first line becomes ">=" instead. This is because that battle is with the last version of the trainer, which can be battled over and over again, so the rematch number needs to be at least the highlighted number, rather than exactly that number.

Page 3[]

The third page is the same as the second page in any other trainer event, in that it handles what happens when the player talks to the trainer after defeating them.

There are two different parts to this page, the first of which is copied a number of times with a minor tweak each time.

The first part is the one that is copied. It looks like this:

@>Conditional Branch: Script: pbPhoneBattleCount(:CAMPER,"Dave") == 1
  @>Text: You may have beaten me twice, but I'll get stronger!
  @>Script: pbPhoneRegisterBattle(_I("Let me register you."), get_self, :CAMPER, "Dave", 4)
  @>Exit Event Processing
  @>
 : Branch End

The text comes from the "EndBattle:" comments in order. Note that the first "EndBattle:" text is skipped here - that first text is below.

The tweak here is the highlighted number - this is the message shown when the player talks to the trainer after defeating them in that exact number of rematches (Note: NOT that number of times altogether, just the rematches). In the example above, the message is shown after the player has defeated the trainer twice (the original first time and the first rematch).

The registering script is called here again, although it currently doesn't serve a purpose. It will once Essentials has been updated to allow the player to delete contacts from the phone; in which case, the script here will allow the player to re-register them later.

Also, the final copy of this part has an extra tweak: the "==" just before the highlighted number becomes ">=" instead. This is because that message goes with the last version of the trainer, which can be battled over and over again, so the number of already won rematches needs to be at least the highlighted number, rather than exactly that number.


The second part to this page is very simple: it is just a text message with the message shown after the player has first defeated the trainer (but has not yet had a rematch with them). This part must be at the bottom of the page, below all the copies of the first part. The text comes from the first "EndBattle:" comment. There is also a call to the registering script again, which allows the player to register the trainer later if they chose not to when they first defeated the trainer.

Tips[]

  • Why not change the kind of battle between rematches? For example, you could have a trainer who starts with single battles, but then moves on to double battles later on.
  • You could have a trainer who is the same the first few times you battle them, and only have their party change later.
Advertisement