• NPC Won't aim where he's going
    6 replies, posted
Basically telling the NPC to go there with [lua] self:SetLastPosition( datpos ) self:SetSchedule( SCHED_FORCED_GO ) [/lua] It works, but the NPC won't look there.. how do I make him look the path? TASK_FACE_PATH won't work, maybe I'm doing it wrong? [lua] local face = ai_schedule.New( "AIPlayerNPCface" ) face:EngTask( "TASK_FACE_PATH", 0 ) [/lua] then called with [lua] self:StartSchedule( face ) [/lua]
I think there are a bunch of tasks that don't work. I'm trying to use [i]TASK_MELEE_ATTACK1[/i] and 2, but they don't do anything. Using the schedule for attacks works, though.
[url]http://forums.artofwarcentral.com/showpost.php?p=5674&postcount=2[/url]
Well, some tasks need objectives, I guess your TAKS_MELEE_ATTACK1/2 isn't working because you haven't specified any enemy/target. I tried specifying target and such or using a schedule to face a target but nothing.. won't work... What can I do? [QUOTE=Drew P. Richard;28512597][url]http://forums.artofwarcentral.com/showpost.php?p=5674&postcount=2[/url][/QUOTE] That's not helping, thanks anyway.
My NPCs had the same problem, when I did that is was fixed. It's worked for a few other people. Can you paste your whole NPC code?
[QUOTE=Wolfo;28523557]Well, some tasks need objectives, I guess your TAKS_MELEE_ATTACK1/2 isn't working because you haven't specified any enemy/target. I tried specifying target and such or using a schedule to face a target but nothing.. won't work... What can I do? That's not helping, thanks anyway.[/QUOTE] [lua] local AttackWindow1 = ai_schedule.New("SCHED_ATTACK_WINDOW1") AttackWindow1:AddTask("SetTarget", "nz_window") AttackWindow1:EngTask("TASK_FACE_TARGET", 0) AttackWindow1:EngTask("TASK_SET_IDEAL_YAW_TO_CURRENT", 0) AttackWindow1:EngTask("TASK_MELEE_ATTACK1", 0) [/lua] SetTarget just uses NPC:SetTarget on the nearest entity with the classname passed to it. It faces the entity, but doesn't attack or stay facing that way. Since you seem to need help setting a target, here's what I used: [lua] function ents.FindByDistance(class, pos) local Ents = ents.FindByClass(class) table.sort(Ents, function(a, b) return pos:Distance(a:GetPos()) < pos:Distance(b:GetPos()) end) return Ents end function ENT:TaskStart_SetTarget(Class) self:SetTarget(ents.FindByDistance(Class, self:GetPos())[1]) end function ENT:Task_SetTarget() self:TaskComplete() end [/lua]
[QUOTE=PortalGod;28530573][lua] local AttackWindow1 = ai_schedule.New("SCHED_ATTACK_WINDOW1") AttackWindow1:AddTask("SetTarget", "nz_window") AttackWindow1:EngTask("TASK_FACE_TARGET", 0) AttackWindow1:EngTask("TASK_SET_IDEAL_YAW_TO_CURRENT", 0) AttackWindow1:EngTask("TASK_MELEE_ATTACK1", 0) [/lua] SetTarget just uses NPC:SetTarget on the nearest entity with the classname passed to it. It faces the entity, but doesn't attack or stay facing that way. Since you seem to need help setting a target, here's what I used: [lua] function ents.FindByDistance(class, pos) local Ents = ents.FindByClass(class) table.sort(Ents, function(a, b) return pos:Distance(a:GetPos()) < pos:Distance(b:GetPos()) end) return Ents end function ENT:TaskStart_SetTarget(Class) self:SetTarget(ents.FindByDistance(Class, self:GetPos())[1]) end function ENT:Task_SetTarget() self:TaskComplete() end [/lua][/QUOTE] Doesn't look like aiming to that entity.. and the problem isn't in the entity trust me. What I'm doing is pasting your code then use the task.
Sorry, you need to Log In to post a reply to this thread.