Map - Detect switchable flashlight attachments for map (#7578)

This commit is contained in:
Filip Maciejewski 2020-04-07 17:48:32 +02:00 committed by GitHub
parent cf3b0467ac
commit 64c30a94be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 48 additions and 20 deletions

View File

@ -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)

View File

@ -13,3 +13,4 @@ PREP(simulateMapLight);
PREP(switchFlashlight);
PREP(updateMapEffects);
PREP(initMainMap);
PREP(isFlashlight);

View File

@ -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

View File

@ -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

View File

@ -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