Home   Help Search Login Register  

Author Topic: Make A Non Group Member Follow The Player  (Read 616 times)

0 Members and 1 Guest are viewing this topic.

Vindamiatrix

  • Guest
Make A Non Group Member Follow The Player
« on: 07 Dec 2004, 13:21:39 »
Hiya.. I'm new to this scripting so I was hoping you guys could help me out...

I'm trying to make a Civilian follow the player without being in the players group....  let's call the civilian "MAN1".. and the player "PLAYER".. just to make it easy :)

I wrote a little sqs file:

#follow
MAN1 domove (getpos PLAYER);
~1
goto "follow"

this works.. but MAN1 will only follow PLAYERS position at a certain time and not really the player....

Is there something like a FOLLOW command? and how does this work if it exists? It would make it a lot easier for me :) and for MAN1  ;D

Offline ACF

  • Members
  • *
  • Llama?? Ain't that French for tanks?
Re:Make A Non Group Member Follow The Player
« Reply #1 on: 07 Dec 2004, 14:08:28 »
In principle, what you've done is all you can really do short of [MAN1] Join Group PLAYER.

You could probably afford to increase the loop delay as the unit will take a couple of seconds to react to the command - that might smoothe things out a little.  Secondly, you could check the distance between the two to stop MAN1 moving when he's already close enough to the player:

#follow
?(MAN1 Distance PLAYER > 10): MAN1 domove (getpos PLAYER)
~5
goto "follow"

You could also offset the position so MAN1 doesn't try to mount the player if he stops, say:

#follow
?(MAN1 Distance PLAYER > 6): MAN1 domove [2 + getpos PLAYER Select 0, 2 + getpos PLAYER Select 1, 0]
~5
goto "follow"

He'll aim for a point nearly 3m NE of the player.  You can get him to move behind the player, but you need trig for that!

Welcome to the wonderful world of OFP scripting.

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Make A Non Group Member Follow The Player
« Reply #2 on: 08 Dec 2004, 16:19:20 »
A 5s loop will work better than a 1s loop.   Otherwise he gets too many commands that he can't complete (because he has been given a new command) and starts to give up a bit, as you have discovered.

Experiment with ACF's excellent suggestions till you get what you want.   Or as close to it as is worth the effort.   There are trigonometry guides in the Ed Depot if you want help going down that route.
Plenty of reviewed ArmA missions for you to play