The RPG Maker Resource Kit

RMRK RPG Maker Creation => RPG Maker General => General Tutorials and Eventing => Topic started by: Yawgmothsbud on May 07, 2007, 03:05:24 PM

Title: Stealth Missions
Post by: Yawgmothsbud on May 07, 2007, 03:05:24 PM
I thought I'd seen a tutorial on this before but I was unable to find it again. I'm working on a series of quests that involve breaking, entering, assassinations and avoiding guards :D. At the moment, however, I'm at a loss as to how to create a "field of vision" for my guards. I figure I can use x and y coordinates to determine whether you are seen or not, but this wouldn't allow you to hide behind obstacles, or to sneak up on the guards (and knife em  :P)

I realize this is going to be quite complicated; in fact, I'm going for the most complex system I can (if I can emulate even the tiniest fraction of the glory of the Hitman series, I'll be happy)

So, if anyone has any general ideas (or knows where that darned tut is) please post ;D
Title: Re: Stealth Missions
Post by: Yawgmothsbud on May 08, 2007, 02:05:32 AM
Wow, this got buried fast...still no one wants to help lil ol' yawggeh?  :-[
Title: Re: Stealth Missions
Post by: Frohman on May 08, 2007, 01:43:42 PM
I think one of the ABS scripts give your enemies fields of visions, don't know if it is exactly what you are looking for.
Title: Re: Stealth Missions
Post by: :) on May 08, 2007, 01:46:20 PM
when you hide behind the object shut off the event for the hero's x and Y
Title: Re: Stealth Missions
Post by: modern algebra on May 08, 2007, 02:13:31 PM
Nah, he couldn't do that, since then guards who should be able to see him wouldn't either:

example: O is player, X's are guards

|X |||||
|   |||||
| O|||||  >X
|   |||||

One of the X's should be able to see him, but he is hiding behind a wall, and if you turn off his position, then you wouldn't be able to.

Let me think about this for a bit, and I'll get back to you with a solution.
Title: Re: Stealth Missions
Post by: Yawgmothsbud on May 08, 2007, 07:00:18 PM
A field of vision for NPC's would be perfect...it would be waaay to much work to event it all. Anyone got a script? I looked around hbgames.org but couldn't find any...
Title: Re: Stealth Missions
Post by: Yawgmothsbud on May 09, 2007, 10:41:56 PM
Still looking...help plocks (sarcasm)  8)
Title: Re: Stealth Missions
Post by: Yawgmothsbud on May 10, 2007, 01:11:21 PM
Still trying to find a way to do this...getting quite frustrated...I really can't continue working on my game until I solve this. Hasn't ANYONE else ever done this before? :-X
Title: Re: Stealth Missions
Post by: Yawgmothsbud on May 11, 2007, 07:35:02 PM
For christ's sake, I've been stuck on this for a week...is it fucking impossible???  >:( >:( >:(
Title: Re: Stealth Missions
Post by: xeph on May 13, 2007, 03:11:37 AM
Found this tutorial in gamingw( to lazy to make my own right now)

Let's begin by adding a fork statement for when the guard FACES UP.

<>FORN Optn:thisEvent-Up Face Direct

Since the guard can only see in a straight line, the hero's X coordinate must be equal to the Guard's X coordinate for the guard to see him:



Notice the same X Coordinates? OK, so add another fork statement that executes when "HeroX" is equal to "WatchX." Make sure that this fork statement is inside the FaceUp FORK statement!

If the guard is facing up, then he can't see what's below him, right? That means that the Hero's Y coordinate must be smakker than the guard's Y coordinate (remember that Y becomes smaller as you go up). Therefore, let's add another fork statement that detects if the "HeroY" variable is less than "GuardY".

Now, inside all those supa-dupa FORK statements, add the "stuff"(tm) that you want to execute when the guard sees you. For example:

Anyway, do the same for when the guard is facing Left, Right, and Down. Just remember:

FACE DOWN: HeroX must equal WatchX, HeroY must be greater than WatchY
FACE LEFT: HeroX must be less than WatchX, HeroY must equal WatchY
FACE LEFT: HeroX must be greater than WatchX, HeroY must equal WatchY

Now, try this program. It should work...except for one little thing: You can't hide from that blasted Sen...uh...guard! So how do you fix this? Simple! We'll need to add more code inside the fork statements!

Let us look at the mountain in the middle - the stuff that you are supposed to hide behind. It starts at (9,5) and ends at (12,10). Hmm...maybe we could add more fork statements inside the existing fork statements that detect if the watcher's vision is blocked by the mountains...it just might work, right?

Let's go back to the "Facing Up" code, inside the three nested FORK statements. If the watcher's vision is blocked by the mountains, then his Y coordinate should be greater than 10 (meaning that he's below the mountains), and the hero's Y coordinate should be below 5 (meaning that the heor is above the mountains). Let's add two fork statements to express this:

<>FORN Optn:Varbl[0002:HeroY]-5less
<>FORN Optn:Varbl[0004:WatchY]-10abov

The watcher's X coordinate (and the Hero's) should also be between 9 and 12, the X coordinates for the beginning and end of the mountain. Let's add another two FORK statements for this condition (remember that inside this look, the hero's X coordinats is equal to the Guard's X coordinate. Thus, you only need to compare one of them.)

I'll wait...Done? Good! Now, remember our good old switch, "Blocked"? Turn the switch ON inside the nested fork statements, which will tell us that Sen...uh...the guard cannot see the hero - his vision is blocked by the mountains.

After these four inner FORK statements, add another FORK statement that activates when the "Blocked" switch is OFF. Put the [guard battle code/stuff that you want to do when the guard sees the hero] in here.

Repeat this procedure for the other three directions. Just make sure to adjust the FORK statements appropriately.