mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Map - Detect switchable flashlight attachments for map (#7578)
This commit is contained in:
parent
cf3b0467ac
commit
64c30a94be
@ -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)
|
||||
|
@ -13,3 +13,4 @@ PREP(simulateMapLight);
|
||||
PREP(switchFlashlight);
|
||||
PREP(updateMapEffects);
|
||||
PREP(initMainMap);
|
||||
PREP(isFlashlight);
|
||||
|
@ -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
|
||||
|
@ -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
addons/map/functions/fnc_isFlashlight.sqf
Normal file
43
addons/map/functions/fnc_isFlashlight.sqf
Normal 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
|
Loading…
Reference in New Issue
Block a user