KiloSwiss

Epic Helicopter Paradrop

Aug 2nd, 2021 (edited)
446
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. Inspired by this reddit post: https://www.reddit.com/r/arma/comments/ow91tk/and_for_my_next_scripting_trick_i_will_be_making/
  3. And based on KillzoneKid's Epic Armour Drop script: http://killzonekid.com/arma-scripting-tutorials-epic-armour-drop/
  4. USAGE: _veh call KK_fnc_paraDrop;
  5. */
  6.  
  7. if (isServer) then {
  8.     KK_fnc_paraDrop = {
  9.         params [ ["_veh", objNull, [objNull]] ];
  10.         if (isNull _veh || {!(_veh isKindOf "Helicopter")}) exitWith {};
  11.         private _offset = _veh selectionPosition ["rotor_center", "MEMORY"];
  12.         if (_offset isEqualTo [0,0,0]) then {_offset = [0, 0.5, 3]};
  13.         private _class = format ["%1_parachute_02_F", toString[(toArray faction _veh)#0]];
  14.         private _para = createVehicle [_class, [0,0,0], [], 0, "CAN_COLLIDE"];
  15.         private _paras = [_para];
  16.         _para attachTo [_veh, _offset];
  17.         detach _para;
  18.         _veh attachTo [_para, _offset apply {-_x}];
  19.         if (_veh isKindOf "Heli_Transport_03_base_F") then {
  20.             _offset = (_veh selectionPosition ["rotor_02_center", "MEMORY"]) vectorDiff _offset;
  21.             private _p = createVehicle [_class, [0,0,0], [], 0, "CAN_COLLIDE"];
  22.             _paras pushBack _p;
  23.             _p attachTo [_para, _offset];
  24.             _p setVectorUp [0,-0.3,0.6];
  25.         } else {
  26.             private _mass = getMass _veh;
  27.             if (_mass > 6000) then {
  28.                 private _extraParas = [[0.5,-0.4,0.6], [-0.5,-0.4,0.6]];
  29.                 if (_mass > 12000) then {_extraParas = _extraParas + [[0.5,0.4,0.6], [-0.5,0.4,0.6]]};
  30.                 _extraParas apply {
  31.                     private _p = createVehicle [_class, [0,0,0], [], 0, "CAN_COLLIDE"];
  32.                     _paras pushBack _p;
  33.                     _p attachTo [_para, [0,0,0]];
  34.                     _p setVectorUp _x;
  35.                 };
  36.             };
  37.         };
  38.        
  39.         [_veh, _paras] spawn {
  40.             params ["_veh","_paras"];
  41.             waitUntil {getPos _veh select 2 < 4};
  42.             private _vel = velocity _veh;
  43.             [_veh, _vel] spawn {
  44.                 params ["_veh","_vel"];
  45.                 private _damageAllowed = isDamageAllowed _veh;
  46.                 _veh allowDamage false;
  47.                 detach _veh;
  48.                 _veh setVelocity _vel;
  49.                 private _delay = time + 3;
  50.                 waitUntil {isTouchingGround _veh && {abs(velocity _veh #2) < 0.1 || time > _delay}};
  51.                 _veh allowDamage _damageAllowed;
  52.             };
  53.             if (isMultiplayer) then {
  54.                 missionNamespace setVariable ["#FX", [_veh, _vel#2]];
  55.                 publicVariable "#FX";
  56.             } else {
  57.                 [_veh, _vel#2] spawn KK_fnc_FX;
  58.             };
  59.             playSound3D ["a3\sounds_f\weapons\Flare_Gun\flaregun_1_shoot.wss", _veh];
  60.             _paras apply {detach _x; _x disableCollisionWith _veh};
  61.             private _delay = time + 8;
  62.             waitUntil {time > _delay};
  63.             _paras select {!isNull _x} apply {deleteVehicle _x};
  64.         };
  65.     };
  66. };
  67.  
  68. if (!isDedicated) then {
  69.     KK_fnc_FX = {
  70.         params ["_veh", "_vel"];
  71.         for "_i" from 1 to 100 do {
  72.             drop [
  73.                 ["\A3\data_f\ParticleEffects\Universal\Universal", 16, 7, 48],
  74.                 "",
  75.                 "Billboard",
  76.                 0,
  77.                 1 + random 0.5,
  78.                 [0, -2, 1.5],
  79.                 [-20 + random 40, -20 + random 40, -5 + _vel],
  80.                 1,
  81.                 0.05,
  82.                 0.04,
  83.                 0,
  84.                 [0.5, 10 + random 20],
  85.                 [
  86.                     [0,0,0,1],
  87.                     [0,0,0,0.3],
  88.                     [1,1,1,0.1],
  89.                     [1,1,1,0.03],
  90.                     [1,1,1,0.01],
  91.                     [1,1,1,0.003],
  92.                     [1,1,1,0.001],
  93.                     [1,1,1,0]
  94.                 ],
  95.                 [1],
  96.                 0.1,
  97.                 0.1,
  98.                 "",
  99.                 "",
  100.                 _veh,
  101.                 random 360,
  102.                 true,
  103.                 0.1
  104.             ];
  105.         };
  106.     };
  107.     "#FX" addPublicVariableEventHandler {_this#1 spawn KK_fnc_FX};
  108. };
RAW Paste Data