Last post I described how bots become aware of different enemy targets and select one as the target to aim at. But just because the bot has an enemy to aim at doesn't mean there isn't something even more demanding of the bot's attention. And what happens when the bot can't find an enemy to look at? They have to look at something, presumably in the direction an enemy is most likely to appear.
The selection of where to look is handled by the aim engine (ai_aim.c). The selection algorithm uses a simple priority structure to arbitrate between conflicting things. For example, if the bot needs to jump over a pit while there is an enemy nearby, the bot will always look in the direction of the jump so it doesn't mess it up. While aiming at the enemy it might score the bot a kill, doing so makes the bot extremely likely to fall down the pit to its death. The bot can always aim at the enemy after landing the jump. Similarly if the bot hears a noise that might have been made by a player, the bot will only turn to inspect that area if the bot doesn't already have a known target. Aiming at enemies has a lower priority than getting air but a higher priority than finding additional targets.
Here is the list of typical aiming reasons, from most to least important, as taken from BotAimSelect():
- Jumping over pits
- Aiming at enemies
- Shooting destructible objects like mines
- Looking forward when swimming
- Face a non-hostile target that has the bot's attention
- Look at the item the bot is going to pick up
- Look in an area enemies are likely to be
- Look at the same thing as last time
- Physiological Needs (being free from short term danger)
- Safety (being free from long term danger)
- Love (being accepted)
- Esteem (being appreciated)
- Self Actualization (just being who you are)
The base of Maslow's pyramid is comprised of immediate pressing needs, just like the top of the aiming priorities. Bots look forward when jumping because they will die if they don't. Bots don't look at items when there's an enemy nearby who wants to kill them. In this regard, bots are like humans. We are all programmed for survival as the greatest need.