• Hi, Guest!
    Some images might be missing as we move away from using embedded images, sorry for the mess!
    From now on, you'll be required to use a third party to host images. You can learn how to add images here, and if your thread is missing images you can request them here.
    Do not use Discord to host any images you post, these links expire quickly!
Setting Up Twin Trainers

any version Setting Up Twin Trainers 1.0

This resource does not pertain to any specific version of Pokémon Essentials.
Pokémon Essentials Version
Non-applicable
Video version:


Twins, Young Couples, Teammates, Backers. These trainers have always been tricky to implement in Essentials, due to their nature as appearing as two on the overworld, but actually being a single entity in-battle. The problem has always been making two events synergistically walk up to the player and initiate battle.

Pokemon Essentials does not have any examples to do this, at least without talking to the dual trainers yourself. Tutorials will result in answers such as making the two trainer sprites a single sprite, or separating each twin as their own trainer. Results that are, imo, not ideal.

In this tutorial, I will show you how to easily solve this problem forever with a single Common Event!
This should (hopefully) work with any version of Essentials. But if it doesn't then oops...

#1. Create your twin trainers. This tutorial will be difficult without them.
dT1.PNG

Create a trainer like normal. However, instead of doing "pbNoticePlayer(get_character(0))" like usual we'll be replacing it with our Common Event. In my case, that's pbNoticeDoubleTrainer.
Also, I'm setting Variable 1 to be the current event's ID number, while Variable 2 will be the partner event's ID number.

#2. Create your twin trainer Common Event. The whole reason you're here.
dT2.PNG

We first make both twins exclaim/[!] in order to notice the player. Since the default Show Animation command requests a specific event, we'll use Scripting instead to do the animation:
Ruby:
pbExclaim([get_character(pbGet(1)),get_character(pbGet(2))])

We then set the direction to whichever direction the "main" twin is facing. We'll also make the partner twin face the same direction, because might as well.
Ruby:
pbSet(3,$game_map.events[pbGet(1)].direction)
$game_map.events[pbGet(2)].direction = pbGet(3) # Make partner twin direction match main.

With the main twin's direction in hand, it's time to prepare to make both twins move towards the player.
The default pbNoticePlayer command includes moving the trainer to the player, but this has weird effects for twins. The oddity being that the partner twin will separate from the main twin in order to also stand next to the player. This isn't what we want.
So we'll instead calculate the distance between the main twin and the player and move them accordingly.
dT3.PNG

Put the following code in the appropriate Conditional Branches (like the above screenshot.)
Ruby:
# Down (2)
t = $game_map.events[pbGet(1)].y # This Trainer's current y position.
p = $game_player.y               # Player's current y position.
d = (t - p).abs - 1              # The distance between the two positions.
pbSet(4,t)                       # Trainer's start value.
pbSet(5,t+d)                     # End value (Positive bc trainer is moving down).
# Left (4)
t = $game_map.events[pbGet(1)].x # This Trainer's current x position.
p = $game_player.x               # Player's current x position.
d = (t - p).abs - 1              # The distance between the two positions.
pbSet(4,t)                       # Trainer's start value.
pbSet(5,t-d)                     # End value (Negative bc trainer is moving left).
# Right (6)
t = $game_map.events[pbGet(1)].x # This Trainer's current x position.
p = $game_player.x               # Player's current x position.
d = (t - p).abs - 1              # The distance between the two positions.
pbSet(4,t)                       # Trainer's start value.
pbSet(5,t+d)                     # End value (Positive bc trainer is moving up).
# Up (8)
t = $game_map.events[pbGet(1)].y # This Trainer's current y position.
p = $game_player.y               # Player's current y position.
d = (t - p).abs - 1              # The distance between the two positions.
pbSet(4,t)                       # Trainer's start value.
pbSet(5,t-d)                     # End value (Negative bc trainer is moving up).
After this, make the Player face the the twin, which is the opposite direction that the twins are facing.

Now it's time to make the twins move!
dT0.png

This will all be done in a loop. At the start, we'll check if Variable 4 (the start value we set/twin's current position) matches Variable 5 (the end value/the twin's destination position). If that is the case, we break the loop. We put this at the start so if the player gets spotted while next to the twins, they don't need to move.

If the twins have not reached their destination yet, we'll move them 1 tile forward using this Script command:
Ruby:
$game_map.events[pbGet(1)].move_forward
$game_map.events[pbGet(2)].move_forward
$game_map.events[pbGet(1)].move_route_forcing
$game_map.events[pbGet(2)].move_route_forcing
Wait 4 frames in order to give them time to move to the next tile. (NOTE: This assumes that you're making the trainers move at the default speed of 3. If your Twin has a higher speed value, you'll most likely need to adjust this wait value.)
Then, we just simply update Variable 4 to match the new position value and loop back to the beginning so we either break the loop or keep moving.

If everything is correct, the end result should look like this:
twinCOMPLETE.gif

That's all! Now you can easily make twin/couple/partner trainer events with a single common event and simply setting variable 1&2 (or whatever disposable variable you wanna use) to the current and partner twin Event IDs.
Credits
No credit needed. I mean, I won't complain if you do give credit but you're not forced to lmao
  • dT1.PNG
    dT1.PNG
    262.3 KB · Views: 100
  • dT1.PNG
    dT1.PNG
    187.5 KB · Views: 97
Author
Peti
Views
1,658
First release
Last update
Rating
5.00 star(s) 1 ratings
Back
Top