Home   Help Search Login Register  

Author Topic: Complex follow script needed  (Read 1697 times)

0 Members and 1 Guest are viewing this topic.

Offline Gruntage

  • Missions Depot
  • Administrator
  • *****
  • How do I get outta this chickensh*t outfit?
Complex follow script needed
« 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
"But one thing I can tell you from not just OFP but life in general:  criticism is directly proportional to quality. The more criticism a mission receives, the better the outcome" - macguba

Offline hoz

  • OFPEC Site
  • Administrator
  • *****
Re: Complex follow script needed
« Reply #1 on: 21 Nov 2009, 01:23:06 »
Theres always my doFollow script. You can tweak mine to stay closer and thus should follow down alleys.    :whistle:
Xbox Rocks

Offline Gruntage

  • Missions Depot
  • Administrator
  • *****
  • How do I get outta this chickensh*t outfit?
Re: Complex follow script needed
« Reply #2 on: 21 Nov 2009, 10:06:45 »
Code: [Select]
_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?
"But one thing I can tell you from not just OFP but life in general:  criticism is directly proportional to quality. The more criticism a mission receives, the better the outcome" - macguba

Offline Supergrunt

  • Members
  • *
Re: Complex follow script needed
« Reply #3 on: 21 Nov 2009, 23:48:20 »
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:

Offline Gruntage

  • Missions Depot
  • Administrator
  • *****
  • How do I get outta this chickensh*t outfit?
Re: Complex follow script needed
« Reply #4 on: 22 Nov 2009, 00:27:20 »
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  ::)
"But one thing I can tell you from not just OFP but life in general:  criticism is directly proportional to quality. The more criticism a mission receives, the better the outcome" - macguba

Offline Supergrunt

  • Members
  • *
Re: Complex follow script needed
« Reply #5 on: 24 Nov 2009, 19:40:15 »
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.)