From 06a9f6028126db6b53afb762bf431ae6183deadd Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Wed, 16 Sep 2015 10:55:23 -0500 Subject: [PATCH 1/2] Cleanup Nightvision --- addons/nightvision/functions/fnc_blending.sqf | 26 +++++++------------ .../functions/fnc_changeNVGBrightness.sqf | 6 +++-- addons/nightvision/script_component.hpp | 2 ++ 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/addons/nightvision/functions/fnc_blending.sqf b/addons/nightvision/functions/fnc_blending.sqf index 8c49711079..a565eb65c0 100644 --- a/addons/nightvision/functions/fnc_blending.sqf +++ b/addons/nightvision/functions/fnc_blending.sqf @@ -23,25 +23,19 @@ if (!hasInterface) exitWith {}; -private ["_vehicle", "_weapon", "_ammo", "_magazine", "_player"]; +params ["_vehicle", "_weapon", "", "", "_ammo", "_magazine"]; -_vehicle = _this select 0; -_weapon = _this select 1; -_ammo = _this select 4; -_magazine = _this select 5; - -_player = ACE_player; //If our vehicle didn't shoot, or we're not in NVG mode, exit -if ((_vehicle != (vehicle _player)) || {(currentVisionMode _player) != 1}) exitWith {}; +if ((_vehicle != (vehicle ACE_player)) || {(currentVisionMode ACE_player) != 1}) exitWith {}; //If we are mounted, and it wasn't our weapon system that fired, exit -if (_player != _vehicle && {!(_weapon in (_vehicle weaponsTurret ([_player] call EFUNC(common,getTurretIndex))))}) exitWith {}; +if (ACE_player != _vehicle && {!(_weapon in (_vehicle weaponsTurret ([ACE_player] call EFUNC(common,getTurretIndex))))}) exitWith {}; -private ["_silencer", "_visibleFireCoef", "_visibleFireTimeCoef", "_visibleFire", "_visibleFireTime", "_nvgBrightnessCoef", "_fnc_isTracer", "_darkness"]; +private["_darkness", "_nvgBrightnessCoef", "_silencer", "_visibleFire", "_visibleFireCoef", "_visibleFireTime", "_visibleFireTimeCoef"]; _silencer = switch (_weapon) do { -case (primaryWeapon _player) : {primaryWeaponItems _player select 0}; -case (secondaryWeapon _player) : {secondaryWeaponItems _player select 0}; -case (handgunWeapon _player) : {handgunItems _player select 0}; + case (primaryWeapon ACE_player) : {primaryWeaponItems ACE_player select 0}; + case (secondaryWeapon ACE_player) : {secondaryWeaponItems ACE_player select 0}; + case (handgunWeapon ACE_player) : {handgunItems ACE_player select 0}; default {""}; }; @@ -55,14 +49,14 @@ if (_silencer != "") then { _visibleFire = getNumber (configFile >> "CfgAmmo" >> _ammo >> "visibleFire"); _visibleFireTime = getNumber (configFile >> "CfgAmmo" >> _ammo >> "visibleFireTime"); -_nvgBrightnessCoef = 1 + (_player getVariable [QGVAR(NVGBrightness), 0]) / 4; +_nvgBrightnessCoef = 1 + (ACE_player getVariable [QGVAR(NVGBrightness), 0]) / 4; _fnc_isTracer = { private ["_indexShot", "_lastRoundsTracer", "_tracersEvery"]; if (getNumber (configFile >> "CfgAmmo" >> _ammo >> "nvgOnly") > 0) exitWith {false}; - _indexShot = (_player ammo _weapon) + 1; + _indexShot = (ACE_player ammo _weapon) + 1; _lastRoundsTracer = getNumber (configFile >> "CfgMagazines" >> _magazine >> "lastRoundsTracer"); if (_indexShot <= _lastRoundsTracer) exitWith {true}; @@ -83,7 +77,7 @@ _darkness = 1 - (call EFUNC(common,ambientBrightness)); _visibleFire = _darkness * _visibleFireCoef * _visibleFire * _nvgBrightnessCoef / 10 min 1; _visibleFireTime = _darkness * _visibleFireTimeCoef * _visibleFireTime * _nvgBrightnessCoef / 10 min 0.5; -// ["NightVision", [_visibleFire, _visibleFireTime], {format ["visibleFire: %1 - visibleFireTime: %2", _this select 0, _this select 1]}] call AGM_Debug_fnc_log; //todo +TRACE_2("Player Shot, Adjusting NVG Effect", _visibleFire, _visibleFireTime); GVAR(ppEffectMuzzleFlash) ppEffectAdjust [1, 1, _visibleFire, [0, 0, 0, 0], [0, 0, 0, 1], [0, 0, 0, 1]]; GVAR(ppEffectMuzzleFlash) ppEffectCommit 0; diff --git a/addons/nightvision/functions/fnc_changeNVGBrightness.sqf b/addons/nightvision/functions/fnc_changeNVGBrightness.sqf index a55535e40a..116ab9b5a5 100644 --- a/addons/nightvision/functions/fnc_changeNVGBrightness.sqf +++ b/addons/nightvision/functions/fnc_changeNVGBrightness.sqf @@ -16,10 +16,12 @@ */ #include "script_component.hpp" -if (!hasInterface) exitWith {}; +params ["_player", "_changeInBrightness"]; +TRACE_2("params",_player,_changeInBrightness); + private ["_brightness"]; -PARAMS_2(_player,_changeInBrightness); +if (!hasInterface) exitWith {}; _brightness = _player getVariable [QGVAR(NVGBrightness), 0]; diff --git a/addons/nightvision/script_component.hpp b/addons/nightvision/script_component.hpp index d322ea0799..9afeeb5d8d 100644 --- a/addons/nightvision/script_component.hpp +++ b/addons/nightvision/script_component.hpp @@ -1,6 +1,8 @@ #define COMPONENT nightvision #include "\z\ace\addons\main\script_mod.hpp" +// #define DEBUG_MODE_FULL + #ifdef DEBUG_ENABLED_NIGHTVISION #define DEBUG_MODE_FULL #endif From 65b8585d60891727e80d94bfeee37d13d6c97675 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Fri, 18 Sep 2015 12:48:59 -0500 Subject: [PATCH 2/2] Use _player instead of ACE_player --- addons/nightvision/functions/fnc_blending.sqf | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/addons/nightvision/functions/fnc_blending.sqf b/addons/nightvision/functions/fnc_blending.sqf index a565eb65c0..42d586248d 100644 --- a/addons/nightvision/functions/fnc_blending.sqf +++ b/addons/nightvision/functions/fnc_blending.sqf @@ -25,17 +25,20 @@ if (!hasInterface) exitWith {}; params ["_vehicle", "_weapon", "", "", "_ammo", "_magazine"]; +private "_player"; +_player = ACE_player; + //If our vehicle didn't shoot, or we're not in NVG mode, exit -if ((_vehicle != (vehicle ACE_player)) || {(currentVisionMode ACE_player) != 1}) exitWith {}; +if ((_vehicle != (vehicle _player)) || {(currentVisionMode _player) != 1}) exitWith {}; //If we are mounted, and it wasn't our weapon system that fired, exit -if (ACE_player != _vehicle && {!(_weapon in (_vehicle weaponsTurret ([ACE_player] call EFUNC(common,getTurretIndex))))}) exitWith {}; +if (_player != _vehicle && {!(_weapon in (_vehicle weaponsTurret ([_player] call EFUNC(common,getTurretIndex))))}) exitWith {}; private["_darkness", "_nvgBrightnessCoef", "_silencer", "_visibleFire", "_visibleFireCoef", "_visibleFireTime", "_visibleFireTimeCoef"]; _silencer = switch (_weapon) do { - case (primaryWeapon ACE_player) : {primaryWeaponItems ACE_player select 0}; - case (secondaryWeapon ACE_player) : {secondaryWeaponItems ACE_player select 0}; - case (handgunWeapon ACE_player) : {handgunItems ACE_player select 0}; + case (primaryWeapon _player): {(primaryWeaponItems _player) select 0}; + case (secondaryWeapon _player): {(secondaryWeaponItems _player) select 0}; + case (handgunWeapon _player): {(handgunItems _player) select 0}; default {""}; }; @@ -49,14 +52,14 @@ if (_silencer != "") then { _visibleFire = getNumber (configFile >> "CfgAmmo" >> _ammo >> "visibleFire"); _visibleFireTime = getNumber (configFile >> "CfgAmmo" >> _ammo >> "visibleFireTime"); -_nvgBrightnessCoef = 1 + (ACE_player getVariable [QGVAR(NVGBrightness), 0]) / 4; +_nvgBrightnessCoef = 1 + (_player getVariable [QGVAR(NVGBrightness), 0]) / 4; _fnc_isTracer = { private ["_indexShot", "_lastRoundsTracer", "_tracersEvery"]; if (getNumber (configFile >> "CfgAmmo" >> _ammo >> "nvgOnly") > 0) exitWith {false}; - _indexShot = (ACE_player ammo _weapon) + 1; + _indexShot = (_player ammo _weapon) + 1; _lastRoundsTracer = getNumber (configFile >> "CfgMagazines" >> _magazine >> "lastRoundsTracer"); if (_indexShot <= _lastRoundsTracer) exitWith {true};