Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Question about events....

So here's my problem....

I have a situation in my game where my character has to sneak past some guards that are patrolling. I want him to be able to get caught if the guards see him and have them throw him out. Is there any way to set like a certain vicinity that if the player get's too close to the guard, he will get caught? I'm not sure if this is possible or not. The only way I could think of to do it would be to have a set of events that move around him accordingly, and set them to "Player Touch", so that if the player touches any of those "Invisible" events that are near the guard, he will be caught.
That is an awful lot of work to organize however, seeing as how I have several guards for him to sneak past.

Anyway, I thought I would check and see if someone knew of any easier way to accomplish this.

Thanks for any help guys!

Also, sorry for the long post. I wanted to be thorough.
 

Tindy

Sponsor

Here....I didn't do it, and I take no credit for it, but it's been in my folder probably since the dawn of time.  (It's by "Nintendo.")

Nintendo":2fkljn74 said:
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
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top