Quick Outline:
This article is merely a collection of some design ideas for a stealth-based game. There will be little to no code here. It's also more targetted at MMF then TGF, but there is still some TGF information in here. It covers information about using invisible detectors in games, intelligent seeking enemies, and naturally the MMF Pathfinder object.


Foreword:
I plugged over 100 extensions into MMF today, even though I still have no idea how to use it. Atleast i'm prepared. >.>

Among the objects I found is a PATHFINDER Object. God, how I wanted this in TGF for my game. Now that I have it, i've been thinking about ways to use it - Mostly for my Bomb Squad Game. One of the many problems in the game is getting caught by the guards - It's a strategy game, not a shoot 'em up. The problem was designing a decent enemy system in an engine that doesn't easily differenate between copies of an object, and can hardly handle any sort of line-of-sight detection.

In the end, the decision was to simply use the 'Invisible detector bullet' system. But with the wide array of extensions for MMF, this is no longer necessary. With a properly designed level, the PATHFINDER object can fairly easily be used to hunt down an opponent.


(In Defense Of) Invisible Detection Bullets:
First of all, I'd like to make a point about invisible detector bullets. Many klickers talk down about them, but I think it's important to point out the usefulness and ease of them too. If your goal is simply to determine if the player breaks the line of sight of something, then in many times it's a perfectly fine system. The downsides are still very much there - the use of extra objects, the delay time of the travelling 'bullet', and most importantly determining the bullets owner. All of these problems can be overcome, however.


Solving the problems with Invisible Detection Bullets:
Extra objects? Sure. But not that many. My game is a top-down scroller. By setting the guards to only 'scan' (shoot detectors) when they were visible on the screen seriously limited the number of detectors in play at once. Also, properly managing the collision detection and destruction when they leave the play area will ensure that you don't have a continious build up of objects until it craps out. You could even set it up to disable the detection routines if the object limit got too close to 260 (approximately the limit), to make sure that they don't block the other object-creation routines. Bullet travel time? Search the Daily Click for Instant-hit bullets in TGF, you'll find a really nice article about using fastlooping to handle that. The bullets owner? Well, I still haven't figured that out quite yet. But i'm pretty sure a solution lies in the SPREAD A NUMBER ability. Of course, if your detection simply has to trigger a global alarm and alert ALL of the baddies, then you don't even need too tag owners. Any time ANY detector hits the player, trip the alarm.

But that's all just TGF solutions. What about MMF, what options are available there? Well firstly - Detector bullets are much more effective in MMF. You can raise the object limit on MMF frames to make sure that you have enough room for them. Fastlooping is built into MMF, so if your worried about bullet travel time you can easily solve that using the same basic instant-hit style.

But that's all irrelevant if your looking for a smart baddy. While a guard that just watches and trips an alarm if he sees you might be sufficent in some games, it's not terribly interesting. Nor is it very threatening, it's just a matter of timing. 'Oops, here comes the red lights. Now he's going to shoot in a straight line at me. *Ducks into a doorway* Hmm. I seem to be safe now. I'll just go shut off that alarm so he stops trying to shoot me.'


My Stealth / Detection Concept:
So here's the idea i'm working on for 'Smart Baddies' in my game. Take your average enemy, we'll just call him 'The Guard' for now. Stick him in a little hallway. Now you rig up the detector bullets, so he fires them in the direction he's looking. (You can use fastlooping if you want the best effect, or just straight fire them if your lazy - Either works) Nothing terribly fancy here. BUT, there are a few key differences. First of all, all of the bullets are tagged to point back at their parent object. (Spread a number? Probably a better way in MMF)

When a detector strikes the player, it has to look up the parent to decide what to do next. One of the parents (The Guard) values is used to reflect an AI state. Lets say the default is 0, where he just stands around and searchs. LOOKING is 1, when he thinks he saw something, and ATTACK is 2 - when he's trying to blow you away.

If the guard is in 0 (Default) mode, then he becomes curious now. Did he see someone? Naww... But I better go look anyway. Set his mode to 1 (LOOKING) We only want him to go where he saw someone though - so we drop a TARGET beacon where the bullet-strike occured. We also want to be able to get back if nobody is there, so we drop a HOMEBASE beacon under the Guard himself. Both of this have to be tagged to the Guard again, don't forget. And since the guard is using line-of-sight detection, there's no need for a pathfinder here - just look at the TARGET beacon and move forward until you reach it. After that, you have to switch to a 4th AI mode - WAITING. This just a little lapse, while he checks things out. He should quickly check all the directions a few times. After your timer expires, set him to a 5th AI Mode - GO_HOME. Just a reverse of LOOKING, where he backtracks to his HOMEBASE beacon, and then resets to mode 0 (Default) when he reaches it.


But what if he should see you? Make sure he's still shooting detectors while moving around. If he should spot you again (AKA if he spots you while he's in any mode except default) he switches to mode 2 (ATTACK). Now this is where the fun is - You can set off an alarm if you like. You can start a timer on the guard so after a while he'll get bored with searching. But now you can fire up the PATHFINDER object and make the guard start HUNTING you. If you want to be real evil, you can make ALL of the nearby guards start hunting the player. And for those of you not in the know, the PATHFINDER kicks out a couple of cool pieces of information:

DISTANCE. Yup, the distance to the target. Good for determining who nearby should respond to the alarm. Also good for checking if your Guard/Enemy is within firing range, so he can blow you away.

LINE OF SIGHT. When the Guard/Enemy finally rounds that corner and gets a straight shot to the player, LOS kicks back as TRUE. That means you could immediately open fire on the player! If you want to give him more of a fighting chance, you can use DISTANCE still. But maybe one of your enemies is armed with a heavy rifle, or a sniper rifle even. Wink wink, nudge nudge.


Summary:
It might be tricky to set up a lot of the things in this article. It might not, I don't know. I know everything here is possible though, and I plan on finding out how much of it is effective. There are all sorts of cool effects you can do with this. For instance, Attack Dogs. Completely skip the LOOKING phase - if they spot you, they jump right into attacking. Then they chase you down and rip you apart.

There are, of course, disadvantages and difficulties. Setting up the PATHFINDER to know where the obstacles are might be a real pain. I hope to overcome that by having a level editor/loading system that handles that on it's own. Instant-hit bullets can be tricky the first time you do them. Flagging objects in such a way that you can find their parent again is pretty hard.

I don't know how well i'll be able to actually get this to work, i'm still learning a lot about MMF. I hope someone else can make good use of these techniques, or atleast learn something from them. (Even if it ends up being how NOT to do stealth tactics) - I'd appreciate any feedback on the article, too. If I made any mistakes, let me know so I can correct them.