Underhell is a Half Life 2 Modification developed by Mxthe in collaboration with We Create Stuff. Underhell Prologue requires a Source Engine game to run, and Source SDK Base 2006 installed. Underhell Chapter 1 will require a Source Engine game to run, and Source SDK Base 2007 installed.
This is a short explanation of how the "Sneaky Gameplay" works in Underhell, and how the enemy AI was improved and tailored to help it work correctly, followed by a short tutorial on the Level Design.
Posted by Mxthe on Aug 20th, 2012
Say what you want, HL2 has one of the best Artificial Intelligence I have seen in a game.
Soldiers work together, communicate, flank the player, flushes him with grenades, and will patrol around the last area where the player was seen if he disappears.
This is all HL2's Default AI, but a few factors can make it seem less impressive than it actually is.
Very early in the development of Underhell I knew I wanted to have a sneaky/tactical gameplay possibilities, therefore I had made a list of features that I wanted to see in, but at the time I designed these Levels, I did not have the code or those features yet, so I had to keep everything in mind before actually being able to test it.
That said, it worked out pretty well...
(or field of view)
The default field of view of the "npc_combine_s" is based around a real Human's being field of view, which is slightly above 180°. This makes it nearly impossible to sneak around them unless they are turned away.
So our first step was to create a set of keyvalues and input to determine the FOS and the View Distance.
Those 2 keyvalues are added in the NPC's properties in hammer, by turning SmartEdit off, they allow for very precise setting of the field of view and the view distance.
We also implemented a set of inputs allowing us to change these values in real time.
As soon as we had these settings in the game, we realized just how cool it was to be able to sneak around a soldier without being detected.
As for the "realism" in lowering the Field Of View, the levels in which it is reduced are extremely dark, and the soldiers are wearing gas masks.
In Source engine, only NPCs that are in the same "Squad" will work together and communicate.
The trick is, that even if one soldier of the squad is at one side of the map, and another at the other end of the map, they will still "Work Together" and be alerted together when one of them spots the player.
So I knew I would need multiple Squads, but the problem in splitting up the squad is given when, 2 squads actually meet in the map, and do not even communicate or work together to take down their enemies.
So we came up with a Temp Squad system, when 2 NPCs that are allied to each other, are within each other's line of sight, they are placed in a "Temporary Squad" and begin sharing target information, independently of their squadname.
Whenever the line of sight is lost, the "Temp Squad" is broken, and they cease to communicate, UNLESS they are within the same Squadname.
This makes it so that every soldier in the game work together when they are close to each other, independent of which squads they are in.
But this system does is not specific to soldiers, but to every NPC type in the game, as long as they are allies, they will now work together.
The following keyvalue must be set to the NPC's properties by turning SmartEdit off :
You can also dynamically turn the SquadTemp on and off with the following inputs
Another major detail in a believable behavior, is the Voices of the soldiers, and how they communicate.
Half Life 2 has 27 "SENTENCES" categories for Soldier Communications.
These can be found in "Scripts/sentences.txt"
So I was looking for a voice actor with a very good "Military" voice and way of speaking, and I stumbled across Michael Tsarouhas.
In a few days he has sent me over 400 lines for the first 7 categories, which are the most commonly spoken, and I have to say I was sold.
We have over 32 lines per category, said in many different ways, and honestly this simple addition provides an incredible amount of "immersion" to the game.
I have spent countless hours just observing Soldiers behave in squad while fighting other enemies, and I have to say I am impressed by the depth of the HL2's default AI, in ways I wasn't before, simply because I couldn't understand a damn thing the "Combine Soldiers" say in HL2.
Soldiers in HL2 have no "default patrolling" system, they have a simple input called "StartPatrolling", which makes them walk around in circles, but they do not navigate a level by themselves unless told to.
I knew that I wanted dynamic and randomized patrols in the Sneaky Levels, because I wanted people to be able to play them over and over again without it being exactly the same twice.
So I came up with a system that randomly teleports a "target" at predefined locations around the level, and the soldier will dynamically create his path to the target, depending on his current position.
Based on a randomized timer, the soldier's target will teleport somewhere else, and the soldier will therefore update his navigation path to get to the target's new position.
This makes extremely dynamic and realistic patrolling system, that is rather hard to predict, but since the locations at which the target teleports are preset, it is not impossible to understand the "patrol area" of a specific soldier.
In addition to this system, I have created another dynamic "Conversation" system based on whether 2 soldiers on patrol find themselves in the same location.
In which case they both stop patrolling, have a randomized conversation, and then resume their patrols.
These Conversations can give very important information to the player about what is going on in the location the player is currently in.
As previously mentioned in the "Bodygroups, Gibs, Ragdolls and Decals" tutorial, we have created a system which allows for soldiers to "Detect" dead bodies.The Keyvalue to add to an NPC to make them find bodies is the following:
An input can also be called to toggle this function On and Off
When the SpotBodies is on, the NPC will fire the following outputs when they spot a body:
OnSpotSoldierBody : Fires when a Soldier body was found
OnSpotI******dBody : Fired when a SPOILERS body was found
OnSpotDefaultBody : Fired when any other type of npc ragdoll was found
In this output link "!caller" is the body itself, and "!activator" is the NPC who spotted the body.
Here's a way it can be used :
This output will make the person who found the body (!activator) Walk to the dead body (!caller)
Depending on how often the player is spotted, and whether or not he opens fire, Soldiers in the map will call for backup, and soon after the nearest Core Access will open, letting in the reinforcements.
This can make the gunfights very dynamic, if the player decides to go in Guns Blazing.
I do not recommend one approach or the other, I will simply say that the game has been designed to support as many approaches as possible, while giving possibilities to the player to change tactic at any given time.
That said, unlike some other games, the reinforcements are NEVER unlimited.