Giving an NPC Memory: Difference between revisions
Jump to navigation
Jump to search
m (minoro) |
No edit summary |
||
Line 1: | Line 1: | ||
{{npc tut}} | {{npc tut}} | ||
== Entity memory == | |||
NPCs can remember other entities in two ways: | |||
== | === Enemies === | ||
* [[ | |||
An NPC's combat memory is managed by the <code>CAI_Enemies</code> class. {{todo|Document it.}} | |||
; <code>UpdateEnemyMemory( [[CBaseEntity]] *pEnemy, const [[Vector]] &position, [[CBaseEntity]] *pInformer )</code> | |||
; <code>ClearEnemyMemory()</code> | |||
; <code>SetEnemyOccluder([[CBaseEntity]] *pBlocker)</code> | |||
=== Unreachable === | |||
; <code>RememberUnreachable( [[CBaseEntity]] *pEntity, [[float]] duration = -1 )</code> | |||
: Causes the NPC to ignore the entity for the specified number of seconds. -1 means the AI's default, which is usually 3 seconds. | |||
; <code>IsUnreachable([[CBaseEntity]] *pEntity)</code> | |||
: Test reachability. | |||
== Memory Bits == | |||
'''Memory bits''' are [[flag]]s which relate to the NPC's current state (for example, <code>bits_MEMORY_SUSPICIOUS</code> and <code>bits_MEMORY_FLINCHED</code>). See <code>game/server/ai_basenpc.h</code> for a full list. | |||
;<code>Remember([[int]] iMemory)</code> | |||
;<code>Forget([[int]] iMemory)</code> | |||
: Set/remove a particular bit. | |||
;<code>HasMemory([[int]] iMemory)</code> | |||
;<code>HasAllMemories([[int]] iMemory)</code> | |||
: Check whether one or more memory bits are set. | |||
;<code>CAI_SchedulesManager::GetMemoryID(const [[char]] *state_name)</code> | |||
: Modify this function to add support for extra memory bits in schedule definitions. You shouldn't need to call it yourself. | |||
{{navbar|Defining the NPC|Creating an NPC|Creating a condition}} | {{navbar|Defining the NPC|Creating an NPC|Creating a condition}} | ||
[[Category:AI Programming]] | [[Category:AI Programming]] |
Revision as of 13:52, 9 September 2011
Entity memory
NPCs can remember other entities in two ways:
Enemies
An NPC's combat memory is managed by the CAI_Enemies
class.
Todo: Document it.
UpdateEnemyMemory( CBaseEntity *pEnemy, const Vector &position, CBaseEntity *pInformer )
ClearEnemyMemory()
SetEnemyOccluder(CBaseEntity *pBlocker)
Unreachable
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.