Extensions Npc
scripts/vscripts/alyxlib/extensions/npc.lua
Methods
StartSchedule
Create and start a new schedule for this NPC.
Parameters
state
ScheduleState
The NPC state that should be set.type
ScheduleType
The type of schedule to perform.interruptability
ScheduleInterruptability
What should interrupt the NPC from the schedule.reacquire
boolean
If the NPC should reacquire the schedule after being interrupted.goal
EntityHandle,Vector
Worldspace position or entity goal (entity origin will be used).
Returns
- EntityHandle
The schedule entity.
StopSchedule
Stops the given schedule for this NPC.
Parameters
schedule
EntityHandle
The previously created schedule.dontKill(optional)
boolean
If true the schedule will not be killed at the same time.
SetState
Set state of the NPC.
Parameters
state
ScheduleState
HasEnemyTarget
Get if this NPC has an enemy target.
This function only works with entities that have enemy or distancetoenemy criteria.
Returns
- boolean
True if the NPC has an enemy target.
EstimateEnemyTarget
Estimate the enemy that this NPC is fighting using its criteria values.
This function only works with entities that have enemy criteria; "npc_combine_s", "npc_zombine", "npc_zombie_blind".
Parameters
distanceTolerance(optional)
number
Discrepancy allowed when comparing distance to enemy. Default 1
Returns
- EntityHandle?
Estimated enemy target.
SetRelationship
Set the relationship of this NPC with a targetname or classname.
Parameters
target
string,EntityHandle
Targetname, classname or entity.disposition
RelationshipDisposition
Type of relationship withtarget.priority(optional)
number
How much the Subject(s) should Like/Hate/Fear the Target(s). Higher priority = stronger feeling. Default is 0.
IsCreature
Get if this NPC is a creature, e.g. combine, headcrab, player
Will return false for all other class types, such as npc_turret and npc_manhack.
Returns
- boolean
IsCombine
Get if this NPC is a combine creature.
Returns
- boolean
IsXen
Get if this NPC is a Xen creature.
Returns
- boolean
GetSquadMembers
Get all members of the same squad as this NPC, including this NPC.
Returns
- CAI_BaseNPC[]
Aliases
RelationshipDisposition
| Value | Description |
|---|---|
"D_HT" |
Hate |
"D_FR" |
Fear |
"D_LI" |
Like |
"D_NU" |
Neutral |