Merge pull request #156 from KoffeinFlummi/nightVisionCleanup

Night vision cleanup
This commit is contained in:
PabstMirror 2015-02-21 20:21:04 -06:00
commit 11be8f6f8f
12 changed files with 211 additions and 175 deletions

View File

@ -1,19 +1,19 @@
class Extended_PreInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_preInit) );
};
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_preInit) );
};
};
class Extended_PostInit_EventHandlers {
class ADDON {
clientInit = QUOTE(call COMPILE_FILE(XEH_postInitClient) );
};
class ADDON {
clientInit = QUOTE(call COMPILE_FILE(XEH_postInitClient) );
};
};
class Extended_FiredBIS_EventHandlers {
class AllVehicles {
class ADDON {
clientFiredBIS = QUOTE( _this call FUNC(blending) );
class AllVehicles {
class ADDON {
clientFiredBIS = QUOTE( _this call FUNC(blending) );
};
};
};
};

View File

@ -1,22 +1,22 @@
class CfgVehicles {
class All {
ACE_NightVision_grain = 0.75;
ACE_NightVision_blur = 0.055;
};
#define MACRO_ADDITEM(ITEM,COUNT) class _xx_##ITEM { \
name = #ITEM; \
count = COUNT; \
};
class Box_NATO_Support_F;
class ACE_Box_Misc: Box_NATO_Support_F {
class TransportItems {
MACRO_ADDITEM(ACE_NVG_Gen1,6)
MACRO_ADDITEM(ACE_NVG_Gen2,6)
//MACRO_ADDITEM(ACE_NVG_Gen3,6)
MACRO_ADDITEM(ACE_NVG_Gen4,6)
MACRO_ADDITEM(ACE_NVG_Wide,6)
class All {
ACE_NightVision_grain = 0.75;
ACE_NightVision_blur = 0.055;
};
#define MACRO_ADDITEM(ITEM,COUNT) class _xx_##ITEM { \
name = #ITEM; \
count = COUNT; \
};
class Box_NATO_Support_F;
class ACE_Box_Misc: Box_NATO_Support_F {
class TransportItems {
MACRO_ADDITEM(ACE_NVG_Gen1,6)
MACRO_ADDITEM(ACE_NVG_Gen2,6)
//MACRO_ADDITEM(ACE_NVG_Gen3,6)
MACRO_ADDITEM(ACE_NVG_Gen4,6)
MACRO_ADDITEM(ACE_NVG_Wide,6)
};
};
};
};

View File

