Skip to content

Commit

Permalink
close #54 filter scopes for nightvision
Browse files Browse the repository at this point in the history
  • Loading branch information
McDiod committed Oct 15, 2019
1 parent 70eaa74 commit 2bdd25b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions functions/selectWeapons/cfgFunctions.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
class gungame_selectWeapons {
class selectWeapons {
class blacklistUtility {};
class filterNvScopes {};
class getAllAvailableWeapons {};
class hasDamagingDefaultMag {};
class isSniper {};
Expand Down
17 changes: 17 additions & 0 deletions functions/selectWeapons/fn_filterNvScopes.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include "component.hpp"

params [["_scopes",[]]];

private _scopesNoNV = [];

{
_allOpticsModes = "true" configClasses (configfile >> "CfgWeapons" >> _x >> "ItemInfo" >> "OpticsModes");
_firstNvModeID = _allOpticsModes findIf {
_allVisionModes = ([_x,"visionMode",[]] call BIS_fnc_returnConfigEntry) apply {toLower _x};
"nvg" in _allVisionModes
};

if (_firstNvModeID < 0) then {_scopesNoNV pushBack _x};
} forEach _scopes;

_scopesNoNV
2 changes: 2 additions & 0 deletions functions/selectWeapons/fn_selectWeapons.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ private _fnc_selectWeapons = {
_compatibleScopes = getArray (configFile >> "CfgWeapons" >> _weapon >> "WeaponSlotsInfo" >> "CowsSlot" >> "compatibleItems");
};

_compatibleScopes = [_compatibleScopes] call FUNC(filterNvScopes);

if (count _compatibleScopes > 0) then {
GVAR(scopes) pushBack selectRandom _compatibleScopes;
} else {
Expand Down

0 comments on commit 2bdd25b

Please sign in to comment.