Advertisement
DarkBall

Untitled

Jun 1st, 2020
891
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 7.04 KB | None | 0 0
  1. [] spawn {
  2.     addMissionEventHandler["TeamSwitch", {
  3.         params["_previousUnit", "_newUnit"];
  4.         group _previousUnit selectLeader _newUnit;
  5.     }];
  6.  
  7.     fn_aiMedCarry = {
  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.         if (isNull _nearUnit) exitWith {};
  25.         _startPos = getPos _nearUnit;
  26.         _nearUnit doMove _pos;
  27.         [_nearUnit, _unit, _startPos] spawn {
  28.             params['_nearUnit', '_unit', '_startPos'];
  29.             waitUntil {
  30.                 _nearUnit distance _unit <= 2.5
  31.             };
  32.             _nearUnit lookAt _unit;
  33.             sleep 1;
  34.             _nearUnit allowDamage false;
  35.             _nearUnit playMove 'AcinPercMrunSnonWnonDf';
  36.             sleep 5;
  37.             _unit attachTo[_nearUnit, [0.1, 0.3, 1.4]];
  38.             _unit setDir(getDir _nearUnit + 90);
  39.             _nearUnit doMove _startPos;
  40.             waitUntil {
  41.                 _nearUnit distance _startPos <= 3
  42.             };
  43.             detach _unit;
  44.             _unit setPos(_nearUnit modelToWorld[0, 1, 0]);
  45.             _nearUnit switchMove "";
  46.             sleep 1;
  47.             _nearUnit playMove 'ainvpknlmstpslaywrfldnon_medicother';
  48.             sleep 6;
  49.             _nearUnit addItem 'FirstAidKit';
  50.             _nearUnit removeItem 'FirstAidKit';
  51.             _unit setVariable['HoldActionLost', true];
  52.             [_unit] call fn_disableUnconscious;
  53.             [_unit, actionId] call BIS_fnc_holdActionRemove;
  54.             _nearUnit allowDamage true;
  55.         };
  56.     };
  57.  
  58.     fn_aiMED = {
  59.         params['_unit', '_pos'];
  60.         private _nearestUnits = player nearEntities["Man", 100];
  61.         private _nearestUnitsArr = [];
  62.  
  63.         if (side _unit countSide _nearestUnits > 0) then {
  64.             {
  65.                 _units = _x;
  66.                 if (side _units == side _unit && _units in units group player) then {
  67.                     _nearestUnitsArr pushBack _units;
  68.                 };
  69.             }
  70.             foreach _nearestUnits;
  71.         };
  72.         _nearestUnitsArr = _nearestUnitsArr - [player];
  73.         _nearestUnitsArr = _nearestUnitsArr - [_unit];
  74.         _nearUnit = selectRandom _nearestUnitsArr;
  75.         if (isNull _nearUnit) exitWith {};
  76.         _startPos = getPos _nearUnit;
  77.         _nearUnit doMove _pos;
  78.         [_nearUnit, _unit, _startPos] spawn {
  79.             params['_nearUnit', '_unit', '_startPos'];
  80.             waitUntil {
  81.                 _nearUnit distance _unit <= 2.5
  82.             };
  83.             _nearUnit lookAt _unit;
  84.             sleep 1;
  85.             _nearUnit allowDamage false;
  86.             _nearUnit playMove 'ainvpknlmstpslaywrfldnon_medicother';
  87.             sleep 6;
  88.             _nearUnit addItem 'FirstAidKit';
  89.             _nearUnit removeItem 'FirstAidKit';
  90.             _unit setVariable['HoldActionLost', true];
  91.             [_unit] call fn_disableUnconscious;
  92.             [_unit, actionId] call BIS_fnc_holdActionRemove;
  93.             _nearUnit doMove _startPos;
  94.             sleep 3;
  95.             _nearUnit allowDamage true;
  96.         };
  97.     };
  98.  
  99.     playerAction = player;
  100.     fn_disableUnconscious = {
  101.         params['_unit'];
  102.         _unit setUnconscious false;
  103.         _unit setDamage 0;
  104.         _unit allowDamage true;
  105.         _unit setCaptive false;
  106.     };
  107.     fn_Unconscious = {
  108.         params['_unit'];
  109.         _unit setUnconscious true;
  110.         _unit setCaptive true;
  111.         _unit allowDamage false;
  112.         [_unit] call fn_holdAction;
  113.     };
  114.     fn_Effects = {
  115.         PP_chrom = ppEffectCreate["ChromAberration", 200];
  116.         PP_chrom ppEffectEnable true;
  117.         PP_chrom ppEffectAdjust[1, 0.41, true];
  118.         PP_chrom ppEffectCommit 120;
  119.         PP_wetD = ppEffectCreate["WetDistortion", 300];
  120.         PP_wetD ppEffectEnable true;
  121.         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];
  122.         PP_wetD ppEffectCommit 120;
  123.     };
  124.     fn_LostHoldAction = {
  125.         unitLostHoldAction = _this select 0;
  126.         [] spawn {
  127.             sleep 180;
  128.  
  129.             if (!(isNil {
  130.                     unitLostHoldAction getVariable "HoldActionLost"
  131.                 })) then {
  132.                 unitLostHoldAction setVariable['HoldActionLost', nil];
  133.                 [unitLostHoldAction] call fn_disableUnconscious;
  134.                 if (isPlayer unitLostHoldAction) then {
  135.                     if (isNil "PP_chrom" || isNil "PP_wetD") exitWith {};
  136.                     ppEffectDestroy[PP_chrom, PP_wetD];
  137.                 };
  138.             } else {
  139.                 unitLostHoldAction setDamage 1;
  140.                 [unitLostHoldAction, actionId] call BIS_fnc_holdActionRemove;
  141.             };
  142.         };
  143.     };
  144.     fn_holdAction = {
  145.         params['_unit'];
  146.         [_unit] call fn_LostHoldAction;
  147.         actionId = [
  148.             _unit,
  149.             "Поднять",
  150.             "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_revive_ca.paa",
  151.             "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_reviveMedic_ca.paa",
  152.             "_this distance2D _target < 3 && 'FirstAidKit' in items _this",
  153.             "_caller distance _target < 3", {
  154.                 targetHoldAction = _this select 0;
  155.                 callerHoldAction = _this select 1;
  156.                 if (stance callerHoldAction == 'PRONE') then {
  157.                     callerHoldAction playMove 'ainvppnemstpslaywrfldnon_medicother';
  158.                 } else {
  159.                     callerHoldAction playMove 'ainvpknlmstpslaywrfldnon_medicother';
  160.                 };
  161.             }, {}, {
  162.                 callerHoldAction removeItem 'FirstAidKit';
  163.                 targetHoldAction setVariable['HoldActionLost', true];
  164.                 [targetHoldAction] call fn_disableUnconscious;
  165.                 [targetHoldAction, actionId] call BIS_fnc_holdActionRemove;
  166.             }, {},
  167.             [],
  168.             6,
  169.             0,
  170.             true,
  171.             false
  172.         ] call BIS_fnc_holdActionAdd;
  173.     }; {
  174.         if (_x in units group player) then {
  175.             _x addEventHandler['HandleDamage', {
  176.                 params['_unit', '', '_damage'];
  177.                 private _veh = objectParent _unit;
  178.                 if (_damage >= 0.7) then {
  179.                     _randomScript = selectRandom[fn_aiMedCarry, fn_aiMed];
  180.                     [_unit, getPos _unit] call _randomScript;
  181.                     if (isPlayer _unit) then {
  182.                         call fn_Effects;
  183.                     };
  184.                     [_unit] call fn_Unconscious;
  185.                 };
  186.             }];
  187.         };
  188.     }
  189.     forEach allUnits;
  190. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement