From b9c1936efc93c599125f204f2bdb8f7e3ba86474 Mon Sep 17 00:00:00 2001 From: Kavinsky Date: Thu, 30 Apr 2015 18:51:30 +0200 Subject: [PATCH 1/2] changed laserpointer to allow 3rd party laser pointers. now there is a new config option for CfgWeapons called ace_laserpointer, number with value 0 no laser, 1 red laser, 2 green laser --- addons/laserpointer/CfgWeapons.hpp | 4 ++++ addons/laserpointer/functions/fnc_onDraw.sqf | 13 ++++++++++--- documentation/development/ace3-config-entries.md | 3 +++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/addons/laserpointer/CfgWeapons.hpp b/addons/laserpointer/CfgWeapons.hpp index 4f6a61c83a..6223c3a988 100644 --- a/addons/laserpointer/CfgWeapons.hpp +++ b/addons/laserpointer/CfgWeapons.hpp @@ -20,6 +20,8 @@ class CfgWeapons { ACE_nextModeClass = "acc_pointer_IR"; ACE_modeDescription = "$STR_ACE_Laserpointer_Laser"; + ACE_laserpointer = 1; + author = "$STR_ACE_Common_ACETeam"; _generalMacro = "ACE_acc_pointer_red"; scope = 1; @@ -79,6 +81,8 @@ class CfgWeapons { ACE_nextModeClass = "ACE_acc_pointer_green_IR"; ACE_modeDescription = "$STR_ACE_Laserpointer_Laser"; + ACE_laserpointer = 2; + author = "$STR_ACE_Common_ACETeam"; _generalMacro = "ACE_acc_pointer_green"; scope = 2; diff --git a/addons/laserpointer/functions/fnc_onDraw.sqf b/addons/laserpointer/functions/fnc_onDraw.sqf index 0e4ddf981a..e3236f7cb5 100644 --- a/addons/laserpointer/functions/fnc_onDraw.sqf +++ b/addons/laserpointer/functions/fnc_onDraw.sqf @@ -25,10 +25,17 @@ _isIR = _isIR == 1; default {""}; }; - _laserID = ["ACE_acc_pointer_red", "ACE_acc_pointer_green"] find _laser; + if (_laser != "") then { + _cacheName = format ["ACE_laserpointer_%1", _laser]; + _laserID = missionNamespace getVariable [_cacheName, -1]; + if (missionNamespace getVariable [_cacheName, -1] == -1) then { + _laserID = getNumber (configFile >> "CfgWeapons" >> _laser >> "ACE_laserpointer"); + missionNamespace setVariable [_cacheName, _laserID]; + }; - if (_laserID > -1 && {_x isFlashlightOn _weapon}) then { - [_x, 50, _laserID == 1 || _isIR] call FUNC(drawLaserpoint); + if (_laserID > 0 && {_x isFlashlightOn _weapon}) then { + [_x, 50, _laserID == 2 || _isIR] call FUNC(drawLaserpoint); + }; }; } forEach GVAR(nearUnits); diff --git a/documentation/development/ace3-config-entries.md b/documentation/development/ace3-config-entries.md index 78f8022856..1033172469 100644 --- a/documentation/development/ace3-config-entries.md +++ b/documentation/development/ace3-config-entries.md @@ -54,6 +54,9 @@ ace_detonator ace_barrelTwist ace_twistDirection ace_barrelLength +ace_laserpointer +ace_nextmodeclass +ace_modedescription ``` From f301491c7a7833c9f36da26d1bf52b606209b300 Mon Sep 17 00:00:00 2001 From: Kavinsky Date: Thu, 30 Apr 2015 23:18:45 +0200 Subject: [PATCH 2/2] changed variable name to use QGVAR macro --- addons/laserpointer/functions/fnc_onDraw.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/laserpointer/functions/fnc_onDraw.sqf b/addons/laserpointer/functions/fnc_onDraw.sqf index e3236f7cb5..c1e955d028 100644 --- a/addons/laserpointer/functions/fnc_onDraw.sqf +++ b/addons/laserpointer/functions/fnc_onDraw.sqf @@ -26,7 +26,7 @@ _isIR = _isIR == 1; }; if (_laser != "") then { - _cacheName = format ["ACE_laserpointer_%1", _laser]; + _cacheName = format [QGVAR(laser_%1), _laser]; _laserID = missionNamespace getVariable [_cacheName, -1]; if (missionNamespace getVariable [_cacheName, -1] == -1) then { _laserID = getNumber (configFile >> "CfgWeapons" >> _laser >> "ACE_laserpointer");