Garry's Mod Wiki

Garry's Mod Wiki

  NPC:AddEntityRelationship( Entity target, number disposition, number priority = 0 )

Description

Makes the NPC like, hate, feel neutral towards, or fear the entity in question. If you want to setup relationship towards a certain entity class, use NPC:AddRelationship.

NPCs do not see NextBots by default. This can be fixed by adding the FL_OBJECT flag to the NextBot.

Arguments

1 Entity target
The entity for the relationship to be applied to.
2 number disposition
A D enum representing the relationship type.
3 number priority = 0
How strong the relationship is. Higher values mean higher priority over relationships with lower priority.

Example

Spawns a manhack and makes it fear player 1.

local manhack = ents.Create( "npc_manhack" ) manhack:Spawn() manhack:AddEntityRelationship( Entity(1), D_FR, 99 )

Example

Make every NPC entity that touches our NPC an enemy.

function ENT:StartTouch( entity ) if entity:IsNPC() then -- if entity is an NPC then continue entity:AddEntityRelationship( self, D_HT, 99 ) -- entity will hate self entity self:AddEntityRelationship( entity, D_HT, 99 ) -- self entity will hate entity end end

This site is a community mirror of the official Garry's Mod wiki.. This site is not maintained by Facepunch Studios.

Page content is automatically updated four times a day. Edits and history are not available.

Last Parsed: Loading...