Advertisement
Brick

A3 Handle Damage

Sep 19th, 2016
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 4.08 KB | None | 0 0
  1. comment
  2. "
  3.    Name            | Source        | Projectile    | Instigator
  4.                    |               |               |
  5.    VDM             | Driver        | Null          | Null
  6.    Vehicle Gun     | Vehicle       | Bullet        | Gunner
  7.    From Vehicle    | Player        | Bullet        | Player
  8.    On Foot         | Player        | Bullet        | Player
  9.    Fall Damage     | Player        | Null          | Null
  10.    Crashing        | Null          | Null          | Null
  11.    Fire            | Null          | Null          | Null
  12.    Explosion       | Null          | Explosion     | Null
  13. ";
  14.  
  15. cursorTarget addEventHandler
  16. [
  17.     "HandleDamage",
  18.     {
  19.         private _unit           = param [0];
  20.         private _selectionName  = param [1];
  21.         private _damage         = param [2];
  22.         private _source         = param [3];
  23.         private _projectile     = param [4];
  24.         private _hitPartIndex   = param [5];
  25.         private _instigator     = param [6];
  26.  
  27.         private _oldDamage =
  28.         if (_hitPartIndex isEqualTo -1) then
  29.         {
  30.             damage _unit;
  31.         }
  32.         else
  33.         {
  34.             _unit getHitIndex _hitPartIndex;
  35.         };
  36.  
  37.         private _newDamage = call
  38.         {
  39.             comment "Ignore 0 Damage";
  40.             if (_damage isEqualTo _oldDamage) exitWith
  41.             {
  42.                 _damage;
  43.             };
  44.  
  45.             comment "Crashing, Fire, Explosion";
  46.             if (isNull _source) exitWith
  47.             {
  48.                 _damage;
  49.             };
  50.  
  51.             comment "Fall Damage"
  52.             if (_source isEqualTo _unit) exitWith
  53.             {
  54.                 _damage;
  55.             };
  56.  
  57.             private _sourceParent = objectParent _source;
  58.  
  59.             comment "VDM";
  60.             if (_projectile isEqualTo "") exitWith
  61.             {
  62.                 comment "Check the source is in a vehicle";
  63.                 if !(isNull _sourceParent) then
  64.                 {
  65.                     hint format ["You were VDM'd by %1", name _source];
  66.                 };
  67.  
  68.                 _oldDamage;
  69.             };
  70.  
  71.             comment "Source is not on foot, shooting a vehicle's gun, or shooting from a vehicle that isn't a car / boat";
  72.             if !(isNull _sourceParent || { _sourceParent isKindOf "Car" } || { _sourceParent isKindOf "Boat" }) exitWith
  73.             {
  74.                 _oldDamage;
  75.             };
  76.  
  77.             comment "Being shot by player";
  78.             private _sourceSide     = side _source;
  79.             private _sourceWeapon   = currentWeapon _source;
  80.  
  81.             private _unitParent     = objectParent _unit;
  82.  
  83.             comment "Player is Cop";
  84.             if (_sourceSide isEqualTo west) then
  85.             {
  86.                 comment "Tazer: P07 Silenced, Rook-40 Silenced - Green Tracer 9mm";
  87.                 if (_sourceWeapon in ["hgun_P07_snds_F", "hgun_Rook40_snds_F"] && { _projectile in ["B_9x21_Ball_Tracer_Green"] }) exitWith
  88.                 {
  89.                     comment "Only play animation if they are on foot";
  90.                     if (isNull _unitParent) then
  91.                     {
  92.                         _unit switchMove "AinjPfalMstpSnonWnonDf_carried_fallwc";
  93.                     };
  94.  
  95.                     _oldDamage;
  96.                 };
  97.  
  98.                 comment "Rubber Bullet: MK20, MK20C, SDAR - Green Tracer 556, Dual Purpose 556";
  99.                 if (_sourceWeapon in ["arifle_Mk20_plain_F", "arifle_Mk20C_plain_F", "arifle_SDAR_F"] && { _projectile in ["B_556x45_Ball_Tracer_Green", "B_556x45_dual"] }) exitWith
  100.                 {
  101.                     comment "Only play animation if they are on foot";
  102.                     if (isNull _unitParent) then
  103.                     {
  104.                         _unit switchMove "AcinPercMstpSnonWnonDnon_agony";
  105.                     };
  106.  
  107.                     _oldDamage;
  108.                 };
  109.             };
  110.         };
  111.  
  112.         comment "Default";
  113.         if (isNil "_newDamage") then
  114.         {
  115.             ["Invalid Damage: %1", _this] call BIS_fnc_error;
  116.  
  117.             _newDamage = _damage;
  118.         };
  119.  
  120.         _newDamage;
  121.     }
  122. ];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement