fnc_fired_deployable_deployServer.sqf 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. params[["_ammo", ""], ["_position", [0,0,0]], ["_direction", 0]];
  2. diag_log format["[RD501][Fired Deployable][Deploy Server] Deploying Squad Shield for %1 at %2", _ammo, _position];
  3. private _config = configFile >> "CfgAmmo" >> _ammo;
  4. if!(isClass _config) exitWith {
  5. diag_log format["[RD501][Fired Deployable][Deploy Server] 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["[RD501][Fired Deployable][Deploy Server] 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["[RD501][Fired Deployable][Deploy Server] Failed to find rd501_fired_deployable_object defined in ammo type %1", _ammo];
  15. };
  16. _config = configFile >> "CfgVehicles" >> _deployable;
  17. private _setInvincible = 0;
  18. if(isNumber(_config >> "rd501_fired_deployable_ignoreDamage")) then {
  19. _setInvincible = getNumber (_config >> "rd501_fired_deployable_ignoreDamage");
  20. };
  21. private _hasLoopSound = isText (_config >> "rd501_fired_deployable_loopSound");
  22. private _loopSound = getText (_config >> "rd501_fired_deployable_loopSound");
  23. private _loopDuration = getNumber (_config >> "rd501_fired_deployable_loopDuration");
  24. private _hasEndSound = isText (_config >> "rd501_fired_deployable_endSound");
  25. private _endSound = getText (_config >> "rd501_fired_deployable_endSound");
  26. private _endDuration = getNumber (_config >> "rd501_fired_deployable_endDuration");
  27. private _soundDistance = getNumber (_config >> "rd501_fired_deployable_soundDistance");
  28. private _deployed = createVehicle [_deployable, _position, [], 0, "CAN_COLLIDE"];
  29. _deployed setPosATL _position;
  30. _deployed setDir _direction;
  31. if(_setInvincible == 1) then {
  32. _deployed allowDamage false;
  33. };
  34. if(_timeToLive > 0) then {
  35. [
  36. {
  37. params["_deployable"];
  38. deleteVehicle _deployable;
  39. },
  40. [_deployed],
  41. _timeToLive
  42. ] call CBA_fnc_waitAndExecute;
  43. if(_hasEndSound && _endSound != "") then {
  44. [
  45. {
  46. params["_deployed", "_endSound", "_endDuration", "_distance"];
  47. ["rd501_fired_deployable_soundEnd", [_deployed, _endSound, _endDuration, _distance]] call CBA_fnc_globalEvent;
  48. },
  49. [_deployed, _endSound, _endDuration, _soundDistance],
  50. (_timeToLive - _endDuration)
  51. ] call CBA_fnc_waitAndExecute;
  52. };
  53. };
  54. if(!_hasLoopSound || _loopSound == "") exitWith {
  55. diag_log format["Decided not to play sound for: Loop Sound: '%1', Loop Sound: '%2'", _loopSound, _hasLoopSound];
  56. };
  57. ["rd501_fired_deployable_soundLoop", [_deployed, _loopSound, _loopDuration, _timeToLive, _soundDistance]] call CBA_fnc_globalEvent;