apply_drones.sqf 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. params[
  2. ["_vic",objNull,[player]],
  3. ["_drone_class","",["string"]],
  4. ["_position_to_attach",[0,0,0],[[]],3]
  5. ];
  6. if (!canSuspend) exitWith {};
  7. if (isNull _vic) exitWith {};
  8. if (_drone_class isEqualTo '') exitWith {};
  9. _disable_sim_time=60;
  10. _time_of_select=time;
  11. waitUntil {
  12. sleep 0.25;
  13. ((simulationEnabled _vic) || ((time-_time_of_select)>_disable_sim_time))
  14. };
  15. if((time-_time_of_select)>_disable_sim_time) exitWith {};
  16. if (!isServer) exitWith {};
  17. sleep 2;
  18. if(!(alive _vic)) exitWith{};
  19. _vic allowDamage false;
  20. _created_attached_drone = _drone_class createVehicle (getPosASL _vic);
  21. _created_attached_drone attachTo [_vic,_position_to_attach];
  22. _created_attached_drone allowDamage false;
  23. createVehicleCrew _created_attached_drone;
  24. _created_attached_drone hideObjectGlobal true;
  25. _current_attached=_vic getVariable ["rd501_attached_gun_object",[]];
  26. _current_attached pushback _created_attached_drone;
  27. _vic setVariable ["rd501_attached_gun_object",_current_attached ,true];
  28. _vic addMPEventHandler ["MPKilled",
  29. {
  30. params ["_vic", "_killer", "_instigator", "_useEffects"];
  31. _attached_objectes=attachedObjects _vic;
  32. {
  33. detach _x;
  34. deleteVehicle _x;
  35. } forEach _attached_objectes;
  36. _vic setVariable ["rd501_attached_gun_object",[],true];
  37. }];
  38. _vic addEventHandler ["Killed",
  39. {
  40. params ["_vic", "_killer", "_instigator", "_useEffects"];
  41. _attached_objectes=attachedObjects _vic;
  42. {
  43. detach _x;
  44. deleteVehicle _x;
  45. } forEach _attached_objectes;
  46. _vic setVariable ["rd501_attached_gun_object",[],true];
  47. }];
  48. [_vic] spawn {
  49. params["_vic_spawn"];
  50. sleep 2;
  51. if(!(alive _vic_spawn)) exitWith{ };
  52. _vic_spawn allowDamage true;
  53. _attached_objectes=attachedObjects _vic_spawn;
  54. {
  55. _x allowDamage true;
  56. } forEach _attached_objectes;
  57. };