Hey everyone,
I am using a dofollow script made by Hoz and it workds great till the followed (leader) gets shot.
Anyway of making the follower follow group leader instead of just one unit?
Here is the script code below:
/*
Do Follow other Unit example - Hoz 01/02/07 / Updated August 2007
Set Hoz_ReleaseUnit to false in some other location to stop the following.
Usage: dummy = [Follower,Leader] execVM DoFollowUnit.sqf
v.4
*/
_Hoz_Follower = _this select 0;
_Hoz_Leader = _this select 1;
Hoz_ReleaseUnit = true;
_Hoz_LongDist = 150;
if !(leader _Hoz_Follower == _Hoz_Follower) then
{
[_Hoz_Follower] join grpNull;
};
_leftc = 0;
_leftg = 0;
_leftk = 0;
_leftd = 0;
_assigned = 0;
while {(alive _Hoz_Follower) && (alive _Hoz_Leader) && Hoz_ReleaseUnit}do
{
// If unit gets too far behind then wait until the follower is closer.
waitUntil {_Hoz_Follower distance _Hoz_Leader < _Hoz_LongDist};
if (vehicle _Hoz_Leader != _Hoz_Leader) then
{
_Hoz_VehicleTmp = vehicle _Hoz_Leader;
_leftc = _Hoz_VehicleTmp emptyPositions "cargo";
_leftg = _Hoz_VehicleTmp emptyPositions "Gunner";
_leftk = _Hoz_VehicleTmp emptyPositions "Commander";
_leftd = _Hoz_VehicleTmp emptyPositions "Driver";
hint format["%1 %2 %3 %4", _leftc, _leftg, _leftk, _leftd];
for [{_i = 0},{_i != count units group _Hoz_Follower},{_i = _i + 1}] do
{
if (_i < _leftc) then
{
(units group _Hoz_Follower select _i) assignAsCargo _Hoz_VehicleTmp;
_assigned = _assigned + 1;
};
if ((_i >= _leftc) && (_i < (_leftc + _leftg))) then
{
(units group _Hoz_Follower select _i) assignAsGunner _Hoz_VehicleTmp;
_assigned = _assigned + 1;
};
if ((_i >= (_leftc + _leftg)) && (_i < (_leftc + _leftg + _leftk))) then
{
(units group _Hoz_Follower select _i) assignAsCommander _Hoz_VehicleTmp;
_assigned = _assigned + 1;
};
if ((_i >= (_leftc + _leftg + _leftk)) && (_i < (_leftc + _leftg + _leftk + _leftd))) then
{
(units group _Hoz_Follower select _i) assignAsDriver _Hoz_VehicleTmp;
_assigned = _assigned + 1;
};
};
(units group _Hoz_Follower) orderGetIn true;
while {vehicle _Hoz_Leader != _Hoz_Leader} do
{
group _Hoz_Follower move [(getpos vehicle _Hoz_Leader select 0) + ((random(10))*sin(getdir vehicle _Hoz_Leader - 180)), (getpos vehicle _Hoz_Leader select 1) + ((random(7))*cos(getdir vehicle _Hoz_Leader - 180))];
sleep 2.5;
};
{unassignVehicle _x} forEach units group _Hoz_Follower;
};
if ((_Hoz_Follower distance _Hoz_Leader) < 10) then
{
sleep 2;
}
else
{
group _Hoz_Follower move [(getpos vehicle _Hoz_Leader select 0) + ((random(10))*sin(getdir vehicle _Hoz_Leader - 180)), (getpos vehicle _Hoz_Leader select 1) + ((random(7))*cos(getdir vehicle _Hoz_Leader - 180))];
sleep 2.5;
};
};
Thanks for your help.