fnc_shield_hitHandler.sqf 1014 B

1234567891011121314151617181920212223242526
  1. params["_ammo", "_target"];
  2. private _health = _target getVariable ["rd501_shield_currentHealth", false];
  3. if(_health isEqualTo false) exitWith { systemChat "[RD501][Shield][Hit Handler] Health not found"; };
  4. _ammo params ["_directHit", "_indirectHit", "_indirectRange", "_explosionHit", "_ammoClass"];
  5. private _hit = _directHit + (_indirectHit/(_indirectRange max 0.1)) + _explosionHit;
  6. private _result = _health - _hit;
  7. if(_result <= 0) then {
  8. _target setVariable ["rd501_shield_currentHealth", _result, true];
  9. private _ehId = _target getVariable ["rd501_shield_ehId", -1];
  10. ["rd501_shield_destroy", [_target], _target] call cba_fnc_targetEvent;
  11. _target removeEventHandler ["HitPart", _ehId];
  12. }
  13. else
  14. {
  15. // Set locally only to reduce network traffic
  16. _target setVariable ["rd501_shield_currentHealth", _result];
  17. [_target] call rd501_fnc_shield_checkState;
  18. private _delay = _target getVariable["rd501_shield_regenDelay", 5];
  19. _target setVariable ["rd501_shield_regenStartsAt", diag_tickTime + _delay];
  20. };