Giving an NPC Memory

From Valve Developer Community
Revision as of 12:52, 9 September 2011 by Artfunkel (talk | contribs)
Jump to: navigation, search

Entity memory

NPCs can remember other entities in two ways:


An NPC's combat memory is managed by the CAI_Enemies class. To do: Document it.

UpdateEnemyMemory( CBaseEntity *pEnemy, const Vector &position, CBaseEntity *pInformer )
SetEnemyOccluder(CBaseEntity *pBlocker)


RememberUnreachable( CBaseEntity *pEntity, float duration = -1 )
Causes the NPC to ignore the entity for the specified number of seconds. -1 means the AI's default, which is usually 3 seconds.
IsUnreachable(CBaseEntity *pEntity)
Test reachability.

Memory Bits

Memory bits are flags which relate to the NPC's current state (for example, bits_MEMORY_SUSPICIOUS and bits_MEMORY_FLINCHED). See game/server/ai_basenpc.h for a full list.

Remember(int iMemory)
Forget(int iMemory)
Set/remove a particular bit.
HasMemory(int iMemory)
HasAllMemories(int iMemory)
Check whether one or more memory bits are set.
CAI_SchedulesManager::GetMemoryID(const char *state_name)
Modify this function to add support for extra memory bits in schedule definitions. You shouldn't need to call it yourself.