Garry's Mod Wiki

NPC:Disposition

  number, number NPC:Disposition( Entity ent )

Description

Returns the way the NPC "feels" about a given entity. See NPC:AddEntityRelationship.

For ai type entities, this will return ENTITY:GetRelationship. If it returns nil or for engine NPCs, this will return whatever was last set by NPC:AddEntityRelationship. As a last resort, engine will decide on the disposition based on this NPC's NPC:Classify.

Arguments

1 Entity ent
The entity to test our disposition towards.

Returns

1 number
The NPCs disposition, see D enum.
2 number
The NPCs disposition priority.

Example

If a player is hurt by a friendly NPC, announce it.

function FriendlyFireAnnouncement( ply, atk ) if atk:IsNPC() and atk:Disposition(ply) == D_LI then --like PrintMessage("A "..atk:GetClass().." attacked "..ply:Nick().."!", HUD_PRINTTALK) end end hook.Add( "PlayerHurt", "FriendlyFire", FriendlyFireAnnouncement )
Output: Prints "A ____ attacked ____!" to everyones chat.