Revision Difference
NPC:AddEntityRelationship#552643
<function name="AddEntityRelationship" parent="NPC" type="classfunc">
<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 <page>NPC:AddRelationship</page>.
<note>NPCs do not see <page>NextBot</page>s by default. This can be fixed by adding the <page text="FL_OBJECT">Enums/FL</page> flag to the NextBot.</note>
</description>
<realm>Server</realm>
<args>
<arg name="target" type="Entity">The entity for the relationship to be applied to.</arg>
<arg name="disposition" type="number">A <page>Enums/D</page> representing the relationship type.</arg>
<arg name="priority" type="number" default="0">How strong the relationship is.</arg>
<arg name="priority" type="number" default="0">How strong the relationship is. Higher values mean higher priority over relationships with lower priority.</arg>
</args>
</function>
<example>
<description>Spawns a manhack and makes it fear player 1.</description>
<code>
local manhack = ents.Create( "npc_manhack" )
manhack:Spawn()
manhack:AddEntityRelationship( Entity(1), D_FR, 99 )
</code>
</example>
<example>
<description>Make every NPC entity that touches our NPC an enemy.</description>
<code>
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
</code>
</example>