daily pastebin goal
71%
SHARE
TWEET

eject.sqf

a guest Sep 22nd, 2015 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.     Filename: Simple ParaDrop Script v0.8 Beta eject.sqf
  3.     Author: Beerkan:
  4.     Additional contributions cobra4v320
  5.    
  6.     Description:
  7.      A simple paradrop script that ejects all units assigned as cargo onboard, including players and AI (excluding crew) regardless of group assignments, side etc.
  8.      If you're in the aircraft you're getting thrown out.
  9.  
  10.     Parameter(s):
  11.     0: VEHICLE  - vehicle that will be doing the paradrop (object)
  12.     1: ALTITUDE - (optional) the altitude where the group will open their parachute (number)
  13.  
  14.     Example:
  15.     _drop = [vehicle, altitude] execVM "eject.sqf"
  16. */
  17.  
  18. if (!isServer && hasInterface) exitWith {};
  19. private ["_vehicle","_chuteheight","_paras","_dir"];
  20. _vehicle = _this select 0;
  21. _chuteheight = if ( count _this > 1 ) then { _this select 1 } else { 150 };
  22. _paras = assignedcargo _vehicle;
  23. _dir = direction _vehicle;
  24. [_paras] allowGetIn false;
  25.  
  26. paraLandSafe =
  27. {
  28.     private ["_unit"];
  29.     _unit = _this select 0;
  30.     (vehicle _unit) allowDamage false;// Set parachute invincible to prevent exploding if it hits buildings
  31.     waitUntil {isTouchingGround _unit || (position _unit select 2) < 1 };
  32.     _unit allowDamage false;
  33.     _unit action ["EJECT", vehicle _unit];
  34.     _unit setvelocity [0,0,0];
  35.     sleep 1;// Para Units sometimes get damaged on landing. Wait to prevent this.
  36.     _unit allowDamage true;
  37. };
  38.  
  39. {
  40.     _x disableCollisionWith _vehicle;
  41.     _x allowdamage false;
  42.     unassignvehicle _x;
  43.     _x action ["GETOUT", _vehicle];
  44.     _x setDir (_dir + 90);
  45.     sleep 0.35;//So units are not too far spread out when they land.
  46. } forEach _paras;
  47.  
  48. {
  49.     waitUntil {(position _x select 2) <= _chuteheight};
  50.     if (vehicle _x != _x) exitWith {};
  51.     _chute = createVehicle ["Steerable_Parachute_F", position _x, [], ((_dir)- 5 + (random 10)), 'FLY'];
  52.     _chute setPos (getPos _x);
  53.     _x assignAsDriver _chute;
  54.         _x moveIndriver _chute;
  55.     _x allowdamage true;
  56. } forEach _paras;
  57.  
  58. {
  59.   [_x] spawn paraLandSafe;
  60. } forEach _paras;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top