AI Variables

From The DarkMod Wiki
Jump to: navigation, search

The AI header is full of variables and it's hard to keep track of what variable is serving which purpose and how often they are updated (and by whom). This list an attempt of listing the most important ones.

AI_AlertNum (scriptFloat)

This is central variable controlling the AI behaviour. AI_AlertNum can be read directly, but write access must be routed through the idAI::SetAlertLevel accessor.

The AI_AlertNum is a floating number representing the current alertness of the AI. Incoming alerts cause the value to increase, long timespans without new alerts let the alertnum decrease. Upon exceeding or falling below certain thresholds, the AI is switching its AI_AlertIndex.

Setting the AI_AlertNum via SetAlertLevel also updates the AI_AlertIndex scriptFloat (see below).

AI_AlertIndex (scriptFloat)

The AI_AlertIndex is always in sync with the AI_AlertNum. Can be queried directly, but write access is not allowed, this must happen through idAI::SetAlertLevel, by whom it is kept up to date.

An AlertIndex of 0 represents the IdleState, the highest AlertIndex is 5 (CombatState). This variable is monitored by the Backbone States, which trigger a State Switch as soon as the AI_AlertIndex is changing (e.g. from IdleState to ObservantState).