# brainAI DOCUMENTATION

Version 5, codename "Krang", by Austin Heilman.

## Config Settings

Brain NPCDesc.cfg Settings
'AISetting' Entries
Settings used by the brain core nerves. Format for them is: AISetting <SettingName> <Packed Value> Example: AISetting CycleWait i10 AISetting SomeString s4Beer
CycleWait | Amount of time the brain will wait for an event before moving on.
SleepWait | Amount of time the brain will wait for an event while in sleep mode before moving on.
IdleTicks | Number of idle ticks (loops) that must pass before entering sleep mode.
NoSleep | If enabled, the NPC will not be allowed to enter sleep mode or run its sleep script.
AreaSize | Sets the distance for triggering SYSEVENT_ENTEREDAREA and SYSEVENT_LEFTAREA. Will also receive SYSEVENT_GONE_CRIMINAL inside of the area range.
DblClickRange | Maximum distance the NPC will accept double click events from.
ListenRange | Distance NPC will listen for SYSEVENT_SPEECH and SYSEVENT_GHOST_SPEECH
HearSpeech | If set to "i1", the NPC will listen to speech events (If it has a 'Listen' nerve).
HearGhosts | If set to "i1", the NPC will listen to ghost speech events (If it has a 'Listen' nerve).
'AIScript' Entries
Script entries inform the brain which paths / scripts to use to handle events as they come in. SYSEVENT_* events will only be received if the appropriate nerve script is setup. Format for them is: AIScript <Script ID> <Path> Example: AIScript Sleep :pkg:nerves/sleep/goSleep AIScript WonFight :brainAI:nerves/wonFight/victoryDance
Combat | Handles SYSEVENT_ENGAGED and SYSEVENT_DAMAGED Responsible for handling NPC movement and other combat related stuff.
Cycle | Runs every time the brain ticks (loops) and is not in sleep mode.
DblClick | Handles SYSEVENT_DOUBLECLICKED
Disengaged | Handles SYSEVENT_DISENGAGED
EnterArea | Handles SYSEVENT_ENTEREDAREA
GoneCriminal | Handles SYSEVENT_GONECRIMINAL
Init | Runs when the NPC is created. Used to setup the NPC's name, equipment, etc.
ItemGiven | Handles SYSEVENT_ITEM_GIVEN
LeftArea | Handles SYSEVENT_LEFTAREA
LookAround | Runs when the NPC is not in sleep mode. Used to track mobiles nearby so it will not go into sleep mod with potential targets around.
Listen | Handles SYSEVENT_SPEECH and SYSEVENT_GHOST_SPEECH
Merchant | Handles SYSEVENT_MERCHANT_BOUGHT and SYSEVENT_MERCHANT_SOLD
Restart | Runs when POL starts up or Restart() has been used on the NPC.
Sleep | Runs when the NPC is in sleep mode.
ShouldWatch | Runs to determine if the NPC should watch something or not.
Virtual | Handles unknown event types.