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
b7ce315240
commit
62349f685c
@ -12,22 +12,25 @@ if (!hasInterface) exitWith {};
|
||||
{false},
|
||||
[20, [true, true, false]], false] call CBA_fnc_addKeybind;
|
||||
|
||||
// make sure to stack effect layers in correct order
|
||||
QGVAR(GogglesEffectsLayer) call BIS_fnc_RSCLayer;
|
||||
QGVAR(GogglesLayer) call BIS_fnc_RSCLayer;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if isNil(QGVAR(UsePP)) then {
|
||||
if (isNil QGVAR(UsePP)) then {
|
||||
GVAR(UsePP) = true;
|
||||
};
|
||||
|
||||
GVAR(PostProcess) = ppEffectCreate ["ColorCorrections", 1995];
|
||||
// init pp effects
|
||||
GVAR(PostProcess) = ppEffectCreate ["ColorCorrections", 1995];
|
||||
GVAR(PostProcessEyes) = ppEffectCreate ["ColorCorrections", 1992];
|
||||
GVAR(PostProcessEyes) ppEffectAdjust[1, 1, 0, [0,0,0,0], [0,0,0,1],[1,1,1,0]];
|
||||
GVAR(PostProcessEyes) ppEffectAdjust [1, 1, 0, [0, 0, 0, 0], [0, 0, 0, 1], [1, 1, 1, 0]];
|
||||
GVAR(PostProcessEyes) ppEffectCommit 0;
|
||||
GVAR(PostProcessEyes) ppEffectEnable false;
|
||||
|
||||
GVAR(EffectsActive) = false;
|
||||
|
||||
SETGLASSES(ace_player,GLASSESDEFAULT);
|
||||
|
||||
GVAR(Current) = "None";
|
||||
GVAR(EyesDamageScript) = -1;
|
||||
GVAR(FrameEvent) = [false, [false,20]];
|
||||
@ -39,82 +42,66 @@ GVAR(RainLastLevel) = 0;
|
||||
GVAR(surfaceCache) = "";
|
||||
GVAR(surfaceCacheIsDust) = false;
|
||||
|
||||
FUNC(CheckGlasses) = {
|
||||
if (GVAR(Current) != (goggles ace_player)) then {
|
||||
GVAR(Current) = (goggles ace_player);
|
||||
["GlassesChanged",[GVAR(Current)]] call EFUNC(common,localEvent);
|
||||
};
|
||||
};
|
||||
|
||||
player addEventHandler ["Explosion", {
|
||||
private "_effects";
|
||||
if (alive ace_player) then {
|
||||
call FUNC(applyDirtEffect);
|
||||
if (GETBROKEN) exitWith {};
|
||||
if (((_this select 1) call FUNC(GetExplosionIndex)) < getNumber(ConfigFile >> "CfgGlasses" >> GVAR(Current) >> "ACE_Resistance")) exitWith {};
|
||||
if !([ace_player] call FUNC(isGogglesVisible)) exitWith {["GlassesCracked",[ace_player]] call EFUNC(common,localEvent);};
|
||||
_effects = GETGLASSES(ace_player);
|
||||
_effects set [BROKEN, true];
|
||||
SETGLASSES(ace_player,_effects);
|
||||
if (getText(ConfigFile >> "CfgGlasses" >> GVAR(Current) >> "ACE_OverlayCracked") != "" && {cameraOn == ace_player}) then {
|
||||
if (call FUNC(ExternalCamera)) exitWith {};
|
||||
if (isNull(GLASSDISPLAY)) then {
|
||||
150 cutRsc["RscACE_Goggles", "PLAIN",1, false];
|
||||
};
|
||||
(GLASSDISPLAY displayCtrl 10650) ctrlSetText getText(ConfigFile >> "CfgGlasses" >> GVAR(Current) >> "ACE_OverlayCracked");
|
||||
};
|
||||
["GlassesCracked",[ace_player]] call EFUNC(common,localEvent);
|
||||
};
|
||||
}];
|
||||
player addEventHandler ["Killed",{
|
||||
GVAR(PostProcessEyes) ppEffectEnable false;
|
||||
SETGLASSES(ace_player,GLASSESDEFAULT);
|
||||
call FUNC(removeGlassesEffect);
|
||||
GVAR(EffectsActive)=false;
|
||||
ace_player setVariable ["ACE_EyesDamaged", false];
|
||||
if (GVAR(EyesDamageScript) != -1) then {
|
||||
[GVAR(EyesDamageScript)] call CALLSTACK(cba_fnc_removePreFrameHandler);
|
||||
};
|
||||
if (GVAR(DustHandler) != -1) then {
|
||||
[GVAR(DustHandler)] call CALLSTACK(cba_fnc_removePerFrameHandler);
|
||||
GVAR(DustHandler) = -1;
|
||||
};
|
||||
}];
|
||||
player addEventHandler ["Fired",{[_this select 0, _this select 1] call FUNC(dustHandler);}];
|
||||
player AddEventHandler ["Take",{call FUNC(checkGlasses);}];
|
||||
player AddEventHandler ["Put", {call FUNC(checkGlasses);}];
|
||||
// init GlassesChanged eventhandler
|
||||
GVAR(OldGlasses) = "#NULLSTRING";
|
||||
|
||||
["GlassesChanged",{
|
||||
SETGLASSES(ace_player,GLASSESDEFAULT);
|
||||
["playerInventoryChanged", {
|
||||
(_this select 1) params ["", "_currentGlasses"];
|
||||
|
||||
if (GVAR(OldGlasses) != _currentGlasses) then {
|
||||
["GlassesChanged", [ACE_player, _currentGlasses]] call EFUNC(common,localEvent);
|
||||
GVAR(OldGlasses) = _currentGlasses;
|
||||
};
|
||||
}] call EFUNC(common,addEventHandler);
|
||||
|
||||
// add glasses eventhandlers
|
||||
["GlassesChanged", {
|
||||
params ["_unit", "_glasses"];
|
||||
|
||||
SETGLASSES(_unit,GLASSESDEFAULT);
|
||||
|
||||
if (call FUNC(ExternalCamera)) exitWith {call FUNC(RemoveGlassesEffect)};
|
||||
|
||||
if ([ace_player] call FUNC(isGogglesVisible)) then {
|
||||
[_this select 0] call FUNC(applyGlassesEffect);
|
||||
if ([_unit] call FUNC(isGogglesVisible)) then {
|
||||
_glasses call FUNC(applyGlassesEffect);
|
||||
} else {
|
||||
call FUNC(removeGlassesEffect);
|
||||
};
|
||||
}] call EFUNC(common,addEventHandler);
|
||||
["GlassesCracked",{
|
||||
if (_this select 0 != ace_player) exitWith {};
|
||||
ace_player setVariable ["ACE_EyesDamaged", true];
|
||||
if (GVAR(EyesDamageScript) != -1) then {
|
||||
[GVAR(EyesDamageScript)] call CALLSTACK(cba_fnc_removePreFrameHandler);
|
||||
};
|
||||
GVAR(PostProcessEyes) ppEffectAdjust[1, 1, 0, [0,0,0,0], [0.5,0.5,0.5,0.5],[1,1,1,0]];
|
||||
|
||||
["GlassesCracked", {
|
||||
params ["_unit"];
|
||||
|
||||
_unit setVariable ["ACE_EyesDamaged", true];
|
||||
|
||||
GVAR(PostProcessEyes) ppEffectAdjust [1, 1, 0, [0, 0, 0, 0], [0.5, 0.5, 0.5, 0.5], [1, 1, 1, 0]];
|
||||
GVAR(PostProcessEyes) ppEffectCommit 0;
|
||||
GVAR(PostProcessEyes) ppEffectEnable true;
|
||||
GVAR(EyesDamageScript) = [{
|
||||
GVAR(PostProcessEyes) ppEffectAdjust[1, 1, 0, [0,0,0,0], [1,1,1,1],[1,1,1,0]];
|
||||
|
||||
[{
|
||||
GVAR(PostProcessEyes) ppEffectAdjust [1, 1, 0, [0, 0, 0, 0], [1, 1, 1, 1], [1, 1, 1, 0]];
|
||||
GVAR(PostProcessEyes) ppEffectCommit 5;
|
||||
|
||||
GVAR(EyesDamageScript) = [{
|
||||
params ["_unit"];
|
||||
|
||||
GVAR(PostProcessEyes) ppEffectEnable false;
|
||||
ace_player setVariable ["ACE_EyesDamaged", false];
|
||||
GVAR(EyesDamageScript) = -1;
|
||||
}, [], 5, 1] call EFUNC(common,waitAndExecute);
|
||||
}, [], 25, 5] call EFUNC(common,waitAndExecute);
|
||||
|
||||
_unit setVariable ["ACE_EyesDamaged", false];
|
||||
|
||||
}, _this, 5] call EFUNC(common,waitAndExecute);
|
||||
|
||||
}, _unit, 25] call EFUNC(common,waitAndExecute);
|
||||
|
||||
}] call EFUNC(common,addEventHandler);
|
||||
call FUNC(checkGlasses);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
[FUNC(CheckGoggles), 1, []] call CBA_fnc_addPerFrameHandler;
|
||||
[FUNC(applyRainEffect), 0.5, []] call CBA_fnc_addPerFrameHandler;
|
||||
[FUNC(onEachFrame), 0, []] call CBA_fnc_addPerFrameHandler;
|
||||
|
@ -31,7 +31,7 @@ if ([_unit] call FUNC(isGogglesVisible)) then {
|
||||
local _dirtImage = getText (configFile >> "CfgGlasses" >> goggles _unit >> "ACE_OverlayDirt");
|
||||
|
||||
if (_dirtImage != "") then {
|
||||
(QGVAR(GogglesEffectsLayer) call BIS_fnc_RSCLayer) cutRsc ["RscACE_GogglesEffects", "PLAIN", 0.1, false]; // @todo init as 100
|
||||
(QGVAR(GogglesEffectsLayer) call BIS_fnc_RSCLayer) cutRsc ["RscACE_GogglesEffects", "PLAIN", 0.1, false];
|
||||
(GETUVAR(GVAR(DisplayEffects),displayNull) displayCtrl 10660) ctrlSetText _dirtImage;
|
||||
};
|
||||
};
|
||||
|
@ -25,7 +25,7 @@ _unit = ACE_player;
|
||||
if ([_unit] call FUNC(isGogglesVisible)) exitWith {
|
||||
(QGVAR(GogglesEffectsLayer) call BIS_fnc_RSCLayer) cutRsc ["RscACE_GogglesEffects", "PLAIN", 2, false];
|
||||
|
||||
((GETUVAR(GVAR(DisplayEffects),displayNull)) displayCtrl 10662) ctrlSetText format [getText (configFile >> "CfgGlasses" >> GVAR(Current) >> "ACE_DustPath"), GETDUSTT(DAMOUNT) + 1];
|
||||
((GETUVAR(GVAR(DisplayEffects),displayNull)) displayCtrl 10662) ctrlSetText format [getText (configFile >> "CfgGlasses" >> goggles _unit >> "ACE_DustPath"), GETDUSTT(DAMOUNT) + 1];
|
||||
|
||||
SETDUST(DAMOUNT,CLAMP(GETDUSTT(DAMOUNT) + 1,0,1));
|
||||
SETDUST(DBULLETS,0);
|
||||
|
@ -42,7 +42,7 @@ if (_postProcessTintAmount != 0 && {GVAR(UsePP)}) then {
|
||||
_imagePath = getText (_config >> ["ACE_Overlay", "ACE_OverlayCracked"] select GETBROKEN);
|
||||
|
||||
if (_imagePath != "") then {
|
||||
(QGVAR(GogglesLayer) call BIS_fnc_RSCLayer) cutRsc ["RscACE_Goggles", "PLAIN", 1, false]; // @todo init as 150
|
||||
(QGVAR(GogglesLayer) call BIS_fnc_RSCLayer) cutRsc ["RscACE_Goggles", "PLAIN", 1, false];
|
||||
(GLASSDISPLAY displayCtrl 10650) ctrlSetText _imagePath;
|
||||
};
|
||||
|
||||
|
@ -23,7 +23,7 @@ if (true) then {
|
||||
call FUNC(removeGlassesEffect);
|
||||
};
|
||||
};
|
||||
call FUNC(checkGlasses);
|
||||
//call FUNC(checkGlasses);
|
||||
if !([ace_player] call FUNC(isGogglesVisible)) exitWith {
|
||||
if (GVAR(EffectsActive)) then {
|
||||
call FUNC(removeGlassesEffect);
|
||||
|
@ -0,0 +1,19 @@
|
||||
#include "script_component.hpp"
|
||||
private "_effects";
|
||||
if (alive ace_player) then {
|
||||
call FUNC(applyDirtEffect);
|
||||
if (GETBROKEN) exitWith {};
|
||||
if (((_this select 1) call FUNC(GetExplosionIndex)) < getNumber(ConfigFile >> "CfgGlasses" >> GVAR(Current) >> "ACE_Resistance")) exitWith {};
|
||||
if !([ace_player] call FUNC(isGogglesVisible)) exitWith {["GlassesCracked",[ace_player]] call EFUNC(common,localEvent);};
|
||||
_effects = GETGLASSES(ace_player);
|
||||
_effects set [BROKEN, true];
|
||||
SETGLASSES(ace_player,_effects);
|
||||
if (getText(ConfigFile >> "CfgGlasses" >> GVAR(Current) >> "ACE_OverlayCracked") != "" && {cameraOn == ace_player}) then {
|
||||
if (call FUNC(ExternalCamera)) exitWith {};
|
||||
if (isNull(GLASSDISPLAY)) then {
|
||||
150 cutRsc["RscACE_Goggles", "PLAIN",1, false];
|
||||
};
|
||||
(GLASSDISPLAY displayCtrl 10650) ctrlSetText getText(ConfigFile >> "CfgGlasses" >> GVAR(Current) >> "ACE_OverlayCracked");
|
||||
};
|
||||
["GlassesCracked",[ace_player]] call EFUNC(common,localEvent);
|
||||
};
|
@ -0,0 +1,2 @@
|
||||
#include "script_component.hpp"
|
||||
[_this select 0, _this select 1] call FUNC(dustHandler);
|
@ -0,0 +1,13 @@
|
||||
#include "script_component.hpp"
|
||||
GVAR(PostProcessEyes) ppEffectEnable false;
|
||||
SETGLASSES(ace_player,GLASSESDEFAULT);
|
||||
call FUNC(removeGlassesEffect);
|
||||
GVAR(EffectsActive)=false;
|
||||
ace_player setVariable ["ACE_EyesDamaged", false];
|
||||
if (GVAR(EyesDamageScript) != -1) then {
|
||||
[GVAR(EyesDamageScript)] call CALLSTACK(cba_fnc_removePreFrameHandler);
|
||||
};
|
||||
if (GVAR(DustHandler) != -1) then {
|
||||
[GVAR(DustHandler)] call CALLSTACK(cba_fnc_removePerFrameHandler);
|
||||
GVAR(DustHandler) = -1;
|
||||
};
|
@ -53,7 +53,7 @@ if !(_safe) then {
|
||||
};
|
||||
};
|
||||
};
|
||||
_safe = (getNumber (ConfigFile >> "CfgGlasses" >> GVAR(Current) >> "ACE_Protection") == 1);
|
||||
_safe = (getNumber (ConfigFile >> "CfgGlasses" >> goggles ace_player >> "ACE_Protection") == 1);
|
||||
};
|
||||
if (_safe) exitWith {};
|
||||
if ((_rotorWash select 1) <= 15) then {
|
||||
|
Loading…
Reference in New Issue
Block a user