deka_shield_init.sqf 946 B

123456789101112131415161718192021222324
  1. params ["_unit"];
  2. private _hitEH = _unit addEventHandler ["HitPart", {
  3. (_this select 0) params ["_target", "_shooter", "_projectile", "_position", "_velocity", "_selection", "_ammo", "_vector", "_radius", "_surfaceType", "_isDirect"];
  4. [{
  5. params["_unit"];
  6. private _ehId = _unit getVariable ["rd501_dekashield_hitEH", -1];
  7. if(alive _unit && _ehId != -1) then {
  8. private _position = getPosATL _unit;
  9. private _shield = "RD501_Droideka_Shield" createVehicle _position;
  10. _unit setVariable ["rd501_dekashield_attached", _shield, true];
  11. _shield setPosATL _position;
  12. _shield attachTo [_unit, [0,0,0]];
  13. [{
  14. params["_shield"];
  15. deleteVehicle _shield;
  16. }, [_shield], 60] call CBA_fnc_waitAndExecute;
  17. _unit setVariable ["rd501_dekashield_hitEH", -1, true];
  18. _unit removeEventHandler ["HitPart", _ehId];
  19. };
  20. }, [_target], 1] call CBA_fnc_waitAndExecute;
  21. }];
  22. _unit setVariable ["rd501_dekashield_hitEH", _hitEH, false];