fnc_shield_regenPerFrameHandler.sqf 1.0 KB

1234567891011121314151617181920212223242526
  1. params["_args", "_handle"];
  2. _args params["_shield"];
  3. if(_shield isEqualTo objNull || !alive _shield) exitWith {
  4. diag_log format["[RD501][Shield] removed PFH %1", _shield];
  5. [_handle] call CBA_fnc_removePerFrameHandler;
  6. };
  7. private _regenDelayTime = _shield getVariable ["rd501_shield_regenStartsAt", diag_tickTime];;
  8. if(diag_tickTime < _regenDelayTime) exitWith {
  9. diag_log format["[RD501][Shield] Still waiting for delay before regen on %1", _regenDelayTime];
  10. };
  11. private _maxHealth = _shield getVariable["rd501_shield_maxHealth", 100];
  12. private _currentHealth = _shield getVariable["rd501_shield_currentHealth", 100];
  13. private _regenAmount = _shield getVariable ["rd501_shield_regenPerSecond", 0];
  14. if(_currentHealth isEqualTo _maxHealth) exitWith { };
  15. private _newHealth = (_currentHealth + _regenAmount) min _maxHealth;
  16. _shield setVariable["rd501_shield_currentHealth", _newHealth];
  17. // diag_log format["[RD501][Shield] Regen health %1 to %2", _currentHealth, _newHealth];
  18. [_shield] call rd501_fnc_shield_checkState;