Jump to content
woodringsa

AI Auto-Load into Players Vehicle

Recommended Posts

I have a mission where the player and their AI squad mates are routinely switching vehicles. I am trying to work towards a solution that will have the AI automatically get in to the same vehicle as the Player. I know that get in commands can be given, but would prefer, from both a speed and efficiency as well as immersion standpoints, to have the AI automatically recognize that the player is in a vehicle, and load up into that vehicle (seating arrangement doesn't matter). All vehicles in the mission will be 4+ seating, to accommodate the 4 man squad (player +3 mates).

 

I am sure that there will be some level of performance hit with a script checking to see if the Player is in a vehicle. Any thoughts on how to best make this happen?

Share this post


Link to post
Share on other sites

Tried this in a trigger and the INIT of my AI, but obviously doing something wrong. Taken from https://forums.bohemia.net/forums/topic/142041-getingetout-help/?tab=comments#comment-3475800

while {alive player} do { 
waitUntil {vehicle player != player}; 

    _x assignAsCargo vehicle player ; 
      _x moveincargo vehicle player; 
}  foreach units group player; 
waitUntil {vehicle player == player}; 

    unassignVehicle _x ; 
      moveOut _x 
}  foreach units group player; 
};

Share this post


Link to post
Share on other sites

ok...figured it out. Maybe not the best way to do this, but it works.

Create Trigger
Mark it as Repeatable
Condition: True
Activation: 
0 = spawn [] {
while {alive player} do { 
waitUntil {vehicle player != player}; 

    _x assignAsCargo vehicle player ; 
      _x moveincargo vehicle player; 
}  foreach units group player; 
waitUntil {vehicle player == player}; 

    unassignVehicle _x ; 
      moveOut _x 
}  foreach units group player; 
}};

And done. AI will automatically be loaded into the same vehicle as the player.

Share this post


Link to post
Share on other sites

Prefer EHs.

in initPlayerLocal.sqf (SP or MP)

 

player addEventHandler ["GetInMan", {
  params ["_unit", "_role", "_vehicle", "_turret"];
  {_x moveInAny _vehicle} count (units _unit - [_unit]);
}];
 
player addEventHandler ["GetOutMan", {
  params ["_unit", "_role", "_vehicle", "_turret", "_isEject"];
  {moveOut _x} count (units _unit - [_unit]);
}];

 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×