So basically, you are trying to create a pawn that switches to attacking different pawns and the player. I have a similar system in my game which I used for my scripted player as an auto targeting function. The way I did it however is a very long and sloppy, and I'm sure there is an easier way, but here it is anyways:
Firstly, you need to set your pawns field of view. Do this in your setup or spawn order by adding this command SetFOV(90); the brackets must contain the ammount in degrees that you want your pawn's visible to be.
Add this command to the pawn most frequently executed order eg. the run or idle orders:
Code: Select all
if(self.enemy_vis=false)
{
newtarget();
}
Then add this order to your script:
Code: Select all
newtarget[ ()
{
if(IsEntityVsible("enemy1"))
{
SetTarget("enemy1");
}
if(IsEntityVsible("enemy2"))
{
SetTarget("enemy2");
}
if(self.enemy_vis = false)
{
SetTarget("");
}
}]
You will need to give the pawns you want to be attacked the entitynames: enemy1, enemy2, enemy3 (however many you want), just make sure that none of the pawns share the same entityname. Once you've done that, then you just add the IsEntityVsible command along with the SetTarget command to the newtarget order (as above) and bobs your uncle. Basically what the newtarget order does is check to see if your pawn can see the the entity with the specified entityname and if it returns true, set that entity to be the current target. What makes this process long is the fact that you have to define every single entity that you want to be a possible target into the newtarget order.
I don't know what your script looks like, but bear in mind that this was run from low level orders in my script. Hope this helps...
A good warrior knows his limits, but a great warrior finds his way around them.