Currently I’m developing a few SNPCS, but a problem I’ve run into is that when given a hate relationship they refuse to attack each other within the specified melee range. They will run toward each other as if they were going to attack any other npc, but no actual attacking goes on.
self:SetEnemy() has proved futile, as well as self:AddEntityRelationship() and self:SetTarget().
This is the code I have so far for targetting:
local schdAtk = ai_schedule.New( “AIFighter Chase” )
schdAtk:EngTask( “TASK_GET_PATH_TO_RANGE_ENEMY_LKP_LOS”, 0 )
schdAtk:EngTask( “TASK_RUN_PATH”, 0 )
schdAtk:EngTask( “TASK_WAIT_FOR_MOVEMENT”, 0 )
schdAtk:EngTask( “TASK_FACE_ENEMY”, 0 )
schdAtk:EngTask( “TASK_MELEE_ATTACK1”, 0 )
local targets = ents.FindInSphere(self.Entity:GetPos(),5000)
for _,v in pairs(targets) do
if v:GetClass() == “npc_militia” then
self:AddEntityRelationship(v, 1, 10 )
self:SetTarget( v )
Could someone explain to me what I’m doing incorrectly?