stun.sqf 946 B

1234567891011121314151617181920212223242526
  1. // Runs only on the machine where the hit unit is local
  2. _fnc_onHit = {
  3. params ["_unit", "_source", "_damage", "_instigator"];
  4. ["rd501_stun_onHit", [_unit, _source], _instigator] call CBA_fnc_targetEvent;
  5. };
  6. // Runs on the person who shot
  7. _fnc_stun = {
  8. params["_unit", "_source"];
  9. private _mag = currentMagazine _source;
  10. private _ammo = (configFile >> "CfgMagazines" >> _mag >> "ammo") call BIS_fnc_getCfgData;
  11. private _stunDuration = (configFile >> "CfgAmmo" >> _ammo >> "RD501_stunDuration") call BIS_fnc_getCfgData;
  12. if (_stunDuration > 0.0) then
  13. {
  14. ["ace_captives_setSurrendered" ,[_unit, true], _unit] call CBA_fnc_targetEvent;
  15. [{
  16. ["ace_captives_setSurrendered", [_this select 0, false], _this select 0] call CBA_fnc_targetEvent;
  17. }, [_unit], _stunDuration] call CBA_fnc_waitAndExecute;
  18. };
  19. };
  20. ["CAManBase", "Hit", _fnc_onHit] call CBA_fnc_addClassEventHandler;
  21. ["rd501_stun_onHit", _fnc_stun] call CBA_fnc_addEventHandler;