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

Map - Detect switchable flashlight attachments for map #7578

Merged
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
2 changes: 1 addition & 1 deletion addons/main/script_mod.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

// MINIMAL required version for the Mod. Components can specify others..
#define REQUIRED_VERSION 1.96
#define REQUIRED_CBA_VERSION {3,14,0}
#define REQUIRED_CBA_VERSION {3,15,0}

#ifdef COMPONENT_BEAUTIFIED
#define COMPONENT_NAME QUOTE(ACE3 - COMPONENT_BEAUTIFIED)
Expand Down
1 change: 1 addition & 0 deletions addons/map/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ PREP(simulateMapLight);
PREP(switchFlashlight);
PREP(updateMapEffects);
PREP(initMainMap);
PREP(isFlashlight);
2 changes: 2 additions & 0 deletions addons/map/XEH_postInitClient.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ LOG(MSG_INIT);
// Calculate the maximum zoom allowed for this map
call FUNC(determineZoom);

GVAR(flashlights) = [] call CBA_fnc_createNamespace;

["ace_settingsInitialized", {
if (isMultiplayer && {GVAR(DefaultChannel) != -1}) then {
//Set the chat channel once the map has finished loading
Expand Down
20 changes: 1 addition & 19 deletions addons/map/functions/fnc_getUnitFlashlights.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,4 @@

params ["_unit"];

private _flashlights = [];
private _cfgWeapons = configFile >> "CfgWeapons";

{
private _weaponConfig = _cfgWeapons >> _x;
if (
-1 < [
_weaponConfig >> "ItemInfo" >> "FlashLight",
_weaponConfig >> "FlashLight"
] findIf {
isText (_x >> "ACE_Flashlight_Colour")
|| {!(getArray (_x >> "ambient") in [[], [0,0,0]])}
}
) then {
_flashlights pushBack _x;
};
} forEach ([_unit, true] call CBA_fnc_uniqueUnitItems);

_flashlights
([_unit, true] call CBA_fnc_uniqueUnitItems) select {_x call FUNC(isFlashlight)} // return
43 changes: 43 additions & 0 deletions addons/map/functions/fnc_isFlashlight.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#include "script_component.hpp"
/*
* Author: veteran29
* Checks if the given item is a flashlight.
*
* Arguments:
* 0: Item Classname <STRING>
*
* Return Value:
* Is flashlight <BOOL>
*
* Example:
* ["acc_flashlight"] call ace_map_fnc_isFlashlight
*
* Public: No
*/

params [["_class", "", [""]]];

private _isFlashlight = GVAR(flashlights) getVariable _class;

if (isNil "_isFlashlight") then {
private _items = ([_class] + (_class call CBA_fnc_switchableAttachments));
private _cfgWeapons = configFile >> "CfgWeapons";

// if this item or any of the switchable items is a flashlight
_isFlashlight = _items findIf {
private _weaponConfig = _cfgWeapons >> _x;

[
_weaponConfig >> "ItemInfo" >> "FlashLight",
_weaponConfig >> "FlashLight"
] findIf {
isText (_x >> "ACE_Flashlight_Colour")
|| {!(getArray (_x >> "ambient") in [[], [0,0,0]])}
} != -1 // return
} != -1;

// cache value
GVAR(flashlights) setVariable [_class, _isFlashlight];
};

_isFlashlight // return