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

Remove unit from laser pointer list if laser removed #5190

Merged
merged 1 commit into from
May 31, 2017
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
29 changes: 16 additions & 13 deletions addons/laserpointer/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -41,30 +41,33 @@ GVAR(greenLaserUnits) = [];
params ["_unit"];

private _weapon = currentWeapon _unit;
if (!(_unit isFlashlightOn _weapon)) exitWith {
GVAR(redLaserUnits) deleteAt (GVAR(redLaserUnits) find _unit);
GVAR(greenLaserUnits) deleteAt (GVAR(greenLaserUnits) find _unit);
};

private _laser = [(_unit weaponAccessories _weapon) select 1] param [0, ""];

if (_laser isEqualTo "") exitWith {};
if (_laser isEqualTo "") exitWith {
GVAR(redLaserUnits) deleteAt (GVAR(redLaserUnits) find _unit);
GVAR(greenLaserUnits) deleteAt (GVAR(greenLaserUnits) find _unit);
};

private _laserID = GVAR(laserClassesCache) getVariable _laser;

if (isNil "_laserID") then {
_laserID = getNumber (configFile >> "CfgWeapons" >> _laser >> "ACE_laserpointer");
GVAR(laserClassesCache) setVariable [_laser, _laserID];
};
TRACE_3("",_weapon,_laser,_laserID);

if (_unit isFlashlightOn _weapon) then {
if (_laserID isEqualTo 1) exitWith {
GVAR(redLaserUnits) pushBackUnique _unit;
GVAR(greenLaserUnits) deleteAt (GVAR(greenLaserUnits) find _unit);
};
if (_laserID isEqualTo 1) exitWith {
GVAR(redLaserUnits) pushBackUnique _unit;
GVAR(greenLaserUnits) deleteAt (GVAR(greenLaserUnits) find _unit);
};

if (_laserID isEqualTo 2) exitWith {
GVAR(greenLaserUnits) pushBackUnique _unit;
GVAR(redLaserUnits) deleteAt (GVAR(redLaserUnits) find _unit);
};
} else {
if (_laserID isEqualTo 2) exitWith {
GVAR(greenLaserUnits) pushBackUnique _unit;
GVAR(redLaserUnits) deleteAt (GVAR(redLaserUnits) find _unit);
GVAR(greenLaserUnits) deleteAt (GVAR(greenLaserUnits) find _unit);
};
};

Expand Down
4 changes: 2 additions & 2 deletions addons/laserpointer/functions/fnc_getNearUnits.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* None
*
* Return Value:
* None
* Near Units <ARRAY>
*
* Public: No
*/
Expand All @@ -15,7 +15,7 @@
private _camPosAGL = positionCameraToWorld [0, 0, 0];

// handle RHS / bugged vehicle slots
if !((_camPosAGL select 0) isEqualType 0) exitWith {};
if !((_camPosAGL select 0) isEqualType 0) exitWith { [] };

private _nearUnits = [];

Expand Down