Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pylons - Fix old weapons not being removed #6100

Merged
merged 3 commits into from
Feb 10, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion addons/pylons/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,17 @@
} forEach GVAR(aircraftWithPylons);

[QGVAR(setPylonLoadOutEvent), {
params ["_aircraft", "_pylonIndex", "_pylon", "_turret"];
params ["_aircraft", "_pylonIndex", "_pylon", "_turret", "_removeWeapon"];
TRACE_5("setPylonLoadOutEvent",_aircraft,_pylonIndex,_pylon,_turret,_removeWeapon);
_aircraft setPylonLoadOut [_pylonIndex, _pylon, false, _turret];
if (_removeWeapon != "") then {
{
if (_aircraft turretLocal _x) then {
TRACE_3("removing",_aircraft,_x,_removeWeapon);
_aircraft removeWeaponTurret [_removeWeapon, _x];
};
} forEach [[-1], [0]];
};
}] call CBA_fnc_addEventHandler;

[QGVAR(setAmmoOnPylonEvent), {
Expand Down
7 changes: 5 additions & 2 deletions addons/pylons/functions/fnc_configurePylons.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,19 @@ 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 _removeWeapon = "";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe call it _weaponToRemove?

private _currentPylonMagazine = (getPylonMagazines GVAR(currentAircraft)) select _pylonIndex;
if (_currentPylonMagazine != "") then {
private _allPylonWeapons = (getPylonMagazines GVAR(currentAircraft)) apply {
getText (configFile >> "CfgMagazines" >> _x >> "pylonWeapon")
};
private _pylonWeapon = _allPylonWeapons select _pylonIndex;
if (({_x == _pylonWeapon} count _allPylonWeapons) == 1) then {
GVAR(currentAircraft) removeWeaponGlobal _pylonWeapon;
TRACE_2("Removing unused weapon",_pylonWeapon,_allPylonWeapons);
_removeWeapon = _pylonWeapon;
};
};

Expand All @@ -47,7 +50,7 @@ if (_currentPylon == count _pylonsToConfigure) exitWith {};

[
QGVAR(setPylonLoadOutEvent),
[GVAR(currentAircraft), _pylonIndex + 1, _pylonMagazine, _turret]
[GVAR(currentAircraft), _pylonIndex + 1, _pylonMagazine, _turret, _removeWeapon]
] call CBA_fnc_globalEvent;

private _count = if (GVAR(rearmNewPylons) || {GVAR(isCurator)}) then {
Expand Down
5 changes: 4 additions & 1 deletion addons/pylons/functions/fnc_showDialog.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a rogue space in the macro.

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;
};