11-24-2010, 02:29 AM
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. This tutorial was made a looong time ago, so let me know if you have any ideas for an updated version!
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.
Death Page 1
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/M...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/M...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/M...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
Quote:@>Conditional Branch: This event is Facing DownYou'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'.
: Branch End
Quote: @>Control Variables: [0001: Player X] = Player's Map XThis 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: [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
Quote: @>Control Variables: [0002: Player Y] -= Variable: [0004: Enemy Y]This is where it starts getting confusing. I'm going to use a small graph since that's how I figured it out.
http://img.photobucket.com/albums/v437/M...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
Quote: @>Conditional Branch: Variable [0001: Player X] == Variable [0003: Enemy X]The X coordinates must be equal.
: Branch End
Quote: @>Conditional Branch: Variable [0002: Player Y] [color=blue]Conditional Branch: Variable [0002: Player Y] >= 0This 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.
: Branch End
Quote: @>Control Switches: [0001: Death] = ONThis 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.
Facing Left
After you copy and paste the event, you have to change a couple of things. Obviously, change the outermost conditional branch.
Quote: @>Conditional Branch: This event is Facing LeftIf 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.
Quote: @>Control Variables: [0003: Enemy X] -= Variable [0001: Player X]http://img.photobucket.com/albums/v437/M...ngLeft.png[/img]
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
Quote: @>Conditional Branch: Variable [0002: Player Y] == Variable [0004: Enemy Y]This time, the Y coordinates must be equal.
: Branch End
Quote: @>Conditional Branch: Variable [0003: Enemy X] [color=blue]Conditional Branch: Variable [0003: Enemy X] >= 0Now the X variable is used to determine the range.
: Branch End
: Branch End
Facing Right
This time, copy Facing Left so there's only a few things you have to change.
Quote: @>Conditional Branch: This event is Facing RightFirst, don't forget to change this.
Quote: @>Control Variables: [0001: Player X] -= Variable [0003: Enemy X]Just switch the player X and enemy X.
Quote: @>Conditional Branch: Variable [0001: Player X] [color=blue]Conditional Branch: Variable [0001: Player X] >= 0Switch these lines from enemy X to player X.
: Branch End
: Branch End
http://img.photobucket.com/albums/v437/M...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.
Quote: @>Conditional Branch: This event is Facing UpMake sure you change this.
Change the subtraction line:
Quote: @>Control Variables: [0004: Enemy Y] -= Variable: [0002: Player Y]You're just switching the player Y and enemy Y.
Quote: @>Conditional Branch: Variable [0004: Enemy Y] [color=blue]Conditional Branch: Variable [0004: Enemy Y] >= 0Then switch the lines from player Y to enemy Y.
: Branch End
: Branch End
http://img.photobucket.com/albums/v437/M...cingUp.png[/img]
The enemy's coordinates are (2,2) and the player's coordinates are (2,1).
2-1=1
Death Page 2
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:
Quote: @>Control Switches: [0001: Death] = OFFThis is the first command because of the parallel event that makes the enemy get tired of chasing the player and stop.
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.
Give Up Common Event
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. This tutorial was made a looong time ago, so let me know if you have any ideas for an updated version!