diff --git a/addons/pylons/XEH_postInit.sqf b/addons/pylons/XEH_postInit.sqf index 8dae8d4552..72a07078d0 100644 --- a/addons/pylons/XEH_postInit.sqf +++ b/addons/pylons/XEH_postInit.sqf @@ -28,8 +28,17 @@ } forEach GVAR(aircraftWithPylons); [QGVAR(setPylonLoadOutEvent), { - params ["_aircraft", "_pylonIndex", "_pylon", "_turret"]; + params ["_aircraft", "_pylonIndex", "_pylon", "_turret", "_weaponToRemove"]; + TRACE_5("setPylonLoadOutEvent",_aircraft,_pylonIndex,_pylon,_turret,_weaponToRemove); _aircraft setPylonLoadOut [_pylonIndex, _pylon, false, _turret]; + if (_weaponToRemove != "") then { + { + if (_aircraft turretLocal _x) then { + TRACE_3("removing",_aircraft,_x,_weaponToRemove); + _aircraft removeWeaponTurret [_weaponToRemove, _x]; + }; + } forEach [[-1], [0]]; + }; }] call CBA_fnc_addEventHandler; [QGVAR(setAmmoOnPylonEvent), { diff --git a/addons/pylons/functions/fnc_configurePylons.sqf b/addons/pylons/functions/fnc_configurePylons.sqf index 2fbc91e949..401063f8a9 100644 --- a/addons/pylons/functions/fnc_configurePylons.sqf +++ b/addons/pylons/functions/fnc_configurePylons.sqf @@ -27,8 +27,10 @@ if (_currentPylon == count _pylonsToConfigure) exitWith {}; { (_this select 0) params ["_pylonsToConfigure", "_currentPylon"]; private _pylonIndex = _pylonsToConfigure select _currentPylon; + TRACE_2("",_currentPylon,_pylonIndex); // Remove the weapon of current pylon from aircraft IF weapon is only on this pylon + private _weaponToRemove = ""; private _currentPylonMagazine = (getPylonMagazines GVAR(currentAircraft)) select _pylonIndex; if (_currentPylonMagazine != "") then { private _allPylonWeapons = (getPylonMagazines GVAR(currentAircraft)) apply { @@ -36,7 +38,8 @@ if (_currentPylon == count _pylonsToConfigure) exitWith {}; }; private _pylonWeapon = _allPylonWeapons select _pylonIndex; if (({_x == _pylonWeapon} count _allPylonWeapons) == 1) then { - GVAR(currentAircraft) removeWeaponGlobal _pylonWeapon; + TRACE_2("Removing unused weapon",_pylonWeapon,_allPylonWeapons); + _weaponToRemove = _pylonWeapon; }; }; @@ -47,7 +50,7 @@ if (_currentPylon == count _pylonsToConfigure) exitWith {}; [ QGVAR(setPylonLoadOutEvent), - [GVAR(currentAircraft), _pylonIndex + 1, _pylonMagazine, _turret] + [GVAR(currentAircraft), _pylonIndex + 1, _pylonMagazine, _turret, _weaponToRemove] ] call CBA_fnc_globalEvent; private _count = if (GVAR(rearmNewPylons) || {GVAR(isCurator)}) then { diff --git a/addons/pylons/functions/fnc_showDialog.sqf b/addons/pylons/functions/fnc_showDialog.sqf index 47b6585c89..5be18d20e8 100644 --- a/addons/pylons/functions/fnc_showDialog.sqf +++ b/addons/pylons/functions/fnc_showDialog.sqf @@ -149,7 +149,10 @@ if (!GVAR(isCurator)) then { isNull (GVAR(currentAircraft) getVariable [QGVAR(currentUser), objNull]) || {(ace_player distanceSqr GVAR(currentAircraft)) > GVAR(searchDistanceSqr)} }, { - [localize LSTRING(TooFar), false, 5] call EFUNC(common,displayText); + TRACE_3("disconnect/far",GVAR(currentAircraft),ace_player distance GVAR(currentAircraft),GVAR(currentAircraft) getVariable QGVAR(currentUser)); + if ((ace_player distanceSqr GVAR(currentAircraft)) > GVAR(searchDistanceSqr)) then { + [localize LSTRING(TooFar), false, 5] call EFUNC(common,displayText); + }; call FUNC(onButtonClose); }] call CBA_fnc_waitUntilAndExecute; };