Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if ((_this select 0) != (_this select 1)) exitwith {hintsilent "Nice try, dumbass ;)"};
- private ["_unit", "_attachement", "_actualWeapon", "_finalSelection", "_remainingAttachements", "_possibleDowngrades", "_hits", "_type", "_muzzles"];
- _unit = _this select 0;
- _attachement = _this select 3;
- _actualWeapon = primaryWeapon _unit;
- _finalSelection = "";
- if (!(_attachement in (getArray(configFile >> "cfgWeapons" >> _actualWeapon >> "hasAttached")))) exitwith {hintsilent format ["No attachements to remove on your %1", _actualWeapon]};
- _remainingAttachements = (getArray(configFile >> "cfgWeapons" >> _actualWeapon >> "hasAttached")) - [_attachement];
- _possibleDowngrades = getArray (configFile >> "cfgWeapons" >> _actualWeapon >> "devolvesTo");
- //Check which devolving class should be used.
- {
- if (count (getArray(configFile >> "cfgWeapons" >> _x >> "hasAttached")) == count _remainingAttachements) then {
- _hits = 0;
- {
- if (_x in _remainingAttachements) then {_hits = _hits + 1};
- } foreach (getArray(configFile >> "cfgWeapons" >> _x >> "hasAttached"));
- if (count _remainingAttachements == _hits) then {_finalSelection = _x};
- };
- } foreach _possibleDowngrades;
- if (_finalSelection == "") then {
- hintsilent format ["You can't remove %1 from your %2", _attachement, _actualWeapon];
- } else {
- _unit removeWeapon _actualWeapon;
- _unit addWeapon _finalSelection;
- _unit addWeapon _attachement;
- if ((primaryWeapon _unit) != "") then {
- _type = primaryWeapon _unit;
- _muzzles = getArray(configFile >> "cfgWeapons" >> _type >> "muzzles");
- if (count _muzzles > 1) then {
- _unit selectWeapon (_muzzles select 0);
- } else {
- _unit selectWeapon _type;
- };
- };
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement