Advertisement
Guest User

POC Attachements2

a guest
Jul 8th, 2010
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.67 KB | None | 0 0
  1. if ((_this select 0) != (_this select 1)) exitwith {hintsilent "Nice try, dumbass ;)"};
  2. private ["_unit", "_attachement", "_actualWeapon", "_finalSelection", "_remainingAttachements", "_possibleDowngrades", "_hits", "_type", "_muzzles"];
  3. _unit = _this select 0;
  4. _attachement = _this select 3;
  5. _actualWeapon = primaryWeapon _unit;
  6. _finalSelection = "";
  7.  
  8. if (!(_attachement in (getArray(configFile >> "cfgWeapons" >> _actualWeapon >> "hasAttached")))) exitwith {hintsilent format ["No attachements to remove on your %1", _actualWeapon]};
  9. _remainingAttachements = (getArray(configFile >> "cfgWeapons" >> _actualWeapon >> "hasAttached")) - [_attachement];
  10. _possibleDowngrades = getArray (configFile >> "cfgWeapons" >> _actualWeapon >> "devolvesTo");
  11.  
  12. //Check which devolving class should be used.
  13.  
  14. {
  15.     if (count (getArray(configFile >> "cfgWeapons" >> _x >> "hasAttached")) == count _remainingAttachements) then {
  16.         _hits = 0;
  17.         {
  18.             if (_x in _remainingAttachements) then {_hits = _hits + 1};
  19.         } foreach (getArray(configFile >> "cfgWeapons" >> _x >> "hasAttached"));
  20.         if (count _remainingAttachements == _hits) then {_finalSelection = _x};
  21.     };
  22. } foreach _possibleDowngrades;
  23.  
  24. if (_finalSelection == "") then {
  25.     hintsilent format ["You can't remove %1 from your %2", _attachement, _actualWeapon];
  26. } else {
  27.     _unit removeWeapon _actualWeapon;
  28.     _unit addWeapon _finalSelection;
  29.     _unit addWeapon _attachement;
  30.     if ((primaryWeapon _unit) != "") then {
  31.         _type = primaryWeapon _unit;
  32.         _muzzles = getArray(configFile >> "cfgWeapons" >> _type >> "muzzles");
  33.         if (count _muzzles > 1) then {
  34.             _unit selectWeapon (_muzzles select 0);
  35.         } else {
  36.             _unit selectWeapon _type;
  37.         };
  38.     };
  39. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement