Friday, August 7, 2009

Of stealth and noise.

Last night I added stealth to F.o.t.E. It will require testing to achieve proper scaling, but it currently works well testing at max level. I was also able to handle stealth simultaneously for friendly AI, hostile AI, and the player.

I achieved stealth with the following elements

1) A method make noise.

2) Adding states to the AI: aggressive, passive, and sleep.

3) A method search.

4) Boolean discovered for each mob.

Mobs are now created undiscovered. At the end of each turn, the actor will search in his line of sight for any hostile actors. If the player spots one, the mob becomes discovered and is viewable. If the AI spots a hostile, the AI becomes aggressive and his aggressive counter is set to 10.

The AI will not seek out enemies or attack unless they are aggressive. Once they become aggressive or receive aggressive stimulus, their aggressive counter will be set at 10. The counter will count down each turn and they will return to passive when it reaches 0.

Additionally, aggressive action will result in noise. The make noise method will wake all AI, both friendly and hostile, within a radius of the actor. Noise will make sleeping and passive AI aggressive. The radius of the sound can be reduced by the stealth skill.

The AI will wander around unaware of a player with high stealth, however combat will quickly wake all nearby enemies.

Given that search is based on line of sight, it's important that line of sight is symmetric. However in F.o.t.E it is not, though the advantage is always given to the player unless he is retreating. A quick fix is implemented such that the AI cannot see the player if the player cannot see the AI.

Given that LoS is not symmetric, this will present opportunities for players to sneak up on enemies avoiding LoS if given favorable terrain.

Enemies with high stealth can and will sneak up on unsuspecting players. You will always have to keep in mind that there just might be a stealthy mob following you into combat.

Please note, see invisible will increase perception and invisibility will just offer a bonus to stealth.

There may be additional ways to go unnoticed and perhaps even ways to alter an enemy's state...

No comments:

Post a Comment