SHARE
TWEET

Untitled

a guest Oct 9th, 2019 97 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //  File: fn_handleVehicleDamage.sqf
  2. //  Author: John "Paratus" VanderZwet
  3. //  Description: Handles special damage events
  4.  
  5. private ["_unit","_damage","_source","_projectile","_hitBox"];
  6.  
  7. _heavyVeh = [
  8.     "O_Heli_Light_02_unarmed_F",
  9.     "O_Heli_Transport_04_F",
  10.     "O_Heli_Transport_04_bench_F",
  11.     "B_MRAP_01_F",
  12.     "I_MRAP_03_F",
  13.     "O_MRAP_02_F",
  14.     "B_Truck_01_box_F",
  15.     "B_Truck_01_transport_F",
  16.     "B_Truck_01_fuel_F",
  17.     "B_T_Truck_01_covered_F",
  18.     "I_Heli_Transport_02_F",
  19.     "B_Heli_Transport_01_F"
  20.  
  21. ];
  22.  
  23. _unit = _this select 0;
  24. _projectile = "";
  25. if ((_this select 4) isEqualTo "<NULL-object>") then {
  26.     _hitBox = _this select 2;
  27.     _damage = _this select 3;
  28.     _source = _this select 4;
  29. } else {
  30.     _hitBox = _this select 1;
  31.     _damage = _this select 2;
  32.     _source = _this select 3;
  33.     _projectile = _this select 4;
  34. };
  35.  
  36. if (_projectile != "") then {
  37.     if !(isNull _unit) then {
  38.         if (local _unit) then {[_source] call life_fnc_setAggressive} else {[_source] remoteExecCall ["life_fnc_setAggressive",_unit]};
  39.     };
  40. };
  41.  
  42. if (_hitBox != "?") then {
  43.     _oldDamage = if (_hitBox isEqualTo "") then { damage _unit } else { _unit getHit _hitBox };
  44.  
  45.     if !(isNil "_oldDamage") then {
  46.         if (isNull _source && _projectile isEqualTo "") exitWith {
  47.             _scale = if (_hitBox select [0,5] == "wheel") then {0.15} else {0.35};
  48.             _damage = ((_damage - _oldDamage) * _scale) + _oldDamage;
  49.         };
  50.     };
  51. };
  52.  
  53. if (_projectile == "mini_Grenade") then {
  54.     _damage = 0;
  55. };
  56.  
  57. if (_hitBox == "palivo") then { _damage = _damage / 3 };
  58.  
  59. //RPG damage nonsense, thanks Pizza Man
  60. if ((typeOf _unit) in _heavyVehicles) then {
  61.     if (_projectile in ["R_PG7_F", "ammo_Penetrator_PG7"]) then {
  62.  
  63.         _hitPointAreas = (getAllHitPointsDamage _unit) select 0;
  64.         {if (((toLower _x) find "wheel") >= 0) then {_unit setHitPointDamage [_x, 1];}} forEach _hitPointAreas;
  65.         {if (((toLower _x) find "engine") >= 0) then {_unit setHitPointDamage [_x, 1];}} forEach _hitPointAreas;
  66.  
  67.         if ((["palivo", "fuel_hit", "ammo_hit", "glass"] findIf {(_hitBox find _x) >= 0}) >= 0) then {_damage = 0;};
  68.  
  69.         if (_hitBox isEqualTo "") then {
  70.             _damage = switch (typeOf _unit) do {
  71.                 case "B_Truck_01_fuel_F": {_damage * 3;};
  72.                 case "O_Heli_Light_02_unarmed_F": {_damage * 0.80;};
  73.                 case "B_Heli_Transport_01_F": {_damage * 0.80;};
  74.                 case "B_MRAP_01_F": {0;}; //TBD, leave at 0 for now
  75.                 default {_damage * 0.75;};
  76.             };
  77.         };
  78.     };
  79. };
  80.  
  81. _damage;
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top