Home   Help Search Login Register  

Author Topic: Script (sqf) - DoFollowUnit (ACCEPTED)  (Read 9250 times)

0 Members and 1 Guest are viewing this topic.

Offline hoz

  • OFPEC Site
  • Administrator
  • *****
Script (sqf) - DoFollowUnit (ACCEPTED)
« on: 10 Feb 2007, 18:14:58 »
This is a simple sqf script to have one unit follow another unit.
This script is useful if you want 1 unit to follow another without having them in the same group.

Run the radio alpha trigger  to have the follower run behind the leader.
Run backwards turning left or right to watch for the unit track the leader.
Run the Juliette trigger to stop the unit from following.


Edit small update to this script, its nothing major but it occurred to me that someone might want to break out of the scripted based on some variable being true.

Edit: v3 updated. The follower now enters vehicles if the leader has.

Edit: v4 updated. The follower can now 'get lost' after the leader gets ahead of the leader (150m)

Edit: v5 updated. removed the small delay for the group of units.


Hopefully the final version.   :cool2:

doFollowUnit
« Last Edit: 27 Apr 2008, 18:08:25 by Mandoble »
Xbox Rocks

Offline sharkattack

  • Former Staff
  • ****
Re: Script (sqf) - DoFollowUnit
« Reply #1 on: 10 Mar 2007, 12:11:55 »
a great script ..
but is it possible to edit so the followers are closer to the followed (ie  bodyguards )

many thanx
"HOLY SARDINE" - see Shark-Attack meet his match

Offline hoz

  • OFPEC Site
  • Administrator
  • *****
Re: Script (sqf) - DoFollowUnit
« Reply #2 on: 11 Mar 2007, 00:14:28 »

Change the  5 to the desired distance in meters. If he gets to close he will be crowding the unit and may not look that great.

Code: [Select]
if ((_Follower distance _Leader) < 5) then
Xbox Rocks

Offline sharkattack

  • Former Staff
  • ****
Re: Script (sqf) - DoFollowUnit
« Reply #3 on: 11 Mar 2007, 12:11:47 »
thanx mate ... looks good ... changed 5 to 2  works great .. thanx     :good:

wonderfull  can be used to have civilian enemys move to youre position
« Last Edit: 16 Mar 2007, 15:33:15 by shark attack »
"HOLY SARDINE" - see Shark-Attack meet his match

Offline SaBrE

  • Members
  • *
  • I was once a Llama
    • www.Armed-Assault-Zone.com
Re: Script (sqf) - DoFollowUnit
« Reply #4 on: 18 Mar 2007, 20:14:07 »
Excellent script.  :clap:
Can you HELP?

Offline hoz

  • OFPEC Site
  • Administrator
  • *****
Re: Script (sqf) - DoFollowUnit
« Reply #5 on: 24 Aug 2007, 18:16:17 »
Updated the top post with a new download there for I'm pimping my topic.   :good:
Xbox Rocks

Offline MattiusRochelle

  • Members
  • *
Re: Script (sqf) - DoFollowUnit
« Reply #6 on: 25 Aug 2007, 10:25:43 »
This is great exactly what i needed for my big SP mission and especially since u can stop the script now woot thankyou!

Offline hoz

  • OFPEC Site
  • Administrator
  • *****
Re: Script (sqf) - DoFollowUnit
« Reply #7 on: 27 Aug 2007, 21:43:17 »
I added the the ability for the unit to follow the leader into vehicles.

first post updated to v3.
Xbox Rocks

Offline johnnyboy

  • OFPEC Patron
  • ****
  • Matan los Pantalones!!!
Re: Script (sqf) - DoFollowUnit
« Reply #8 on: 28 Aug 2007, 06:21:34 »
Hey Hoz, this is very cool!

I played around with a few variations.  Here's what I discovered.

1. I added a third unit and ran the same script on him.  It worked well, they both followed me.  But if you stay stationary for too long, they calculate the exact same spot to move to.  If you add a random element to the position calculation, it could reduce chances of multiple followers hitting the same spot.  Providing you would like to provide for the case of one unit following another unit...

2. Also, in your script, I changed...

Code: [Select]
[_Hoz_Follower] join grpNull;
...to...

