Split event handlers

This commit is contained in:
BaerMitUmlaut 2015-10-08 19:29:30 +02:00
parent e50a28874f
commit 2fe53431c7
4 changed files with 39 additions and 8 deletions

View File

@ -32,12 +32,12 @@ GVAR(ppEffectMuzzleFlash) ppEffectCommit 0;
["playerInventoryChanged", {_this call FUNC(updatePPEffects)}] call EFUNC(common,addEventHandler);
["playerVisionModeChanged", {
_this call FUNC(updatePPEffects);
_this call FUNC(handleNVGs);
_this call FUNC(onVisionModeChanged);
}] call EFUNC(common,addEventHandler);
["zeusDisplayChanged", {_this call FUNC(updatePPEffects)}] call EFUNC(common,addEventHandler);
["cameraViewChanged", {
_this call FUNC(updatePPEffects);
_this call FUNC(handleNVGs);
_this call FUNC(onCameraViewChanged);
}] call EFUNC(common,addEventHandler);
["playerVehicleChanged", {_this call FUNC(updatePPEffects)}] call EFUNC(common,addEventHandler);
["playerTurretChanged", {_this call FUNC(updatePPEffects)}] call EFUNC(common,addEventHandler);

View File

@ -4,8 +4,9 @@ ADDON = false;
PREP(blending);
PREP(changeNVGBrightness);
PREP(handleNVGs);
PREP(initModule);
PREP(onCameraViewChanged);
PREP(onVisionModeChanged);
PREP(updatePPEffects);
ADDON = true;

View File

@ -1,31 +1,32 @@
/*
* Author: BaerMitUmlaut
* Disables NVGs when the player aims down his sight.
* Disables/re-enables NVGs when the player starts/stops aiming down his sight.
*
* Arguments:
* 0: Unit <OBJECT>
* 1: New camera view <STRING>
*
* Return Value:
* None
*
* Example:
* [player] call ace_nightvision_fnc_disableNVGs
* [player, "GUNNER"] call ace_nightvision_fnc_onCameraViewChanged
*
* Public: No
*/
#include "script_component.hpp"
params ["_unit"];
params ["_unit", "_cameraView"];
if (GVAR(disableNVGsWithSights) && {(hmd _unit) != ""}) then {
(assignedVehicleRole _unit) params ["_role", "_turretPath"];
if ((vehicle _unit == _unit) || {isTurnedOut _unit} || {_role == "cargo" && {!(isNil "_turretPath")}}) then {
if ((cameraView == "GUNNER") && {currentVisionMode _unit > 0}) then {
if ((_cameraView == "GUNNER") && {currentVisionMode _unit > 0}) then {
_unit action ["NVGogglesOff", _unit];
GVAR(reenableNVGs) = true;
} else {
if (GVAR(reenableNVGs) && {cameraView != "GUNNER"}) then {
if (GVAR(reenableNVGs) && {_cameraView != "GUNNER"}) then {
_unit action ["NVGoggles", _unit];
GVAR(reenableNVGs) = false;
};

View File

@ -0,0 +1,29 @@
/*
* Author: BaerMitUmlaut
* Disables turning on NVGs while the player aims down his sight.
*
* Arguments:
* 0: Unit <OBJECT>
* 1: New vision mode <NUMBER>
*
* Return Value:
* None
*
* Example:
* [player, 1] call ace_nightvision_fnc_onVisionModeChanged
*
* Public: No
*/
#include "script_component.hpp"
params ["_unit", "_visionMode"];
if (GVAR(disableNVGsWithSights) && {(hmd _unit) != ""}) then {
(assignedVehicleRole _unit) params ["_role", "_turretPath"];
if ((vehicle _unit == _unit) || {isTurnedOut _unit} || {_role == "cargo" && {!(isNil "_turretPath")}}) then {
if ((cameraView == "GUNNER") && {_visionMode > 0}) then {
_unit action ["NVGogglesOff", _unit];
};
};
};