First things first… make a new game and create a map (I recommend it small if it is not for your game and you are trying it out) and make the player start position.
Uhhh…
Next… Make a guard (I recommend a pirate) somewhere on the map.
Have the pirate be facing down, call it ‘guard‘, movement type any, and triggered by collision with hero. Just have the event commands game over or minus some kind of variable to health, depending on your game. You can actually have it do whatever but remember this is only when you hit the pirate.
For this example, I am making the guard see up to five tiles in front of him. Right in front of his face make an event on collision with hero, no graphics and below hero. Have the Event Commands whatever you want when you walk in front of his face. Call this event GuardVisA1. Copy in paste it four times, each going down a straight line below his face naming each one
GuardVisA2, GuardVisA3, and so on. Now to the right of him, paste it four more time in a line to the right. Name each one GuardVisB1, GuardVisB2, and so on.
Now for the harder part.
Make a parallel process below hero somewhere on the map. You need an extra, similar event with the changed variables (I.E. Guard1X = Guard2X) for every guard on your map.
Variables needed:
Guard1X
Guard1Y
(You need Guard variables for each guard you have)
HeroX
HeroY
Switches needed:
NONE
Let’s get started:
(I use RM2K3 so the code might differ but you’ll get it anyway) Branch = Fork OPTN
<>Variable Oper: [????: HeroX] Set, Hero X Coord
<>Variable Oper: [????: HeroY] Set, Hero Y Coord
<>Variable Oper: [????: Guard1X] Set, guard X Coord
<>Variable Oper: [????: Guard1Y] Set, guard Y Coord
<>Branch: guard Up Facing
<>Variable Oper: [GuardY] + 1]
<>Change Event Location: GuardVisA1, (V[????], V[????]) (Use the variables GuardX and GuardY)
<>Variable Oper: [GuardY] + 1]
<>Change Event Location: GuardVisA2, (V[????], V[????]) (Use the variables GuardX and GuardY)
<>Variable Oper: [GuardY] + 1]
<>Change Event Location: GuardVisA3, (V[????], V[????]) (Use the variables GuardX and GuardY)
<>Variable Oper: [GuardY] + 1]
<>Change Event Location: GuardVisA4, (V[????], V[????]) (Use the variables GuardX and GuardY)
<>Branch: Var [????: HeroX] is V[????] (That’s GuardX) Equal
<>Branch: Var [????: HeroY] is V[????] (That’s GuardY) Equal
<> (Whatever you want to happen when seen)
<>
: End
<>
: End
<>
:End
<>Branch: guard Rightng
<>Variable Oper: [GuardX + 1]
<>Change Event Location: GuardVisA1, (V[????], V[????]) (Use the variables GuardX and GuardY)
<>Variable Oper: [GuardX + 1]
<>Change Event Location: GuardVisA2, (V[????], V[????]) (Use the variables GuardX and GuardY)
<>Variable Oper: [GuardX + 1]
<>Change Event Location: GuardVisA3, (V[????], V[????]) (Use the variables GuardX and GuardY)
<>Variable Oper: [GuardX + 1]
<>Change Event Location: GuardVisA4, (V[????], V[????]) (Use the variables GuardX and GuardY)
<>Branch: Var [????: HeroX] is V[????] (That’s GuardX) Equal
<>Branch: Var [????: HeroY] is V[????] (That’s GuardY) Equal
<> (Whatever you want to happen when seen)
<>
: End
<>
: End
<>
:End
<>Branch: guard Doenng
<>Variable Oper: [GuardY] -1
<>Change Event Location: GuardVisB1, (V[????], V[????]) (Use the variables GuardX and GuardY)
<>Variable Oper: [GuardY] -1
<>Change Event Location: GuardVisB2, (V[????], V[????]) (Use the variables GuardX and GuardY)
<>Variable Oper: [GuardY] -1
<>Change Event Location: GuardVisB3, (V[????], V[????]) (Use the variables GuardX and GuardY)
<>Variable Oper: [GuardY] -1
<>Change Event Location: GuardVisB4, (V[????], V[????]) (Use the variables GuardX and GuardY)
<>Branch: Var [????: HeroX] is V[????] (That’s GuardX) Equal
<>Branch: Var [????: HeroY] is V[????] (That’s GuardY) Equal
<> (Whatever you want to happen when seen)
<>
: End
<>
: End
<>
:End
<>Branch: guard Left Facing
<>Variable Oper: [GuardX] -1
<>Change Event Location: GuardVisA1, (V[????], V[????]) (Use the variables GuardX and GuardY)
<>Variable Oper: [GuardX] -1
<>Change Event Location: GuardVisA2, (V[????], V[????]) (Use the variables GuardX and GuardY)
<>Variable Oper: [GuardX] -1
<>Change Event Location: GuardVisA3, (V[????], V[????]) (Use the variables GuardX and GuardY)
<>Variable Oper: [GuardX] -1
<>Change Event Location: GuardVisA4, (V[????], V[????]) (Use the variables GuardX and GuardY)
<>Branch: Var [????: HeroX] is V[????] (That’s GuardX) Equal
<>Branch: Var [????: HeroY] is V[????] (That’s GuardY) Equal
<> (Whatever you want to happen when seen)
<>
: End
<>
: End
<>
:End