if !(leader _Hoz_Follower == _Hoz_Follower) then
{
  [_Hoz_Follower] join grpNull;
};

So the follower only joins grpNull if he is not a groupLeader.  This allowed the leader of a group to follow me, and the members of the group to still follow their leader.  It worked well, except the group members would only follow their leader after he came to a stop behind me.  If I was constantly moving, the group members could get pretty far behind.

Anyway, great script.  You might consider the change above to allow an entire group to follow a unit also.
El Cojon: "Do you like to Tango?"
You: "Only in Bagango."
Download Last Tango in Bagango and discover how El Cojon earned his name...

Offline hoz

  • OFPEC Site
  • Administrator
  • *****
Re: Script (sqf) - DoFollowUnit
« Reply #9 on: 29 Aug 2007, 05:26:54 »
Your right about running it on multiple units. I will add some randomness to that.

Mandoble suggested that I add some clause for if the unit gets to far behind he just stays there and then when the follower knowsabout the unit he continue on his following adventure. I tried to implement this but it needs a bit more work, everytime I got into vehicle the unit automatically followed me into the vehicle even if he was quite a ways away

Xbox Rocks

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Script (sqf) - DoFollowUnit
« Reply #10 on: 29 Aug 2007, 17:55:50 »
Quote
Mandoble suggested that I add some clause for if the unit gets to far behind he just stays there and then when the follower knowsabout the unit he continue on his following adventure.

One problem with knowsAbout is that it takes awhile for it to reset back to 0. Don't know if this is the issue...
Why use knowsAbout at all instead of the distance?

edit: hoz get rid of the action ["getin"... and just use assignAs... type commands coupled with [_Hoz_follower] orderGetIn TRUE. Using action is what causes the problem.
i.e. replace:
Code: [Select]
_Hoz_Follower action ["GETINGUNNER", _Hoz_VehicleTmp];with
Code: [Select]
_Hoz_Follower assignAsGunner  _Hoz_VehicleTmp;
_Hoz_Follower orderGetIn TRUE;
« Last Edit: 29 Aug 2007, 18:07:45 by Mr.Peanut »
urp!

Offline hoz

  • OFPEC Site
  • Administrator
  • *****
Re: Script (sqf) - DoFollowUnit
« Reply #11 on: 04 Sep 2007, 16:27:53 »
Updated first post with new and hopefully final version.
Xbox Rocks

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Script (sqf) - DoFollowUnit
« Reply #12 on: 16 Sep 2007, 11:23:16 »
hopefully final version.

Dont think so  :P

Current issues:
- All the following group units should not delay when following their leader.
- The following units should board vehicles depending on free positions, the units that cannot board the vehicle should keep following it.
- The following group units should copy the behaviour and combat mode of the unit being followed.
- You might add some action menus to the unit being followed to have some control of the following groups.
- Hoz_ReleaseUnit has the opposite effect that its "release" meaning.
- More than one group might follow a single unit, but you dont need one script per group, else boarding vehicles would be a total mess.
- More than one group might follow a single unit and you might need to release only one of them.

EDIT:
If the followers have a vehicle they might use it to follow the indicated unit, even in the case that unit boards another vehicle. As example, a group of 12 units with its truck should follow another group of 12 units with another truck, a third group should follow the second group, also with its own truck and a fourth group will follow the third group that is already following the second one and so on...
« Last Edit: 16 Sep 2007, 12:56:43 by Mandoble »

Offline hoz

  • OFPEC Site
  • Administrator
  • *****
Re: Script (sqf) - DoFollowUnit (DELAYED)
« Reply #13 on: 26 Nov 2007, 19:14:59 »
Added v.5 to the top thread. I don't think I'm going to add all the nice capabilities your suggesting Mandoble. My original intention was to just have 1 unit follow another. But its otherwise working well. I think I got rid of that delay with the group of units.
Xbox Rocks

Offline LeeHunt

  • Former Staff
  • ****
  • John 21:25
Re: Script (sqf) - DoFollowUnit (DELAYED)
« Reply #14 on: 28 Nov 2007, 00:22:17 »
i like it, though Mandoble's suggestions are pretty neat its also a lot more work and does work pretty well for its original intention.  Are you ready to call it final hoz?