fnc_fired_deployable_deployServer.sqf 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. params[["_ammo", ""], ["_position", [0,0,0]]];
  2. diag_log format["Deploying Squad Shield for %1 at %2", _ammo, _position];
  3. private _config = configFile >> "CfgAmmo" >> _ammo;
  4. if!(isClass _config) exitWith {
  5. diag_log format["Unable to find class '%1' in CfgAmmo", _ammo];
  6. };
  7. private _isValid = getNumber (_config >> "rd501_fired_deployable") == 1;
  8. private _deployable = getText (_config >> "rd501_fired_deployable_object");
  9. private _timeToLive = getNumber (_config >> "rd501_fired_deployable_timeToLive");
  10. if(!_isValid) exitWith {
  11. diag_log format["Requested throw type '%1' is does not contain rd501_fired_deployable=1", _ammo];
  12. };
  13. if(isNil "_deployable" || _deployable isEqualTo "") exitWith {
  14. diag_log format["Failed to find rd501_fired_deployable_object defined in ammo type %1", _ammo];
  15. };
  16. _config = configFile >> "CfgVehicles" >> _deployable;
  17. private _loopSound = getText (_config >> "rd501_fired_deployable_loopSound");
  18. private _loopDuration = getNumber (_config >> "rd501_fired_deployable_loopDuration");
  19. private _endSound = getText (_config >> "rd501_fired_deployable_endSound");
  20. private _endDuration = getNumber (_config >> "rd501_fired_deployable_endDuration");
  21. private _soundDistance = getNumber (_config >> "rd501_fired_deployable_soundDistance");
  22. private _deployed = createVehicle [_deployable, _position, [], 0, "CAN_COLLIDE"];
  23. _deployed setPosATL _position;
  24. if(_timeToLive > 0) then {
  25. [
  26. {
  27. params["_deployable"];
  28. deleteVehicle _deployable;
  29. },
  30. [_deployed],
  31. _timeToLive
  32. ] call CBA_fnc_waitAndExecute;
  33. [
  34. {
  35. params["_deployed", "_endSound", "_endDuration", "_distance"];
  36. ["rd501_fired_deployable_soundEnd", [_deployed, _endSound, _endDuration, _distance]] call CBA_fnc_globalEvent;
  37. },
  38. [_deployed, _endSound, _endDuration, _soundDistance],
  39. (_timeToLive - _endDuration)
  40. ] call CBA_fnc_waitAndExecute;
  41. ["rd501_fired_deployable_soundLoop", [_deployed, _loopSound, _loopDuration, _timeToLive, _soundDistance]] call CBA_fnc_globalEvent;
  42. };