From 87c12a94a9236edd756acc9566489660a406d07d Mon Sep 17 00:00:00 2001 From: BaerMitUmlaut Date: Wed, 5 Sep 2018 00:47:40 +0200 Subject: [PATCH 01/12] Initial IR flashlight tests --- addons/irlight/$PBOPREFIX$ | 1 + addons/irlight/CfgEventHandlers.hpp | 17 +++++++ addons/irlight/CfgJointRails.hpp | 6 +++ addons/irlight/CfgWeapons.hpp | 45 ++++++++++++++++ addons/irlight/README.md | 11 ++++ addons/irlight/XEH_PREP.hpp | 3 ++ addons/irlight/XEH_postInit.sqf | 8 +++ addons/irlight/XEH_preInit.sqf | 27 ++++++++++ addons/irlight/XEH_preStart.sqf | 3 ++ addons/irlight/config.cpp | 19 +++++++ .../functions/fnc_handleLoadoutChanged.sqf | 3 ++ .../functions/fnc_handleVisionModeChanged.sqf | 13 +++++ .../functions/fnc_updateWeaponLights.sqf | 51 +++++++++++++++++++ addons/irlight/functions/script_component.hpp | 1 + addons/irlight/script_component.hpp | 17 +++++++ 15 files changed, 225 insertions(+) create mode 100644 addons/irlight/$PBOPREFIX$ create mode 100644 addons/irlight/CfgEventHandlers.hpp create mode 100644 addons/irlight/CfgJointRails.hpp create mode 100644 addons/irlight/CfgWeapons.hpp create mode 100644 addons/irlight/README.md create mode 100644 addons/irlight/XEH_PREP.hpp create mode 100644 addons/irlight/XEH_postInit.sqf create mode 100644 addons/irlight/XEH_preInit.sqf create mode 100644 addons/irlight/XEH_preStart.sqf create mode 100644 addons/irlight/config.cpp create mode 100644 addons/irlight/functions/fnc_handleLoadoutChanged.sqf create mode 100644 addons/irlight/functions/fnc_handleVisionModeChanged.sqf create mode 100644 addons/irlight/functions/fnc_updateWeaponLights.sqf create mode 100644 addons/irlight/functions/script_component.hpp create mode 100644 addons/irlight/script_component.hpp diff --git a/addons/irlight/$PBOPREFIX$ b/addons/irlight/$PBOPREFIX$ new file mode 100644 index 00000000000..5bb6f986811 --- /dev/null +++ b/addons/irlight/$PBOPREFIX$ @@ -0,0 +1 @@ +z\ace\addons\irlight diff --git a/addons/irlight/CfgEventHandlers.hpp b/addons/irlight/CfgEventHandlers.hpp new file mode 100644 index 00000000000..0d3301d6e0a --- /dev/null +++ b/addons/irlight/CfgEventHandlers.hpp @@ -0,0 +1,17 @@ +class Extended_PreStart_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_preStart)); + }; +}; + +class Extended_PreInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_preInit)); + }; +}; + +class Extended_PostInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_postInit)); + }; +}; diff --git a/addons/irlight/CfgJointRails.hpp b/addons/irlight/CfgJointRails.hpp new file mode 100644 index 00000000000..e3fc4ed6ffd --- /dev/null +++ b/addons/irlight/CfgJointRails.hpp @@ -0,0 +1,6 @@ +class asdg_SlotInfo; +class asdg_FrontSideRail: asdg_SlotInfo { + class compatibleItems { + ACE_acc_pointer_IR_flashlight = 1; + }; +}; diff --git a/addons/irlight/CfgWeapons.hpp b/addons/irlight/CfgWeapons.hpp new file mode 100644 index 00000000000..d4446fc19b4 --- /dev/null +++ b/addons/irlight/CfgWeapons.hpp @@ -0,0 +1,45 @@ +class SlotInfo; +class PointerSlot: SlotInfo { + compatibleItems[] += { + "ACE_acc_pointer_IR_flashlight" + }; +}; + +class CfgWeapons { + class ItemCore; + class acc_pointer_IR: ItemCore { + class ItemInfo; + }; + class ACE_acc_pointer_IR_flashlight: acc_pointer_IR { + author = ECSTRING(common,ACETeam); + displayName = "ACE IR flashlight"; // TODO: stringtable + + class ItemInfo: ItemInfo { + class Flashlight { + color[] = {180,160,130}; + ambient[] = {0.9,0.81,0.7}; + intensity = 100; // Brightness + size = 1; // TODO: OwO what's this? + innerAngle = 5; // Can't really tell if there are actually two cones? + outerAngle = 10; + coneFadeCoef = 8; // Higher value = sharper outline + position = "laser pos"; + direction = "laser dir"; + useFlare = 1; + flareSize = 1.4; + flareMaxDistance = 100; + dayLight = 0; + scale[] = {0}; + + class Attentuation { + start = 0; + constant = 0.5; + linear = 0.1; + quadratic = 0.2; + hardLimitStart = 27; + hardLimitEnd = 34; + }; + }; + }; + }; +}; diff --git a/addons/irlight/README.md b/addons/irlight/README.md new file mode 100644 index 00000000000..1ad38174d9d --- /dev/null +++ b/addons/irlight/README.md @@ -0,0 +1,11 @@ +ace_irlight +=================== + +Adds scripted IR flashlights. + + +## Maintainers + +The people responsible for merging changes to this component or answering potential questions. + +- [BaerMitUmlaut](https://github.com/BaerMitUmlaut) diff --git a/addons/irlight/XEH_PREP.hpp b/addons/irlight/XEH_PREP.hpp new file mode 100644 index 00000000000..79c749d3380 --- /dev/null +++ b/addons/irlight/XEH_PREP.hpp @@ -0,0 +1,3 @@ +PREP(handleLoadoutChanged); +PREP(updateWeaponLights); +PREP(handleVisionModeChanged); diff --git a/addons/irlight/XEH_postInit.sqf b/addons/irlight/XEH_postInit.sqf new file mode 100644 index 00000000000..42b8d314d88 --- /dev/null +++ b/addons/irlight/XEH_postInit.sqf @@ -0,0 +1,8 @@ +#include "script_component.hpp" + +// Make sure JIPs can see already turned on IR lights +GVAR(units) = allPlayers select { + _x getVariable [QGVAR(turnedOn), false] +}; + +[FUNC(updateWeaponLights), 0, []] call CBA_fnc_addPerFrameHandler; diff --git a/addons/irlight/XEH_preInit.sqf b/addons/irlight/XEH_preInit.sqf new file mode 100644 index 00000000000..a52f51f2a8f --- /dev/null +++ b/addons/irlight/XEH_preInit.sqf @@ -0,0 +1,27 @@ +#include "script_component.hpp" + +ADDON = false; + +PREP_RECOMPILE_START; +#include "XEH_PREP.hpp" +PREP_RECOMPILE_END; + +// List of units with an enabled IR light +GVAR(units) = []; + +[QGVAR(switchedLight), { + params ["_unit", "_lightOn"]; + + if (_lightOn) then { + _unit action ["GunLightOn", _unit]; + GVAR(units) pushBack _unit; + } else { + _unit action ["GunLightOff", _unit]; + GVAR(units) deleteAt (GVAR(units) find _unit); + }; +}] call CBA_fnc_addEventHandler; + +["loadout", FUNC(handleLoadoutChanged)] call CBA_fnc_addPlayerEventHandler; +["visionMode", FUNC(handleVisionModeChanged)] call CBA_fnc_addPlayerEventHandler; + +ADDON = true; diff --git a/addons/irlight/XEH_preStart.sqf b/addons/irlight/XEH_preStart.sqf new file mode 100644 index 00000000000..022888575ed --- /dev/null +++ b/addons/irlight/XEH_preStart.sqf @@ -0,0 +1,3 @@ +#include "script_component.hpp" + +#include "XEH_PREP.hpp" diff --git a/addons/irlight/config.cpp b/addons/irlight/config.cpp new file mode 100644 index 00000000000..167d51d15a5 --- /dev/null +++ b/addons/irlight/config.cpp @@ -0,0 +1,19 @@ +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + name = COMPONENT_NAME; + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"ace_common"}; + author = ECSTRING(common,ACETeam); + authors[] = {"BaerMitUmlaut"}; + url = ECSTRING(main,URL); + VERSION_CONFIG; + }; +}; + +#include "CfgEventHandlers.hpp" +#include "CfgJointRails.hpp" +#include "CfgWeapons.hpp" diff --git a/addons/irlight/functions/fnc_handleLoadoutChanged.sqf b/addons/irlight/functions/fnc_handleLoadoutChanged.sqf new file mode 100644 index 00000000000..5a249578a5a --- /dev/null +++ b/addons/irlight/functions/fnc_handleLoadoutChanged.sqf @@ -0,0 +1,3 @@ +#include "script_component.hpp" +// TODO: save if the current weapon has an ir flashlight capable attachment +// isKindOf forEach attachment? config property? diff --git a/addons/irlight/functions/fnc_handleVisionModeChanged.sqf b/addons/irlight/functions/fnc_handleVisionModeChanged.sqf new file mode 100644 index 00000000000..ddc752e4645 --- /dev/null +++ b/addons/irlight/functions/fnc_handleVisionModeChanged.sqf @@ -0,0 +1,13 @@ +#include "script_component.hpp" + +// Manually update weapon lights once for instant change +// TODO: Check if still necessary? +if (IN_NVGS) then { + { + _x action ["GunLightOn", _x]; + } forEach GVAR(units); +} else { + { + _x action ["GunLightOff", _x]; + } forEach GVAR(units); +}; diff --git a/addons/irlight/functions/fnc_updateWeaponLights.sqf b/addons/irlight/functions/fnc_updateWeaponLights.sqf new file mode 100644 index 00000000000..53fe3444075 --- /dev/null +++ b/addons/irlight/functions/fnc_updateWeaponLights.sqf @@ -0,0 +1,51 @@ +/* + * Author: BaerMitUmlaut + * Makes the IR weapon lights visible depending on wether the player wears NVGs or not. + * + * Arguments: + * None + * + * Return Value: + * None + * + * Example: + * [] call ace_irlight_fnc_updateWeaponLights + * + * Public: No + */ +#include "script_component.hpp" + +private _hasIRLight = "ACE_acc_pointer_IR_flashlight" in primaryWeaponItems ACE_player; +private _isLightOn = ACE_player isFlashlightOn primaryWeapon ACE_player; +private _synchedOn = ACE_player getVariable [QGVAR(turnedOn), false]; +private _inNVGS = IN_NVGS; + +// Detect if player switched light on or off +if (_hasIRLight) then { + if (_inNVGS) then { + // Synch weapon light state with virtual state + if !(_isLightOn isEqualTo _synchedOn) then { + [QGVAR(switchedLight), [ACE_player, _isLightOn]] call CBA_fnc_globalEvent; + ACE_player setVariable [QGVAR(turnedOn), _isLightOn, true]; + }; + } else { + // No NVGs, but light is on + // -> player pressed the weapon light button + // -> switch light status + if (_isLightOn) then { + [QGVAR(switchedLight), [ACE_player, !_synchedOn]] call CBA_fnc_globalEvent; + ACE_player setVariable [QGVAR(turnedOn), !_synchedOn, true]; + }; + }; +}; + +// Override weapon light of all units with enabled IR light +if (_inNVGS) then { + { + _x action ["GunLightOn", _x]; + } forEach GVAR(units); +} else { + { + _x action ["GunLightOff", _x]; + } forEach GVAR(units); +}; diff --git a/addons/irlight/functions/script_component.hpp b/addons/irlight/functions/script_component.hpp new file mode 100644 index 00000000000..3dab1f1e8ef --- /dev/null +++ b/addons/irlight/functions/script_component.hpp @@ -0,0 +1 @@ +#include "\z\ace\addons\irlight\script_component.hpp" diff --git a/addons/irlight/script_component.hpp b/addons/irlight/script_component.hpp new file mode 100644 index 00000000000..d742691d782 --- /dev/null +++ b/addons/irlight/script_component.hpp @@ -0,0 +1,17 @@ +#define COMPONENT irlight +#define COMPONENT_BEAUTIFIED IR Light +#include "\z\ace\addons\main\script_mod.hpp" + +// #define DEBUG_MODE_FULL +// #define DISABLE_COMPILE_CACHE +// #define ENABLE_PERFORMANCE_COUNTERS + +#ifdef DEBUG_ENABLED_IRLIGHT + #define DEBUG_MODE_FULL +#endif + +#ifdef DEBUG_SETTINGS_IRLIGHT + #define DEBUG_SETTINGS DEBUG_SETTINGS_IRLIGHT +#endif + +#include "\z\ace\addons\main\script_macros.hpp" From 9ceacf32d5421127010634cd5569e1abb16ba54e Mon Sep 17 00:00:00 2001 From: BaerMitUmlaut Date: Thu, 21 May 2020 00:00:19 +0200 Subject: [PATCH 02/12] More experiments --- addons/irlight/CfgWeapons.hpp | 112 ++++++++++++++++++++++++++-- addons/irlight/script_component.hpp | 2 + 2 files changed, 107 insertions(+), 7 deletions(-) diff --git a/addons/irlight/CfgWeapons.hpp b/addons/irlight/CfgWeapons.hpp index d4446fc19b4..4e572cffefa 100644 --- a/addons/irlight/CfgWeapons.hpp +++ b/addons/irlight/CfgWeapons.hpp @@ -1,7 +1,18 @@ class SlotInfo; class PointerSlot: SlotInfo { compatibleItems[] += { - "ACE_acc_pointer_IR_flashlight" + "ACE_acc_pointer_IR_flashlight", + "ACE_acc_pointer_IR_flashlight2", + "ACE_acc_pointer_IR_flashlight3", + "ACE_acc_pointer_IR_flashlight4" + }; +}; +class PointerSlot_Rail: PointerSlot { + class compatibleItems { + ACE_acc_pointer_IR_flashlight = 1; + ACE_acc_pointer_IR_flashlight2 = 1; + ACE_acc_pointer_IR_flashlight3 = 1; + ACE_acc_pointer_IR_flashlight4 = 1; }; }; @@ -18,10 +29,97 @@ class CfgWeapons { class Flashlight { color[] = {180,160,130}; ambient[] = {0.9,0.81,0.7}; - intensity = 100; // Brightness + intensity = 5000; // Brightness + size = 1; // TODO: OwO what's this? + innerAngle = 10; // Can't really tell if there are actually two cones? + outerAngle = 12; + coneFadeCoef = 2; // Higher value = sharper outline + position = "laser pos"; + direction = "laser dir"; + useFlare = 1; + flareSize = 1.4; + flareMaxDistance = 100; + dayLight = 0; + scale[] = {0}; + + class Attentuation { + start = 0; + constant = 0.5; + linear = 0.1; + quadratic = 0.1; + hardLimitStart = 500; + hardLimitEnd = 600; + }; + }; + }; + }; + class ACE_acc_pointer_IR_flashlight2: acc_pointer_IR { + class ItemInfo: ItemInfo { + class Flashlight { + color[] = {180,160,130}; + ambient[] = {0.9,0.81,0.7}; + intensity = 5000; // Brightness + size = 1; // TODO: OwO what's this? + innerAngle = 10; // Can't really tell if there are actually two cones? + outerAngle = 12; + coneFadeCoef = 4; // Higher value = sharper outline + position = "laser pos"; + direction = "laser dir"; + useFlare = 1; + flareSize = 1.4; + flareMaxDistance = 100; + dayLight = 0; + scale[] = {0}; + + class Attentuation { + start = 0; + constant = 0.5; + linear = 0.1; + quadratic = 0.1; + hardLimitStart = 500; + hardLimitEnd = 600; + }; + }; + }; + }; + class ACE_acc_pointer_IR_flashlight3: acc_pointer_IR { + class ItemInfo: ItemInfo { + class Flashlight { + color[] = {180,160,130}; + ambient[] = {0.9,0.81,0.7}; + intensity = 5000; // Brightness + size = 1; // TODO: OwO what's this? + innerAngle = 10; // Can't really tell if there are actually two cones? + outerAngle = 12; + coneFadeCoef = 6; // Higher value = sharper outline + position = "laser pos"; + direction = "laser dir"; + useFlare = 1; + flareSize = 1.4; + flareMaxDistance = 100; + dayLight = 0; + scale[] = {0}; + + class Attentuation { + start = 0; + constant = 0.5; + linear = 0.1; + quadratic = 0.1; + hardLimitStart = 500; + hardLimitEnd = 600; + }; + }; + }; + }; + class ACE_acc_pointer_IR_flashlight4: acc_pointer_IR { + class ItemInfo: ItemInfo { + class Flashlight { + color[] = {180,160,130}; + ambient[] = {0.9,0.81,0.7}; + intensity = 5000; // Brightness size = 1; // TODO: OwO what's this? - innerAngle = 5; // Can't really tell if there are actually two cones? - outerAngle = 10; + innerAngle = 10; // Can't really tell if there are actually two cones? + outerAngle = 12; coneFadeCoef = 8; // Higher value = sharper outline position = "laser pos"; direction = "laser dir"; @@ -35,9 +133,9 @@ class CfgWeapons { start = 0; constant = 0.5; linear = 0.1; - quadratic = 0.2; - hardLimitStart = 27; - hardLimitEnd = 34; + quadratic = 0.1; + hardLimitStart = 500; + hardLimitEnd = 600; }; }; }; diff --git a/addons/irlight/script_component.hpp b/addons/irlight/script_component.hpp index d742691d782..c4c04f2c55c 100644 --- a/addons/irlight/script_component.hpp +++ b/addons/irlight/script_component.hpp @@ -15,3 +15,5 @@ #endif #include "\z\ace\addons\main\script_macros.hpp" + +#define IN_NVGS (currentVisionMode ACE_player == 1) From dc371469c9f80c467114856f7abe221318d0c0e7 Mon Sep 17 00:00:00 2001 From: BaerMitUmlaut Date: Mon, 8 Mar 2021 16:11:17 +0100 Subject: [PATCH 03/12] Rewrite using engine IR lights --- addons/irlight/CfgEventHandlers.hpp | 12 - addons/irlight/CfgJointRails.hpp | 12 +- addons/irlight/CfgWeapons.hpp | 305 +++++++++++++----- addons/irlight/README.md | 2 +- addons/irlight/XEH_PREP.hpp | 3 - addons/irlight/XEH_postInit.sqf | 51 ++- addons/irlight/XEH_preInit.sqf | 27 -- addons/irlight/XEH_preStart.sqf | 3 - addons/irlight/config.cpp | 2 +- .../functions/fnc_handleLoadoutChanged.sqf | 3 - .../functions/fnc_handleVisionModeChanged.sqf | 13 - .../functions/fnc_updateWeaponLights.sqf | 51 --- addons/irlight/functions/script_component.hpp | 1 - addons/irlight/script_component.hpp | 2 - addons/irlight/stringtable.xml | 57 ++++ 15 files changed, 339 insertions(+), 205 deletions(-) delete mode 100644 addons/irlight/XEH_PREP.hpp delete mode 100644 addons/irlight/XEH_preInit.sqf delete mode 100644 addons/irlight/XEH_preStart.sqf delete mode 100644 addons/irlight/functions/fnc_handleLoadoutChanged.sqf delete mode 100644 addons/irlight/functions/fnc_handleVisionModeChanged.sqf delete mode 100644 addons/irlight/functions/fnc_updateWeaponLights.sqf delete mode 100644 addons/irlight/functions/script_component.hpp create mode 100644 addons/irlight/stringtable.xml diff --git a/addons/irlight/CfgEventHandlers.hpp b/addons/irlight/CfgEventHandlers.hpp index 0d3301d6e0a..b0cc92b5137 100644 --- a/addons/irlight/CfgEventHandlers.hpp +++ b/addons/irlight/CfgEventHandlers.hpp @@ -1,15 +1,3 @@ -class Extended_PreStart_EventHandlers { - class ADDON { - init = QUOTE(call COMPILE_FILE(XEH_preStart)); - }; -}; - -class Extended_PreInit_EventHandlers { - class ADDON { - init = QUOTE(call COMPILE_FILE(XEH_preInit)); - }; -}; - class Extended_PostInit_EventHandlers { class ADDON { init = QUOTE(call COMPILE_FILE(XEH_postInit)); diff --git a/addons/irlight/CfgJointRails.hpp b/addons/irlight/CfgJointRails.hpp index e3fc4ed6ffd..99ff2860383 100644 --- a/addons/irlight/CfgJointRails.hpp +++ b/addons/irlight/CfgJointRails.hpp @@ -1,6 +1,16 @@ class asdg_SlotInfo; class asdg_FrontSideRail: asdg_SlotInfo { class compatibleItems { - ACE_acc_pointer_IR_flashlight = 1; + ACE_DBAL_A3_Red = 1; + ACE_DBAL_A3_Red_IP = 1; + ACE_DBAL_A3_Red_II = 1; + ACE_DBAL_A3_Red_VP = 1; + ACE_DBAL_A3_Green = 1; + ACE_DBAL_A3_Green_IP = 1; + ACE_DBAL_A3_Green_II = 1; + ACE_DBAL_A3_Green_VP = 1; + ACE_SPIR = 1; + ACE_SPIR_Medium = 1; + ACE_SPIR_Narrow = 1; }; }; diff --git a/addons/irlight/CfgWeapons.hpp b/addons/irlight/CfgWeapons.hpp index 4e572cffefa..fe8cb7d1faa 100644 --- a/addons/irlight/CfgWeapons.hpp +++ b/addons/irlight/CfgWeapons.hpp @@ -1,18 +1,32 @@ class SlotInfo; class PointerSlot: SlotInfo { compatibleItems[] += { - "ACE_acc_pointer_IR_flashlight", - "ACE_acc_pointer_IR_flashlight2", - "ACE_acc_pointer_IR_flashlight3", - "ACE_acc_pointer_IR_flashlight4" + "ACE_DBAL_A3_Red", + "ACE_DBAL_A3_Red_IP", + "ACE_DBAL_A3_Red_II", + "ACE_DBAL_A3_Red_VP", + "ACE_DBAL_A3_Green", + "ACE_DBAL_A3_Green_IP", + "ACE_DBAL_A3_Green_II", + "ACE_DBAL_A3_Green_VP", + "ACE_SPIR", + "ACE_SPIR_Medium", + "ACE_SPIR_Narrow" }; }; class PointerSlot_Rail: PointerSlot { class compatibleItems { - ACE_acc_pointer_IR_flashlight = 1; - ACE_acc_pointer_IR_flashlight2 = 1; - ACE_acc_pointer_IR_flashlight3 = 1; - ACE_acc_pointer_IR_flashlight4 = 1; + ACE_DBAL_A3_Red = 1; + ACE_DBAL_A3_Red_IP = 1; + ACE_DBAL_A3_Red_II = 1; + ACE_DBAL_A3_Red_VP = 1; + ACE_DBAL_A3_Green = 1; + ACE_DBAL_A3_Green_IP = 1; + ACE_DBAL_A3_Green_II = 1; + ACE_DBAL_A3_Green_VP = 1; + ACE_SPIR = 1; + ACE_SPIR_Medium = 1; + ACE_SPIR_Narrow = 1; }; }; @@ -21,121 +35,248 @@ class CfgWeapons { class acc_pointer_IR: ItemCore { class ItemInfo; }; - class ACE_acc_pointer_IR_flashlight: acc_pointer_IR { + + class acc_flashlight: ItemCore { + class ItemInfo; + }; + + // DBAL A3 (red pointer) + class ACE_DBAL_A3_Red: acc_pointer_IR { author = ECSTRING(common,ACETeam); - displayName = "ACE IR flashlight"; // TODO: stringtable + displayName = CSTRING(DBAL_A3_Red); + descriptionUse = CSTRING(DBAL_A3_DescriptionUse); + descriptionShort = CSTRING(DBAL_A3_DescriptionShort); + + MRT_SwitchItemNextClass = "ACE_DBAL_A3_Red_IP"; + MRT_SwitchItemPrevClass = "ACE_DBAL_A3_Red_VP"; + MRT_SwitchItemHintText = CSTRING(Mode_IRDual); class ItemInfo: ItemInfo { class Flashlight { - color[] = {180,160,130}; - ambient[] = {0.9,0.81,0.7}; - intensity = 5000; // Brightness - size = 1; // TODO: OwO what's this? - innerAngle = 10; // Can't really tell if there are actually two cones? + color[] = {1, 1, 1, 1}; + ambient[] = {1, 1, 1, 1}; + size = 1; + innerAngle = 10; outerAngle = 12; - coneFadeCoef = 2; // Higher value = sharper outline position = "laser pos"; direction = "laser dir"; useFlare = 1; flareSize = 1.4; - flareMaxDistance = 100; - dayLight = 0; + flareMaxDistance = 200; scale[] = {0}; + coneFadeCoef = 6; + intensity = 100; + irLight = 1; - class Attentuation { - start = 0; - constant = 0.5; - linear = 0.1; - quadratic = 0.1; - hardLimitStart = 500; - hardLimitEnd = 600; + class Attenuation { + constant = 1; + linear = 0; + quadratic = 0; + start = 500; + hardLimitStart = 1; + hardLimitEnd = 500; }; }; }; }; - class ACE_acc_pointer_IR_flashlight2: acc_pointer_IR { + + class ACE_DBAL_A3_Red_IP: ACE_DBAL_A3_Red { + scope = 1; + + MRT_SwitchItemNextClass = "ACE_DBAL_A3_Red_II"; + MRT_SwitchItemPrevClass = "ACE_DBAL_A3_Red"; + MRT_SwitchItemHintText = CSTRING(Mode_IRPointer); + + class ItemInfo: ItemInfo { + class Flashlight {}; + }; + }; + + class ACE_DBAL_A3_Red_II: ACE_DBAL_A3_Red { + scope = 1; + + MRT_SwitchItemNextClass = "ACE_DBAL_A3_Red_VP"; + MRT_SwitchItemPrevClass = "ACE_DBAL_A3_Red_IP"; + MRT_SwitchItemHintText = CSTRING(Mode_IRIlluminator); + + class ItemInfo: ItemInfo { + class Pointer {}; + }; + }; + + class ACE_DBAL_A3_Red_VP: ACE_DBAL_A3_Red { + scope = 1; + ACE_laserpointer = 1; + + MRT_SwitchItemNextClass = "ACE_DBAL_A3_Red"; + MRT_SwitchItemPrevClass = "ACE_DBAL_A3_Red_II"; + MRT_SwitchItemHintText = CSTRING(Mode_VisiblePointer); + + class ItemInfo: ItemInfo { + class Pointer {}; + class Flashlight: Flashlight { + color[] = {0, 0, 0, 0}; + ambient[] = {0, 0, 0, 0}; + size = 0; + innerAngle = 0; + outerAngle = 0; + useFlare = 0; + intensity = 0; + irLight = 0; + + class Attenuation: Attenuation { + hardLimitStart = 0; + hardLimitEnd = 0; + }; + }; + }; + }; + + // DBAL A3 (green pointer) + class ACE_DBAL_A3_Green: ACE_DBAL_A3_Red { + scope = 2; + displayName = CSTRING(DBAL_A3_Green); + + MRT_SwitchItemNextClass = "ACE_DBAL_A3_Green_IP"; + MRT_SwitchItemPrevClass = "ACE_DBAL_A3_Green_VP"; + MRT_SwitchItemHintText = CSTRING(Mode_IRDual); + }; + + class ACE_DBAL_A3_Green_IP: ACE_DBAL_A3_Red_IP { + scope = 1; + displayName = CSTRING(DBAL_A3_Green); + + MRT_SwitchItemNextClass = "ACE_DBAL_A3_Green_II"; + MRT_SwitchItemPrevClass = "ACE_DBAL_A3_Green"; + MRT_SwitchItemHintText = CSTRING(Mode_IRPointer); + }; + + class ACE_DBAL_A3_Green_II: ACE_DBAL_A3_Red_II { + scope = 1; + displayName = CSTRING(DBAL_A3_Green); + + MRT_SwitchItemNextClass = "ACE_DBAL_A3_Green_VP"; + MRT_SwitchItemPrevClass = "ACE_DBAL_A3_Green_IP"; + MRT_SwitchItemHintText = CSTRING(Mode_IRIlluminator); + }; + + class ACE_DBAL_A3_Green_VP: ACE_DBAL_A3_Red_VP { + scope = 1; + displayName = CSTRING(DBAL_A3_Green); + ACE_laserpointer = 2; + + MRT_SwitchItemNextClass = "ACE_DBAL_A3_Green"; + MRT_SwitchItemPrevClass = "ACE_DBAL_A3_Green_II"; + MRT_SwitchItemHintText = CSTRING(Mode_VisiblePointer); + }; + + // SPIR + class ACE_SPIR: acc_flashlight { + author = ECSTRING(common,ACETeam); + displayName = "SPIR"; + descriptionUse = CSTRING(SPIR_DescriptionUse); + descriptionShort = CSTRING(SPIR_DescriptionShort); + + MRT_SwitchItemNextClass = "ACE_SPIR_Medium"; + MRT_SwitchItemPrevClass = "ACE_SPIR_Narrow"; + MRT_SwitchItemHintText = CSTRING(Mode_Wide); + class ItemInfo: ItemInfo { class Flashlight { - color[] = {180,160,130}; - ambient[] = {0.9,0.81,0.7}; - intensity = 5000; // Brightness - size = 1; // TODO: OwO what's this? - innerAngle = 10; // Can't really tell if there are actually two cones? - outerAngle = 12; - coneFadeCoef = 4; // Higher value = sharper outline - position = "laser pos"; - direction = "laser dir"; + color[] = {1, 1, 1, 1}; + ambient[] = {1, 1, 1, 1}; + size = 1; + innerAngle = 25; + outerAngle = 32; + position = "flash dir"; + direction = "flash"; useFlare = 1; flareSize = 1.4; - flareMaxDistance = 100; - dayLight = 0; + flareMaxDistance = 200; scale[] = {0}; + coneFadeCoef = 6; + intensity = 100; + irLight = 1; - class Attentuation { - start = 0; - constant = 0.5; - linear = 0.1; - quadratic = 0.1; - hardLimitStart = 500; - hardLimitEnd = 600; + class Attenuation { + constant = 1; + linear = 0; + quadratic = 0; + start = 200; + hardLimitStart = 1; + hardLimitEnd = 200; }; }; }; }; - class ACE_acc_pointer_IR_flashlight3: acc_pointer_IR { + + class ACE_SPIR_Medium: ACE_SPIR { + scope = 1; + + MRT_SwitchItemNextClass = "ACE_SPIR_Narrow"; + MRT_SwitchItemPrevClass = "ACE_SPIR"; + MRT_SwitchItemHintText = CSTRING(Mode_Medium); + class ItemInfo: ItemInfo { class Flashlight { - color[] = {180,160,130}; - ambient[] = {0.9,0.81,0.7}; - intensity = 5000; // Brightness - size = 1; // TODO: OwO what's this? - innerAngle = 10; // Can't really tell if there are actually two cones? - outerAngle = 12; - coneFadeCoef = 6; // Higher value = sharper outline - position = "laser pos"; - direction = "laser dir"; + color[] = {1, 1, 1, 1}; + ambient[] = {1, 1, 1, 1}; + size = 1; + position = "flash dir"; + direction = "flash"; useFlare = 1; flareSize = 1.4; - flareMaxDistance = 100; - dayLight = 0; + flareMaxDistance = 200; scale[] = {0}; + coneFadeCoef = 6; + intensity = 100; + irLight = 1; + innerAngle = 10; + outerAngle = 12; - class Attentuation { - start = 0; - constant = 0.5; - linear = 0.1; - quadratic = 0.1; - hardLimitStart = 500; - hardLimitEnd = 600; + class Attenuation { + constant = 1; + linear = 0; + quadratic = 0; + hardLimitStart = 1; + start = 350; + hardLimitEnd = 350; }; }; }; }; - class ACE_acc_pointer_IR_flashlight4: acc_pointer_IR { + + class ACE_SPIR_Narrow: ACE_SPIR { + scope = 1; + + MRT_SwitchItemNextClass = "ACE_SPIR"; + MRT_SwitchItemPrevClass = "ACE_SPIR_Medium"; + MRT_SwitchItemHintText = CSTRING(Mode_Narrow); + class ItemInfo: ItemInfo { class Flashlight { - color[] = {180,160,130}; - ambient[] = {0.9,0.81,0.7}; - intensity = 5000; // Brightness - size = 1; // TODO: OwO what's this? - innerAngle = 10; // Can't really tell if there are actually two cones? - outerAngle = 12; - coneFadeCoef = 8; // Higher value = sharper outline - position = "laser pos"; - direction = "laser dir"; + color[] = {1, 1, 1, 1}; + ambient[] = {1, 1, 1, 1}; + size = 1; + position = "flash dir"; + direction = "flash"; useFlare = 1; flareSize = 1.4; - flareMaxDistance = 100; - dayLight = 0; + flareMaxDistance = 200; scale[] = {0}; + coneFadeCoef = 6; + intensity = 100; + irLight = 1; + innerAngle = 5; + outerAngle = 6; - class Attentuation { - start = 0; - constant = 0.5; - linear = 0.1; - quadratic = 0.1; - hardLimitStart = 500; - hardLimitEnd = 600; + class Attenuation { + constant = 1; + linear = 0; + quadratic = 0; + hardLimitStart = 1; + start = 500; + hardLimitEnd = 500; }; }; }; diff --git a/addons/irlight/README.md b/addons/irlight/README.md index 1ad38174d9d..c92d5e0f848 100644 --- a/addons/irlight/README.md +++ b/addons/irlight/README.md @@ -1,7 +1,7 @@ ace_irlight =================== -Adds scripted IR flashlights. +Adds IR flashlights. ## Maintainers diff --git a/addons/irlight/XEH_PREP.hpp b/addons/irlight/XEH_PREP.hpp deleted file mode 100644 index 79c749d3380..00000000000 --- a/addons/irlight/XEH_PREP.hpp +++ /dev/null @@ -1,3 +0,0 @@ -PREP(handleLoadoutChanged); -PREP(updateWeaponLights); -PREP(handleVisionModeChanged); diff --git a/addons/irlight/XEH_postInit.sqf b/addons/irlight/XEH_postInit.sqf index 42b8d314d88..b7fd6226f90 100644 --- a/addons/irlight/XEH_postInit.sqf +++ b/addons/irlight/XEH_postInit.sqf @@ -1,8 +1,49 @@ #include "script_component.hpp" -// Make sure JIPs can see already turned on IR lights -GVAR(units) = allPlayers select { - _x getVariable [QGVAR(turnedOn), false] -}; +{ + _x params ["_variant", "_displayName"]; -[FUNC(updateWeaponLights), 0, []] call CBA_fnc_addPerFrameHandler; + [ + "ACE_DBAL_A3_Red", "POINTER", _displayName, [], "", { + params ["", "", "_item", "", "_variant"]; + + private _baseClass = if (_item select [0, 15] == "ACE_DBAL_A3_Red") then { + "ACE_DBAL_A3_Red" + } else { + "ACE_DBAL_A3_Green" + }; + + _item != _baseClass + _variant + }, { + params ["", "", "_item", "", "_variant"]; + + private _baseClass = if (_item select [0, 15] == "ACE_DBAL_A3_Red") then { + "ACE_DBAL_A3_Red" + } else { + "ACE_DBAL_A3_Green" + }; + + private _turnedOn = ACE_player isFlashlightOn primaryWeapon ACE_player + || ACE_player isIRLaserOn primaryWeapon ACE_player; + + ACE_player removePrimaryWeaponItem _item; + ACE_player addPrimaryWeaponItem (_baseClass + _variant); + playSound "click"; + + if (_turnedOn) then { + // Force update of flashlight + ACE_player action ["GunLightOff", ACE_player]; + + { + ACE_player action ["GunLightOn", ACE_player]; + ACE_player action ["IRLaserOn", ACE_player]; + } call CBA_fnc_execNextFrame; + }; + }, false, _variant + ] call CBA_fnc_addItemContextMenuOption; +} forEach [ + ["", LSTRING(Mode_IRDual)], + ["_IP", LSTRING(Mode_IRPointer)], + ["_II", LSTRING(Mode_IRIlluminator)], + ["_VP", LSTRING(Mode_VisiblePointer)] +]; diff --git a/addons/irlight/XEH_preInit.sqf b/addons/irlight/XEH_preInit.sqf deleted file mode 100644 index a52f51f2a8f..00000000000 --- a/addons/irlight/XEH_preInit.sqf +++ /dev/null @@ -1,27 +0,0 @@ -#include "script_component.hpp" - -ADDON = false; - -PREP_RECOMPILE_START; -#include "XEH_PREP.hpp" -PREP_RECOMPILE_END; - -// List of units with an enabled IR light -GVAR(units) = []; - -[QGVAR(switchedLight), { - params ["_unit", "_lightOn"]; - - if (_lightOn) then { - _unit action ["GunLightOn", _unit]; - GVAR(units) pushBack _unit; - } else { - _unit action ["GunLightOff", _unit]; - GVAR(units) deleteAt (GVAR(units) find _unit); - }; -}] call CBA_fnc_addEventHandler; - -["loadout", FUNC(handleLoadoutChanged)] call CBA_fnc_addPlayerEventHandler; -["visionMode", FUNC(handleVisionModeChanged)] call CBA_fnc_addPlayerEventHandler; - -ADDON = true; diff --git a/addons/irlight/XEH_preStart.sqf b/addons/irlight/XEH_preStart.sqf deleted file mode 100644 index 022888575ed..00000000000 --- a/addons/irlight/XEH_preStart.sqf +++ /dev/null @@ -1,3 +0,0 @@ -#include "script_component.hpp" - -#include "XEH_PREP.hpp" diff --git a/addons/irlight/config.cpp b/addons/irlight/config.cpp index 167d51d15a5..aa2dc8806c4 100644 --- a/addons/irlight/config.cpp +++ b/addons/irlight/config.cpp @@ -6,7 +6,7 @@ class CfgPatches { units[] = {}; weapons[] = {}; requiredVersion = REQUIRED_VERSION; - requiredAddons[] = {"ace_common"}; + requiredAddons[] = {"ace_common", "ace_laserpointer"}; author = ECSTRING(common,ACETeam); authors[] = {"BaerMitUmlaut"}; url = ECSTRING(main,URL); diff --git a/addons/irlight/functions/fnc_handleLoadoutChanged.sqf b/addons/irlight/functions/fnc_handleLoadoutChanged.sqf deleted file mode 100644 index 5a249578a5a..00000000000 --- a/addons/irlight/functions/fnc_handleLoadoutChanged.sqf +++ /dev/null @@ -1,3 +0,0 @@ -#include "script_component.hpp" -// TODO: save if the current weapon has an ir flashlight capable attachment -// isKindOf forEach attachment? config property? diff --git a/addons/irlight/functions/fnc_handleVisionModeChanged.sqf b/addons/irlight/functions/fnc_handleVisionModeChanged.sqf deleted file mode 100644 index ddc752e4645..00000000000 --- a/addons/irlight/functions/fnc_handleVisionModeChanged.sqf +++ /dev/null @@ -1,13 +0,0 @@ -#include "script_component.hpp" - -// Manually update weapon lights once for instant change -// TODO: Check if still necessary? -if (IN_NVGS) then { - { - _x action ["GunLightOn", _x]; - } forEach GVAR(units); -} else { - { - _x action ["GunLightOff", _x]; - } forEach GVAR(units); -}; diff --git a/addons/irlight/functions/fnc_updateWeaponLights.sqf b/addons/irlight/functions/fnc_updateWeaponLights.sqf deleted file mode 100644 index 53fe3444075..00000000000 --- a/addons/irlight/functions/fnc_updateWeaponLights.sqf +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Author: BaerMitUmlaut - * Makes the IR weapon lights visible depending on wether the player wears NVGs or not. - * - * Arguments: - * None - * - * Return Value: - * None - * - * Example: - * [] call ace_irlight_fnc_updateWeaponLights - * - * Public: No - */ -#include "script_component.hpp" - -private _hasIRLight = "ACE_acc_pointer_IR_flashlight" in primaryWeaponItems ACE_player; -private _isLightOn = ACE_player isFlashlightOn primaryWeapon ACE_player; -private _synchedOn = ACE_player getVariable [QGVAR(turnedOn), false]; -private _inNVGS = IN_NVGS; - -// Detect if player switched light on or off -if (_hasIRLight) then { - if (_inNVGS) then { - // Synch weapon light state with virtual state - if !(_isLightOn isEqualTo _synchedOn) then { - [QGVAR(switchedLight), [ACE_player, _isLightOn]] call CBA_fnc_globalEvent; - ACE_player setVariable [QGVAR(turnedOn), _isLightOn, true]; - }; - } else { - // No NVGs, but light is on - // -> player pressed the weapon light button - // -> switch light status - if (_isLightOn) then { - [QGVAR(switchedLight), [ACE_player, !_synchedOn]] call CBA_fnc_globalEvent; - ACE_player setVariable [QGVAR(turnedOn), !_synchedOn, true]; - }; - }; -}; - -// Override weapon light of all units with enabled IR light -if (_inNVGS) then { - { - _x action ["GunLightOn", _x]; - } forEach GVAR(units); -} else { - { - _x action ["GunLightOff", _x]; - } forEach GVAR(units); -}; diff --git a/addons/irlight/functions/script_component.hpp b/addons/irlight/functions/script_component.hpp deleted file mode 100644 index 3dab1f1e8ef..00000000000 --- a/addons/irlight/functions/script_component.hpp +++ /dev/null @@ -1 +0,0 @@ -#include "\z\ace\addons\irlight\script_component.hpp" diff --git a/addons/irlight/script_component.hpp b/addons/irlight/script_component.hpp index c4c04f2c55c..d742691d782 100644 --- a/addons/irlight/script_component.hpp +++ b/addons/irlight/script_component.hpp @@ -15,5 +15,3 @@ #endif #include "\z\ace\addons\main\script_macros.hpp" - -#define IN_NVGS (currentVisionMode ACE_player == 1) diff --git a/addons/irlight/stringtable.xml b/addons/irlight/stringtable.xml new file mode 100644 index 00000000000..a326e83bd54 --- /dev/null +++ b/addons/irlight/stringtable.xml @@ -0,0 +1,57 @@ + + + + + DBAL A3 (red) + DBAL A3 (rot) + + + DBAL A3 (green) + DBAL A3 (grün) + + + <t color='#9cf953'>Use: </t>Turn Laser ON/OFF<br>Double click to switch mode + <t color='#9cf953'>Benutzen: </t>Laser EIN/AUS<br>Doppelklick um Modus zu wechseln + + + Dual Beam Aiming Laser + Doppelstrahllaservisier + + + Visible Laser + Sichtbarer Laser + + + IR Laser + IR-Laser + + + IR Illuminator + IR-Taschenlampe + + + IR Laser and Illuminator + IR-Laser und -Licht + + + Wide Beam + Breiter Lichtstrahl + + + Medium Beam + Mittlerer Lichtstrahl + + + Narrow Beam + Schmaler Lichtstrahl + + + <t color='#9cf953'>Use: </t>Turn Light ON/OFF<br>Double click to switch mode + <t color='#9cf953'>Benutzen: </t>Licht EIN/AUS<br>Doppelklick um Modus zu wechseln + + + Special Purpose IR LED Illuminator + Infrarot LED Taschenlampe + + + From 5a23114d325c9b84f32a95ade71ecab7626bfbdd Mon Sep 17 00:00:00 2001 From: BaerMitUmlaut Date: Fri, 7 Apr 2023 14:52:29 +0200 Subject: [PATCH 04/12] Rework ranges, fix bugs, add docs --- addons/irlight/CfgEventHandlers.hpp | 12 + addons/irlight/CfgJointRails.hpp | 66 +++ addons/irlight/CfgWeapons.hpp | 449 +++++++++++------- addons/irlight/README.md | 7 - addons/irlight/XEH_PREP.hpp | 3 + addons/irlight/XEH_postInit.sqf | 75 ++- addons/irlight/XEH_preInit.sqf | 9 + addons/irlight/XEH_preStart.sqf | 3 + addons/irlight/config.cpp | 2 +- addons/irlight/data/irglow.p3d | Bin 0 -> 13082 bytes addons/irlight/data/irglow.rvmat | 79 +++ addons/irlight/data/model.cfg | 8 + addons/irlight/dev/createTestLight.sqf | 42 ++ .../irlight/functions/fnc_getGlowOffset.sqf | 41 ++ .../functions/fnc_initItemContextMenu.sqf | 52 ++ .../irlight/functions/fnc_onLightToggled.sqf | 36 ++ addons/irlight/script_component.hpp | 2 +- addons/irlight/stringtable.xml | 12 +- addons/laserpointer/XEH_postInit.sqf | 21 +- addons/laserpointer/script_component.hpp | 2 +- addons/map/functions/fnc_isFlashlight.sqf | 2 +- docs/wiki/class-names.md | 12 + docs/wiki/feature/irlight.md | 45 ++ 23 files changed, 740 insertions(+), 240 deletions(-) create mode 100644 addons/irlight/XEH_PREP.hpp create mode 100644 addons/irlight/XEH_preInit.sqf create mode 100644 addons/irlight/XEH_preStart.sqf create mode 100644 addons/irlight/data/irglow.p3d create mode 100644 addons/irlight/data/irglow.rvmat create mode 100644 addons/irlight/data/model.cfg create mode 100644 addons/irlight/dev/createTestLight.sqf create mode 100644 addons/irlight/functions/fnc_getGlowOffset.sqf create mode 100644 addons/irlight/functions/fnc_initItemContextMenu.sqf create mode 100644 addons/irlight/functions/fnc_onLightToggled.sqf create mode 100644 docs/wiki/feature/irlight.md diff --git a/addons/irlight/CfgEventHandlers.hpp b/addons/irlight/CfgEventHandlers.hpp index b0cc92b5137..66a525846a6 100644 --- a/addons/irlight/CfgEventHandlers.hpp +++ b/addons/irlight/CfgEventHandlers.hpp @@ -1,3 +1,15 @@ +class Extended_PreStart_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_SCRIPT(XEH_preStart)); + }; +}; + +class Extended_PreInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_SCRIPT(XEH_preInit)); + }; +}; + class Extended_PostInit_EventHandlers { class ADDON { init = QUOTE(call COMPILE_FILE(XEH_postInit)); diff --git a/addons/irlight/CfgJointRails.hpp b/addons/irlight/CfgJointRails.hpp index 99ff2860383..f9b3081c42b 100644 --- a/addons/irlight/CfgJointRails.hpp +++ b/addons/irlight/CfgJointRails.hpp @@ -1,3 +1,58 @@ +class SlotInfo; +class PointerSlot: SlotInfo { + compatibleItems[] += { + "ACE_DBAL_A3_Red", + "ACE_DBAL_A3_Red_IP", + "ACE_DBAL_A3_Red_II", + "ACE_DBAL_A3_Red_VP", + "ACE_DBAL_A3_Red_LR", + "ACE_DBAL_A3_Red_LR_IP", + "ACE_DBAL_A3_Red_LR_II", + "ACE_DBAL_A3_Red_LR_VP", + "ACE_DBAL_A3_Green", + "ACE_DBAL_A3_Green_IP", + "ACE_DBAL_A3_Green_II", + "ACE_DBAL_A3_Green_VP", + "ACE_DBAL_A3_Green_LR", + "ACE_DBAL_A3_Green_LR_IP", + "ACE_DBAL_A3_Green_LR_II", + "ACE_DBAL_A3_Green_LR_VP", + "ACE_SPIR", + "ACE_SPIR_Medium", + "ACE_SPIR_Narrow", + "ACE_SPIR_LR", + "ACE_SPIR_LR_Medium", + "ACE_SPIR_LR_Narrow" + }; +}; + +class PointerSlot_Rail: PointerSlot { + class compatibleItems { + ACE_DBAL_A3_Red = 1; + ACE_DBAL_A3_Red_IP = 1; + ACE_DBAL_A3_Red_II = 1; + ACE_DBAL_A3_Red_VP = 1; + ACE_DBAL_A3_Red_LR = 1; + ACE_DBAL_A3_Red_LR_IP = 1; + ACE_DBAL_A3_Red_LR_II = 1; + ACE_DBAL_A3_Red_LR_VP = 1; + ACE_DBAL_A3_Green = 1; + ACE_DBAL_A3_Green_IP = 1; + ACE_DBAL_A3_Green_II = 1; + ACE_DBAL_A3_Green_VP = 1; + ACE_DBAL_A3_Green_LR = 1; + ACE_DBAL_A3_Green_LR_IP = 1; + ACE_DBAL_A3_Green_LR_II = 1; + ACE_DBAL_A3_Green_LR_VP = 1; + ACE_SPIR = 1; + ACE_SPIR_Medium = 1; + ACE_SPIR_Narrow = 1; + ACE_SPIR_LR = 1; + ACE_SPIR_LR_Medium = 1; + ACE_SPIR_LR_Narrow = 1; + }; +}; + class asdg_SlotInfo; class asdg_FrontSideRail: asdg_SlotInfo { class compatibleItems { @@ -5,12 +60,23 @@ class asdg_FrontSideRail: asdg_SlotInfo { ACE_DBAL_A3_Red_IP = 1; ACE_DBAL_A3_Red_II = 1; ACE_DBAL_A3_Red_VP = 1; + ACE_DBAL_A3_Red_LR = 1; + ACE_DBAL_A3_Red_LR_IP = 1; + ACE_DBAL_A3_Red_LR_II = 1; + ACE_DBAL_A3_Red_LR_VP = 1; ACE_DBAL_A3_Green = 1; ACE_DBAL_A3_Green_IP = 1; ACE_DBAL_A3_Green_II = 1; ACE_DBAL_A3_Green_VP = 1; + ACE_DBAL_A3_Green_LR = 1; + ACE_DBAL_A3_Green_LR_IP = 1; + ACE_DBAL_A3_Green_LR_II = 1; + ACE_DBAL_A3_Green_LR_VP = 1; ACE_SPIR = 1; ACE_SPIR_Medium = 1; ACE_SPIR_Narrow = 1; + ACE_SPIR_LR = 1; + ACE_SPIR_LR_Medium = 1; + ACE_SPIR_LR_Narrow = 1; }; }; diff --git a/addons/irlight/CfgWeapons.hpp b/addons/irlight/CfgWeapons.hpp index fe8cb7d1faa..2b29f1e2990 100644 --- a/addons/irlight/CfgWeapons.hpp +++ b/addons/irlight/CfgWeapons.hpp @@ -1,173 +1,284 @@ -class SlotInfo; -class PointerSlot: SlotInfo { - compatibleItems[] += { - "ACE_DBAL_A3_Red", - "ACE_DBAL_A3_Red_IP", - "ACE_DBAL_A3_Red_II", - "ACE_DBAL_A3_Red_VP", - "ACE_DBAL_A3_Green", - "ACE_DBAL_A3_Green_IP", - "ACE_DBAL_A3_Green_II", - "ACE_DBAL_A3_Green_VP", - "ACE_SPIR", - "ACE_SPIR_Medium", - "ACE_SPIR_Narrow" - }; -}; -class PointerSlot_Rail: PointerSlot { - class compatibleItems { - ACE_DBAL_A3_Red = 1; - ACE_DBAL_A3_Red_IP = 1; - ACE_DBAL_A3_Red_II = 1; - ACE_DBAL_A3_Red_VP = 1; - ACE_DBAL_A3_Green = 1; - ACE_DBAL_A3_Green_IP = 1; - ACE_DBAL_A3_Green_II = 1; - ACE_DBAL_A3_Green_VP = 1; - ACE_SPIR = 1; - ACE_SPIR_Medium = 1; - ACE_SPIR_Narrow = 1; - }; -}; +// Attenuation and Flashlight seem to not work with inheritance +#define VISIBLE_POINTER_FLASHLIGHT \ + class Flashlight { \ + color[] = {0, 0, 0}; \ + ambient[] = {0, 0, 0}; \ + size = 0; \ + innerAngle = 0; \ + outerAngle = 0; \ + position = "laser pos"; \ + direction = "laser dir"; \ + useFlare = 0; \ + flareSize = 0; \ + flareMaxDistance = 0; \ + coneFadeCoef = 0; \ + intensity = 0; \ + irLight = 0; \ + volumeShape = ""; \ + scale[] = {0, 0, 0}; \ + class Attenuation { \ + constant = 0; \ + linear = 0; \ + quadratic = 0; \ + start = 0; \ + hardLimitStart = 0; \ + hardLimitEnd = 0; \ + }; \ + } +#define DBAL_A3_FLASHLIGHT \ + class Flashlight { \ + color[] = {1, 1, 1}; \ + ambient[] = {1, 1, 1}; \ + size = 1; \ + innerAngle = 10; \ + outerAngle = 12; \ + position = "laser pos"; \ + direction = "laser dir"; \ + useFlare = 1; \ + flareSize = 1.4; \ + flareMaxDistance = 200; \ + coneFadeCoef = 6; \ + intensity = 100; \ + irLight = 1; \ + volumeShape = "a3\data_f\VolumeLightFlashlight.p3d"; \ + scale[] = {0.25, 0.25, 1}; \ + class Attenuation { \ + constant = 1; \ + linear = 0; \ + quadratic = 0.008; \ + start = 1; \ + hardLimitStart = 220; \ + hardLimitEnd = 250; \ + }; \ + } +#define DBAL_A3_FLASHLIGHT_LR \ + class Flashlight { \ + color[] = {1, 1, 1}; \ + ambient[] = {1, 1, 1}; \ + size = 1; \ + innerAngle = 10; \ + outerAngle = 12; \ + position = "laser pos"; \ + direction = "laser dir"; \ + useFlare = 1; \ + flareSize = 1.4; \ + flareMaxDistance = 200; \ + coneFadeCoef = 6; \ + intensity = 200; \ + irLight = 1; \ + volumeShape = "a3\data_f\VolumeLightFlashlight.p3d"; \ + scale[] = {0.25, 0.25, 1}; \ + class Attenuation { \ + constant = 1; \ + linear = 0; \ + quadratic = 0.001; \ + start = 1; \ + hardLimitStart = 570; \ + hardLimitEnd = 600; \ + }; \ + } +#define SPIR_FLASHLIGHT(hardLimitStart,hardLimitEnd) \ + color[] = {1, 1, 1}; \ + ambient[] = {1, 1, 1}; \ + size = 1; \ + position = "flash dir"; \ + direction = "flash"; \ + useFlare = 1; \ + flareSize = 1.4; \ + flareMaxDistance = 100; \ + irLight = 1; \ + volumeShape = "a3\data_f\VolumeLightFlashlight.p3d"; \ + class Attenuation { \ + constant = 1; \ + linear = 0; \ + quadratic = 0.02; \ + start = 1; \ + hardLimitStart = hardLimitStart; \ + hardLimitEnd = hardLimitEnd; \ + } +#define SPIR_FLASHLIGHT_LR(hardLimitStart,hardLimitEnd) \ + color[] = {1, 1, 1}; \ + ambient[] = {1, 1, 1}; \ + size = 1; \ + position = "flash dir"; \ + direction = "flash"; \ + useFlare = 1; \ + flareSize = 1.4; \ + flareMaxDistance = 100; \ + irLight = 1; \ + volumeShape = "a3\data_f\VolumeLightFlashlight.p3d"; \ + class Attenuation { \ + constant = 1; \ + linear = 0; \ + quadratic = 0.002; \ + start = 1; \ + hardLimitStart = hardLimitStart; \ + hardLimitEnd = hardLimitEnd; \ + } +#define POINTER \ + class Pointer { \ + irLaserPos = "laser pos"; \ + irLaserEnd = "laser dir"; \ + irDistance = 5; \ + } class CfgWeapons { - class ItemCore; - class acc_pointer_IR: ItemCore { - class ItemInfo; - }; + class acc_pointer_IR; + class acc_flashlight; + class InventoryFlashlightItem_Base_F; - class acc_flashlight: ItemCore { - class ItemInfo; - }; - - // DBAL A3 (red pointer) + // DBAL-A3 (red pointer) class ACE_DBAL_A3_Red: acc_pointer_IR { author = ECSTRING(common,ACETeam); displayName = CSTRING(DBAL_A3_Red); descriptionUse = CSTRING(DBAL_A3_DescriptionUse); descriptionShort = CSTRING(DBAL_A3_DescriptionShort); - MRT_SwitchItemNextClass = "ACE_DBAL_A3_Red_IP"; MRT_SwitchItemPrevClass = "ACE_DBAL_A3_Red_VP"; MRT_SwitchItemHintText = CSTRING(Mode_IRDual); + GVAR(baseClass) = "ACE_DBAL_A3_Red"; - class ItemInfo: ItemInfo { - class Flashlight { - color[] = {1, 1, 1, 1}; - ambient[] = {1, 1, 1, 1}; - size = 1; - innerAngle = 10; - outerAngle = 12; - position = "laser pos"; - direction = "laser dir"; - useFlare = 1; - flareSize = 1.4; - flareMaxDistance = 200; - scale[] = {0}; - coneFadeCoef = 6; - intensity = 100; - irLight = 1; - - class Attenuation { - constant = 1; - linear = 0; - quadratic = 0; - start = 500; - hardLimitStart = 1; - hardLimitEnd = 500; - }; - }; + class ItemInfo: InventoryFlashLightItem_Base_F { + DBAL_A3_FLASHLIGHT; + POINTER; }; }; class ACE_DBAL_A3_Red_IP: ACE_DBAL_A3_Red { scope = 1; - MRT_SwitchItemNextClass = "ACE_DBAL_A3_Red_II"; MRT_SwitchItemPrevClass = "ACE_DBAL_A3_Red"; MRT_SwitchItemHintText = CSTRING(Mode_IRPointer); - class ItemInfo: ItemInfo { + class ItemInfo: InventoryFlashLightItem_Base_F { class Flashlight {}; + POINTER; }; }; class ACE_DBAL_A3_Red_II: ACE_DBAL_A3_Red { scope = 1; - MRT_SwitchItemNextClass = "ACE_DBAL_A3_Red_VP"; MRT_SwitchItemPrevClass = "ACE_DBAL_A3_Red_IP"; MRT_SwitchItemHintText = CSTRING(Mode_IRIlluminator); - class ItemInfo: ItemInfo { - class Pointer {}; + class ItemInfo: InventoryFlashLightItem_Base_F { + DBAL_A3_FLASHLIGHT; }; }; class ACE_DBAL_A3_Red_VP: ACE_DBAL_A3_Red { scope = 1; ACE_laserpointer = 1; - MRT_SwitchItemNextClass = "ACE_DBAL_A3_Red"; MRT_SwitchItemPrevClass = "ACE_DBAL_A3_Red_II"; MRT_SwitchItemHintText = CSTRING(Mode_VisiblePointer); - class ItemInfo: ItemInfo { - class Pointer {}; - class Flashlight: Flashlight { - color[] = {0, 0, 0, 0}; - ambient[] = {0, 0, 0, 0}; - size = 0; - innerAngle = 0; - outerAngle = 0; - useFlare = 0; - intensity = 0; - irLight = 0; - - class Attenuation: Attenuation { - hardLimitStart = 0; - hardLimitEnd = 0; - }; - }; + class ItemInfo: InventoryFlashLightItem_Base_F { + VISIBLE_POINTER_FLASHLIGHT; + POINTER; + }; + }; + + // DBAL-A3 (red pointer, long range) + class ACE_DBAL_A3_Red_LR: ACE_DBAL_A3_Red { + scope = 1; + MRT_SwitchItemNextClass = "ACE_DBAL_A3_Red_LR_IP"; + MRT_SwitchItemPrevClass = "ACE_DBAL_A3_Red_LR_VP"; + GVAR(baseClass) = "ACE_DBAL_A3_Red_LR"; + + class ItemInfo: InventoryFlashLightItem_Base_F { + DBAL_A3_FLASHLIGHT_LR; + POINTER; }; }; - // DBAL A3 (green pointer) + class ACE_DBAL_A3_Red_LR_IP: ACE_DBAL_A3_Red_IP { + MRT_SwitchItemNextClass = "ACE_DBAL_A3_Red_LR_II"; + MRT_SwitchItemPrevClass = "ACE_DBAL_A3_Red_LR"; + GVAR(baseClass) = "ACE_DBAL_A3_Red_LR"; + }; + + class ACE_DBAL_A3_Red_LR_II: ACE_DBAL_A3_Red_II { + MRT_SwitchItemNextClass = "ACE_DBAL_A3_Red_LR_VP"; + MRT_SwitchItemPrevClass = "ACE_DBAL_A3_Red_LR_IP"; + GVAR(baseClass) = "ACE_DBAL_A3_Red_LR"; + + class ItemInfo: InventoryFlashLightItem_Base_F { + DBAL_A3_FLASHLIGHT_LR; + }; + }; + + class ACE_DBAL_A3_Red_LR_VP: ACE_DBAL_A3_Red_VP { + MRT_SwitchItemNextClass = "ACE_DBAL_A3_Red_LR"; + MRT_SwitchItemPrevClass = "ACE_DBAL_A3_Red_LR_II"; + GVAR(baseClass) = "ACE_DBAL_A3_Red_LR"; + }; + + // DBAL-A3 (green pointer) class ACE_DBAL_A3_Green: ACE_DBAL_A3_Red { scope = 2; displayName = CSTRING(DBAL_A3_Green); - MRT_SwitchItemNextClass = "ACE_DBAL_A3_Green_IP"; MRT_SwitchItemPrevClass = "ACE_DBAL_A3_Green_VP"; - MRT_SwitchItemHintText = CSTRING(Mode_IRDual); + GVAR(baseClass) = "ACE_DBAL_A3_Green"; }; class ACE_DBAL_A3_Green_IP: ACE_DBAL_A3_Red_IP { - scope = 1; displayName = CSTRING(DBAL_A3_Green); - MRT_SwitchItemNextClass = "ACE_DBAL_A3_Green_II"; MRT_SwitchItemPrevClass = "ACE_DBAL_A3_Green"; - MRT_SwitchItemHintText = CSTRING(Mode_IRPointer); + GVAR(baseClass) = "ACE_DBAL_A3_Green"; }; class ACE_DBAL_A3_Green_II: ACE_DBAL_A3_Red_II { - scope = 1; displayName = CSTRING(DBAL_A3_Green); - MRT_SwitchItemNextClass = "ACE_DBAL_A3_Green_VP"; MRT_SwitchItemPrevClass = "ACE_DBAL_A3_Green_IP"; - MRT_SwitchItemHintText = CSTRING(Mode_IRIlluminator); + GVAR(baseClass) = "ACE_DBAL_A3_Green"; }; class ACE_DBAL_A3_Green_VP: ACE_DBAL_A3_Red_VP { - scope = 1; displayName = CSTRING(DBAL_A3_Green); ACE_laserpointer = 2; - MRT_SwitchItemNextClass = "ACE_DBAL_A3_Green"; MRT_SwitchItemPrevClass = "ACE_DBAL_A3_Green_II"; - MRT_SwitchItemHintText = CSTRING(Mode_VisiblePointer); + GVAR(baseClass) = "ACE_DBAL_A3_Green"; + }; + + // DBAL-A3 (green pointer, long range) + class ACE_DBAL_A3_Green_LR: ACE_DBAL_A3_Green { + scope = 1; + MRT_SwitchItemNextClass = "ACE_DBAL_A3_Green_LR_IP"; + MRT_SwitchItemPrevClass = "ACE_DBAL_A3_Green_LR_VP"; + GVAR(baseClass) = "ACE_DBAL_A3_Green_LR"; + + class ItemInfo: InventoryFlashLightItem_Base_F { + DBAL_A3_FLASHLIGHT; + POINTER; + }; + }; + + class ACE_DBAL_A3_Green_LR_IP: ACE_DBAL_A3_Green_IP { + MRT_SwitchItemNextClass = "ACE_DBAL_A3_Green_LR_II"; + MRT_SwitchItemPrevClass = "ACE_DBAL_A3_Green_LR"; + GVAR(baseClass) = "ACE_DBAL_A3_Green_LR"; + }; + + class ACE_DBAL_A3_Green_LR_II: ACE_DBAL_A3_Green_II { + MRT_SwitchItemNextClass = "ACE_DBAL_A3_Green_LR_VP"; + MRT_SwitchItemPrevClass = "ACE_DBAL_A3_Green_LR_IP"; + GVAR(baseClass) = "ACE_DBAL_A3_Green_LR"; + + class ItemInfo: InventoryFlashLightItem_Base_F { + DBAL_A3_FLASHLIGHT; + }; + }; + + class ACE_DBAL_A3_Green_LR_VP: ACE_DBAL_A3_Green_VP { + MRT_SwitchItemNextClass = "ACE_DBAL_A3_Green_LR"; + MRT_SwitchItemPrevClass = "ACE_DBAL_A3_Green_LR_II"; + GVAR(baseClass) = "ACE_DBAL_A3_Green_LR"; }; // SPIR @@ -176,108 +287,106 @@ class CfgWeapons { displayName = "SPIR"; descriptionUse = CSTRING(SPIR_DescriptionUse); descriptionShort = CSTRING(SPIR_DescriptionShort); - MRT_SwitchItemNextClass = "ACE_SPIR_Medium"; MRT_SwitchItemPrevClass = "ACE_SPIR_Narrow"; MRT_SwitchItemHintText = CSTRING(Mode_Wide); - class ItemInfo: ItemInfo { + class ItemInfo: InventoryFlashlightItem_Base_F { class Flashlight { - color[] = {1, 1, 1, 1}; - ambient[] = {1, 1, 1, 1}; - size = 1; - innerAngle = 25; + SPIR_FLASHLIGHT(50,70); + innerAngle = 20; outerAngle = 32; - position = "flash dir"; - direction = "flash"; - useFlare = 1; - flareSize = 1.4; - flareMaxDistance = 200; - scale[] = {0}; - coneFadeCoef = 6; - intensity = 100; - irLight = 1; - - class Attenuation { - constant = 1; - linear = 0; - quadratic = 0; - start = 200; - hardLimitStart = 1; - hardLimitEnd = 200; - }; + coneFadeCoef = 2; + intensity = 50; + scale[] = {1, 1, 1}; }; }; }; class ACE_SPIR_Medium: ACE_SPIR { scope = 1; - MRT_SwitchItemNextClass = "ACE_SPIR_Narrow"; MRT_SwitchItemPrevClass = "ACE_SPIR"; MRT_SwitchItemHintText = CSTRING(Mode_Medium); - class ItemInfo: ItemInfo { + class ItemInfo: InventoryFlashlightItem_Base_F { class Flashlight { - color[] = {1, 1, 1, 1}; - ambient[] = {1, 1, 1, 1}; - size = 1; - position = "flash dir"; - direction = "flash"; - useFlare = 1; - flareSize = 1.4; - flareMaxDistance = 200; - scale[] = {0}; - coneFadeCoef = 6; + SPIR_FLASHLIGHT(80,100); intensity = 100; - irLight = 1; innerAngle = 10; outerAngle = 12; - - class Attenuation { - constant = 1; - linear = 0; - quadratic = 0; - hardLimitStart = 1; - start = 350; - hardLimitEnd = 350; - }; + coneFadeCoef = 3; + scale[] = {1, 1, 5}; }; }; }; class ACE_SPIR_Narrow: ACE_SPIR { scope = 1; - MRT_SwitchItemNextClass = "ACE_SPIR"; MRT_SwitchItemPrevClass = "ACE_SPIR_Medium"; MRT_SwitchItemHintText = CSTRING(Mode_Narrow); - class ItemInfo: ItemInfo { + class ItemInfo: InventoryFlashlightItem_Base_F { class Flashlight { - color[] = {1, 1, 1, 1}; - ambient[] = {1, 1, 1, 1}; - size = 1; - position = "flash dir"; - direction = "flash"; - useFlare = 1; - flareSize = 1.4; - flareMaxDistance = 200; - scale[] = {0}; - coneFadeCoef = 6; - intensity = 100; - irLight = 1; + SPIR_FLASHLIGHT(120,150); + intensity = 200; innerAngle = 5; outerAngle = 6; + coneFadeCoef = 4; + scale[] = {1, 1, 10}; + }; + }; + }; + + // SPIR (long range) + class ACE_SPIR_LR: ACE_SPIR { + scope = 1; + MRT_SwitchItemNextClass = "ACE_SPIR_LR_Medium"; + MRT_SwitchItemPrevClass = "ACE_SPIR_LR_Narrow"; - class Attenuation { - constant = 1; - linear = 0; - quadratic = 0; - hardLimitStart = 1; - start = 500; - hardLimitEnd = 500; - }; + class ItemInfo: InventoryFlashlightItem_Base_F { + class Flashlight { + SPIR_FLASHLIGHT_LR(80,100); + innerAngle = 20; + outerAngle = 32; + coneFadeCoef = 2; + intensity = 50; + scale[] = {1, 1, 1}; + }; + }; + }; + + class ACE_SPIR_LR_Medium: ACE_SPIR_LR { + MRT_SwitchItemNextClass = "ACE_SPIR_LR_Narrow"; + MRT_SwitchItemPrevClass = "ACE_SPIR_LR"; + MRT_SwitchItemHintText = CSTRING(Mode_Medium); + + class ItemInfo: InventoryFlashlightItem_Base_F { + class Flashlight { + SPIR_FLASHLIGHT_LR(100,120); + intensity = 100; + innerAngle = 10; + outerAngle = 12; + coneFadeCoef = 3; + scale[] = {1, 1, 5}; + }; + }; + }; + + class ACE_SPIR_LR_Narrow: ACE_SPIR_LR { + MRT_SwitchItemNextClass = "ACE_SPIR_LR"; + MRT_SwitchItemPrevClass = "ACE_SPIR_LR_Medium"; + MRT_SwitchItemHintText = CSTRING(Mode_Narrow); + + class ItemInfo: InventoryFlashlightItem_Base_F { + class Flashlight { + SPIR_FLASHLIGHT_LR(180,200); + intensity = 200; + innerAngle = 5; + outerAngle = 6; + coneFadeCoef = 4; + scale[] = {1, 1, 10}; }; }; }; diff --git a/addons/irlight/README.md b/addons/irlight/README.md index c92d5e0f848..3e55e4903f9 100644 --- a/addons/irlight/README.md +++ b/addons/irlight/README.md @@ -2,10 +2,3 @@ ace_irlight =================== Adds IR flashlights. - - -## Maintainers - -The people responsible for merging changes to this component or answering potential questions. - -- [BaerMitUmlaut](https://github.com/BaerMitUmlaut) diff --git a/addons/irlight/XEH_PREP.hpp b/addons/irlight/XEH_PREP.hpp new file mode 100644 index 00000000000..db1a29d22e1 --- /dev/null +++ b/addons/irlight/XEH_PREP.hpp @@ -0,0 +1,3 @@ +PREP(getGlowOffset); +PREP(initItemContextMenu); +PREP(onLightToggled); diff --git a/addons/irlight/XEH_postInit.sqf b/addons/irlight/XEH_postInit.sqf index b7fd6226f90..47763b8414f 100644 --- a/addons/irlight/XEH_postInit.sqf +++ b/addons/irlight/XEH_postInit.sqf @@ -1,49 +1,30 @@ #include "script_component.hpp" -{ - _x params ["_variant", "_displayName"]; - - [ - "ACE_DBAL_A3_Red", "POINTER", _displayName, [], "", { - params ["", "", "_item", "", "_variant"]; - - private _baseClass = if (_item select [0, 15] == "ACE_DBAL_A3_Red") then { - "ACE_DBAL_A3_Red" - } else { - "ACE_DBAL_A3_Green" - }; - - _item != _baseClass + _variant - }, { - params ["", "", "_item", "", "_variant"]; - - private _baseClass = if (_item select [0, 15] == "ACE_DBAL_A3_Red") then { - "ACE_DBAL_A3_Red" - } else { - "ACE_DBAL_A3_Green" - }; - - private _turnedOn = ACE_player isFlashlightOn primaryWeapon ACE_player - || ACE_player isIRLaserOn primaryWeapon ACE_player; - - ACE_player removePrimaryWeaponItem _item; - ACE_player addPrimaryWeaponItem (_baseClass + _variant); - playSound "click"; - - if (_turnedOn) then { - // Force update of flashlight - ACE_player action ["GunLightOff", ACE_player]; - - { - ACE_player action ["GunLightOn", ACE_player]; - ACE_player action ["IRLaserOn", ACE_player]; - } call CBA_fnc_execNextFrame; - }; - }, false, _variant - ] call CBA_fnc_addItemContextMenuOption; -} forEach [ - ["", LSTRING(Mode_IRDual)], - ["_IP", LSTRING(Mode_IRPointer)], - ["_II", LSTRING(Mode_IRIlluminator)], - ["_VP", LSTRING(Mode_VisiblePointer)] -]; +[] call FUNC(initItemContextMenu); + +addUserActionEventHandler ["headlights", "Deactivate", FUNC(onLightToggled)]; + +["ACE3 Equipment", QGVAR(hold), LLSTRING(MomentarySwitch), { + ACE_player action ["GunLightOn", ACE_player]; + ACE_player action ["IRLaserOn", ACE_player]; + [] call FUNC(onLightToggled); + true +}, { + ACE_player action ["GunLightOff", ACE_player]; + ACE_player action ["IRLaserOff", ACE_player]; + [] call FUNC(onLightToggled); + true +}] call CBA_fnc_addKeybind; + +["CBA_attachmentSwitched", { + params ["", "", "_item"]; + + private _substr = _item select [0, 8]; + if ( + ACE_player getVariable [QGVAR(isTurnedOn), false] + && {_substr == "ACE_SPIR" || {_substr == "ACE_DBAL"}} + ) then { + ACE_player action ["GunLightOn", ACE_player]; + ACE_player action ["IRLaserOn", ACE_player]; + }; +}] call CBA_fnc_addEventHandler; diff --git a/addons/irlight/XEH_preInit.sqf b/addons/irlight/XEH_preInit.sqf new file mode 100644 index 00000000000..b47cf6628db --- /dev/null +++ b/addons/irlight/XEH_preInit.sqf @@ -0,0 +1,9 @@ +#include "script_component.hpp" + +ADDON = false; + +PREP_RECOMPILE_START; +#include "XEH_PREP.hpp" +PREP_RECOMPILE_END; + +ADDON = true; diff --git a/addons/irlight/XEH_preStart.sqf b/addons/irlight/XEH_preStart.sqf new file mode 100644 index 00000000000..022888575ed --- /dev/null +++ b/addons/irlight/XEH_preStart.sqf @@ -0,0 +1,3 @@ +#include "script_component.hpp" + +#include "XEH_PREP.hpp" diff --git a/addons/irlight/config.cpp b/addons/irlight/config.cpp index aa2dc8806c4..c63753c9412 100644 --- a/addons/irlight/config.cpp +++ b/addons/irlight/config.cpp @@ -8,7 +8,7 @@ class CfgPatches { requiredVersion = REQUIRED_VERSION; requiredAddons[] = {"ace_common", "ace_laserpointer"}; author = ECSTRING(common,ACETeam); - authors[] = {"BaerMitUmlaut"}; + authors[] = {"BaerMitUmlaut", "OmniMan"}; url = ECSTRING(main,URL); VERSION_CONFIG; }; diff --git a/addons/irlight/data/irglow.p3d b/addons/irlight/data/irglow.p3d new file mode 100644 index 0000000000000000000000000000000000000000..d43e40d0f09e8a85b0bf3773710a69f195dc575d GIT binary patch literal 13082 zcmc(mO>A6O701U3`6#rsrHRwTA-FZphY7*?Bacsvn zBn}G9f(0!?fwr``h3;Af6XFyvK+4oZ9BQO=+OR-CsVcFkVADkz z@W|` zdx=MPz1KoK4TkI85#mwwar`tM8Hb;aFL?W+=-Yw+ezpDGOI)w$Q)%PBi_*vVSC6c} z6!fW#gQw#^Tz4(|*6d@+jm5>eYv;b1l@v?tW&XXBwI$}fT6eT`|2xlQ|15a_5&VDeD2r{ujol-d z^j{WC=1PCU-pZwr!4n)}nvp^ti(~)ApjAyE&yvnX@{~ zS-0kiTxyP-`#GoEw&hL)%u{mCd|5JCEAuxApTBxOx!Q2OzpcBTOI=HXPw>x3Pc}*X zd5QD8+Mk@oKOYEhuE8ILMEo-w{F!WjXTvP`i!w+2Oh0~0HcUR73%<>5o~(5~n5#RQ z?CV;^c_RK#gij9JSA~yoNU)_}uEp7YN3P}M>2YWK?Y0+l;wxvnUasq;pHnLM>vgub zN&i@wKPf(3CG+7aewbrEx=eU~f>WYj*BY1pErAc(?e{!O!=n2E&kg^S#Gl|KzmYjx z!gUc39}C{0%4V}kcXxM^m2+9&wSPI?l&q2SRZ^y=HYc>#$~pG|+RT^JOvBFn*zvFJ z{-XTL?&=*G8X4Q!yl3x&dv`bQX>NHy{Q!KRCwXX5-6hY&Es<7n7US%=(2`yBz`&_rH)lMgKcoGZQ^et!CCQ z^@GciYn6Sh-;1 z%W7;jwDAYSSln!US&glxHvVFAvwpE_laqH#k?%zkZ__#Q;!~k5Rn%Ote$ia$8~BI2 zKe2z@6S&-}T>t)InhUMjS(gjsXswi~si|9bU+`QCiS-MywMokJ!fmB< z!D?n>pZ(+B;5Vrfa&~iQ$Ib;C+g4+%Df{l0z>U3FPNU_i)zJFU`l*`6F>-LY4(-^vU^TO` z&)&8zaN%Che)5@0J8mvm4Xq!opQ>pbD;KPW){oXtR%3Btls$x8uo~(;%jbr_U!^sL zi#=laEuE)7o7(L1)M{2QL@0kMm-nsoJ$>t^d zM}rjnMxL^Nd^T{4eb2HQT0dGp)eA35TH_e;#y!hwX#HsYWHlCuXnATi)I9aM;qM7) zP2pmX7=BCV>EFwp66=MeUKXaPW{q-Ak+JMb=c$b+s~JAq?zp)>33;%?offjO^VG(Z z%}e%=oq-E^%Kovd(vEvSt(SEus-g9x^;0#CW5gSIYBjWew0^Q03q-U$wHj)k`rPpM zgtVq`u}3Vwr8INTbJZ{Mt}hV|3A~!593L2PZDQ?nq0M_5IgR2sG)-yd-n*n?U)oJM za&)&8xbg0T9Q}M~$G&H!V%t6UwtlpJ!iReTH{I`IX=*jJezbnF8Vk)RnywaHtD)w? z-mHI@X*Gq5J!1F`ZZ%SPmgKn<6031F4OfC2xnMQ3ej+EoAVuEuyIdeInnOEwE?B?V z*eC8=0vGlSc(#Ui>|C(1ZT)Ed#Qu>D+@y-OzY%X%L(PR3roQ6VwVH~_vLkjbJny&^ z6031F4K2AC+{gtRUshwQp^ZOy#^PrEV%H|N*k^c0uJ=#)=sR=HV{x;7v9V8%t_fV& zGssc=4L7Nx=7NoN&4rrGezz`r+4{icR{hQ)@f~?;+ zmOnLkVsvC|B0t>QFC8E8Xla(?Bif{=*EDoLdaQqn;xZdCfiEd4>2ZVJ?F z7W(5TYC%ZoCsFl>O7t(a3vQg7e;SVsQE?TATKic?aTSkR*H^r-vAQobaM6Cwbw20V zQENZ^^amR^!w)s|M-$kE4=WWs)}dc9wB{j!u0sv3;xQ+^uD10>JvDtgUtgO0@ur-< zxMmJ~=vQ9h;e_L(IMmwDx{9lKzV?1dZY7NRG`K$f)nz; z;BeHA8eWRaJm#w%b+~?qt6y~KXJ61Sn~JY^X?y1B7dvXjXIS?WnaM zT>Y{^KW+WMuRQ2iJn-qqUU8_?>uQ^Qntp2R)AQj^zt)P!`uc%S_j&!$g*`ZFJY5%i z`nA@6@Ua6|@u=yqX?SS3@94nc!J&Shmv9u4^#3~XeM^7+r-pEsa`#%x?`MtZl{|hWz?X&;@ literal 0 HcmV?d00001 diff --git a/addons/irlight/data/irglow.rvmat b/addons/irlight/data/irglow.rvmat new file mode 100644 index 00000000000..d39184a535b --- /dev/null +++ b/addons/irlight/data/irglow.rvmat @@ -0,0 +1,79 @@ +ambient[] = {0, 0, 0, 1}; +diffuse[] = {0, 0, 0, 1}; +forcedDiffuse[] = {0, 0, 0, 1}; +emmisive[] = {775, 121, 549, 0}; +specular[] = {0, 0, 0, 1}; +specularPower = 30; +PixelShaderID = "Super"; +VertexShaderID = "Super"; +class Stage1 { + texture = "#(argb,8,8,3)color(0.5,0.5,1,1,NOHQ)"; + uvSource = "tex"; + class uvTransform { + aside[] = {1, 0, 0}; + up[] = {0, 1, 0}; + dir[] = {0, 0, 0}; + pos[] = {0, 0, 0}; + }; +}; +class Stage2 { + texture = "#(argb,8,8,3)color(0.5,0.5,0.5,0.5,DT)"; + uvSource = "tex"; + class uvTransform { + aside[] = {1, 0, 0}; + up[] = {0, 1, 0}; + dir[] = {0, 0, 0}; + pos[] = {0, 0, 0}; + }; +}; +class Stage3 { + texture = "#(argb,8,8,3)color(1.0,1.0,1.0,0.0,MC)"; + uvSource = "tex"; + class uvTransform { + aside[] = {1, 0, 0}; + up[] = {0, 1, 0}; + dir[] = {0, 0, 0}; + pos[] = {0, 0, 0}; + }; +}; +class Stage4 { + texture = "#(argb,8,8,3)color(1.0,1.0,1.0,1.0,AS)"; + uvSource = "tex"; + class uvTransform { + aside[] = {1, 0, 0}; + up[] = {0, 1, 0}; + dir[] = {0, 0, 0}; + pos[] = {0, 0, 0}; + }; +}; +class Stage5 { + texture = "#(argb,8,8,3)color(1,0.0,1,0,SMDI)"; + uvSource = "tex"; + class uvTransform { + aside[] = {1, 0, 0}; + up[] = {0, 1, 0}; + dir[] = {0, 0, 0}; + pos[] = {0, 0, 0}; + }; +}; +class Stage6 { + texture = "#(ai,64,64,1)fresnel(0.4,0.2)"; + uvSource = "tex"; + class uvTransform { + aside[] = {1, 0, 0}; + up[] = {0, 1, 0}; + dir[] = {0, 0, 0}; + pos[] = {0, 0, 0}; + }; +}; +class Stage7 { + texture = "a3\data_f\env_land_co.paa"; + useWorldEnvMap = "true"; + uvSource = "tex"; + class uvTransform { + aside[] = {1, 0, 0}; + up[] = {0, 1, 0}; + dir[] = {0, 0, 0}; + pos[] = {0, 0, 0}; + }; +}; diff --git a/addons/irlight/data/model.cfg b/addons/irlight/data/model.cfg new file mode 100644 index 00000000000..949c7bebcc3 --- /dev/null +++ b/addons/irlight/data/model.cfg @@ -0,0 +1,8 @@ +class CfgModels { + class Default { + sectionsInherit = ""; + sections[] = {""}; + skeletonName = ""; + }; + class irglow: Default {}; +}; diff --git a/addons/irlight/dev/createTestLight.sqf b/addons/irlight/dev/createTestLight.sqf new file mode 100644 index 00000000000..3aace8ab3d8 --- /dev/null +++ b/addons/irlight/dev/createTestLight.sqf @@ -0,0 +1,42 @@ +#include "..\script_component.hpp" +/* + * Author: BaerMitUmlaut + * Creates a scripted test light to test weapon lights without reloading. + * + * Arguments: + * 0: Flashlight class name + * + * Return Value: + * None + * + * Example: + * "ACE_SPIR" call compile preprocessFileLineNumbers "\z\ace\addons\irlight\dev\createTestLight.sqf" + * + * Public: No + */ + +params ["_className"]; + +private _cfg = configFile >> "CfgWeapons" >> _className >> "ItemInfo" >> "Flashlight"; + +deleteVehicle lgt; +lgt = "#lightreflector" createVehicleLocal [0, 0, 0]; +lgt attachTo [player, [0.0396804,0.237947,0.104276], "proxy:\a3\characters_f\proxies\weapon.001", true]; +lgt setLightIntensity getNumber (_cfg >> "intensity"); +lgt setLightColor (getArray (_cfg >> "color") select [0, 3]); +lgt setLightAmbient (getArray (_cfg >> "ambient") select [0, 3]); +lgt setLightConePars [ + getNumber (_cfg >> "outerAngle"), + getNumber (_cfg >> "innerAngle"), + getNumber (_cfg >> "coneFadeCoef") +]; + +attenuation = [ + getNumber (_cfg >> "Attenuation" >> "start"), + getNumber (_cfg >> "Attenuation" >> "constant"), + getNumber (_cfg >> "Attenuation" >> "linear"), + getNumber (_cfg >> "Attenuation" >> "quadratic"), + getNumber (_cfg >> "Attenuation" >> "hardLimitStart"), + getNumber (_cfg >> "Attenuation" >> "hardLimitEnd") +]; +lgt setLightAttenuation attenuation; diff --git a/addons/irlight/functions/fnc_getGlowOffset.sqf b/addons/irlight/functions/fnc_getGlowOffset.sqf new file mode 100644 index 00000000000..613e551111c --- /dev/null +++ b/addons/irlight/functions/fnc_getGlowOffset.sqf @@ -0,0 +1,41 @@ +#include "..\script_component.hpp" +/* + * Author: BaerMitUmlaut + * Gets the player model offset of the IR laser origin. + * Currently unused, see onLightToggled. + * + * Arguments: + * None + * + * Return Value: + * None + * + * Example: + * [] call ace_irlight_fnc_getGlowOffset + * + * Public: No + */ + +if (isNil QGVAR(offsetCache)) then { + GVAR(offsetCache) = createHashMap; +}; + +private _weapon = currentWeapon ACE_player; +private _laser = ((weaponsItems ACE_player) select {_x#0 == _weapon})#0#2; + +GVAR(offsetCache) getOrDefaultCall [[_weapon, _laser], { + private _model = getText (configFile >> "CfgWeapons" >> _weapon >> "model"); + private _dummy = createSimpleObject [_model, [0, 0, 0], true]; + private _proxyOffset = _dummy selectionPosition ["\a3\data_f\proxies\weapon_slots\SIDE.001", 1]; + _proxyOffset = [_proxyOffset#1, _proxyOffset#0 * -1, _proxyOffset#2]; + deleteVehicle _dummy; + + _model = getText (configFile >> "CfgWeapons" >> _laser >> "model"); + _dummy = createSimpleObject [_model, [0, 0, 0], true]; + private _selection = getText (configFile >> "CfgWeapons" >> _laser >> "ItemInfo" >> "Pointer" >> "irLaserPos"); + private _laserOffset = _dummy selectionPosition [_selection, "Memory"]; + _laserOffset = [_laserOffset#1, _laserOffset#0 * -1, _laserOffset#2 * -1]; + deleteVehicle _dummy; + + _proxyOffset vectorAdd _laserOffset +}, true]; diff --git a/addons/irlight/functions/fnc_initItemContextMenu.sqf b/addons/irlight/functions/fnc_initItemContextMenu.sqf new file mode 100644 index 00000000000..df65bf08820 --- /dev/null +++ b/addons/irlight/functions/fnc_initItemContextMenu.sqf @@ -0,0 +1,52 @@ +#include "..\script_component.hpp" +/* + * Author: BaerMitUmlaut + * Initializes the item context menu for the DBAL. + * + * Arguments: + * None + * + * Return Value: + * None + * + * Example: + * [] call ace_irlight_fnc_initItemContextMenu + * + * Public: No + */ + +{ + _x params ["_variant", "_displayName"]; + + [ + "ACE_DBAL_A3_Red", "POINTER", _displayName, [], "", { + params ["", "", "_item", "", "_variant"]; + + private _baseClass = getText (configFile >> "CfgWeapons" >> _item >> QGVAR(baseClass)); + _item != _baseClass + _variant + }, { + params ["", "", "_item", "", "_variant"]; + + private _baseClass = getText (configFile >> "CfgWeapons" >> _item >> QGVAR(baseClass)); + + ACE_player removePrimaryWeaponItem _item; + ACE_player addPrimaryWeaponItem (_baseClass + _variant); + playSound "click"; + + if (_turnedOn) then { + // Force update of flashlight + ACE_player action ["GunLightOff", ACE_player]; + + { + ACE_player action ["GunLightOn", ACE_player]; + ACE_player action ["IRLaserOn", ACE_player]; + } call CBA_fnc_execNextFrame; + }; + }, false, _variant + ] call CBA_fnc_addItemContextMenuOption; +} forEach [ + ["", LSTRING(Mode_IRDual)], + ["_IP", LSTRING(Mode_IRPointer)], + ["_II", LSTRING(Mode_IRIlluminator)], + ["_VP", LSTRING(Mode_VisiblePointer)] +]; diff --git a/addons/irlight/functions/fnc_onLightToggled.sqf b/addons/irlight/functions/fnc_onLightToggled.sqf new file mode 100644 index 00000000000..b3592f28f60 --- /dev/null +++ b/addons/irlight/functions/fnc_onLightToggled.sqf @@ -0,0 +1,36 @@ +#include "..\script_component.hpp" +/* + * Author: BaerMitUmlaut + * Handles toggling flashlights on and off. + * + * Arguments: + * None + * + * Return Value: + * None + * + * Example: + * [] call ace_irlight_fnc_onLightToggled + * + * Public: No + */ + +private _isTurnedOn = ACE_player isFlashlightOn primaryWeapon ACE_player + || ACE_player isIRLaserOn primaryWeapon ACE_player; +ACE_player setVariable [QGVAR(isTurnedOn), _isTurnedOn]; + +// This is a surprise tool that will help us later +// Requires: https://feedback.bistudio.com/T170774 +/* +deleteVehicle (ACE_player getVariable [QGVAR(glow), objNull]); + +if (ACE_player isIRLaserOn currentWeapon ACE_player) then { + private _offset = [] call FUNC(getGlowOffset); + private _glow = createSimpleObject [QPATHTOF(data\irglow.p3d), [0, 0, 0]]; + _glow attachTo [ACE_player, _offset, "proxy:\a3\characters_f\proxies\weapon.001", true]; + _glow setObjectTexture [0, "#(rgb,8,8,3)color(0.35,0,0.38,0.1)"]; + _glow setObjectScale 0.1; + + ACE_player setVariable [QGVAR(glow), _glow]; +}; +*/ diff --git a/addons/irlight/script_component.hpp b/addons/irlight/script_component.hpp index d742691d782..76e3eb11a32 100644 --- a/addons/irlight/script_component.hpp +++ b/addons/irlight/script_component.hpp @@ -1,5 +1,5 @@ #define COMPONENT irlight -#define COMPONENT_BEAUTIFIED IR Light +#define COMPONENT_BEAUTIFIED IR Lights #include "\z\ace\addons\main\script_mod.hpp" // #define DEBUG_MODE_FULL diff --git a/addons/irlight/stringtable.xml b/addons/irlight/stringtable.xml index a326e83bd54..50d93bcd565 100644 --- a/addons/irlight/stringtable.xml +++ b/addons/irlight/stringtable.xml @@ -2,12 +2,12 @@ - DBAL A3 (red) - DBAL A3 (rot) + DBAL-A3 (red) + DBAL-A3 (rot) - DBAL A3 (green) - DBAL A3 (grün) + DBAL-A3 (green) + DBAL-A3 (grün) <t color='#9cf953'>Use: </t>Turn Laser ON/OFF<br>Double click to switch mode @@ -53,5 +53,9 @@ Special Purpose IR LED Illuminator Infrarot LED Taschenlampe + + Illuminator / Laser Momentary Switch + Licht / Laser Tastschalter + diff --git a/addons/laserpointer/XEH_postInit.sqf b/addons/laserpointer/XEH_postInit.sqf index d2d1aec747d..3a6fa90c2ad 100644 --- a/addons/laserpointer/XEH_postInit.sqf +++ b/addons/laserpointer/XEH_postInit.sqf @@ -62,14 +62,19 @@ GVAR(greenLaserUnits) = []; }; TRACE_3("",_weapon,_laser,_laserID); - if (_laserID isEqualTo 1) exitWith { - GVAR(redLaserUnits) pushBackUnique _unit; - GVAR(greenLaserUnits) deleteAt (GVAR(greenLaserUnits) find _unit); - }; - - if (_laserID isEqualTo 2) exitWith { - GVAR(greenLaserUnits) pushBackUnique _unit; - GVAR(redLaserUnits) deleteAt (GVAR(redLaserUnits) find _unit); + switch (_laserID) do { + case 0: { + GVAR(redLaserUnits) deleteAt (GVAR(redLaserUnits) find _unit); + GVAR(greenLaserUnits) deleteAt (GVAR(greenLaserUnits) find _unit); + }; + case 1: { + GVAR(redLaserUnits) pushBackUnique _unit; + GVAR(greenLaserUnits) deleteAt (GVAR(greenLaserUnits) find _unit); + }; + case 2: { + GVAR(greenLaserUnits) pushBackUnique _unit; + GVAR(redLaserUnits) deleteAt (GVAR(redLaserUnits) find _unit); + }; }; }; diff --git a/addons/laserpointer/script_component.hpp b/addons/laserpointer/script_component.hpp index 4b7b2e0d394..698ea5acb45 100644 --- a/addons/laserpointer/script_component.hpp +++ b/addons/laserpointer/script_component.hpp @@ -3,7 +3,7 @@ #include "\z\ace\addons\main\script_mod.hpp" // #define DEBUG_MODE_FULL -// #define DISABLE_COMPILE_CACHE +#define DISABLE_COMPILE_CACHE // #define ENABLE_PERFORMANCE_COUNTERS #ifdef DEBUG_ENABLED_LASERPOINTER diff --git a/addons/map/functions/fnc_isFlashlight.sqf b/addons/map/functions/fnc_isFlashlight.sqf index 2ec7a2c9685..e563d741145 100644 --- a/addons/map/functions/fnc_isFlashlight.sqf +++ b/addons/map/functions/fnc_isFlashlight.sqf @@ -32,7 +32,7 @@ if (isNil "_isFlashlight") then { _weaponConfig >> "FlashLight" ] findIf { isText (_x >> "ACE_Flashlight_Colour") - || {!(getArray (_x >> "ambient") in [[], [0,0,0]])} + || {!(getArray (_x >> "ambient") in [[], [0,0,0]]) && {getNumber (_x >> "irLight") == 0}} } != -1 // return } != -1; diff --git a/docs/wiki/class-names.md b/docs/wiki/class-names.md index e01989c90bb..d8537f06458 100644 --- a/docs/wiki/class-names.md +++ b/docs/wiki/class-names.md @@ -171,6 +171,18 @@ ACE_HuntIR_monitor | HuntIR monitor | ACE_ItemCore | ACE_HuntIR_M203 | HuntIR Round | Grenade shell | ACE_HuntIR_Box | HuntIR Transport Box | ammo box | +### IR Lights +`Added in 3.16.0` + +Class Name | In-Game Name | Type | +---------- | --------- | --------- +ACE_DBAL_A3_Red | DBAL-A3 (red) | Weapon accessory | +ACE_DBAL_A3_Red_LR | DBAL-A3 (red) | Weapon accessory | +ACE_DBAL_A3_Green | DBAL-A3 (green) | Weapon accessory | +ACE_DBAL_A3_Green_LR | DBAL-A3 (green) | Weapon accessory | +ACE_SPIR | SPIR | Weapon accessory | +ACE_SPIR_LR | SPIR | Weapon accessory | + ### Kestrel `Added in 3.0.0` diff --git a/docs/wiki/feature/irlight.md b/docs/wiki/feature/irlight.md new file mode 100644 index 00000000000..c909ef6bcd4 --- /dev/null +++ b/docs/wiki/feature/irlight.md @@ -0,0 +1,45 @@ +--- +layout: wiki +title: IR Lights +component: irlight +description: IR flashlights and multi function lasers. +group: feature +category: equipment +parent: wiki +mod: ace +version: + major: 3 + minor: 16 + patch: 0 +--- + +## 1. Overview + +### 1.1 DBAL-A3 +The DBAL-A3 is a multi function laser and can be run in the following modes: + +- IR laser and IR illuminator +- IR laser +- IR illuminator +- Visible laser + +### 1.2 SPIR +The SPIR is an IR only flashlight. It uses a diffused laser, which improves its effective range considerably compared to a conventional flashlight. It has three modes with different beam widths to allow both easy terrain navigation and engagements at longer ranges during difficult lighting conditions. + +### 1.3 Long Range Variants +Due to Arma 3's dated lighting system, flashlights can shine through objects and walls. To avoid these visual bugs, we have opted to tone down their range considerably compared to their real life counterparts. Although the DBAL-A3 has a range of up to 4000 m according to its manufacturer, such intense lights are simply not feasible in Arma. + +Realism focused players which are not bothered by some visual bugs can use the long range variants of the DBAL-A3 and the SPIR. They are, besides their increased lighting power, identical to their normal range counterparts and can be accessed by appending `_LR` to the class name (see [Class Names](../class-names#ir-lights)). They still provide a lower lighting range than their real life counter parts, but should offer a nice middleground. + +| Attachment | Normal Range | Long Range | +| ---------- | --------------- | ---------------- | +| DBAL-A3 | 220 m | 570 m | +| SPIR | 50 / 80 / 120 m | 80 / 100 / 180 m | + +## 2. Usage + +## 2.1 Momentary Switch +ACE IR Lights adds a keybind in the equipment category to temporarily turn on a flashlight or laser while holding down the key. There is no default keybind set. + +## 2.2 Function Mode Switching +The DBAL-A3 function mode can be switched using the [CBA Accessory Functions](https://github.com/CBATeam/CBA_A3/wiki/Accessory-Functions) (default: Ctrl + L) or the item context menu, which can be accessed by double clicking the attachment in the inventory menu. From e7b1ecfbc623f887a6b2bc515a703a6ac623b867 Mon Sep 17 00:00:00 2001 From: BaerMitUmlaut Date: Thu, 14 Sep 2023 21:25:55 +0200 Subject: [PATCH 05/12] Fix uncommented DISABLE_COMPILE_CACHE Co-authored-by: jonpas --- addons/laserpointer/script_component.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/laserpointer/script_component.hpp b/addons/laserpointer/script_component.hpp index 698ea5acb45..4b7b2e0d394 100644 --- a/addons/laserpointer/script_component.hpp +++ b/addons/laserpointer/script_component.hpp @@ -3,7 +3,7 @@ #include "\z\ace\addons\main\script_mod.hpp" // #define DEBUG_MODE_FULL -#define DISABLE_COMPILE_CACHE +// #define DISABLE_COMPILE_CACHE // #define ENABLE_PERFORMANCE_COUNTERS #ifdef DEBUG_ENABLED_LASERPOINTER From a291a7d5c43a79a01e5175b8ece77e7fe9a02320 Mon Sep 17 00:00:00 2001 From: BaerMitUmlaut Date: Thu, 14 Sep 2023 21:35:26 +0200 Subject: [PATCH 06/12] Markdown fixes Co-authored-by: jonpas --- docs/wiki/feature/irlight.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/wiki/feature/irlight.md b/docs/wiki/feature/irlight.md index c909ef6bcd4..6c04e97bcbc 100644 --- a/docs/wiki/feature/irlight.md +++ b/docs/wiki/feature/irlight.md @@ -16,6 +16,7 @@ version: ## 1. Overview ### 1.1 DBAL-A3 + The DBAL-A3 is a multi function laser and can be run in the following modes: - IR laser and IR illuminator From 51328094da22ce99c6568d4d8132f00ec4a73b86 Mon Sep 17 00:00:00 2001 From: BaerMitUmlaut Date: Thu, 14 Sep 2023 21:35:34 +0200 Subject: [PATCH 07/12] Markdown fixes Co-authored-by: jonpas --- docs/wiki/feature/irlight.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/wiki/feature/irlight.md b/docs/wiki/feature/irlight.md index 6c04e97bcbc..cd7de3cba85 100644 --- a/docs/wiki/feature/irlight.md +++ b/docs/wiki/feature/irlight.md @@ -25,6 +25,7 @@ The DBAL-A3 is a multi function laser and can be run in the following modes: - Visible laser ### 1.2 SPIR + The SPIR is an IR only flashlight. It uses a diffused laser, which improves its effective range considerably compared to a conventional flashlight. It has three modes with different beam widths to allow both easy terrain navigation and engagements at longer ranges during difficult lighting conditions. ### 1.3 Long Range Variants From 413355aec626622abcf5ba0de79c9656d259ee04 Mon Sep 17 00:00:00 2001 From: BaerMitUmlaut Date: Thu, 14 Sep 2023 21:35:42 +0200 Subject: [PATCH 08/12] Markdown fixes Co-authored-by: jonpas --- docs/wiki/feature/irlight.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/wiki/feature/irlight.md b/docs/wiki/feature/irlight.md index cd7de3cba85..1ef0c5e5d97 100644 --- a/docs/wiki/feature/irlight.md +++ b/docs/wiki/feature/irlight.md @@ -29,6 +29,7 @@ The DBAL-A3 is a multi function laser and can be run in the following modes: The SPIR is an IR only flashlight. It uses a diffused laser, which improves its effective range considerably compared to a conventional flashlight. It has three modes with different beam widths to allow both easy terrain navigation and engagements at longer ranges during difficult lighting conditions. ### 1.3 Long Range Variants + Due to Arma 3's dated lighting system, flashlights can shine through objects and walls. To avoid these visual bugs, we have opted to tone down their range considerably compared to their real life counterparts. Although the DBAL-A3 has a range of up to 4000 m according to its manufacturer, such intense lights are simply not feasible in Arma. Realism focused players which are not bothered by some visual bugs can use the long range variants of the DBAL-A3 and the SPIR. They are, besides their increased lighting power, identical to their normal range counterparts and can be accessed by appending `_LR` to the class name (see [Class Names](../class-names#ir-lights)). They still provide a lower lighting range than their real life counter parts, but should offer a nice middleground. From 20589f0b762ea77020b93a67c6f08a58f36de044 Mon Sep 17 00:00:00 2001 From: BaerMitUmlaut Date: Thu, 14 Sep 2023 21:35:50 +0200 Subject: [PATCH 09/12] Markdown fixes Co-authored-by: jonpas --- docs/wiki/feature/irlight.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/wiki/feature/irlight.md b/docs/wiki/feature/irlight.md index 1ef0c5e5d97..cd75904d047 100644 --- a/docs/wiki/feature/irlight.md +++ b/docs/wiki/feature/irlight.md @@ -42,6 +42,7 @@ Realism focused players which are not bothered by some visual bugs can use the l ## 2. Usage ## 2.1 Momentary Switch + ACE IR Lights adds a keybind in the equipment category to temporarily turn on a flashlight or laser while holding down the key. There is no default keybind set. ## 2.2 Function Mode Switching From 1872c6f68b031745143fcd0511a39733f372ffb5 Mon Sep 17 00:00:00 2001 From: BaerMitUmlaut Date: Thu, 14 Sep 2023 21:36:05 +0200 Subject: [PATCH 10/12] Markdown fixes Co-authored-by: jonpas --- docs/wiki/feature/irlight.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/wiki/feature/irlight.md b/docs/wiki/feature/irlight.md index cd75904d047..0273e083b86 100644 --- a/docs/wiki/feature/irlight.md +++ b/docs/wiki/feature/irlight.md @@ -46,4 +46,5 @@ Realism focused players which are not bothered by some visual bugs can use the l ACE IR Lights adds a keybind in the equipment category to temporarily turn on a flashlight or laser while holding down the key. There is no default keybind set. ## 2.2 Function Mode Switching + The DBAL-A3 function mode can be switched using the [CBA Accessory Functions](https://github.com/CBATeam/CBA_A3/wiki/Accessory-Functions) (default: Ctrl + L) or the item context menu, which can be accessed by double clicking the attachment in the inventory menu. From eb0477928f073720a9a5ad6baa92409aef71be9c Mon Sep 17 00:00:00 2001 From: BaerMitUmlaut Date: Fri, 15 Sep 2023 22:45:35 +0200 Subject: [PATCH 11/12] Use baseWeapon instead of custom property --- addons/irlight/CfgWeapons.hpp | 26 +++++++++---------- .../functions/fnc_initItemContextMenu.sqf | 4 +-- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/addons/irlight/CfgWeapons.hpp b/addons/irlight/CfgWeapons.hpp index 2b29f1e2990..40872e1be98 100644 --- a/addons/irlight/CfgWeapons.hpp +++ b/addons/irlight/CfgWeapons.hpp @@ -136,7 +136,7 @@ class CfgWeapons { MRT_SwitchItemNextClass = "ACE_DBAL_A3_Red_IP"; MRT_SwitchItemPrevClass = "ACE_DBAL_A3_Red_VP"; MRT_SwitchItemHintText = CSTRING(Mode_IRDual); - GVAR(baseClass) = "ACE_DBAL_A3_Red"; + baseWeapon = "ACE_DBAL_A3_Red"; class ItemInfo: InventoryFlashLightItem_Base_F { DBAL_A3_FLASHLIGHT; @@ -185,7 +185,7 @@ class CfgWeapons { scope = 1; MRT_SwitchItemNextClass = "ACE_DBAL_A3_Red_LR_IP"; MRT_SwitchItemPrevClass = "ACE_DBAL_A3_Red_LR_VP"; - GVAR(baseClass) = "ACE_DBAL_A3_Red_LR"; + baseWeapon = "ACE_DBAL_A3_Red_LR"; class ItemInfo: InventoryFlashLightItem_Base_F { DBAL_A3_FLASHLIGHT_LR; @@ -196,13 +196,13 @@ class CfgWeapons { class ACE_DBAL_A3_Red_LR_IP: ACE_DBAL_A3_Red_IP { MRT_SwitchItemNextClass = "ACE_DBAL_A3_Red_LR_II"; MRT_SwitchItemPrevClass = "ACE_DBAL_A3_Red_LR"; - GVAR(baseClass) = "ACE_DBAL_A3_Red_LR"; + baseWeapon = "ACE_DBAL_A3_Red_LR"; }; class ACE_DBAL_A3_Red_LR_II: ACE_DBAL_A3_Red_II { MRT_SwitchItemNextClass = "ACE_DBAL_A3_Red_LR_VP"; MRT_SwitchItemPrevClass = "ACE_DBAL_A3_Red_LR_IP"; - GVAR(baseClass) = "ACE_DBAL_A3_Red_LR"; + baseWeapon = "ACE_DBAL_A3_Red_LR"; class ItemInfo: InventoryFlashLightItem_Base_F { DBAL_A3_FLASHLIGHT_LR; @@ -212,7 +212,7 @@ class CfgWeapons { class ACE_DBAL_A3_Red_LR_VP: ACE_DBAL_A3_Red_VP { MRT_SwitchItemNextClass = "ACE_DBAL_A3_Red_LR"; MRT_SwitchItemPrevClass = "ACE_DBAL_A3_Red_LR_II"; - GVAR(baseClass) = "ACE_DBAL_A3_Red_LR"; + baseWeapon = "ACE_DBAL_A3_Red_LR"; }; // DBAL-A3 (green pointer) @@ -221,21 +221,21 @@ class CfgWeapons { displayName = CSTRING(DBAL_A3_Green); MRT_SwitchItemNextClass = "ACE_DBAL_A3_Green_IP"; MRT_SwitchItemPrevClass = "ACE_DBAL_A3_Green_VP"; - GVAR(baseClass) = "ACE_DBAL_A3_Green"; + baseWeapon = "ACE_DBAL_A3_Green"; }; class ACE_DBAL_A3_Green_IP: ACE_DBAL_A3_Red_IP { displayName = CSTRING(DBAL_A3_Green); MRT_SwitchItemNextClass = "ACE_DBAL_A3_Green_II"; MRT_SwitchItemPrevClass = "ACE_DBAL_A3_Green"; - GVAR(baseClass) = "ACE_DBAL_A3_Green"; + baseWeapon = "ACE_DBAL_A3_Green"; }; class ACE_DBAL_A3_Green_II: ACE_DBAL_A3_Red_II { displayName = CSTRING(DBAL_A3_Green); MRT_SwitchItemNextClass = "ACE_DBAL_A3_Green_VP"; MRT_SwitchItemPrevClass = "ACE_DBAL_A3_Green_IP"; - GVAR(baseClass) = "ACE_DBAL_A3_Green"; + baseWeapon = "ACE_DBAL_A3_Green"; }; class ACE_DBAL_A3_Green_VP: ACE_DBAL_A3_Red_VP { @@ -243,7 +243,7 @@ class CfgWeapons { ACE_laserpointer = 2; MRT_SwitchItemNextClass = "ACE_DBAL_A3_Green"; MRT_SwitchItemPrevClass = "ACE_DBAL_A3_Green_II"; - GVAR(baseClass) = "ACE_DBAL_A3_Green"; + baseWeapon = "ACE_DBAL_A3_Green"; }; // DBAL-A3 (green pointer, long range) @@ -251,7 +251,7 @@ class CfgWeapons { scope = 1; MRT_SwitchItemNextClass = "ACE_DBAL_A3_Green_LR_IP"; MRT_SwitchItemPrevClass = "ACE_DBAL_A3_Green_LR_VP"; - GVAR(baseClass) = "ACE_DBAL_A3_Green_LR"; + baseWeapon = "ACE_DBAL_A3_Green_LR"; class ItemInfo: InventoryFlashLightItem_Base_F { DBAL_A3_FLASHLIGHT; @@ -262,13 +262,13 @@ class CfgWeapons { class ACE_DBAL_A3_Green_LR_IP: ACE_DBAL_A3_Green_IP { MRT_SwitchItemNextClass = "ACE_DBAL_A3_Green_LR_II"; MRT_SwitchItemPrevClass = "ACE_DBAL_A3_Green_LR"; - GVAR(baseClass) = "ACE_DBAL_A3_Green_LR"; + baseWeapon = "ACE_DBAL_A3_Green_LR"; }; class ACE_DBAL_A3_Green_LR_II: ACE_DBAL_A3_Green_II { MRT_SwitchItemNextClass = "ACE_DBAL_A3_Green_LR_VP"; MRT_SwitchItemPrevClass = "ACE_DBAL_A3_Green_LR_IP"; - GVAR(baseClass) = "ACE_DBAL_A3_Green_LR"; + baseWeapon = "ACE_DBAL_A3_Green_LR"; class ItemInfo: InventoryFlashLightItem_Base_F { DBAL_A3_FLASHLIGHT; @@ -278,7 +278,7 @@ class CfgWeapons { class ACE_DBAL_A3_Green_LR_VP: ACE_DBAL_A3_Green_VP { MRT_SwitchItemNextClass = "ACE_DBAL_A3_Green_LR"; MRT_SwitchItemPrevClass = "ACE_DBAL_A3_Green_LR_II"; - GVAR(baseClass) = "ACE_DBAL_A3_Green_LR"; + baseWeapon = "ACE_DBAL_A3_Green_LR"; }; // SPIR diff --git a/addons/irlight/functions/fnc_initItemContextMenu.sqf b/addons/irlight/functions/fnc_initItemContextMenu.sqf index df65bf08820..fa75eba77be 100644 --- a/addons/irlight/functions/fnc_initItemContextMenu.sqf +++ b/addons/irlight/functions/fnc_initItemContextMenu.sqf @@ -22,12 +22,12 @@ "ACE_DBAL_A3_Red", "POINTER", _displayName, [], "", { params ["", "", "_item", "", "_variant"]; - private _baseClass = getText (configFile >> "CfgWeapons" >> _item >> QGVAR(baseClass)); + private _baseClass = getText (configFile >> "CfgWeapons" >> _item >> "baseWeapon"); _item != _baseClass + _variant }, { params ["", "", "_item", "", "_variant"]; - private _baseClass = getText (configFile >> "CfgWeapons" >> _item >> QGVAR(baseClass)); + private _baseClass = getText (configFile >> "CfgWeapons" >> _item >> "baseWeapon"); ACE_player removePrimaryWeaponItem _item; ACE_player addPrimaryWeaponItem (_baseClass + _variant); From 013efea339c94ef600344e7aa7cd7d7574c2b9ce Mon Sep 17 00:00:00 2001 From: BaerMitUmlaut Date: Sat, 16 Sep 2023 19:53:53 +0200 Subject: [PATCH 12/12] Add baseWeapon to SPIR --- addons/irlight/CfgWeapons.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/irlight/CfgWeapons.hpp b/addons/irlight/CfgWeapons.hpp index 40872e1be98..4cc6de72945 100644 --- a/addons/irlight/CfgWeapons.hpp +++ b/addons/irlight/CfgWeapons.hpp @@ -290,6 +290,7 @@ class CfgWeapons { MRT_SwitchItemNextClass = "ACE_SPIR_Medium"; MRT_SwitchItemPrevClass = "ACE_SPIR_Narrow"; MRT_SwitchItemHintText = CSTRING(Mode_Wide); + baseWeapon = "ACE_SPIR"; class ItemInfo: InventoryFlashlightItem_Base_F { class Flashlight { @@ -344,6 +345,7 @@ class CfgWeapons { scope = 1; MRT_SwitchItemNextClass = "ACE_SPIR_LR_Medium"; MRT_SwitchItemPrevClass = "ACE_SPIR_LR_Narrow"; + baseWeapon = "ACE_SPIR_LR"; class ItemInfo: InventoryFlashlightItem_Base_F { class Flashlight {