Advertisement
Guest User

Untitled

a guest
Apr 5th, 2020
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 2.42 KB | None | 0 0
  1. /*
  2. @filename: feats\vehicleLoadout\setPylons.sqf
  3. Author:
  4.     ben
  5. Description:
  6.     run anywhere,
  7.     apply given pylons mag selection to the given vehicle
  8. */
  9.  
  10. params ["_player", "_veh", "_pylons"];
  11.  
  12. if ( isNull _player || isNull _veh ) exitWith { diag_log "hmmm"; };
  13.  
  14. if !( local _veh ) exitWith {
  15.      diag_log "not local, remote exec";
  16.     _this remoteExec ["vehicleLoadout_fnc_setPylons", _veh, false];    
  17. };
  18.  
  19. diag_log "local, doing it";
  20.  
  21. private _isUAV = ( _veh in allUnitsUAV );
  22. private _trgt = _veh;
  23.  
  24.  
  25. if ( _isUAV ) then {
  26.     _trgt = objNull;
  27.     if ( isUAVConnected _veh ) then { _trgt = ((UAVControl _veh) select 0); };
  28. };
  29.  
  30. //store fuel, stop engine, remove fuel, stop vehicle
  31. private _fuel = fuel _veh;
  32. _veh engineOn false;
  33. _veh setFuel 0;
  34. _veh setVelocity [0,0,0];
  35.  
  36. private _vType = (typeOf _veh);
  37. private _vName = getText(configFile >> "CfgVehicles" >> _vType >> "DisplayName");
  38. private _sleep = (["vehicleLoadout", "sleep"] call core_fnc_getSetting);
  39.  
  40. private _msg = format[(["vehicleLoadout", "start"] call core_fnc_getSetting), _vName, (count _pylons)];
  41. [_msg, _trgt, _isUAV] call vehicleRepair_fnc_message;
  42. [_player, _msg] call common_fnc_systemChat;
  43.  
  44. //Need to be able to remove the weapons that are no longer going to be used.
  45. private _pylonMags = getPylonMagazines _veh;
  46. private _nonPylonMags = (magazines _veh) - _pylonMags;
  47.  
  48. {
  49.     private _weaponMags = getArray (configFile >> "cfgWeapons" >> _x >> "Magazines");
  50.     if (_nonPylonMags arrayIntersect _weaponMags isEqualTo []) then {
  51.          _veh removeWeapon _x;
  52.     };
  53. } forEach (weapons _veh);
  54.  
  55. sleep _sleep;
  56.  
  57. {
  58.     _x params ["_mag", "_turret"];
  59.    
  60.     private _current = (_forEachIndex + 1);
  61.     if ( _mag isEqualTo "" ) then {
  62.         _msg = format[(["vehicleLoadout", "emptyProgress"] call core_fnc_getSetting), _current];
  63.     } else {
  64.         private _magName = getText(configFile >> "cfgMagazines" >> _mag >> "displayName");
  65.         _msg = format[(["vehicleLoadout", "progress"] call core_fnc_getSetting), _magName, _current];    
  66.     };
  67.     [_msg, _trgt, _isUAV] call vehicleRepair_fnc_message;
  68.     [_player, _msg] call common_fnc_systemChat;
  69.        
  70.     _veh setPylonLoadout [(_forEachIndex + 1), _mag, false, _turret];
  71.    
  72.     sleep _sleep;
  73.    
  74. } forEach _pylons;
  75.  
  76. _msg = format[(["vehicleLoadout", "end"] call core_fnc_getSetting), _vName];
  77. [_msg, _trgt, _isUAV] call vehicleRepair_fnc_message;
  78. [_player, _msg] call common_fnc_systemChat;
  79.  
  80. _veh setFuel _fuel;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement