2015-01-18 21:50:45 +00:00
|
|
|
/*
|
2015-02-02 09:04:53 +00:00
|
|
|
* Author: Garth 'L-H' de Wet
|
|
|
|
* Sets up the glasses mod for usage. Initialises variables and event handlers.
|
|
|
|
* Shouldn't be called by a user/modder ever. Done by the engine.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
2015-01-18 21:50:45 +00:00
|
|
|
#include "script_component.hpp"
|
|
|
|
if (!hasInterface) exitWith {};
|
|
|
|
|
2015-03-05 07:32:26 +00:00
|
|
|
["ACE3", QGVAR(wipeGlasses), localize "STR_ACE_Goggles_WipeGlasses",
|
2015-01-18 22:57:39 +00:00
|
|
|
{
|
2015-03-05 07:32:26 +00:00
|
|
|
if (!(GETVAR(ace_player,ACE_isUnconscious,false))) exitWith {
|
|
|
|
call FUNC(clearGlasses);
|
|
|
|
true
|
|
|
|
};
|
|
|
|
false
|
|
|
|
},
|
2015-03-05 08:51:24 +00:00
|
|
|
{false},
|
2015-03-10 17:45:08 +00:00
|
|
|
[20, [true, true, false]], false] call cba_fnc_addKeybind;
|
2015-01-18 22:57:39 +00:00
|
|
|
|
|
|
|
if isNil(QGVAR(UsePP)) then {
|
2015-03-05 07:32:26 +00:00
|
|
|
GVAR(UsePP) = true;
|
2015-01-18 21:50:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
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) ppEffectCommit 0;
|
|
|
|
GVAR(PostProcessEyes) ppEffectEnable false;
|
|
|
|
GVAR(EffectsActive) = false;
|
2015-01-18 23:38:54 +00:00
|
|
|
SETGLASSES(ace_player,GLASSESDEFAULT);
|
2015-01-18 21:50:45 +00:00
|
|
|
GVAR(Current) = "None";
|
2015-01-19 08:34:49 +00:00
|
|
|
GVAR(EyesDamageScript) = -1;
|
2015-01-18 21:50:45 +00:00
|
|
|
GVAR(FrameEvent) = [false, [false,20]];
|
|
|
|
GVAR(PostProcessEyes_Enabled) = false;
|
2015-01-18 22:57:39 +00:00
|
|
|
GVAR(DustHandler) = -1;
|
2015-01-18 21:50:45 +00:00
|
|
|
GVAR(RainDrops) = objNull;
|
2015-01-18 22:57:39 +00:00
|
|
|
GVAR(RainActive) = false;
|
|
|
|
GVAR(RainLastLevel) = 0;
|
2015-01-18 21:50:45 +00:00
|
|
|
|
|
|
|
FUNC(CheckGlasses) = {
|
2015-03-05 07:32:26 +00:00
|
|
|
if (GVAR(Current) != (goggles ace_player)) then {
|
|
|
|
GVAR(Current) = (goggles ace_player);
|
|
|
|
["GlassesChanged",[GVAR(Current)]] call EFUNC(common,localEvent);
|
|
|
|
};
|
2015-01-18 21:50:45 +00:00
|
|
|
};
|
|
|
|
|
2015-01-18 22:57:39 +00:00
|
|
|
player addEventHandler ["Explosion", {
|
2015-03-05 07:32:26 +00:00
|
|
|
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);
|
2015-01-18 21:50:45 +00:00
|
|
|
};
|
|
|
|
}];
|
2015-01-18 22:57:39 +00:00
|
|
|
player addEventHandler ["Killed",{
|
2015-03-05 07:32:26 +00:00
|
|
|
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;
|
|
|
|
};
|
2015-01-18 21:50:45 +00:00
|
|
|
}];
|
2015-01-18 22:57:39 +00:00
|
|
|
player addEventHandler ["Fired",{[_this select 0, _this select 1] call FUNC(dustHandler);}];
|
|
|
|
player AddEventHandler ["Take",{call FUNC(checkGlasses);}];
|
|
|
|
player AddEventHandler ["Put", {call FUNC(checkGlasses);}];
|
2015-01-18 21:50:45 +00:00
|
|
|
|
|
|
|
["GlassesChanged",{
|
2015-03-05 07:32:26 +00:00
|
|
|
SETGLASSES(ace_player,GLASSESDEFAULT);
|
2015-01-18 21:50:45 +00:00
|
|
|
|
2015-03-05 07:32:26 +00:00
|
|
|
if (call FUNC(ExternalCamera)) exitWith {call FUNC(RemoveGlassesEffect)};
|
2015-01-18 21:50:45 +00:00
|
|
|
|
2015-03-05 07:32:26 +00:00
|
|
|
if ([ace_player] call FUNC(isGogglesVisible)) then {
|
|
|
|
[_this select 0] call FUNC(applyGlassesEffect);
|
|
|
|
} else {
|
|
|
|
call FUNC(removeGlassesEffect);
|
|
|
|
};
|
2015-01-18 22:57:39 +00:00
|
|
|
}] call EFUNC(common,addEventHandler);
|
2015-01-18 21:50:45 +00:00
|
|
|
["GlassesCracked",{
|
2015-03-05 07:32:26 +00:00
|
|
|
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]];
|
|
|
|
GVAR(PostProcessEyes) ppEffectCommit 0;
|
|
|
|
GVAR(PostProcessEyes) ppEffectEnable true;
|
2015-01-19 08:34:49 +00:00
|
|
|
GVAR(EyesDamageScript) = [{
|
2015-03-05 07:32:26 +00:00
|
|
|
GVAR(PostProcessEyes) ppEffectAdjust[1, 1, 0, [0,0,0,0], [1,1,1,1],[1,1,1,0]];
|
|
|
|
GVAR(PostProcessEyes) ppEffectCommit 5;
|
|
|
|
GVAR(EyesDamageScript) = [{
|
|
|
|
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);
|
2015-01-18 22:57:39 +00:00
|
|
|
}] call EFUNC(common,addEventHandler);
|
|
|
|
call FUNC(checkGlasses);
|
|
|
|
[FUNC(CheckGoggles), 1, []] call CBA_fnc_addPerFrameHandler;
|
|
|
|
[FUNC(rainEffect), 0.5, []] call CBA_fnc_addPerFrameHandler;
|
|
|
|
[FUNC(onEachFrame), 0, []] call CBA_fnc_addPerFrameHandler;
|