OFPEC Forum
Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: Gruntage on 20 Nov 2009, 21:49:03
-
Hi folks
I kinda need a rly good follow script. Im making a mission where i need 4 of my troops to follow me rly closely, with about 2m distance between each unit. Ive tried several following scripts but the troops dont seem to want to follow me if i go down lets say an alleyway or a gate. Any ideas? ???
Thx in advance :D
Gruntage
-
Theres always my doFollow (http://www.ofpec.com/ed_depot/index.php?action=details&id=541&game=ArmA)script. You can tweak mine to stay closer and thus should follow down alleys. :whistle:
-
_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(7))*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) < 3) then
{
sleep 2;
}
else
{
group _Hoz_Follower move [(getpos vehicle _Hoz_Leader select 0) + ((random(7))*sin(getdir vehicle _Hoz_Leader - 180)), (getpos vehicle _Hoz_Leader select 1) + ((random(7))*cos(getdir vehicle _Hoz_Leader - 180))];
sleep 2.5;
};
};
Heres the script. which part do i need to tweak to get them to be closer to the unitleader?
-
http://www.ofpec.com/forum/index.php?topic=28711.0
read the topic about the script it tels you how to close the troops up :cool2:
-
Thx for the help guys. Ive tried adjusting the distance to a lower value as the thread in the link suggests, but the AI just wont go down alleyways; they just go a different route and that's sooooo annoying ::)
-
the units not following in alleys seems to be a pathing problem
AI units dislike any thing narrow (try a roadblock with a bargate and wires along the side and you will see the AI hardly passes the roadblock AI is retarded in ofp/arma/(probably arma2 aswell) (i am starting to play arma 2 just about now so havent seen the AI in action yet.)