SNPCS with their model as a combine solder or elite don't move?
6 replies, posted
Using "TASK_RUN_PATH" with the SNPC's model as "models/Humans/Group01/Male_07.mdl" works just fine, but if I set the SNPC's model to a combine solder like "models/combine_super_soldier.mdl" it doesn't run or walk. Does anyone know a way to move it?
Use a schedule instead?
First set the position:
[url]http://wiki.garrysmod.com/?title=NPC.SetLastPosition[/url]
then:
[lua]
npc:SetSchedule( SCHED_FORCED_GO )
[/lua]
I suspect it's part of your schedule is the problem.
Make sure you are facing the target before you try to find the path.
[code]soldier.Task_Move_Forward_Run = START( "Soldier Move Forward Running" )
SENG( "TASK_FACE_TARGET", 0 )
SENG( "TASK_GET_PATH_TO_TARGET", 0 )
SENG( "TASK_RUN_PATH", 0 )
SEND( )[/code]
With
[code]function START( name )
if CLIENT then return nil end
cursched = ai_schedule.New( name )
return cursched
end
function SLUA( name, data )
if CLIENT then return end
assert( cursched, "No schedule!" )
cursched:AddTask( name, data )
end
function SENG( name, data )
if CLIENT then return end
assert( cursched, "No schedule!" )
cursched:EngTask( name, data )
end
function SEND( )
cursched = nil
end[/code]
Since I'm incredibly lazy.
Thanks Kogitsune/Capsup, but general SNPC coding help isn't what I'm asking for. I'm asking if anyone can get an SNPC with its model set as a combine soldier or super soldier to actually move, If it's a metrocop or human citizen models it moves just fine.
Here is some basic sample code, you should see to it that when the model is a super soldier the SNPC won't move.
[code]
local schedfollow = ai_schedule.New("follow")
schedfollow:EngTask("TASK_GET_PATH_TO_TARGET", 0)
schedfollow:EngTask("TASK_RUN_PATH", 0)
function ENT:Initialize()
--self:SetModel("models/combine_super_soldier.mdl")
self:SetModel("models/Humans/Group01/Male_07.mdl")
self:SetHullType( HULL_HUMAN );
self:SetHullSizeNormal();
self:SetSolid( SOLID_BBOX )
self:SetMoveType( MOVETYPE_STEP )
self:CapabilitiesAdd( CAP_MOVE_GROUND|CAP_ANIMATEDFACE|CAP_USE_WEAPONS|CAP_USE_SHOT_REGULATOR|CAP_AIM_GUN)
self:SetHealth(100)
self:DropToFloor()
end
function ENT:SelectSchedule()
end
function ENT:Think()
self:SetTarget(player.GetAll()[1])
self:StartSchedule(schedfollow)
end
[/code]
Have you tried NPC:SetMovementActivity? I've never used it but I assume you can pass it an activity for the NPC to use while moving. You should check the Combine soldier model with HLMV and get a valid running activity with it. If I remember correctly, Combine soldiers are kind of finicky because their models use different activities than most other NPCs, so you may have to set the run animation to something valid manually.
Yea they do use different animations. That must be the problem.
[QUOTE=Ghor;29133809]Have you tried [b]NPC:SetMovementActivity?[/b][/QUOTE]
Yes I have before, and it didn't work. Until now.
Since you mentioned it, I had another idea of how to use it.
I put this in Think -
[code]
self:SetMovementActivity(ACT_RUN_RIFLE)
[/code]
I noticed how he moved on spawn as part of SCHED_IDLE_WANDER which I have in my code. He still couldn't follow though with TASK_RUN_PATH.
I had to guess what task to use instead, and on my first guess it worked -
[code]
local schedfollow = ai_schedule.New("follow")
schedfollow:EngTask("TASK_GET_PATH_TO_TARGET", 0)
--schedfollow:EngTask("TASK_RUN_PATH", 0)
schedfollow:EngTask("TASK_CUSTOM_MOVE_TO_TARGET", 0)
[/code]
He follows me now! Thank you very much Ghor for getting me on the right track.
[QUOTE=Ultragamer;29133373]I'm asking if anyone can get an SNPC with its model set as a combine soldier or super soldier to actually move, If it's a metrocop or human citizen models it moves just fine.[/QUOTE]
I'm sort of working on snpc soldiers using the combine soldier model and I the same issue:
The schedule apparently must tell them to face a target / enemy before getting the relevant path - without this, they just sat there like lemons ignoring the movement orders.
I know posting the source to my simple wrappers hid what I was saying, though.
Sorry, you need to Log In to post a reply to this thread.