Demox AI #2 – Sensors

I’ve made some relatively large updates to AI behaviours and sensors before the summer arrived- something that might sound familiar to you who follow me on Twitter, since I’ve shown some of these things there already. Haven’t posted any development logs touching the subject though, primarily since I tend to do other things than sitting in front of the nerd-station when the snow finally melt… anyways, let’s get on with it!

Dynamic Point System Behaviour

I’ve talked about the DPBS earlier already, if not you can find the post HERE, the AI in Demox will continuously evaluate their current situation and perform actions relevant to the conditions of said situation.
A new behaviour has been added to this system, to equip items found near the AI agent and to throw the equipment if it’s beneficial for the AI agent.

Clip showcasing both new AI hearing sensor, aswell as AI item useage behaviour

A quite simple behaviour but it opens up for more combat challenges, since AI who can collect weapons will increase their damage output. Also, if the AI can throw the weapon they can do so if the player tries to run away from them- giving them a ranged attack opportunity.

Situational Awareness

Furthermore, I wanted my AI to be a bit more aware of their surroundings, earlier the player could run and jump around right behind the AI and they wouldn’t notice a thing- two new sensors have been implemented, namely, “Smell Sensor” and “Sound Sensor”. Two components that simulate exactly what they sound like.

Smell Sensor

The Smell sensor is not used by all AI, at first I implemented it only for the Maradeur monster since it has no eyes. Another primary way of detecting hostiles was required so the smell sensor felt appropriate. Recently I’ve also used it for other creatures to some extent.

The way it works is that characters in the game feed the game master logic with some information at regular intervals. First, their own smell– some AI can determine what creature they’re facing by their smell. Second, a value to determine how far the character’s smell can be detected is sent. Information about the current area the character is in is sent aswell and the world position of the character when the smell data was registered.

Area and Character smell volumes
The Maradeur

The idea is that some areas with strong smells should cloak a character’s smell- not completely but for a pre-defined percent of the character’s scent range.

An example is in an area with very strong smells, a character who has a scent range of 8 meters would receive a 75% smell-cloak benefit, resulting in a reduced scent range of 2 meters, therefore making it alot harder for other AI to detect by smell. This can be seen in action in the attached Twitter-post to the left, the red circles represent the player character’s scent range. When entering different area volumes ( colored boxes ) the size of those red circles are reduced.

As can be seen in the video the trail of smell information left behind the player shrink over time.

So in order for the AI smell sensor to make use of this information it must first be collected from the Game Master, all registered smell information is filtered to find only information relevant to the AI, ie. smell data with a location reference within x meters of the AI’s world position.

The “x meters” is the smell sensors detection range, while the detection range is not printed in the video shown here it can still be noticed since the AI does not have to be inside the red circles to start investigating a smell. This is because only the sensors detection range volume have to intersect with the smell information’s volume, not the character itself.

Sound Sensor

The sound sensor was implemented since I found it weird that as the player you could jump and run around right behind an enemy and they’ld be completely clueless about what was going on behind their back. All AI characters in the game now use sound sensors, essentially it work the same way as my smell sensor– characters and actions happening in the game feed the game master with data containers holding information about the sound: noise radius (volume), origin (friendly, wildlife, hostile, combat, environment, unknown) and world position.

The AI regularly check the noises registered within the range that they can hear and depending on how the AI character is set up it will interact with the noise.

Combat sounds will make all combatant characters investigate, while non-combatants will get scared, try to hide, or run away from the sound. Hostile sounds ( primarily monster voices & footsteps ) will agitate friendly AI, and scare most wildlife AI, vice verca for friendly sounds, wildlife sounds ( animal voices & footsteps ) is ignored by friendly AI and agitates some of the hostile AI characters. Environment and unknown-flagged sounds depend alot on what type of sound is registered, but these two sound types are either ignored or investigated.