@ -1,56 +1,56 @@
class CfgWeapons {
class Binocular;
class NVGoggles: Binocular {
displayName = "$STR_ACE_NightVision_NVG_Gen3_brown";
ACE_NightVision_grain = 0.75;
ACE_NightVision_blur = 0.055;
ACE_NightVision_radBlur = 0.001;
};
class NVGoggles_OPFOR: NVGoggles {
displayName = "$STR_ACE_NightVision_NVG_Gen3_black";
};
class NVGoggles_INDEP: NVGoggles {
displayName = "$STR_ACE_NightVision_NVG_Gen3_green";
};
class Binocular;
class NVGoggles: Binocular {
displayName = "$STR_ACE_NightVision_NVG_Gen3_brown";
ACE_NightVision_grain = 0.75;
ACE_NightVision_blur = 0.055;
ACE_NightVision_radBlur = 0.001;
};
class NVGoggles_OPFOR: NVGoggles {
displayName = "$STR_ACE_NightVision_NVG_Gen3_black";
};
class NVGoggles_INDEP: NVGoggles {
displayName = "$STR_ACE_NightVision_NVG_Gen3_green";
};
class ACE_NVG_Gen1: NVGoggles_OPFOR {
author = "$STR_ACE_Common_ACETeam";
modelOptics = "\A3\weapons_f\reticle\optics_night";
displayName = "$STR_ACE_NightVision_NVG_Gen1";
ACE_NightVision_grain = 2.25;
ACE_NightVision_blur = 0.22;
ACE_NightVision_radBlur = 0.004;
};
class ACE_NVG_Gen2: NVGoggles_INDEP {
author = "$STR_ACE_Common_ACETeam";
modelOptics = "\A3\weapons_f\reticle\optics_night";
displayName = "$STR_ACE_NightVision_NVG_Gen2";
ACE_NightVision_grain = 1.5;
ACE_NightVision_blur = 0.11;
ACE_NightVision_radBlur = 0.002;
};
/*class ACE_NVG_Gen3: NVGoggles {
class ACE_NVG_Gen1: NVGoggles_OPFOR {
author = "$STR_ACE_Common_ACETeam";
modelOptics = "\A3\weapons_f\reticle\optics_night";
displayName = "$STR_ACE_NightVision_NVG_Gen1";
ACE_NightVision_grain = 2.25;
ACE_NightVision_blur = 0.22;
ACE_NightVision_radBlur = 0.004;
};
class ACE_NVG_Gen2: NVGoggles_INDEP {
author = "$STR_ACE_Common_ACETeam";
modelOptics = "\A3\weapons_f\reticle\optics_night";
displayName = "$STR_ACE_NightVision_NVG_Gen2";
ACE_NightVision_grain = 1.5;
ACE_NightVision_blur = 0.11;
ACE_NightVision_radBlur = 0.002;
};
/*class ACE_NVG_Gen3: NVGoggles {
author = "$STR_ACE_Common_ACETeam";
modelOptics = "\A3\weapons_f\reticle\optics_night";
displayName = "$STR_ACE_NightVision_NVG_Gen3";
ACE_NightVision_grain = 0.75;
ACE_NightVision_blur = 0.055;
ACE_NightVision_radBlur = 0.001;
};*/
class ACE_NVG_Gen4: NVGoggles {
author = "$STR_ACE_Common_ACETeam";
modelOptics = "\A3\weapons_f\reticle\optics_night";
displayName = "$STR_ACE_NightVision_NVG_Gen4";
ACE_NightVision_grain = 0.0;
ACE_NightVision_blur = 0.0;
ACE_NightVision_radBlur = 0.0;
};
class ACE_NVG_Wide: NVGoggles {
author = "$STR_ACE_Common_ACETeam";
modelOptics = QUOTE(PATHTOF(ACE_nvg_wide_optics));
displayName = "$STR_ACE_NightVision_NVG_FullScreen";
ACE_NightVision_grain = 0.75;
ACE_NightVision_blur = 0.055;
ACE_NightVision_radBlur = 0.001;
};
};*/
class ACE_NVG_Gen4: NVGoggles {
author = "$STR_ACE_Common_ACETeam";
modelOptics = "\A3\weapons_f\reticle\optics_night";
displayName = "$STR_ACE_NightVision_NVG_Gen4";
ACE_NightVision_grain = 0.0;
ACE_NightVision_blur = 0.0;
ACE_NightVision_radBlur = 0.0;
};
class ACE_NVG_Wide: NVGoggles {
author = "$STR_ACE_Common_ACETeam";
modelOptics = QUOTE(PATHTOF(models\ACE_nvg_wide_optics));
displayName = "$STR_ACE_NightVision_NVG_FullScreen";
ACE_NightVision_grain = 0.75;
ACE_NightVision_blur = 0.055;
ACE_NightVision_radBlur = 0.001;
};
};

View File

@ -35,3 +35,40 @@ GVAR(ppEffectMuzzleFlash) ppEffectCommit 0;
["cameraViewChanged", {_this call FUNC(updatePPEffects)}] call EFUNC(common,addEventHandler);
["playerVehicleChanged", {_this call FUNC(updatePPEffects)}] call EFUNC(common,addEventHandler);
["playerTurretChanged", {_this call FUNC(updatePPEffects)}] call EFUNC(common,addEventHandler);
// Add keybinds
["ACE3",
localize "STR_ACE_NightVision_IncreaseNVGBrightness",
{
// Conditions: canInteract
_exceptions = [QEGVAR(captives,isNotEscorting)];
if !(_exceptions call EGVAR(common,canInteract)) exitWith {false};
// Conditions: specific
if ((currentVisionMode _player != 1)) exitWith {false};
// Statement
[ACE_player, 1] call FUNC(changeNVGBrightness);
true
},
[201, [false, false, true]], //PageUp + ALT
false,
"keydown"
] call cba_fnc_registerKeybind;
["ACE3",
localize "STR_ACE_NightVision_DecreaseNVGBrightness",
{
// Conditions: canInteract
_exceptions = [QEGVAR(captives,isNotEscorting)];
if !(_exceptions call EGVAR(common,canInteract)) exitWith {false};
// Conditions: specific
if ((currentVisionMode _player != 1)) exitWith {false};
// Statement
[ACE_player, -1] call FUNC(changeNVGBrightness);
true
},
[209, [false, false, true]], //PageDown + ALT
false,
"keydown"
] call cba_fnc_registerKeybind;

View File

@ -3,8 +3,7 @@
ADDON = false;
PREP(blending);
PREP(decreaseNVGBrightness);
PREP(increaseNVGBrightness);
PREP(changeNVGBrightness);
PREP(updatePPEffects);
ADDON = true;

View File

