Game Development Community

Stealth-based game (How hard would it be?)

by Dragoness · in General Discussion · 06/01/2006 (10:42 pm) · 10 replies

Is it possible to create a stealth-based game, like Thief? You know, where shadows and light determine how visible you are and NPCs will see you and attack if you're too visible etc. How difficult would it be to implement this? How would I go about doing it? I realize I am probably way over my head here but I still want to know. I am new here, so excuse my ignorance. :)

About the author


#1
06/01/2006 (10:50 pm)
What you described, from what I know, can't be done in just torque script, you would need to edit the C++ source to retrieve light locations and visibility. I am sure it can be done, but will leave the explanations up to somone who knows better than me.

I am sure you will be hard pressed to find somone willing enough to walk you through the code needed to do this. Either way, good luck.
#2
06/02/2006 (5:40 am)
I thought so. :( Sounds like a huge headache already. Thanks for response.
#3
06/02/2006 (6:12 am)
Dragoness,

It might sound difficult, but in reality it's not. You'll have to add one single function to the engine, then you're good to go and can work with scripts from there. It's a matter of grabbing the lightmap under the player, and applying behaviour to the AI based on the color of the lightmap.

Edit: $p11ing. :p
#4
06/02/2006 (7:01 am)
To prototype, you could use an old-throw-back for stealthgames: triggers. If you do not have dynamic lights (say, a cop with a flashlight), then this system can work very well and be done completely in script. It's not as accurate as the sytem that Stefan describes, but if all of the shadows are static, you can visually set up your triggers if your character's feet are in shadow but her upper torso is not. It's a quick prototyping method that would be easy to set up.

But a stealth-based game is quite difficult in terms of AI tuning since you want to make sure that the players don't feel cheated because they are much more aware of enemy behaviors than in a fast-action firefight. They have time to watch and note what enemies are doing, the paths they take, how they determine whether you are there or not.
#5
06/02/2006 (4:21 pm)
Ahh I see. I was thinking of going with dynamic lights :) Laterns, torches etc. I know virtually nothing about C+++ though, it looks so cryptic. I wish all programming languages looked like Basic lol. :( Anyone willing to write a step by step tutorial on how to do this though? I think it would benefit alot of people, not just me.
#6
06/02/2006 (5:28 pm)
While the basic prinicple is very easy(heck, the christmas update of fxFoliage even has the grabbing the lightmap function in it)so getting a very primitive setup wouldnt be hard
To get a more complexe deal, you could do stuff like grabbing the distance from a light, and adding it into a 'visibility' variable for the player, the higher the value, the more likely they are to be seen. So you could say, grab the lightmap to get the ambient lighting, and then once you do that, check the nearby relevant lights, and adjust your visibilty variable accordingly, then just have the AI check against that when looking in your direction.
Other things you could add to make it more complexe and detailed are stances(so the lower to the ground you are, the harder to see), movement speed(running will be like waving a glowing sign saying "i'm right here") and distance to the AI.

As it was said, the only major change you'd need to make to get hte core idea going is to add that lightmap grabbing function.
Once that's added, you could have script tie-ins, and do most of the rest through script.

As for writing a step by step, i doubt someone would be willing to just shoot out on a limb and do it, but the idea isnt too hard, and if you're dedicated to the idea, it wouldnt be too hard to get it working, at least on a basic level.
#7
06/02/2006 (7:10 pm)
A sneak game needs realtime lighting and shadows.. i mean.. c'mon.. you're supposed to be sneaking around unseen.


There's a stensil buffer shadow resource out there that's pretty difficult to implement if you're unfamiliar with C++. it took me a few tries to get it in. but it's a pretty good performance hit.
#8
06/05/2006 (7:57 am)
If I were to attempt this, I would use a dual - trigger system and simply move the trigger with each light that was moving.

The dual trigger would be a box within a box... When you enter the outer box, you have a certain amount of time to retreat before the alarm.

If you ever hit the inner box, the alarm goes off.

Some simple code to move the triggers bounding box during animation should do the trick.

:)
Sumner
#9
06/05/2006 (11:46 am)
Sumner Mccarty:
That's a really good idea! One improvement I might suggest is on collisions, casting a ray to see if there is anything in the way between the player and the light source (such as terrain, or a wall, a vehicle, or a barrel or something), and if there is a collision of one of those kinds of objects in between the player and the light, then it doesn't set it off (because the player is hidden from it).

Great idea!

--clint
#10
06/05/2006 (12:44 pm)
If you want a proper stealth game, faking it is just going to be more trouble than it's worth. Box shapped triggers aren't near detailed enough to make it work right. They weren't even asking about with TGE, just in general how to do this. TGE's stock lighting isn't good enough to make it plausible from an art standpoint anyways. Splinter Cell is the best implementation out there, it's so good, it works both on a code level for AI, and with actual physical visibility in multiplayer. But overall... making a game based around stealth is a pretty heady task, it'll require a lighting focused renderer and very good art design.