Found something useful on KatsBits? Support the site and help keep content free
Or click here to learn more about this important message »

RtCW NPC basics - why are AI stupid?

Why are Bots & AI so stupid?

Making single player levels for Return to Castle Wolfenstein, or indeed any game that makes use of Non-player Characters (NPC's), can be frustrating and difficult at the best of times. However, depending on the options available to the level or scripting designer there are ways to mitigate some of the problems that arise as a result of using NPC's.

The following explains how understanding two core mechanics of most AI, that is their 'distance awareness' and 'all-round vision' can be used to control their behaviour, making NPC's and the situations within which they can be used, more controllable.

Design note: that although the following concerns editing Return to Castle Wolfenstein by way of explanation, the general principles should be applicable to any game where NPC's can be controlled to finer degrees by altering settings that expose their respective 'personalities' (the properties and parameters controlling their reactions and responses to in-game and/or triggered events

NPC's are not stupid ^

To answer the question posed in the heading; NPC's are not really "stupid" but they can certainly be a real nuisance to work with at times. Having them react to the player, but not so aggressively they appear to be psychic or apparently pre-emptive, can take some cajoling, especially when they should be performing various actions whilst 'waiting' for the player - a patrol, butt scratch or some other ambient action that provides context and an reason for the NPC to be where it is in the first place. It's this latter aspect of working with NPC's that can take a long time to work out, tweaking and adjusting different settings to mitigate issues whilst trying to avoid making them 'stupid'.

As an example of this the default 'sensitivity' (how reactive the character is to its environment) for an NPC in Return to Castle Wolfenstein is 16,000 game units - as measured using Radiant level editor. A typical room might be 256 units high by 512 units wide/deep, so the NPC's default alertness value represents an extremely large active area of engagement in comparison (shown below). This disparity, between room/level size and alertness distance, typically equates to NPC's inadvertently triggering events prematurely, if those are ambient NPC actions (patrol, butt scratch etc.), the player will rarely see them because they (the player) is spotted long beforehand and the function cancelled or over-ridden by a reactive property ("attack" for example). The upshot of this is a wasted event script.

Comparative size versus distance of NPC to its "alertness" attribute

Default 'alertness' distance of a typical NPC in RtCW set at 16,000 game units - NPC editing entity and some basic brush volumes show comparative size versus distance - the teeny-tiny red spot on the left stands next to a 128, 256 and 512 unit cube on a ground plain stretching out 16,000+ units to the far right

Dumbing down NPC's ^

Where triggered events are needed this overt sensitivity can be fixed by making the NPC 'dumb' or 'blind'. Whilst this is usually a simple matter of changing an "attribute" value, the inherent problem with this often has the player being able to walk right up to the NPC and literally kick them in the butt to no effect or avail!. To avoid this what tends to be necessary is a combination of making the NPC 'blind' and 'deaf' on spawn (non-reactive) so some sort of default action can be triggered, then as part of that sequence, changing the AI's properties to better suit the environment within which it's located.

For example, if an AI is placed into a small 512 x 512 room and never required to leave, its sensitivity can be reduced without necessarily effecting other attributes that might otherwise negatively impact its reactions to the players presence once in the same room. The trick, if it can be called that, is in trying to achieve a balance between the NPC not triggering too early - whilst the player is in another room for example, and/or unless there are compounding events triggering the NPC to changes its status (to become "alert") - and at the same time reacting reasonably to the player during interaction. For Return to Castle Wolfenstein single player editing this is typically done using the "alertness" and "field of view" attributes properties.

NPC in RtCW not reacting to players presence (simulatation using "notarget")

Using the "notarget" developer code in RtCW an Infantry soldier is simulated being blind to the players presence standing behind due to its attributes properties being set to low, or more likely, the result of compounding instructions needed so a particular function can be performed without the AI being triggered to early

NPC 'alertness' and 'field of view' attributes ^

For most NPC's in RtCW the two basic properties, or "attributes" to give them their proper descriptor, that control a characters sensitivity are the aforementioned "alertness", and "field of view" (FOV); the former determines distance (as previously described); the latter an 'arc of attention', i.e. a radius around itself of which its aware. Whilst the default alertness distance is 16,000 editor units, if that were to be directed at a narrower FOV, 60° for example (the default is 240°), it would result in an AI that could see a long way but within a restricted view, a 'sniper' type character. Similarly, a short 'alertness' distance (2048 units) with full fov (360° or close to it) results in a 'watch tower' guard with unrestricted views all around.

An NPC's "alertness" attribute versus its "field of view" (all round vision)

Understanding an NPC's "Field of View" (FOV) can mean reducing how reactive an AI might be to its environment absent problems typically associated with having to keep or use a large area of "alertness"

Understanding this it means that an NPC can be controlled to a certain extent to prevent it from triggering or reacting too early whilst allowing for any actions or events to play out until the NPC is directly confronted by the player. This is not to say it works all the time, it's a compromise that may result in 'deaf/blind AI's in certain circumstances, but this is needed if the player is to be engaged in the game environment. Else one might as well spawn the AI in a duck pond for easy shooting.

How changing an NPC's FOV and "alertness" can be used to achieve workable AI

Changing the "alertness" and "fov" values of NPC's to alter the characteristics and general behaviour of AI and how they react to in-game events - a narrow FOV can mean the AI tends to focus directly on events directly in front like a sentry, or all around like a patrolling guard; different settings being used to create different behavioural characteristics

KatsBits Web
Search KatsBits using StartPage
Hottest item in Store right now!
Hot Product in Store
Visit the Store Now
  • Blender Art Magazine