fnc_volatile_handleDamage.sqf 999 B

12345678910111213141516171819202122
  1. (_this select 0) params ["_target", "_shooter", "_projectile", "_position", "_velocity", "_selection", "_ammo", "_vector", "_radius", "_surfaceType", "_isDirect"];
  2. if(_target isEqualTo objNull) exitWith { systemChat "Target is null idk why"; };
  3. private _health = _target getVariable ["rd501_volatile_health", false];
  4. if(_health isEqualTo false) exitWith { systemChat "Health not found"; };
  5. _ammo params ["_directHit", "_indirectHit", "_indirectRange", "_explosionHit", "_ammoClass"];
  6. private _hit = _directHit + (_indirectHit/(_indirectRange max 0.1)) + _explosionHit;
  7. private _result = _health - _hit;
  8. if(_result <= 0) then {
  9. _target setVariable ["rd501_volatile_health", _result, true];
  10. private _ehId = _target getVariable ["rd501_volatile_ehId", -1];
  11. ["rd501_volatile_destroy", [_target], _target] call cba_fnc_targetEvent;
  12. _target removeEventHandler ["HitPart", _ehId];
  13. }
  14. else
  15. {
  16. // Set locally only to reduce network traffic
  17. _target setVariable ["rd501_volatile_health", _result];
  18. };