@ -1,42 +1,17 @@
#include "script_component.hpp"
class CfgPatches {
class ADDON {
units[] = {};
weapons[] = {"ACE_NVG_Gen1", "ACE_NVG_Gen2", /*"ACE_NVG_Gen3",*/ "ACE_NVG_Gen4", "ACE_NVG_Wide"};
requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"ace_common"};
author[] = {"commy2", "KoffeinFlummi", "PabstMirror"};
authorUrl = "https://github.com/commy2/";
VERSION_CONFIG;
};
class ADDON {
units[] = {};
weapons[] = {"ACE_NVG_Gen1", "ACE_NVG_Gen2", /*"ACE_NVG_Gen3",*/ "ACE_NVG_Gen4", "ACE_NVG_Wide"};
requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"ace_common"};
author[] = {"commy2", "KoffeinFlummi", "PabstMirror"};
authorUrl = "https://github.com/commy2/";
VERSION_CONFIG;
};
};
#include "CfgEventHandlers.hpp"
#include "CfgVehicles.hpp"
#include "CfgWeapons.hpp"
// class EGVAR(common,Default_Keys) { //???
class ACE_common_Default_Keys {
class increaseNVGBrightness {
displayName = "$STR_ACE_NightVision_IncreaseNVGBrightness";
condition = QUOTE( currentVisionMode _player == 1 );
statement = QUOTE( [_player, _vehicle] call FUNC(increaseNVGBrightness) );
key = 201;
shift = 0;
control = 0;
alt = 1;
allowHolding = 1;
};
class decreaseNVGBrightness {
displayName = "$STR_ACE_NightVision_DecreaseNVGBrightness";
condition = QUOTE( currentVisionMode _player == 1 );
statement = QUOTE( [_player, _vehicle] call FUNC(decreaseNVGBrightness) );
key = 209;
shift = 0;
control = 0;
alt = 1;
allowHolding = 1;
};
};

View File

