mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Map - Improve flashlight support (#6608)
* Improve flashlight support * Speed up items check loop * Speed up more * Remove useless var
This commit is contained in:
parent
8580cb250a
commit
1fe7c5c29c
@ -65,6 +65,7 @@ class CfgWeapons {
|
|||||||
ACE_Flashlight_Colour = "green";
|
ACE_Flashlight_Colour = "green";
|
||||||
ACE_Flashlight_Beam = QPATHTOF(UI\chemlight_shield_beam_green_ca.paa);
|
ACE_Flashlight_Beam = QPATHTOF(UI\chemlight_shield_beam_green_ca.paa);
|
||||||
ACE_Flashlight_Size = 0.8;
|
ACE_Flashlight_Size = 0.8;
|
||||||
|
ACE_Flashlight_Sound = 0;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@ -74,12 +75,10 @@ class CfgWeapons {
|
|||||||
displayName = CSTRING(Shield_Red_DisplayName);
|
displayName = CSTRING(Shield_Red_DisplayName);
|
||||||
descriptionShort = CSTRING(Shield_Red_DescriptionShort);
|
descriptionShort = CSTRING(Shield_Red_DescriptionShort);
|
||||||
picture = QPATHTOF(UI\ace_chemlight_shield_red_x_ca.paa);
|
picture = QPATHTOF(UI\ace_chemlight_shield_red_x_ca.paa);
|
||||||
class ItemInfo: CBA_MiscItem_ItemInfo {
|
class ItemInfo: ItemInfo {
|
||||||
mass = 1;
|
class FlashLight: FlashLight {
|
||||||
class FlashLight {
|
|
||||||
ACE_Flashlight_Colour = "red";
|
ACE_Flashlight_Colour = "red";
|
||||||
ACE_Flashlight_Beam = QPATHTOF(UI\chemlight_shield_beam_red_ca.paa);
|
ACE_Flashlight_Beam = QPATHTOF(UI\chemlight_shield_beam_red_ca.paa);
|
||||||
ACE_Flashlight_Size = 0.8;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@ -89,12 +88,10 @@ class CfgWeapons {
|
|||||||
displayName = CSTRING(Shield_Blue_DisplayName);
|
displayName = CSTRING(Shield_Blue_DisplayName);
|
||||||
descriptionShort = CSTRING(Shield_Blue_DescriptionShort);
|
descriptionShort = CSTRING(Shield_Blue_DescriptionShort);
|
||||||
picture = QPATHTOF(UI\ace_chemlight_shield_blue_x_ca.paa);
|
picture = QPATHTOF(UI\ace_chemlight_shield_blue_x_ca.paa);
|
||||||
class ItemInfo: CBA_MiscItem_ItemInfo {
|
class ItemInfo: ItemInfo {
|
||||||
mass = 1;
|
class FlashLight: FlashLight {
|
||||||
class FlashLight {
|
|
||||||
ACE_Flashlight_Colour = "blue";
|
ACE_Flashlight_Colour = "blue";
|
||||||
ACE_Flashlight_Beam = QPATHTOF(UI\chemlight_shield_beam_blue_ca.paa);
|
ACE_Flashlight_Beam = QPATHTOF(UI\chemlight_shield_beam_blue_ca.paa);
|
||||||
ACE_Flashlight_Size = 0.8;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@ -104,12 +101,10 @@ class CfgWeapons {
|
|||||||
displayName = CSTRING(Shield_Yellow_DisplayName);
|
displayName = CSTRING(Shield_Yellow_DisplayName);
|
||||||
descriptionShort = CSTRING(Shield_Yellow_DescriptionShort);
|
descriptionShort = CSTRING(Shield_Yellow_DescriptionShort);
|
||||||
picture = QPATHTOF(UI\ace_chemlight_shield_yellow_x_ca.paa);
|
picture = QPATHTOF(UI\ace_chemlight_shield_yellow_x_ca.paa);
|
||||||
class ItemInfo: CBA_MiscItem_ItemInfo {
|
class ItemInfo: ItemInfo {
|
||||||
mass = 1;
|
class FlashLight: FlashLight {
|
||||||
class FlashLight {
|
|
||||||
ACE_Flashlight_Colour = "yellow";
|
ACE_Flashlight_Colour = "yellow";
|
||||||
ACE_Flashlight_Beam = QPATHTOF(UI\chemlight_shield_beam_yellow_ca.paa);
|
ACE_Flashlight_Beam = QPATHTOF(UI\chemlight_shield_beam_yellow_ca.paa);
|
||||||
ACE_Flashlight_Size = 0.8;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@ -119,12 +114,10 @@ class CfgWeapons {
|
|||||||
displayName = CSTRING(Shield_Orange_DisplayName);
|
displayName = CSTRING(Shield_Orange_DisplayName);
|
||||||
descriptionShort = CSTRING(Shield_Orange_DescriptionShort);
|
descriptionShort = CSTRING(Shield_Orange_DescriptionShort);
|
||||||
picture = QPATHTOF(UI\ace_chemlight_shield_orange_x_ca.paa);
|
picture = QPATHTOF(UI\ace_chemlight_shield_orange_x_ca.paa);
|
||||||
class ItemInfo: CBA_MiscItem_ItemInfo {
|
class ItemInfo: ItemInfo {
|
||||||
mass = 1;
|
class FlashLight: FlashLight {
|
||||||
class FlashLight {
|
|
||||||
ACE_Flashlight_Colour = "orange";
|
ACE_Flashlight_Colour = "orange";
|
||||||
ACE_Flashlight_Beam = QPATHTOF(UI\chemlight_shield_beam_orange_ca.paa);
|
ACE_Flashlight_Beam = QPATHTOF(UI\chemlight_shield_beam_orange_ca.paa);
|
||||||
ACE_Flashlight_Size = 0.8;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@ -134,12 +127,10 @@ class CfgWeapons {
|
|||||||
displayName = CSTRING(Shield_White_DisplayName);
|
displayName = CSTRING(Shield_White_DisplayName);
|
||||||
descriptionShort = CSTRING(Shield_White_DescriptionShort);
|
descriptionShort = CSTRING(Shield_White_DescriptionShort);
|
||||||
picture = QPATHTOF(UI\ace_chemlight_shield_white_x_ca.paa);
|
picture = QPATHTOF(UI\ace_chemlight_shield_white_x_ca.paa);
|
||||||
class ItemInfo: CBA_MiscItem_ItemInfo {
|
class ItemInfo: ItemInfo {
|
||||||
mass = 1;
|
class FlashLight: FlashLight {
|
||||||
class FlashLight {
|
|
||||||
ACE_Flashlight_Colour = "white";
|
ACE_Flashlight_Colour = "white";
|
||||||
ACE_Flashlight_Beam = QPATHTOF(UI\chemlight_shield_beam_white_ca.paa);
|
ACE_Flashlight_Beam = QPATHTOF(UI\chemlight_shield_beam_white_ca.paa);
|
||||||
ACE_Flashlight_Size = 0.8;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -16,7 +16,6 @@ class CfgWeapons {
|
|||||||
ACE_Flashlight_Colour = "red";
|
ACE_Flashlight_Colour = "red";
|
||||||
ACE_Flashlight_Beam = QPATHTOF(UI\Flashlight_beam_red_ca.paa);
|
ACE_Flashlight_Beam = QPATHTOF(UI\Flashlight_beam_red_ca.paa);
|
||||||
ACE_Flashlight_Size = 1.75;
|
ACE_Flashlight_Size = 1.75;
|
||||||
ACE_Flashlight_Sound = 1;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@ -34,7 +33,6 @@ class CfgWeapons {
|
|||||||
ACE_Flashlight_Colour = "red";
|
ACE_Flashlight_Colour = "red";
|
||||||
ACE_Flashlight_Beam = QPATHTOF(UI\Flashlight_beam_red_ca.paa);
|
ACE_Flashlight_Beam = QPATHTOF(UI\Flashlight_beam_red_ca.paa);
|
||||||
ACE_Flashlight_Size = 1.5;
|
ACE_Flashlight_Size = 1.5;
|
||||||
ACE_Flashlight_Sound = 1;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@ -52,7 +50,6 @@ class CfgWeapons {
|
|||||||
ACE_Flashlight_Colour = "white";
|
ACE_Flashlight_Colour = "white";
|
||||||
ACE_Flashlight_Beam = QPATHTOF(UI\Flashlight_beam_white_ca.paa);
|
ACE_Flashlight_Beam = QPATHTOF(UI\Flashlight_beam_white_ca.paa);
|
||||||
ACE_Flashlight_Size = 2.15;
|
ACE_Flashlight_Size = 2.15;
|
||||||
ACE_Flashlight_Sound = 1;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -5,7 +5,7 @@ class CfgVehicles {
|
|||||||
class ACE_MapFlashlight {
|
class ACE_MapFlashlight {
|
||||||
displayName = CSTRING(Action_Flashlights);
|
displayName = CSTRING(Action_Flashlights);
|
||||||
icon = QUOTE(\a3\ui_f\data\IGUI\Cfg\VehicleToggles\lightsiconon_ca.paa);
|
icon = QUOTE(\a3\ui_f\data\IGUI\Cfg\VehicleToggles\lightsiconon_ca.paa);
|
||||||
condition = QUOTE(GVAR(mapIllumination) && visibleMap && {count ([ACE_player] call FUNC(getUnitFlashlights)) > 0});
|
condition = QUOTE(GVAR(mapIllumination) && visibleMap && {!([] isEqualTo (_player call FUNC(getUnitFlashlights)))});
|
||||||
statement = "true";
|
statement = "true";
|
||||||
exceptions[] = {"isNotDragging", "notOnMap", "isNotInside", "isNotSitting"};
|
exceptions[] = {"isNotDragging", "notOnMap", "isNotInside", "isNotSitting"};
|
||||||
insertChildren = QUOTE(_this call DFUNC(compileFlashlightMenu));
|
insertChildren = QUOTE(_this call DFUNC(compileFlashlightMenu));
|
||||||
|
@ -8,7 +8,7 @@ class CfgWeapons {
|
|||||||
class FlashLight {
|
class FlashLight {
|
||||||
ACE_Flashlight_Colour = "white";
|
ACE_Flashlight_Colour = "white";
|
||||||
ACE_Flashlight_Beam = QPATHTOF(UI\Flashlight_beam_white_ca.paa);
|
ACE_Flashlight_Beam = QPATHTOF(UI\Flashlight_beam_white_ca.paa);
|
||||||
ACE_Flashlight_Size = 2.75;
|
ACE_Flashlight_Size = DEFAULT_FLASHLIGHT_SIZE;
|
||||||
ACE_Flashlight_Sound = 1;
|
ACE_Flashlight_Sound = 1;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@ -18,7 +18,7 @@ class CfgWeapons {
|
|||||||
class FlashLight {
|
class FlashLight {
|
||||||
ACE_Flashlight_Colour = "white";
|
ACE_Flashlight_Colour = "white";
|
||||||
ACE_Flashlight_Beam = QPATHTOF(UI\Flashlight_beam_white_ca.paa);
|
ACE_Flashlight_Beam = QPATHTOF(UI\Flashlight_beam_white_ca.paa);
|
||||||
ACE_Flashlight_Size = 2.75;
|
ACE_Flashlight_Size = DEFAULT_FLASHLIGHT_SIZE;
|
||||||
ACE_Flashlight_Sound = 1;
|
ACE_Flashlight_Sound = 1;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -7,6 +7,7 @@ PREP(determineZoom);
|
|||||||
PREP(flashlightGlow);
|
PREP(flashlightGlow);
|
||||||
PREP(getUnitFlashlights);
|
PREP(getUnitFlashlights);
|
||||||
PREP(moduleMap);
|
PREP(moduleMap);
|
||||||
|
PREP(needPlaySound);
|
||||||
PREP(onDrawMap);
|
PREP(onDrawMap);
|
||||||
PREP(simulateMapLight);
|
PREP(simulateMapLight);
|
||||||
PREP(switchFlashlight);
|
PREP(switchFlashlight);
|
||||||
|
@ -50,15 +50,15 @@ call FUNC(determineZoom);
|
|||||||
params ["_player", "_mapOn"];
|
params ["_player", "_mapOn"];
|
||||||
private _unitLight = _player getVariable [QGVAR(flashlight), ["", objNull]];
|
private _unitLight = _player getVariable [QGVAR(flashlight), ["", objNull]];
|
||||||
_unitLight params ["_flashlight", "_glow"];
|
_unitLight params ["_flashlight", "_glow"];
|
||||||
private _flashlightOn = !(_flashlight isEqualTo "");
|
|
||||||
if (_mapOn) then {
|
if (_mapOn) then {
|
||||||
if (_flashlightOn && {isNull _glow}) then {
|
if (!(_flashlight isEqualTo "") && {isNull _glow}) then {
|
||||||
[_player, _flashlight] call FUNC(flashlightGlow);
|
[_player, _flashlight] call FUNC(flashlightGlow);
|
||||||
playSound QGVAR(flashlightClick);
|
if ([_player, _flashlight] call FUNC(needPlaySound)) then {playSound QGVAR(flashlightClick)};
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
if (!isNull _glow) then {
|
if (!isNull _glow) then {
|
||||||
[_player, ""] call FUNC(flashlightGlow);
|
[_player, ""] call FUNC(flashlightGlow);
|
||||||
|
if ([_player, _flashlight] call FUNC(needPlaySound)) then {playSound QGVAR(flashlightClick)};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}] call CBA_fnc_addPlayerEventHandler;
|
}] call CBA_fnc_addPlayerEventHandler;
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
* Flashlight classnames (empty for none) <ARRAY>
|
* Flashlight classnames (empty for none) <ARRAY>
|
||||||
*
|
*
|
||||||
* Example:
|
* Example:
|
||||||
* [unit] call ace_map_fnc_getUnitFlashlights;
|
* player call ace_map_fnc_getUnitFlashlights
|
||||||
*
|
*
|
||||||
* Public: No
|
* Public: No
|
||||||
*/
|
*/
|
||||||
@ -18,11 +18,21 @@
|
|||||||
params ["_unit"];
|
params ["_unit"];
|
||||||
|
|
||||||
private _flashlights = [];
|
private _flashlights = [];
|
||||||
|
private _cfgWeapons = configFile >> "CfgWeapons";
|
||||||
|
|
||||||
{
|
{
|
||||||
if (isText (configFile >> "CfgWeapons" >> _x >> "ItemInfo" >> "FlashLight" >> "ACE_Flashlight_Colour")) then {
|
private _weaponConfig = _cfgWeapons >> _x;
|
||||||
_flashlights pushBackUnique _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 call EFUNC(common,uniqueItems));
|
} forEach ([_unit, true] call CBA_fnc_uniqueUnitItems);
|
||||||
|
|
||||||
_flashlights
|
_flashlights
|
||||||
|
42
addons/map/functions/fnc_needPlaySound.sqf
Normal file
42
addons/map/functions/fnc_needPlaySound.sqf
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
#include "script_component.hpp"
|
||||||
|
/*
|
||||||
|
* Author: Dystopian
|
||||||
|
* Checks if sound needs to be played when flashlight is toggled.
|
||||||
|
*
|
||||||
|
* Arguments:
|
||||||
|
* 0: Unit <OBJECT>
|
||||||
|
* 1: Flashlight <STRING>
|
||||||
|
*
|
||||||
|
* Return Value:
|
||||||
|
* Need to play sound <BOOL>
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* [player, "acc_flashlight"] call ace_map_fnc_needPlaySound
|
||||||
|
*
|
||||||
|
* Public: No
|
||||||
|
*/
|
||||||
|
|
||||||
|
params ["_unit", "_flashlight"];
|
||||||
|
|
||||||
|
if (_flashlight isEqualTo "") exitWith {
|
||||||
|
LOG("empty flashlight");
|
||||||
|
false
|
||||||
|
};
|
||||||
|
|
||||||
|
private _currentWeapon = currentWeapon _unit;
|
||||||
|
if (
|
||||||
|
_unit isFlashlightOn _currentWeapon
|
||||||
|
// _currentWeapon==_flashlight should be checked here but it's not supported by isFlashlightOn
|
||||||
|
&& {_flashlight isEqualTo ((weaponsItems _unit select {(_x select 0) isEqualTo _currentWeapon}) select 0 select 2)}
|
||||||
|
) exitWith {
|
||||||
|
TRACE_1("weapon flashlight is on",_flashlight);
|
||||||
|
false
|
||||||
|
};
|
||||||
|
|
||||||
|
private _config = configFile >> "CfgWeapons" >> _flashlight >> "ItemInfo" >> "FlashLight";
|
||||||
|
if (!isClass _config) exitWith {
|
||||||
|
TRACE_1("weapon with unmountable flashlight",_flashlight);
|
||||||
|
true
|
||||||
|
};
|
||||||
|
|
||||||
|
0 < [_config >> "ACE_Flashlight_Sound", "number", 1] call CBA_fnc_getConfigEntry
|
@ -55,9 +55,9 @@ if (_flashlight == "") then {
|
|||||||
private _mousePos = GVAR(mousePos);
|
private _mousePos = GVAR(mousePos);
|
||||||
|
|
||||||
//flashlight settings
|
//flashlight settings
|
||||||
private _cfg = (configFile >> "CfgWeapons" >> _flashlight >> "ItemInfo" >> "FlashLight");
|
private _cfg = configFile >> "CfgWeapons" >> _flashlight >> "ItemInfo" >> "FlashLight";
|
||||||
private _size = getNumber (_cfg >> "ACE_Flashlight_Size");
|
private _size = [_cfg >> "ACE_Flashlight_Size", "number", DEFAULT_FLASHLIGHT_SIZE] call CBA_fnc_getConfigEntry;
|
||||||
private _flashTex = getText (_cfg >> "ACE_Flashlight_Beam");
|
private _flashTex = [_cfg >> "ACE_Flashlight_Beam", "text", QPATHTOF(UI\Flashlight_beam_white_ca.paa)] call CBA_fnc_getConfigEntry;
|
||||||
private _beamSize = (safeZoneW/safeZoneWAbs) * _screenSize / _size;
|
private _beamSize = (safeZoneW/safeZoneWAbs) * _screenSize / _size;
|
||||||
|
|
||||||
//after 5x zoom, it's simulated to be fixed (it actually gets bigger relative to zoom)
|
//after 5x zoom, it's simulated to be fixed (it actually gets bigger relative to zoom)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
/*
|
/*
|
||||||
* Author: voioper
|
* Author: voiper
|
||||||
* Switch flashlight on/off.
|
* Switch flashlight on/off.
|
||||||
*
|
*
|
||||||
* Arguments:
|
* Arguments:
|
||||||
@ -26,12 +26,7 @@ if (GVAR(mapGlow)) then {
|
|||||||
_glow = [_unit, _newFlashlight, false] call FUNC(flashlightGlow);
|
_glow = [_unit, _newFlashlight, false] call FUNC(flashlightGlow);
|
||||||
};
|
};
|
||||||
|
|
||||||
private _config = (configFile >> "CfgWeapons");
|
if (-1 < [_newFlashlight, _flashlight] findIf {[_unit, _x] call FUNC(needPlaySound)}) then {
|
||||||
|
|
||||||
if (
|
|
||||||
(getNumber (_config >> _newFlashlight >> "ItemInfo" >> "FlashLight" >> "ACE_Flashlight_Sound") > 0) ||
|
|
||||||
{getNumber (_config >> _flashlight >> "ItemInfo" >> "FlashLight" >> "ACE_Flashlight_Sound") > 0}
|
|
||||||
) then {
|
|
||||||
playSound QGVAR(flashlightClick);
|
playSound QGVAR(flashlightClick);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -19,3 +19,5 @@
|
|||||||
#define MARKERNAME_MAPTOOL_FIXED "ACE_MapToolFixed"
|
#define MARKERNAME_MAPTOOL_FIXED "ACE_MapToolFixed"
|
||||||
#define MARKERNAME_MAPTOOL_ROTATINGNORMAL "ACE_MapToolRotatingNormal"
|
#define MARKERNAME_MAPTOOL_ROTATINGNORMAL "ACE_MapToolRotatingNormal"
|
||||||
#define MARKERNAME_MAPTOOL_ROTATINGSMALL "ACE_MapToolRotatingSmall"
|
#define MARKERNAME_MAPTOOL_ROTATINGSMALL "ACE_MapToolRotatingSmall"
|
||||||
|
|
||||||
|
#define DEFAULT_FLASHLIGHT_SIZE 2.75
|
||||||
|
@ -158,18 +158,4 @@ class CfgWeapons {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Flashlights */
|
|
||||||
class InventoryFlashLightItem_Base_F;
|
|
||||||
|
|
||||||
class RH_SFM952V: ItemCore {
|
|
||||||
class ItemInfo: InventoryFlashLightItem_Base_F {
|
|
||||||
class FlashLight {
|
|
||||||
ACE_Flashlight_Colour = "white";
|
|
||||||
ACE_Flashlight_Beam = QPATHTOEF(map,UI\Flashlight_beam_white_ca.paa);
|
|
||||||
ACE_Flashlight_Size = 2.75;
|
|
||||||
ACE_Flashlight_Sound = 1;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user