Advertisement
DarkBall

Untitled

May 22nd, 2020
459
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 5.08 KB | None | 0 0
  1. [] spawn {
  2.     addMissionEventHandler["TeamSwitch", {
  3.         params["_previousUnit", "_newUnit"];
  4.         group _previousUnit selectLeader _newUnit;
  5.     }];
  6.  
  7.     fn_aiMED = {
  8.         params['_unit', '_pos'];
  9.         private _nearestUnits = player nearEntities["Man", 100];
  10.         private _nearestUnitsArr = [];
  11.  
  12.         if (side _unit countSide _nearestUnits > 0) then {
  13.             {
  14.                 _units = _x;
  15.                 if (side _units == side _unit && _units in units group player) then {
  16.                     _nearestUnitsArr pushBack _units;
  17.                 };
  18.             }
  19.             foreach _nearestUnits;
  20.         };
  21.         _nearestUnitsArr = _nearestUnitsArr - [player];
  22.         _nearestUnitsArr = _nearestUnitsArr - [_unit];
  23.         _nearUnit = selectRandom _nearestUnitsArr;
  24.         _nearUnit doMove _pos;
  25.         [_nearUnit, _unit] spawn {
  26.             params['_nearUnit', '_unit'];
  27.             waitUntil {
  28.                 _nearUnit distance _unit <= 4.5
  29.             };
  30.             _nearUnit lookAt _unit;
  31.             _nearUnit playMove 'ainvpknlmstpslaywrfldnon_medicother';
  32.             sleep 6;
  33.             _nearUnit removeItem 'FirstAidKit';
  34.             missionNamespace setVariable['HoldActionLost', true];
  35.             [_unit] call fn_disableUnconscious;
  36.             [_unit, actionId] call BIS_fnc_holdActionRemove;
  37.         };
  38.         hint str typeOf _nearUnit;
  39.     };
  40.  
  41.     playerAction = player;
  42.     fn_disableUnconscious = {
  43.         params['_unit'];
  44.         _unit setUnconscious false;
  45.         _unit setDamage 0;
  46.         _unit allowDamage true;
  47.         _unit setCaptive false;
  48.     };
  49.     fn_Unconscious = {
  50.         params['_unit'];
  51.         _unit setUnconscious true;
  52.         _unit setCaptive true;
  53.         _unit allowDamage false;
  54.         [_unit] call fn_holdAction;
  55.         if (isPlayer _unit) then {
  56.             addMissionEventHandler["TeamSwitch", {
  57.                 params["_previousUnit", "_newUnit"];
  58.                 if (_newUnit == playerAction) then {
  59.                     call fn_Effects;
  60.                 };
  61.                 ppEffectDestroy[PP_chrom, PP_wetD];
  62.             }];
  63.         };
  64.     };
  65.     fn_Effects = {
  66.         PP_chrom = ppEffectCreate["ChromAberration", 200];
  67.         PP_chrom ppEffectEnable true;
  68.         PP_chrom ppEffectAdjust[1, 0.41, true];
  69.         PP_chrom ppEffectCommit 120;
  70.         PP_wetD = ppEffectCreate["WetDistortion", 300];
  71.         PP_wetD ppEffectEnable true;
  72.         PP_wetD ppEffectAdjust[1, 0.2, 0.2, 1, 1, 1, 1, 0.05, 0.01, 0.05, 0.01, 0.1, 0.1, 0.2, 0.2];
  73.         PP_wetD ppEffectCommit 120;
  74.     };
  75.     fn_LostHoldAction = {
  76.         unitLostHoldAction = _this select 0;
  77.         [] spawn {
  78.             sleep 40;
  79.  
  80.             if (!(isNil {
  81.                     missionNamespace getVariable "HoldActionLost"
  82.                 })) then {
  83.                 [unitLostHoldAction] call fn_disableUnconscious;
  84.                 missionNamespace setVariable['HoldActionLost', nil];
  85.                 if (isPlayer unitLostHoldAction) then {
  86.                     ppEffectDestroy[PP_chrom, PP_wetD];
  87.                 };
  88.             } else {
  89.                 unitLostHoldAction setDamage 1;
  90.                 [unitLostHoldAction, actionId] call BIS_fnc_holdActionRemove;
  91.             };
  92.         };
  93.     };
  94.     fn_holdAction = {
  95.         params['_unit'];
  96.         [_unit] call fn_LostHoldAction;
  97.         actionId = [
  98.             _unit,
  99.             "Поднять",
  100.             "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_revive_ca.paa",
  101.             "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_reviveMedic_ca.paa",
  102.             "_this distance _target < 3 && 'FirstAidKit' in items _this",
  103.             "_caller distance _target < 3 && 'FirstAidKit' in items _caller", {
  104.                 targetHoldAction = _this select 0;
  105.                 callerHoldAction = _this select 1;
  106.                 if (stance callerHoldAction == 'PRONE') then {
  107.                     callerHoldAction playMove 'ainvppnemstpslaywrfldnon_medicother';
  108.                 } else {
  109.                     callerHoldAction playMove 'ainvpknlmstpslaywrfldnon_medicother';
  110.                 };
  111.             }, {}, {
  112.                 callerHoldAction removeItem 'FirstAidKit';
  113.                 missionNamespace setVariable['HoldActionLost', true];
  114.                 [targetHoldAction] call fn_disableUnconscious;
  115.                 [targetHoldAction, actionId] call BIS_fnc_holdActionRemove;
  116.             }, {},
  117.             [],
  118.             6,
  119.             0,
  120.             true,
  121.             false
  122.         ] call BIS_fnc_holdActionAdd;
  123.     }; {
  124.         if (_x in units group player) then {
  125.             _x addEventHandler['HandleDamage', {
  126.                 params['_unit', '', '_damage'];
  127.                 if (_damage >= 0.7) then {
  128.                     [_unit, getPos _unit] call fn_aiMED;
  129.                     if (isPlayer _unit) then {
  130.                         call fn_Effects;
  131.                         call fn_Player_HoldActionLost;
  132.                     };
  133.                     [_unit] call fn_Unconscious;
  134.                 };
  135.             }];
  136.         };
  137.     }
  138.     forEach allUnits;
  139. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement