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

switchUnits - Fix switching units not working (#6188) #7676

Merged
merged 1 commit into from
Jun 7, 2020
Merged
Show file tree
Hide file tree
Changes from all 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: 4 additions & 7 deletions addons/switchunits/functions/fnc_addMapFunction.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,9 @@
* Public: No
*/

params ["_unit", "_sides"];

["theMapClick", "onMapSingleClick", {
// IGNORE_PRIVATE_WARNING(_pos,_shift,_alt)
addMissionEventHandler ["MapSingleClick", {
params ["", "_pos"];
if (alive ACE_player && {GVAR(OriginalUnit) getVariable ["ACE_CanSwitchUnits", false]}) then {
[_this, _pos, _shift, _alt] call FUNC(handleMapClick);
[GVAR(switchableSides), _pos] call FUNC(handleMapClick);
};

}, [_unit, _sides]] call BIS_fnc_addStackedEventHandler;
}];
3 changes: 1 addition & 2 deletions addons/switchunits/functions/fnc_handleMapClick.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
* Public: No
*/

params ["_faction", "_pos"];
_faction params ["", "_sides"];
params ["_sides", "_pos"];

private _nearestObjects = nearestObjects [_pos, ["Man"], 15];

Expand Down
6 changes: 3 additions & 3 deletions addons/switchunits/functions/fnc_initPlayer.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
* Public: No
*/

params ["_playerUnit", "_sides"];
params ["_playerUnit"];

if (vehicle _playerUnit == _playerUnit) then {
[_sides] call FUNC(markAiOnMap);
[GVAR(switchableSides)] call FUNC(markAiOnMap);

_playerUnit setVariable [QGVAR(IsPlayerUnit), true, true];
_playerUnit allowDamage false;
Expand All @@ -38,5 +38,5 @@ if (vehicle _playerUnit == _playerUnit) then {

[_playerUnit, "forceWalk", "ACE_SwitchUnits", true] call EFUNC(common,statusEffect_set);

[_playerUnit, _sides] call FUNC(addMapFunction);
[] call FUNC(addMapFunction);
};
12 changes: 6 additions & 6 deletions addons/switchunits/functions/fnc_startSwitchUnits.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
params ["_player"];

if (GVAR(EnableSwitchUnits)) then {
private _sides = [];
GVAR(switchableSides) = [];

if (GVAR(SwitchToWest)) then {_sides pushBack west;};
if (GVAR(SwitchToEast)) then {_sides pushBack east;};
if (GVAR(SwitchToIndependent)) then {_sides pushBack independent;};
if (GVAR(SwitchToCivilian)) then {_sides pushBack civilian;};
if (GVAR(SwitchToWest)) then {GVAR(switchableSides) pushBack west;};
if (GVAR(SwitchToEast)) then {GVAR(switchableSides) pushBack east;};
if (GVAR(SwitchToIndependent)) then {GVAR(switchableSides) pushBack independent;};
if (GVAR(SwitchToCivilian)) then {GVAR(switchableSides) pushBack civilian;};

if (_player getVariable ["ACE_CanSwitchUnits", false]) then {
[_player, _sides] call FUNC(initPlayer);
[_player] call FUNC(initPlayer);
};
};