[b]1.[/b] How do I get an SNPC to attack a player? I tried using a custom schedule:
[lua]
local AttackPlayers = ai_schedule.New("SCHED_ATTACK_PLAYERS")
AttackPlayers:AddTask("FindEnemy", {Class = "player", Radius = 1024})
AttackPlayers:EngTask("TASK_GET_PATH_TO_RANGE_ENEMY_LKP_LOS")
AttackPlayers:EngTask("TASK_RUN_PATH")
AttackPlayers:EngTask("TASK_WAIT_FOR_MOVEMENT")
AttackPlayers:EngTask("TASK_STOP_MOVING")
AttackPlayers:EngTask("TASK_FACE_ENEMY")
AttackPlayers:EngTask("TASK_MELEE_ATTACK1")
[/lua]
The majority of that is stolen from Garry's example SNPC, and it won't work. FindEnemy is a defined lua task, and the schedule is being called with StartSchedule. It just stands there and attacks.
[b]2.[/b] If there is a ladder in the way of an SNPC, and it has CAP_MOVE_CLIMB, will it climb it? I'm trying to use it for a waist-high obstacle kind of thing.
[b]3.[/b] How can I get an SNPC to go to a specified vector? I tried doing this:
[lua]
local ClimbWindow = ai_schedule.New("SCHED_CLIMB_WINDOW")
ClimbWindow:EngTask("TASK_GET_PATH_TO_LASTPOSITION")
ClimbWindow:EngTask("TASK_WAIT_FOR_MOVEMENT")
function ENT:ClimbWindow()
self:StopMoving()
local Window = ents.FindByDistance("nz_window", self:GetPos())[1]
local GotoLocalPos = Window:WorldToLocal(self:GetPos())
local GotoPos = Window:LocalToWorld(-GotoLocalPos)
GotoPos.z = self:GetPos().z
self:SetLastPosition(GotoPos)
self:StartSchedule(ClimbWindow)
end
[/lua]
The vector is correct, but the SNPC doesn't move.
Bump.
And another.
Best choice for you is to lookup some code from the SNPCs you can find scattered around the internet, very few "official" documentation on them.
Even code I stole from Garry's example SNPC isn't working too well, so it isn't the code.
[editline]5th April 2011[/editline]
It's just these two schedules that are giving me trouble though, the other ones for the SNPC work fine
:sigh:
I hate to keep bumping this, but it's the last major problem with my gamemode :saddowns:
Still hopeful.
I feel so sorry for this guy, so
[b][u]BUMP[/u][/b]
Question 1:
Have you tried setting a hate relationship to the entity you want the npc to attack, and then use [url]http://wiki.garrysmod.com/?title=NPC.SetEnemy[/url]
Question 2:
Not sure.
Question 3:
To make an npc move to a specific position, you would use [url]http://wiki.garrysmod.com/?title=NPC.SetLastPosition[/url] and then either npc:SetSchedule( SCHED_FORCED_GO ) to make the npc walk there, or npc:SetSchedule( SCHED_FORCED_GO_RUN ) to run to the specified position.
Just a note:
Not alot of people know much about snpc's. Silverlan is probably the best guy you could ask about such things, as he's probably the one who has dealt most with them. I've been dealing with them quite alot too, so I could help you aswell if you want to do more with snpc's.
[QUOTE=Capsup;29122657]Question 1:
Have you tried setting a hate relationship to the entity you want the npc to attack, and then use [url]http://wiki.garrysmod.com/?title=NPC.SetEnemy[/url]
Question 2:
Not sure.
Question 3:
To make an npc move to a specific position, you would use [url]http://wiki.garrysmod.com/?title=NPC.SetLastPosition[/url] and then either npc:SetSchedule( SCHED_FORCED_GO ) to make the npc walk there, or npc:SetSchedule( SCHED_FORCED_GO_RUN ) to run to the specified position.
Just a note:
Not alot of people know much about snpc's. Silverlan is probably the best guy you could ask about such things, as he's probably the one who has dealt most with them. I've been dealing with them quite alot too, so I could help you aswell if you want to do more with snpc's.[/QUOTE]
Yes, but it didn't affect the SNPCs idling.
For 3, I prefer to move it with a custom schedule, just to keep it neat. I might have to resort to that, though.
[QUOTE=PortalGod;29124559]Yes, but it didn't affect the SNPCs idling.
For 3, I prefer to move it with a custom schedule, just to keep it neat. I might have to resort to that, though.[/QUOTE]
Why create a custom schedule to move when there is already a default schedule for moving?
You might have tried this already, but put TASK_FACE_ENEMY before you try to get the path. My snpcs have refused to navigate when they aren't facing their enemy / target.
[QUOTE=Capsup;29124764]Why create a custom schedule to move when there is already a default schedule for moving?[/QUOTE]
Interestingly enough, SCHED_FORCED_GO didn't make it move either.
[editline]17th April 2011[/editline]
[QUOTE=Kogitsune;29125476]You might have tried this already, but put TASK_FACE_ENEMY before you try to get the path. My snpcs have refused to navigate when they aren't facing their enemy / target.[/QUOTE]
Didn't work.
Ah i have this same problem, npcs just dont attack, No matter what i do.
[QUOTE=Queer Flawless;29248326]Ah i have this same problem, npcs just dont attack, No matter what i do.[/QUOTE]
Are you even using SNPC
[QUOTE=King Flawless @ Queer Flawless;29248541]Are you even using SNPC[/QUOTE]
Stop acting like you know lua i haven't seen you post any gamemodes or lua stuff in what do you need help with
[QUOTE=IlikTurtles;29250444]Stop acting like you know lua i haven't seen you post any gamemodes or lua stuff in what do you need help with[/QUOTE]
Because I don't need any help?
[QUOTE=IlikTurtles;29250444]Stop acting like you know lua i haven't seen you post any gamemodes or lua stuff in what do you need help with[/QUOTE]
Have you seen me post asking for help either?
When I saw that people replied, I got all happy. Then I read the replies.
:smith:
-snip-
Daily bump.
And another. Still need an answer for these.
Sorry, you need to Log In to post a reply to this thread.