mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
more goggles code cleanup
This commit is contained in:
parent
c0105bf083
commit
dc882a3c66
@ -31,9 +31,8 @@ GVAR(EffectsActive) = false;
|
||||
|
||||
SETGLASSES(ace_player,GLASSESDEFAULT);
|
||||
|
||||
GVAR(Current) = "None";
|
||||
GVAR(EyesDamageScript) = -1;
|
||||
GVAR(FrameEvent) = [false, [false,20]];
|
||||
GVAR(FrameEvent) = [false, [false, 20]];
|
||||
GVAR(PostProcessEyes_Enabled) = false;
|
||||
GVAR(DustHandler) = -1;
|
||||
GVAR(RainDrops) = objNull;
|
||||
@ -42,7 +41,6 @@ GVAR(RainLastLevel) = 0;
|
||||
GVAR(surfaceCache) = "";
|
||||
GVAR(surfaceCacheIsDust) = false;
|
||||
|
||||
|
||||
// init GlassesChanged eventhandler
|
||||
GVAR(OldGlasses) = "#NULLSTRING";
|
||||
|
||||
@ -96,12 +94,36 @@ GVAR(OldGlasses) = "#NULLSTRING";
|
||||
|
||||
}] call EFUNC(common,addEventHandler);
|
||||
|
||||
// check goggles
|
||||
local _fnc_checkGoggles = {
|
||||
params ["_unit"];
|
||||
|
||||
if (GVAR(EffectsActive)) then {
|
||||
if (call FUNC(externalCamera) || {!([_unit] call FUNC(isGogglesVisible))}) then {
|
||||
call FUNC(removeGlassesEffect);
|
||||
};
|
||||
} else {
|
||||
if (!(call FUNC(externalCamera)) && {[_unit] call FUNC(isGogglesVisible)}) then {
|
||||
[goggles _unit] call FUNC(applyGlassesEffect);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
["cameraViewChanged", _fnc_checkGoggles] call EFUNC(common,addEventHandler);
|
||||
["activeCameraChanged", _fnc_checkGoggles] call EFUNC(common,addEventHandler);
|
||||
|
||||
// goggles effects main PFH
|
||||
[{
|
||||
// rain
|
||||
call FUNC(applyRainEffect);
|
||||
|
||||
// auto remove effects under water
|
||||
if (GVAR(EffectsActive) && {[goggles ACE_player] call FUNC(isDivingGoggles) && {underwater ACE_player}}) then {
|
||||
call FUNC(removeRainEffect);
|
||||
call FUNC(removeDirtEffect);
|
||||
call FUNC(removeDustEffect);
|
||||
};
|
||||
|
||||
|
||||
[FUNC(CheckGoggles), 1, []] call CBA_fnc_addPerFrameHandler;
|
||||
[FUNC(applyRainEffect), 0.5, []] call CBA_fnc_addPerFrameHandler;
|
||||
[FUNC(onEachFrame), 0, []] call CBA_fnc_addPerFrameHandler;
|
||||
// rotor wash effect
|
||||
call FUNC(applyRotorWashEffect)
|
||||
}, 0.5, _fnc_checkGoggles] call CBA_fnc_addPerFrameHandler;
|
||||
|
@ -7,6 +7,7 @@ PREP(applyDirtEffect);
|
||||
PREP(applyDustEffect);
|
||||
PREP(applyGlassesEffect);
|
||||
PREP(applyRainEffect);
|
||||
PREP(applyRotorWashEffect);
|
||||
PREP(removeDirtEffect);
|
||||
PREP(removeDustEffect);
|
||||
PREP(removeGlassesEffect);
|
||||
@ -27,11 +28,4 @@ PREP(handleExplosion);
|
||||
PREP(handleFired);
|
||||
PREP(handleKilled);
|
||||
|
||||
|
||||
|
||||
PREP(checkGoggles);
|
||||
PREP(onEachFrame);
|
||||
|
||||
|
||||
|
||||
ADDON = true;
|
||||
|
@ -62,13 +62,17 @@ GVAR(DustHandler) = [{
|
||||
};
|
||||
|
||||
if (GETDUSTT(DAMOUNT) <= 0) then {
|
||||
SETDUST(DACTIVE,false);
|
||||
SETDUST(DBULLETS,0);
|
||||
|
||||
GVAR(PostProcessEyes) ppEffectAdjust [1, 1, 0, [0, 0, 0, 0], [1, 1, 1, 1], [1, 1, 1, 0]];
|
||||
GVAR(PostProcessEyes) ppEffectCommit 2;
|
||||
|
||||
[{GVAR(PostProcessEyes) ppEffectEnable false}, [], 2] call EFUNC(common,waitAndExecute);
|
||||
|
||||
SETDUST(DACTIVE,false);
|
||||
SETDUST(DBULLETS,0);
|
||||
[{
|
||||
if (GVAR(DustHandler) == -1) then {
|
||||
GVAR(PostProcessEyes) ppEffectEnable false
|
||||
};
|
||||
}, [], 2] call EFUNC(common,waitAndExecute);
|
||||
|
||||
[GVAR(DustHandler)] call CBA_fnc_removePerFrameHandler;
|
||||
GVAR(DustHandler) = -1;
|
||||
|
108
addons/goggles/functions/fnc_applyRotorWashEffect.sqf
Normal file
108
addons/goggles/functions/fnc_applyRotorWashEffect.sqf
Normal file
@ -0,0 +1,108 @@
|
||||
/*
|
||||
* Author: Garth 'L-H' de Wet, commy2
|
||||
* Handles the rotor wash effects.
|
||||
*
|
||||
* Arguments:
|
||||
* None
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* call ace_goggles_fnc_applyRotorWashEffect;
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_unit", "_fnc_underCover"];
|
||||
|
||||
_unit = ACE_player;
|
||||
|
||||
if (!alive _unit) exitWith {};
|
||||
|
||||
// idk. chaching magic? ends with isInRotorWash check.
|
||||
GVAR(FrameEvent) set [0, !(GVAR(FrameEvent) select 0)];
|
||||
|
||||
if (GVAR(FrameEvent) select 0) exitWith {
|
||||
if (vehicle _unit != _unit && {!isTurnedOut _unit}) exitWith {
|
||||
(GVAR(FrameEvent) select 1) set [0, false];
|
||||
};
|
||||
|
||||
GVAR(FrameEvent) set [1, ([_unit] call FUNC(isInRotorWash))];
|
||||
};
|
||||
|
||||
// check if the unit is affected by rotor wash
|
||||
private ["_rotorWash", "_safe"];
|
||||
|
||||
_rotorWash = GVAR(FrameEvent) select 1;
|
||||
_safe = false;
|
||||
|
||||
// no rotor wash? remove effects.
|
||||
if !(_rotorWash select 0) exitWith {
|
||||
if (GVAR(PostProcessEyes_Enabled)) then {
|
||||
GVAR(PostProcessEyes_Enabled) = false;
|
||||
|
||||
GVAR(PostProcessEyes) ppEffectAdjust [1, 1, 0, [0, 0, 0, 0], [0, 0, 0, 1], [1, 1, 1, 0]];
|
||||
GVAR(PostProcessEyes) ppEffectCommit 2;
|
||||
|
||||
[{
|
||||
if (GVAR(DustHandler) == -1) then {
|
||||
GVAR(PostProcessEyes) ppEffectEnable false;
|
||||
}
|
||||
}, [], 2] call EFUNC(common,waitAndExecute);
|
||||
|
||||
[GVAR(DustHandler)] call CBA_fnc_removePerFrameHandler;
|
||||
GVAR(DustHandler) = -1;
|
||||
};
|
||||
};
|
||||
|
||||
// check protection of helmet
|
||||
if (headgear _unit != "") then {
|
||||
_safe = getNumber (configFile >> "CfgWeapons" >> headgear _unit >> "ACE_Protection") == 1;
|
||||
};
|
||||
|
||||
// check protection of goggles
|
||||
if !(_safe) then {
|
||||
if !([_unit] call FUNC(isGogglesVisible)) exitWith {};
|
||||
|
||||
if (GETDUSTT(DAMOUNT) < 2) then {
|
||||
if !(GETDUSTT(DACTIVE)) then {
|
||||
SETDUST(DACTIVE,true);
|
||||
|
||||
call FUNC(applyDustEffect);
|
||||
} else {
|
||||
if (_rotorWash select 1 > 0.5) then {
|
||||
call FUNC(applyDustEffect);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
_safe = getNumber (ConfigFile >> "CfgGlasses" >> goggles _unit >> "ACE_Protection") == 1;
|
||||
};
|
||||
|
||||
// quit if protected by goggles or helmet
|
||||
if (_safe) exitWith {};
|
||||
|
||||
// apply rotor wash effect
|
||||
if (_rotorWash select 1 > 0) then {
|
||||
local _scale = 0.7;
|
||||
|
||||
if (_rotorWash select 1 > 0) then {
|
||||
_scale = CLAMP(0.3 * (_rotorWash select 1),0.1,0.3);
|
||||
} else {
|
||||
_scale = 0.1;
|
||||
};
|
||||
|
||||
_scale = 1 - _scale;
|
||||
|
||||
[GVAR(DustHandler)] call CBA_fnc_removePerFrameHandler;
|
||||
GVAR(DustHandler) = -1;
|
||||
|
||||
if !(_unit getVariable ["ACE_EyesDamaged", false]) then {
|
||||
GVAR(PostProcessEyes_Enabled) = true;
|
||||
GVAR(PostProcessEyes) ppEffectAdjust [1, 1, 0, [0, 0, 0, 0], [_scale, _scale, _scale, _scale], [1, 1, 1, 0]];
|
||||
GVAR(PostProcessEyes) ppEffectCommit 0.5;
|
||||
GVAR(PostProcessEyes) ppEffectEnable true;
|
||||
};
|
||||
};
|
@ -1,46 +0,0 @@
|
||||
/*
|
||||
* Author: Garth 'L-H' de Wet
|
||||
* Performs rain checks and checks to see whether glasses effects have been applied or not.
|
||||
* Checks for external camera and removes effects.
|
||||
*
|
||||
* Arguments:
|
||||
* None
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* None
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
if (!alive ace_player) exitWith {};
|
||||
if (true) then {
|
||||
// Detect if curator interface is open and disable effects
|
||||
if !(isNull curatorCamera) exitWith {
|
||||
if (GVAR(EffectsActive)) then {
|
||||
call FUNC(removeGlassesEffect);
|
||||
};
|
||||
};
|
||||
//call FUNC(checkGlasses);
|
||||
if !([ace_player] call FUNC(isGogglesVisible)) exitWith {
|
||||
if (GVAR(EffectsActive)) then {
|
||||
call FUNC(removeGlassesEffect);
|
||||
};
|
||||
};
|
||||
if (call FUNC(externalCamera)) exitWith {
|
||||
if (GVAR(EffectsActive)) then {
|
||||
call FUNC(removeGlassesEffect);
|
||||
};
|
||||
};
|
||||
if !(GVAR(EffectsActive)) then {
|
||||
[goggles ace_player] call FUNC(applyGlassesEffect);
|
||||
} else {
|
||||
if ([goggles ace_player] call FUNC(isDivingGoggles) && {underwater ace_player}) then {
|
||||
call FUNC(removeRainEffect);
|
||||
call FUNC(removeDirtEffect);
|
||||
call FUNC(removeDustEffect);
|
||||
};
|
||||
};
|
||||
};
|
@ -1,78 +0,0 @@
|
||||
/*
|
||||
* Author: Garth 'L-H' de Wet
|
||||
* Checks whether the player is in the downwash of a helicopter and handles applying effects of that.
|
||||
*
|
||||
* Arguments:
|
||||
* None
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* ["ACE_Goggles_RotorWash", "OnEachFrame", "call ace_goggles_fnc_OnEachFrame;"] call BIS_fnc_addStackedEventHandler;
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
if (isNull(ace_player)) exitWith {};
|
||||
GVAR(FrameEvent) set [0, !(GVAR(FrameEvent) select 0)];
|
||||
if (GVAR(FrameEvent) select 0) exitWith {
|
||||
if (vehicle ace_player != ace_player && {!isTurnedOut ACE_player}) exitWith {(GVAR(FrameEvent) select 1) set [0, false]; };
|
||||
GVAR(FrameEvent) set [1, ([ace_player] call FUNC(isInRotorWash))];
|
||||
};
|
||||
private ["_rotorWash","_safe"];
|
||||
_rotorWash = GVAR(FrameEvent) select 1;
|
||||
_safe = false;
|
||||
if !(_rotorWash select 0) exitWith {
|
||||
if (GVAR(PostProcessEyes_Enabled)) then {
|
||||
GVAR(PostProcessEyes_Enabled) = false;
|
||||
if (GVAR(DustHandler) != -1) then { // should be fixed in dev CBA
|
||||
[GVAR(DustHandler)] call CALLSTACK(cba_fnc_removePerFrameHandler);
|
||||
GVAR(DustHandler) = -1;
|
||||
};
|
||||
GVAR(PostProcessEyes) ppEffectAdjust [1, 1, 0, [0,0,0,0], [0,0,0,1],[1,1,1,0]];
|
||||
GVAR(PostProcessEyes) ppEffectCommit 2;
|
||||
GVAR(DustHandler) = [{
|
||||
GVAR(PostProcessEyes) ppEffectEnable false;
|
||||
GVAR(DustHandler) = -1;
|
||||
}, [], 2, 0.5] call EFUNC(common,waitAndExecute);
|
||||
};
|
||||
};
|
||||
if ((headgear ace_player) != "") then {
|
||||
_safe = (getNumber (ConfigFile >> "CfgWeapons" >> (headgear ace_player) >> "ACE_Protection") == 1);
|
||||
};
|
||||
if !(_safe) then {
|
||||
if !([ace_player] call FUNC(isGogglesVisible)) exitWith{};
|
||||
if (GETDUSTT(DAMOUNT) < 2) then {
|
||||
if (!GETDUSTT(DACTIVE)) then {
|
||||
SETDUST(DACTIVE,true);
|
||||
call FUNC(applyDustEffect);
|
||||
} else {
|
||||
if ((_rotorWash select 1) > 0.5) then {
|
||||
call FUNC(applyDustEffect);
|
||||
};
|
||||
};
|
||||
};
|
||||
_safe = (getNumber (ConfigFile >> "CfgGlasses" >> goggles ace_player >> "ACE_Protection") == 1);
|
||||
};
|
||||
if (_safe) exitWith {};
|
||||
if ((_rotorWash select 1) <= 15) then {
|
||||
private "_scale";
|
||||
_scale = 0.7;
|
||||
if ((_rotorWash select 1) != 0) then {
|
||||
_scale = CLAMP(0.3*(_rotorWash select 1),0.1,0.3);
|
||||
} else {
|
||||
_scale = 0.1;
|
||||
};
|
||||
_scale = 1 - _scale;
|
||||
if (GVAR(DustHandler) != -1) then { // should be fixed in dev CBA
|
||||
[GVAR(DustHandler)] call CALLSTACK(cba_fnc_removePerFrameHandler);
|
||||
GVAR(DustHandler) = -1;
|
||||
};
|
||||
if !(ace_player getVariable ["ACE_EyesDamaged", false]) then {
|
||||
GVAR(PostProcessEyes_Enabled) = true;
|
||||
GVAR(PostProcessEyes) ppEffectAdjust [1, 1, 0, [0,0,0,0], [_scale,_scale,_scale,_scale],[1,1,1,0]];
|
||||
GVAR(PostProcessEyes) ppEffectCommit 0.5;
|
||||
GVAR(PostProcessEyes) ppEffectEnable true;
|
||||
};
|
||||
};
|
Loading…
Reference in New Issue
Block a user