Make ped go to a location, guard the location, and stay there...
I have a bodyguard ped (ped that is a member to the player's group). I want him to stay in a certain area and guard there. Here's my code:
allbodyguards[i].Task.ClearAllImmediately(); TaskSequence sequence = new TaskSequence(); sequence.AddTask.RunTo(theray.HitCoords); sequence.AddTask.GuardCurrentPosition(); sequence.Close(); allbodyguards[i].Task.PerformSequence(sequence); allbodyguards[i].AlwaysKeepTask = true; sequence.Dispose();
This will make the bodyguard run to the given location and stand there for a bit, and then he'll move back close to the player. I want him to stay there and stand. If there's an enemy, I want him to start shooting the enemy too.
I tried doing the
sequence.Close(true)to set the sequence on repeat. It kinda works, he stays there - but he won't shoot the enemies even if the enemies are shooting. If I clear his task, he'll start following me again but won't shoot the enemy anymore. Weird.
@nightmareexe You forgot to task combat hated, and/or supplied invalid (no) params to guard current position, so there is nothing for the ped to do besides the 1 valid thing that it's told/scripted to, which is to go/run to a specific set of coordinates