Pokemon Type Trainer Encounters

Keiro

Dis weeb
Member
Joined
Mar 27, 2018
Messages
4
Reaction score
0
First Language
English
Primarily Uses
RMVXA
So I have enemies that stay in a certain area, and I want to be able to have them approach the player if they enter a certain distance in front of them. How would I do this?
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,253
First Language
English
Primarily Uses
RMVXA
If you want them to approach as you get closer, you will probably need a script, as any other solution I know of will lag if you ever have more than 2 or so enemies on the map. Otherwise if you are ok with them chasing you at all times, just set them to move route -> Approach player.
 

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
5,610
Reaction score
5,080
First Language
English
Primarily Uses
RMVXA
I disagree with @bgillisp that other solutions will be infeasible/cause lag, although I do agree that a script would be the ideal method to pull this off if you have the expertise to code it or the money to commission it.

The easiest solution would be to have invisible events set to Player Touch (and Below Characters) in a short line in front of the enemies where their line of sight is. If you walk over those events, a switch will be activated, and that switch is the condition for an enemy's second page (where they approach you) to become active. You can usually get between 100 and 200 well-constructed events onto a map in Ace before you start to notice any significant lag, so with 4 invisible events in a line in front of each enemy (I think this was the line of sight for Pokemon trainers), you could put 20-30 enemies on a map safely.

An even better (but more complex) solution would be to have a control event (set to Parallel Process) frequently (every 3 or 4 frames - more frequently can cause lag unless your event is very well constructed; less frequently can mean that your player might walk through the enemy's line of sight without it being noticed) checking the player's X and Y coordinates, and if the X and Y coordinates are certain amounts compared to any given enemy (for example, if the player is between -4 and 0 in the X direction, and 0 in the Y direction, from an enemy that is facing left), then it activates the switch to make that enemy approach the player. This eliminates the need for invisible events and with some clever eventing you can even allow the enemies to walk around and still implement the line-of-sight system from wherever they are at any given time.

Beyond that, the Script really is the best way to do this kind of thing throughout your entire game (if you need it in your entire game rather than just on a couple of maps), because it's much more scalable (less work and less redundancy in the long run), and tends to be better at avoiding lag if you have a really large number of enemies on a map.
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,253
First Language
English
Primarily Uses
RMVXA
@Wavelength : See I was thinking of that solution with the parallel process, but was putting it on every enemy. And if the enemy moves you will need it either on the enemy or checking their x/y too in case the player backs up and runs away. Might work if you have it check the event x/y for each and every enemy, though coding that will be a pain if you have many enemies.

PS: I hit 100/200 events easily so I'd hate to try the invisible player touch idea. Might work for small maps though :)
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,573
Reaction score
6,503
First Language
Indonesian
Primarily Uses
RMVXA
If you want a script solution, I'd advise to use Moghunter's Event Sensor. It saves a headache of checking the distance between event and player. Although, the specific "in front of them" need a little edit.
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Haired slime? Trying some different styles of art. Maybe I can make some resources with this new kind of painting.......
i love my game very much
Uh, I'm probably overthinking this, but I think that some of my music sounds kinda...bad?
The melodies are just sort of awkward, and don't flow.
I'm really not sure what to do. Why am I even worrying about this? I don't even have a battle system yet!
And the Lord said, let there be lighting effects! And there were lighting effects! And it was good...ish? Might tweak this some more.
Today was a day of good things! Thank you fate! I pray to the darkness that those that read this will enjoy a good day as well! Power to the gam mak.

Forum statistics

Threads
105,724
Messages
1,015,915
Members
137,402
Latest member
Lopilon
Top