Demos:
XP: http://www.mediafire.com/?m9buccxhygx
VX: http://www.mediafire.com/?pdgxbndcqxd
This tutorial is very difficult to understand at first. I recommend downloading the demo and following along with me as I explain each line of the event, but you can just copy and paste the events if you want. With this tutorial, you will be able to give an enemy sight range as well as make them chase after the player upon detection.
Multiple Enemies:
These are some things to be aware of when making multiple enemies. First, you'll need different variables for each enemy's X and Y coordinates, but you can use the same variables for the player's X and Y coordinates. Also, you'll want to use different switches for each enemy and different common events for each enemy. This way, you're not only allowing the player to be followed by multiple enemies, but you can also set different time frames for when the enemies get tired.
If I need to make anything clearer or if you want to know how to change something, please post in this thread or PM me and I'll get back to you as soon as possible.
XP: http://www.mediafire.com/?m9buccxhygx
VX: http://www.mediafire.com/?pdgxbndcqxd
This tutorial is very difficult to understand at first. I recommend downloading the demo and following along with me as I explain each line of the event, but you can just copy and paste the events if you want. With this tutorial, you will be able to give an enemy sight range as well as make them chase after the player upon detection.
Setup
Conditions: None
Graphic: Evil 6 (Can be changed)
Autonomous Movement: Type: Fixed (Can be changed)
Speed: 3
Freq: 3
Options: Walking Animation
Priority: Same as Characters
Trigger: Parallel Process
Facing Down
http://img.photobucket.com/albums/v437/ ... ngDown.png[/img]
In this example, you can see that the X variables must be equal (which is included later), but you need to find the difference of the Y variables. In this example, the enemy's coordinates are (2,2) and the player's coordinates are (2, 3). To make the variable positive, I'm subtracting the enemy Y from the player Y:
3-2=1
Facing Left
After you copy and paste the event, you have to change a couple of things. Obviously, change the outermost conditional branch.
Now, the enemy's coordinates are (2,2) and the player's coordinates are (1,2), so I subtracted the player's X from the enemy's X to make the variable positive.
2-1=1
Facing Right
This time, copy Facing Left so there's only a few things you have to change.
http://img.photobucket.com/albums/v437/ ... gRight.png[/img]
The enemy's coordinates are (2,2) and the player's coordinates are (3,2).
3-2=1
Facing Up
Copy the Facing Up conditional branch.
Change the subtraction line:
http://img.photobucket.com/albums/v437/ ... cingUp.png[/img]
The enemy's coordinates are (2,2) and the player's coordinates are (2,1).
2-1=1
Conditions: None
Graphic: Evil 6 (Can be changed)
Autonomous Movement: Type: Fixed (Can be changed)
Speed: 3
Freq: 3
Options: Walking Animation
Priority: Same as Characters
Trigger: Parallel Process
Facing Down
You'll want to start with just one direction. It's much easier to copy and paste this conditional branch once it's finished than make each one separately. You should uncheck 'Set handling when condtions do not apply'.@>Conditional Branch: This event is Facing Down
: Branch End
This sets the variables that will be needed. It records the player's map position and the enemy's map position so that they can be compared later.@>Control Variables: [0001: Player X] = Player's Map X
@>Control Variables: [0002: Player Y] = Player's Map Y
@>Control Variables: [0003: Enemy X] = This event's Map X
@>Control Variables: [0004: Enemy Y] = This event's Map Y
This is where it starts getting confusing. I'm going to use a small graph since that's how I figured it out.@>Control Variables: [0002: Player Y] -= Variable: [0004: Enemy Y]
http://img.photobucket.com/albums/v437/ ... ngDown.png[/img]
In this example, you can see that the X variables must be equal (which is included later), but you need to find the difference of the Y variables. In this example, the enemy's coordinates are (2,2) and the player's coordinates are (2, 3). To make the variable positive, I'm subtracting the enemy Y from the player Y:
3-2=1
The X coordinates must be equal.@>Conditional Branch: Variable [0001: Player X] == Variable [0003: Enemy X]
: Branch End
This is the number of spaces that you want the enemy to see you. In this demo, the enemy can see up to 5 spaces away.@>Conditional Branch: Variable [0002: Player Y] <= 5
: Branch End
This is needed because variables can be both positive and negative. If you don't have this, the enemy will be able to see behind him infinitely.@>Conditional Branch: Variable [0002: Player Y] >= 0
: Branch End
This is a switch and not a self switch because you'll probably want the enemy to give up the chase after a certain amount of time. If you want them to chase the player until they catch them, you can use a self switch instead.@>Control Switches: [0001: Death] = ON
Facing Left
After you copy and paste the event, you have to change a couple of things. Obviously, change the outermost conditional branch.
If you forget to change this, your enemy will be able to see in all directions when facing down and be blind when facing left, right, or up.@>Conditional Branch: This event is Facing Left
http://img.photobucket.com/albums/v437/ ... ngLeft.png[/img]@>Control Variables: [0003: Enemy X] -= Variable [0001: Player X]
Now, the enemy's coordinates are (2,2) and the player's coordinates are (1,2), so I subtracted the player's X from the enemy's X to make the variable positive.
2-1=1
This time, the Y coordinates must be equal.@>Conditional Branch: Variable [0002: Player Y] == Variable [0004: Enemy Y]
: Branch End
Now the X variable is used to determine the range.@>Conditional Branch: Variable [0003: Enemy X] <= 5
@>Conditional Branch: Variable [0003: Enemy X] >= 0
: Branch End
: Branch End
Facing Right
This time, copy Facing Left so there's only a few things you have to change.
First, don't forget to change this.@>Conditional Branch: This event is Facing Right
Just switch the player X and enemy X.@>Control Variables: [0001: Player X] -= Variable [0003: Enemy X]
Switch these lines from enemy X to player X.@>Conditional Branch: Variable [0001: Player X] <= 5
@>Conditional Branch: Variable [0001: Player X] >= 0
: Branch End
: Branch End
http://img.photobucket.com/albums/v437/ ... gRight.png[/img]
The enemy's coordinates are (2,2) and the player's coordinates are (3,2).
3-2=1
Facing Up
Copy the Facing Up conditional branch.
Make sure you change this.@>Conditional Branch: This event is Facing Up
Change the subtraction line:
You're just switching the player Y and enemy Y.@>Control Variables: [0004: Enemy Y] -= Variable: [0002: Player Y]
Then switch the lines from player Y to enemy Y.@>Conditional Branch: Variable [0004: Enemy Y] <= 5
@>Conditional Branch: Variable [0004: Enemy Y] >= 0
: Branch End
: Branch End
http://img.photobucket.com/albums/v437/ ... cingUp.png[/img]
The enemy's coordinates are (2,2) and the player's coordinates are (2,1).
2-1=1
Setup
Conditions: Switch [0001: Death] is ON
Graphic: Evil 6 (Can be changed)
Autonomous Movement: Type: Approach
Speed: 4 (Can be changed)
Freq: 5
Options: Walking Animation
Priority: Same as Characters
Trigger: Parallel Process (You can also use Event Touch. Just get rid of all the location conditional branches and skip right to the battle processing. This will make the battle occur when the enemy touches the player instead of when they're one tile apart.)
Facings
Copy and paste the entire first event page, either using copy event page or copying the commands. First, change the values for sight range from 5 to 1 (this means it will activate when they are 1 space apart. If you have a ranged enemy, this can be higher).
I've tried using Player Touch, but for that, the player has to walk into the enemy. Event touch is risky because it will activate whenever it touches an event, whether it's the player or that torch in the middle of the floor.
Next, change the switch line in each facing:
Then, use a battle processing to start the battle. After the battle, you'd usually use the Erase Event command to make the event disappear until the player comes back to the map. I used a move route to move the player back so you could activate the enemy more than once. Make sure you add these to all facings.
Conditions: Switch [0001: Death] is ON
Graphic: Evil 6 (Can be changed)
Autonomous Movement: Type: Approach
Speed: 4 (Can be changed)
Freq: 5
Options: Walking Animation
Priority: Same as Characters
Trigger: Parallel Process (You can also use Event Touch. Just get rid of all the location conditional branches and skip right to the battle processing. This will make the battle occur when the enemy touches the player instead of when they're one tile apart.)
Facings
Copy and paste the entire first event page, either using copy event page or copying the commands. First, change the values for sight range from 5 to 1 (this means it will activate when they are 1 space apart. If you have a ranged enemy, this can be higher).
I've tried using Player Touch, but for that, the player has to walk into the enemy. Event touch is risky because it will activate whenever it touches an event, whether it's the player or that torch in the middle of the floor.
Next, change the switch line in each facing:
This is the first command because of the parallel event that makes the enemy get tired of chasing the player and stop.@>Control Switches: [0001: Death] = OFF
Then, use a battle processing to start the battle. After the battle, you'd usually use the Erase Event command to make the event disappear until the player comes back to the map. I used a move route to move the player back so you could activate the enemy more than once. Make sure you add these to all facings.
Setup
Trigger: Parallel
Condition Switch: [0001: Death]
Commands
You'll want a wait command that waits for however many frames you wish your enemy to pursue the player. Then, turn the switch [0001: Death] to OFF. This puts the enemy back to the first event page.
Trigger: Parallel
Condition Switch: [0001: Death]
Commands
You'll want a wait command that waits for however many frames you wish your enemy to pursue the player. Then, turn the switch [0001: Death] to OFF. This puts the enemy back to the first event page.
Multiple Enemies:
These are some things to be aware of when making multiple enemies. First, you'll need different variables for each enemy's X and Y coordinates, but you can use the same variables for the player's X and Y coordinates. Also, you'll want to use different switches for each enemy and different common events for each enemy. This way, you're not only allowing the player to be followed by multiple enemies, but you can also set different time frames for when the enemies get tired.
If I need to make anything clearer or if you want to know how to change something, please post in this thread or PM me and I'll get back to you as soon as possible.