Help making a pokemon trainer-npc like event

matgraz

Veteran
Veteran
Joined
Feb 4, 2018
Messages
66
Reaction score
4
First Language
Portuguese
Primarily Uses
RMMV
I'm currently trying to make a NPC that behaves like the trainers in the pokemon games: if you pass in a area of tiles in front of them they'll trigger a battle. I actually got this working with a parallel event and a bunch of coditions (if looking in a certain direction).

The only thing that's missing is activating the fight by 'talking' to the NPC, since i used parallel eventing for the NPC i don't know how to make it also trigger by pressing a button.

This is how it looks:

and this is how the first page looks (the other pages are the animation of it walking up to the player and triggering the fight), 'Jogador' means 'Player' in portuguese and Laminha is the name of the monster NPC

Code:
◆Control Variables:#0001 Jogador X = Map X of Player
◆Control Variables:#0002 Jogador Y = Map Y of Player
◆Control Variables:#0003 Laminha01_X = Map X of This Event
◆Control Variables:#0004 Laminha01_Y = Map Y of This Event
◆If:This Event is facing Down
  ◆If:Jogador X = Laminha01_X
    ◆Control Variables:#0002 Jogador Y -= Laminha01_Y
    ◆If:Jogador Y ≤ 3
      ◆If:Jogador Y > 0
        ◆Control Switches:#0002 Giro Pausa = ON
        ◆Control Self Switch:A = ON
        ◆
      :End
      ◆
    :End
    ◆
  :End
  ◆
:Else
  ◆If:This Event is facing Right
    ◆If:Jogador Y = Laminha01_Y
      ◆Control Variables:#0001 Jogador X -= Laminha01_X
      ◆If:Jogador X ≤ 3
        ◆If:Jogador X > 0
          ◆Control Switches:#0002 Giro Pausa = ON
          ◆Control Self Switch:B = ON
          ◆
        :End
        ◆
      :End
      ◆
    :End
    ◆
  :Else
    ◆If:Laminha 01 is facing Up
      ◆If:Jogador X = Laminha01_X
        ◆Control Variables:#0002 Jogador Y -= Laminha01_Y
        ◆If:Jogador Y ≥ -3
          ◆If:Jogador Y < 0
            ◆Control Switches:#0002 Giro Pausa = ON
            ◆Control Self Switch:C = ON
            ◆
          :End
          ◆
        :End
        ◆
      :End
      ◆
    :Else
      ◆If:Jogador Y = Laminha01_Y
        ◆Control Variables:#0001 Jogador X -= Laminha01_X
        ◆If:Jogador X ≥ -3
          ◆If:Jogador X < 0
            ◆Control Switches:#0002 Giro Pausa = ON
            ◆Control Self Switch:D = ON
            ◆
          :End
          ◆
        :End
        ◆
      :End
      ◆
    :End
    ◆
  :End
  ◆
:End
 

belatucadrus

Veteran
Veteran
Joined
Mar 6, 2017
Messages
112
Reaction score
15
First Language
french
Primarily Uses
RMMV
If you'd like to use the "event way" to minimize compatibility issues, or you just like to have fun with events, you can use regions.

In a common event running in parallel process, put this :

Code:
> Set variable "Region ID"  == Script : $gameMap.regionId($gamePlayer.x, $gamePlayer.y);
> wait 1 frame
That's all.

In all of your maps, you will make all your enemies as 3-pages event with a line of region drew in their line of sight.

Page 1) Action button triggered event, which wil start a fight when talked to
Page 2) Automatic Event triggered when the Variable "Region ID" matches the region in front of it
Page 3) Event for defeated enemy


Tip : If regions overlaps, just add them up, place a new region and a new page for all the enemies to be triggered at once

(Ex : Enemy 2 with Region ID 2'line of sight, and Enemy 3 with Region ID 3's line of sight are overlapping. Make the region ID where it's overlapping Region ID 5, and create a page for both events to trigger when the players enter Region 5)

Another tip : This also works when your enemies are looking around (therefore changing direction. If they do so place a line of sight of region IDS wherever the enemy will be looking, then just make it a parallel process instead of an automatic one, just to do an additional check for the direction + the X or Y difference

(Ex : if the enemy is looking down, and the player's Y is greater than the enemy's, given the fact the player is actually in one of the line of sights, the battle can be triggered)

IMPORTANT : This solution works ONLY if your enemies are NOT moving ! For moving enemies, you'll be using a plugin

Basically, it would look like this :

1588467361740.png
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Don't forget, aspiring writers: Personality isn't what your characters do, it is WHY they do it.
Hello! I would like to know if there are any pluggings or any way to customize how battles look?
I was thinking that when you start the battle for it to appear the eyes of your characters and opponents sorta like Ace Attorney.
Sadly I don't know how that would be possible so I would be needing help! If you can help me in any way I would really apreciate it!
The biggest debate we need to complete on which is better, Waffles or Pancakes?
rux
How is it going? :D

Forum statistics

Threads
106,051
Messages
1,018,551
Members
137,837
Latest member
Dabi
Top