@ -1,4 +1,24 @@
// by commy2
/*
* Author: commy2
* Change the blending when the player fires??
*
* Arguments:
* 0: unit - Object the event handler is assigned to <OBJECT>
* 1: weapon - Fired weapon <STRING>
* 2: muzzle - Muzzle that was used <STRING>
* 3: mode - Current mode of the fired weapon <STRING>
* 4: ammo - Ammo used <STRING>
* 5: magazine - magazine name which was used <STRING>
* 6: projectile - Object of the projectile that was shot <OBJECT>
*
* Return Value:
* Nothing
*
* Example:
* [clientFiredBIS-XEH] call ace_nightvision_fnc_blending
*
* Public: No
*/
#include "script_component.hpp"
private ["_vehicle", "_weapon", "_ammo", "_magazine", "_player"];
@ -8,26 +28,26 @@ _weapon = _this select 1;
_ammo = _this select 4;
_magazine = _this select 5;
if ((_vehicle != (vehicle ACE_player)) || {(currentVisionMode _vehicle) != 1}) exitWith {};
_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 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 {};
private ["_silencer", "_visibleFireCoef", "_visibleFireTimeCoef", "_visibleFire", "_visibleFireTime", "_nvgBrightnessCoef", "_fnc_isTracer", "_darkness"];
_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};
default {""};
case (primaryWeapon _player) : {primaryWeaponItems _player select 0};
case (secondaryWeapon _player) : {secondaryWeaponItems _player select 0};
case (handgunWeapon _player) : {handgunItems _player select 0};
default {""};
};
_visibleFireCoef = 1;
_visibleFireTimeCoef = 1;
if (_silencer != "") then {
_visibleFireCoef = getNumber (configFile >> "CfgWeapons" >> _silencer >> "ItemInfo" >> "AmmoCoef" >> "visibleFire");
_visibleFireTimeCoef = getNumber (configFile >> "CfgWeapons" >> _silencer >> "ItemInfo" >> "AmmoCoef" >> "visibleFireTime");
_visibleFireCoef = getNumber (configFile >> "CfgWeapons" >> _silencer >> "ItemInfo" >> "AmmoCoef" >> "visibleFire");
_visibleFireTimeCoef = getNumber (configFile >> "CfgWeapons" >> _silencer >> "ItemInfo" >> "AmmoCoef" >> "visibleFireTime");
};
_visibleFire = getNumber (configFile >> "CfgAmmo" >> _ammo >> "visibleFire");
@ -36,24 +56,24 @@ _visibleFireTime = getNumber (configFile >> "CfgAmmo" >> _ammo >> "visibleFireTi
_nvgBrightnessCoef = 1 + (_player getVariable [QGVAR(NVGBrightness), 0]) / 4;
_fnc_isTracer = {
private ["_indexShot", "_lastRoundsTracer", "_tracersEvery"];
private ["_indexShot", "_lastRoundsTracer", "_tracersEvery"];
if (getNumber (configFile >> "CfgAmmo" >> _ammo >> "nvgOnly") > 0) exitWith {false};
if (getNumber (configFile >> "CfgAmmo" >> _ammo >> "nvgOnly") > 0) exitWith {false};
_indexShot = (_player ammo _weapon) + 1;
_indexShot = (_player ammo _weapon) + 1;
_lastRoundsTracer = getNumber (configFile >> "CfgMagazines" >> _magazine >> "lastRoundsTracer");
if (_indexShot <= _lastRoundsTracer) exitWith {true};
_lastRoundsTracer = getNumber (configFile >> "CfgMagazines" >> _magazine >> "lastRoundsTracer");
if (_indexShot <= _lastRoundsTracer) exitWith {true};
_tracersEvery = getNumber (configFile >> "CfgMagazines" >> _magazine >> "tracersEvery");
if (_tracersEvery == 0) exitWith {false};
_tracersEvery = getNumber (configFile >> "CfgMagazines" >> _magazine >> "tracersEvery");
if (_tracersEvery == 0) exitWith {false};
(_indexShot - _lastRoundsTracer) % _tracersEvery == 0
(_indexShot - _lastRoundsTracer) % _tracersEvery == 0
};
if (call _fnc_isTracer) then {
_visibleFire = _visibleFire + 2;
_visibleFireTime = _visibleFireTime + 2;
_visibleFire = _visibleFire + 2;
_visibleFireTime = _visibleFireTime + 2;
};
_darkness = 1 - (call EFUNC(common,ambientBrightness));

View File

@ -0,0 +1,33 @@
/*
* Author: commy2
* Change the brightness of the unit's NVG
*
* Arguments:
* 0: The Unit <OBJECT>
* 1: Change in brightness (1 or -1) <SCALAR>
*
* Return Value:
* Nothing
*
* Example:
* [player, 1] call ace_nightvision_fnc_changeNVGBrightness
*
* Public: No
*/
#include "script_component.hpp"
private ["_brightness"];
PARAMS_2(_player,_changeInBrightness);
_brightness = _player getVariable [QGVAR(NVGBrightness), 0];
_brightness = ((round (10 * _brightness + _changeInBrightness) / 10) min 1) max -1;
_player setVariable [QGVAR(NVGBrightness), _brightness, false];
GVAR(ppEffectNVGBrightness) ppEffectAdjust [1, 1, _brightness / 4, [0, 0, 0, 0], [0, 0, 0, 1], [0, 0, 0, 1]];
GVAR(ppEffectNVGBrightness) ppEffectCommit 0;
[format [(localize "STR_ACE_NightVision_NVGBrightness"), (_brightness * 100)]] call EFUNC(common,displayTextStructured);
playSound "ACE_Sound_Click";

View File

@ -1,21 +0,0 @@
// by commy2
#include "script_component.hpp"
private ["_player", "_vehicle", "_brightness"];
_player = _this select 0;
_vehicle = _this select 1;
_brightness = _player getVariable [QGVAR(NVGBrightness), 0];
if (_brightness > -1) then {
_brightness = round (10 * _brightness - 1) / 10;
_player setVariable [QGVAR(NVGBrightness), _brightness, false];
GVAR(ppEffectNVGBrightness) ppEffectAdjust [1, 1, _brightness / 4, [0, 0, 0, 0], [0, 0, 0, 1], [0, 0, 0, 1]];
GVAR(ppEffectNVGBrightness) ppEffectCommit 0;
[format [localize "STR_ACE_NightVision_NVGBrightness", format ["%1%", _brightness * 100]]] call EFUNC(common,displayTextStructured);
playSound "ACE_Sound_Click";
};

View File

@ -1,21 +0,0 @@
// by commy2
#include "script_component.hpp"
private ["_player", "_vehicle", "_brightness"];
_player = _this select 0;
_vehicle = _this select 1;
_brightness = _player getVariable [QGVAR(NVGBrightness), 0];
if (_brightness < 1) then {
_brightness = round (10 * _brightness + 1) / 10;
_player setVariable [QGVAR(NVGBrightness), _brightness, false];
GVAR(ppEffectNVGBrightness) ppEffectAdjust [1, 1, _brightness / 4, [0, 0, 0, 0], [0, 0, 0, 1], [0, 0, 0, 1]];
GVAR(ppEffectNVGBrightness) ppEffectCommit 0;
[format [localize "STR_ACE_NightVision_NVGBrightness", format ["%1%", _brightness * 100]]] call EFUNC(common,displayTextStructured);
playSound "ACE_Sound_Click";
};

View File

@ -1,4 +1,18 @@
//by commy2, PabstMirror and CAA-Picard
/*
* Author: commy2, PabstMirror and CAA-Picard
* Update the ppEffects everytime something changes
*
* Arguments:
* Nothing
*
* Return Value:
* Nothing
*
* Example:
* [someEvent] call ace_nightvision_fnc_updatePPEffects
*
* Public: No
*/
#include "script_component.hpp"
private ["_currentVehicle", "_grainSetting", "_blurSetting", "_radBlurSetting", "_config"];