fnc_fired_deployable_deployServer.sqf 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. params[["_ammo", ""], ["_position", [0,0,0]], ["_direction", 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 _hasLoopSound = isText (_config >> "rd501_fired_deployable_loopSound");
  18. private _loopSound = getText (_config >> "rd501_fired_deployable_loopSound");
  19. private _loopDuration = getNumber (_config >> "rd501_fired_deployable_loopDuration");
  20. private _hasEndSound = isText (_config >> "rd501_fired_deployable_endSound");
  21. private _endSound = getText (_config >> "rd501_fired_deployable_endSound");
  22. private _endDuration = getNumber (_config >> "rd501_fired_deployable_endDuration");
  23. private _soundDistance = getNumber (_config >> "rd501_fired_deployable_soundDistance");
  24. private _deployed = createVehicle [_deployable, _position, [], 0, "CAN_COLLIDE"];
  25. _deployed setPosATL _position;
  26. _deployed setDir _direction;
  27. if(_timeToLive > 0) then {
  28. [
  29. {
  30. params["_deployable"];
  31. deleteVehicle _deployable;
  32. },
  33. [_deployed],
  34. _timeToLive
  35. ] call CBA_fnc_waitAndExecute;
  36. if(_hasEndSound && _endSound != "") then {
  37. [
  38. {
  39. params["_deployed", "_endSound", "_endDuration", "_distance"];
  40. ["rd501_fired_deployable_soundEnd", [_deployed, _endSound, _endDuration, _distance]] call CBA_fnc_globalEvent;
  41. },
  42. [_deployed, _endSound, _endDuration, _soundDistance],
  43. (_timeToLive - _endDuration)
  44. ] call CBA_fnc_waitAndExecute;
  45. };
  46. };
  47. if(!_hasLoopSound || _loopSound == "") exitWith {
  48. diag_log format["Decided not to play sound for: Loop Sound: '%1', Loop Sound: '%2'", _loopSound, _hasLoopSound];
  49. };
  50. ["rd501_fired_deployable_soundLoop", [_deployed, _loopSound, _loopDuration, _timeToLive, _soundDistance]] call CBA_fnc_globalEvent;