Removed a bunch of spawns and used PFH's in their place.

This commit is contained in:
Garth L-H de Wet 2015-01-19 00:57:39 +02:00
parent fc18cb443f
commit 49e19610c2
9 changed files with 107 additions and 143 deletions

View File

@ -16,7 +16,16 @@
#include "script_component.hpp" #include "script_component.hpp"
if (!hasInterface) exitWith {}; if (!hasInterface) exitWith {};
if isNil(QGAR(UsePP)) then { ["ACE3", localize "STR_ACE_Goggles_WipeGlasses",
{
if (!(GETVAR(ace_player,ACE_isUnconscious,false))) exitWith {
call FUNC(clearGlasses);
true
};
false
}, [20, true, true, false], false, "keydown"] call CALLSTACK(cba_fnc_registerKeybind);
if isNil(QGVAR(UsePP)) then {
GVAR(UsePP) = true; GVAR(UsePP) = true;
}; };
@ -31,22 +40,24 @@ GVAR(Current) = "None";
GVAR(EyesDamageScript) = 0 spawn {}; GVAR(EyesDamageScript) = 0 spawn {};
GVAR(FrameEvent) = [false, [false,20]]; GVAR(FrameEvent) = [false, [false,20]];
GVAR(PostProcessEyes_Enabled) = false; GVAR(PostProcessEyes_Enabled) = false;
GVAR(DustHandler) = 0 spawn {}; GVAR(DustHandler) = -1;
GVAR(RainDrops) = objNull; GVAR(RainDrops) = objNull;
GVAR(RainActive) = false;
GVAR(RainLastLevel) = 0;
FUNC(CheckGlasses) = { FUNC(CheckGlasses) = {
if (GVAR(Current) != (goggles ace_player)) then { if (GVAR(Current) != (goggles ace_player)) then {
GVAR(Current) = (goggles ace_player); GVAR(Current) = (goggles ace_player);
["GlassesChanged",[GVAR(Current)]] call CBA_fnc_localEvent; ["GlassesChanged",[GVAR(Current)]] call EFUNC(common,localEvent);
}; };
}; };
ace_player addEventHandler ["Explosion", { player addEventHandler ["Explosion", {
if (alive ace_player) then { if (alive ace_player) then {
call FUNC(ApplyDirtEffect); call FUNC(ApplyDirtEffect);
if (GETBROKEN) exitWith {}; if (GETBROKEN) exitWith {};
if (((_this select 1) call FUNC(GetExplosionIndex)) < getNumber(ConfigFile >> "CfgGlasses" >> GVAR(Current) >> "ACE_Resistance")) 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 CBA_fnc_localEvent;}; if !(ace_player call FUNC(isGogglesVisible)) exitWith {["GlassesCracked",[ace_player]] call EFUNC(common,localEvent);};
GVAR(Effects) set [BROKEN, true]; GVAR(Effects) set [BROKEN, true];
if (getText(ConfigFile >> "CfgGlasses" >> GVAR(Current) >> "ACE_OverlayCracked") != "" && {cameraOn == ace_player}) then { if (getText(ConfigFile >> "CfgGlasses" >> GVAR(Current) >> "ACE_OverlayCracked") != "" && {cameraOn == ace_player}) then {
if (call FUNC(ExternalCamera)) exitWith {}; if (call FUNC(ExternalCamera)) exitWith {};
@ -55,26 +66,22 @@ ace_player addEventHandler ["Explosion", {
}; };
(GLASSDISPLAY displayCtrl 10650) ctrlSetText getText(ConfigFile >> "CfgGlasses" >> GVAR(Current) >> "ACE_OverlayCracked"); (GLASSDISPLAY displayCtrl 10650) ctrlSetText getText(ConfigFile >> "CfgGlasses" >> GVAR(Current) >> "ACE_OverlayCracked");
}; };
["GlassesCracked",[ace_player]] call CBA_fnc_localEvent; ["GlassesCracked",[ace_player]] call EFUNC(common,localEvent);
}; };
}]; }];
ace_player addEventHandler ["Killed",{ player addEventHandler ["Killed",{
[] spawn { GVAR(PostProcessEyes) ppEffectEnable false;
sleep 2; GVAR(Effects) = GLASSESDEFAULT;
GVAR(PostProcessEyes) ppEffectEnable false; call FUNC(removeGlassesEffect);
GVAR(Effects) = GLASSESDEFAULT; GVAR(EffectsActive)=false;
call FUNC(removeGlassesEffect); ace_player setVariable ["ACE_EyesDamaged", false];
GVAR(EffectsActive)=false; terminate GVAR(EyesDamageScript);
ace_player setVariable ["ACE_EyesDamaged", false]; [GVAR(DustHandler)] call CALLSTACK(cba_fnc_removePerFrameHandler);
terminate GVAR(EyesDamageScript); GVAR(DustHandler) = -1;
terminate GVAR(MainLoop);
terminate GVAR(DustHandler);
GVAR(MainLoop) = [] spawn FUNC(checkGoggles);
};
}]; }];
ace_player addEventHandler ["Fired",{[_this select 0, _this select 1] call FUNC(dustHandler);}]; player addEventHandler ["Fired",{[_this select 0, _this select 1] call FUNC(dustHandler);}];
ace_player AddEventHandler ["Take",{call FUNC(checkGlasses);}]; player AddEventHandler ["Take",{call FUNC(checkGlasses);}];
ace_player AddEventHandler ["Put", {call FUNC(checkGlasses);}]; player AddEventHandler ["Put", {call FUNC(checkGlasses);}];
["GlassesChanged",{ ["GlassesChanged",{
GVAR(Effects) = GLASSESDEFAULT; GVAR(Effects) = GLASSESDEFAULT;
@ -86,7 +93,7 @@ ace_player AddEventHandler ["Put", {call FUNC(checkGlasses);}];
} else { } else {
call FUNC(removeGlassesEffect); call FUNC(removeGlassesEffect);
}; };
}] call CBA_fnc_addEventHandler; }] call EFUNC(common,addEventHandler);
["GlassesCracked",{ ["GlassesCracked",{
if (_this select 0 != ace_player) exitWith {}; if (_this select 0 != ace_player) exitWith {};
ace_player setVariable ["ACE_EyesDamaged", true]; ace_player setVariable ["ACE_EyesDamaged", true];
@ -104,5 +111,8 @@ ace_player AddEventHandler ["Put", {call FUNC(checkGlasses);}];
GVAR(PostProcessEyes) ppEffectEnable false; GVAR(PostProcessEyes) ppEffectEnable false;
ace_player setVariable ["ACE_EyesDamaged", false]; ace_player setVariable ["ACE_EyesDamaged", false];
}; };
}] call CBA_fnc_addEventHandler; }] call EFUNC(common,addEventHandler);
GVAR(MainLoop) = [] spawn FUNC(CheckGoggles); 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;

View File

@ -243,19 +243,6 @@ class SniperCloud {
ACE_Goggles_BulletCount = 1; ACE_Goggles_BulletCount = 1;
}; };
class ACE_Default_Keys {
class wipeGlasses {
displayName = $STR_ACE_Goggles_WipeGlasses;
//condition = QUOTE(!(GETVAR(ace_player,isUnconscious,false)));
condition = "true";
statement = QUOTE(call FUNC(clearGlasses););
key = 20; // T
shift = 1;
control = 1;
alt = 0;
};
};
class ACE_Options { class ACE_Options {
class showInThirdPerson { class showInThirdPerson {
displayName = $STR_ACE_Goggles_ShowInThirdPerson; displayName = $STR_ACE_Goggles_ShowInThirdPerson;

View File

@ -22,7 +22,7 @@ private "_dirtImage";
GVAR(Effects) set [DIRT, true]; GVAR(Effects) set [DIRT, true];
if (ace_player call FUNC(isGogglesVisible)) then{ if (ace_player call FUNC(isGogglesVisible)) then{
_dirtImage = getText(ConfigFile >> "CfgGlasses" >> goggles ace_player >> "ACE_OverlayDirt"); _dirtImage = getText(ConfigFile >> "CfgGlasses" >> (goggles ace_player) >> "ACE_OverlayDirt");
if (_dirtImage != "") then { if (_dirtImage != "") then {
100 cutRsc["RscACE_GogglesEffects", "PLAIN",0.1, false]; 100 cutRsc["RscACE_GogglesEffects", "PLAIN",0.1, false];

View File

@ -33,37 +33,26 @@ _amount = 1 - (GETDUSTT(DAMOUNT) * 0.125);
GVAR(PostProcessEyes) ppEffectAdjust[1, 1, 0, [0,0,0,0], [_amount,_amount,_amount,_amount],[1,1,1,0]]; GVAR(PostProcessEyes) ppEffectAdjust[1, 1, 0, [0,0,0,0], [_amount,_amount,_amount,_amount],[1,1,1,0]];
GVAR(PostProcessEyes) ppEffectCommit 1; GVAR(PostProcessEyes) ppEffectCommit 1;
GVAR(PostProcessEyes) ppEffectEnable true; GVAR(PostProcessEyes) ppEffectEnable true;
if !(scriptDone GVAR(DustHandler)) then { if (GVAR(DustHandler) != -1) then { // should be fixed in dev CBA
terminate GVAR(DustHandler); [GVAR(DustHandler)] call CALLSTACK(cba_fnc_removePerFrameHandler);
}; };
SETDUST(DBULLETS,0); SETDUST(DBULLETS,0);
GVAR(DustHandler) = [3] spawn { GVAR(DustHandler) = [{
private ["_loop", "_timeToSleep"]; EXPLODE_2_PVT(_this select 0,_sleep,_startTime);
_timeToSleep = _this select 0; if (diag_tickTime >= GETDUSTT(DTIME) + 3) then {
_loop = true; SETDUST(DAMOUNT,CLAMP(GETDUSTT(DAMOUNT)-1,0,2));
while {_loop} do { private "_amount";
sleep _timeToSleep; _amount = 1 - (GETDUSTT(DAMOUNT) * 0.125);
_timeToSleep = GETDUSTT(DTIME); if !(ace_player getVariable ["ACE_EyesDamaged", false]) then {
GVAR(PostProcessEyes) ppEffectAdjust[1, 1, 0, [0,0,0,0], [_amount,_amount,_amount,_amount],[1,1,1,0]];
if(_timeToSleep >= (time - 2.5)) then { GVAR(PostProcessEyes) ppEffectCommit 0.5;
_timeToSleep = time - _timeToSleep; };
} else { if (GETDUSTT(DAMOUNT) <= 0) then {
SETDUST(DAMOUNT,CLAMP(GETDUSTT(DAMOUNT)-1,0,2)); GVAR(PostProcessEyes) ppEffectEnable false;
private "_amount"; SETDUST(DACTIVE,false);
_amount = 1 - (GETDUSTT(DAMOUNT) * 0.125); SETDUST(DBULLETS,0);
if !(ace_player getVariable ["ACE_EyesDamaged", false]) then { [GVAR(DustHandler)] call CALLSTACK(cba_fnc_removePerFrameHandler);
GVAR(PostProcessEyes) ppEffectAdjust[1, 1, 0, [0,0,0,0], [_amount,_amount,_amount,_amount],[1,1,1,0]]; GVAR(DustHandler) = -1;
GVAR(PostProcessEyes) ppEffectCommit 1;
sleep 1;
};
if (GETDUSTT(DAMOUNT) <= 0) then {
GVAR(PostProcessEyes) ppEffectEnable false;
SETDUST(DACTIVE,false);
SETDUST(DBULLETS,0);
_loop = false;
};
SETDUST(DTIME,time);
_timeToSleep = 3;
}; };
}; };
}; },0,[]] call CALLSTACK(cba_fnc_addPerFrameHandler);

View File

@ -4,48 +4,34 @@
Description: Description:
Performs rain checks and checks to see whether glasses effects have been applied or not. Performs rain checks and checks to see whether glasses effects have been applied or not.
Checks for external camera and removes effects. Checks for external camera and removes effects.
Parameters:
Nothing
Returns:
Nothing
Example:
[] execVM "ACE_Goggles\functions\fn_CheckGoggles.sqf";
*/ */
#include "script_component.hpp" #include "script_component.hpp"
call FUNC(checkGlasses); if (!alive ace_player) exitWith {};
[QGVAR(RotorWash), "OnEachFrame", {call FUNC(onEachFrame);}] call CALLSTACK(BIS_fnc_addStackedEventHandler); if (true) then {
[] spawn FUNC(rainEffect); // Detect if curator interface is open and disable effects
while {alive ace_player} do { if (!isNull(findDisplay 312)) exitWith {
sleep 1; if (GVAR(EffectsActive)) then {
if (true) then { call FUNC(removeGlassesEffect);
// Detect if curator interface is open and disable effects
if (!isNull(findDisplay 312)) exitWith {
if (GVAR(EffectsActive)) then {
call FUNC(removeGlassesEffect);
};
}; };
call FUNC(checkGlasses); };
if !(ace_player call FUNC(isGogglesVisible)) exitWith { call FUNC(checkGlasses);
if (GVAR(EffectsActive)) then { if !(ace_player call FUNC(isGogglesVisible)) exitWith {
call FUNC(removeGlassesEffect); if (GVAR(EffectsActive)) then {
}; call FUNC(removeGlassesEffect);
}; };
if (call FUNC(externalCamera)) exitWith { };
if (GVAR(EffectsActive)) then { if (call FUNC(externalCamera)) exitWith {
call FUNC(removeGlassesEffect); if (GVAR(EffectsActive)) then {
}; call FUNC(removeGlassesEffect);
}; };
if !(GVAR(EffectsActive)) then { };
(goggles ace_player) call FUNC(applyGlassesEffect); if !(GVAR(EffectsActive)) then {
} else { (goggles ace_player) call FUNC(applyGlassesEffect);
if ((goggles ace_player) call FUNC(isDivingGoggles) && {underwater ace_player}) then { } else {
call FUNC(removeRainEffect); if ((goggles ace_player) call FUNC(isDivingGoggles) && {underwater ace_player}) then {
call FUNC(removeDirtEffect); call FUNC(removeRainEffect);
call FUNC(removeDustEffect); call FUNC(removeDirtEffect);
}; call FUNC(removeDustEffect);
}; };
}; };
}; };

View File

@ -18,7 +18,6 @@
See http://community.bistudio.com/wiki/ArmA_3:_Event_Handlers#Fired See http://community.bistudio.com/wiki/ArmA_3:_Event_Handlers#Fired
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_bullets", "_position", "_surface", "_found", "_weapon", "_cloudType"]; private ["_bullets", "_position", "_surface", "_found", "_weapon", "_cloudType"];
_weapon = _this select 1; _weapon = _this select 1;
_cloudType = ""; _cloudType = "";
@ -52,13 +51,13 @@ if (!_found) exitWith {};
_bullets = GETDUSTT(DBULLETS); _bullets = GETDUSTT(DBULLETS);
if ((time - GETDUSTT(DTIME)) > 1) then { if ((diag_tickTime - GETDUSTT(DTIME)) > 1) then {
_bullets = 0; _bullets = 0;
}; };
_bullets = _bullets + 1; _bullets = _bullets + 1;
SETDUST(DBULLETS,_bullets); SETDUST(DBULLETS,_bullets);
SETDUST(DTIME,time); SETDUST(DTIME,diag_tickTime);
if (GETDUSTT(DAMOUNT) < 2) then { if (GETDUSTT(DAMOUNT) < 2) then {
private "_bulletsRequired"; private "_bulletsRequired";

View File

@ -16,9 +16,7 @@
["ACE_Goggles_RotorWash", "OnEachFrame", "call FUNC(OnEachFrame);"] call BIS_fnc_addStackedEventHandler; ["ACE_Goggles_RotorWash", "OnEachFrame", "call FUNC(OnEachFrame);"] call BIS_fnc_addStackedEventHandler;
*/ */
#include "script_component.hpp" #include "script_component.hpp"
if (isNull(ace_player)) then { if (isNull(ace_player)) exitWith {};
[QGVAR(RotorWash), "OnEachFrame"] call CALLSTACK(BIS_fnc_removeStackedEventHandler);
};
GVAR(FrameEvent) set [0, !(GVAR(FrameEvent) select 0)]; GVAR(FrameEvent) set [0, !(GVAR(FrameEvent) select 0)];
if (GVAR(FrameEvent) select 0) exitWith { if (GVAR(FrameEvent) select 0) exitWith {
if (vehicle ace_player != ace_player && {!([ace_player] call EFUNC(common,isTurnedOut))}) exitWith {(GVAR(FrameEvent) select 1) set [0, false]; }; if (vehicle ace_player != ace_player && {!([ace_player] call EFUNC(common,isTurnedOut))}) exitWith {(GVAR(FrameEvent) select 1) set [0, false]; };

View File

@ -16,8 +16,8 @@
[] spawn FUNC(RainEffect); [] spawn FUNC(RainEffect);
*/ */
#include "script_component.hpp" #include "script_component.hpp"
GVAR(RainDrops) = objNull; private ["_fnc_underCover"];
GVAR(RainActive) = false; if (isNull(ace_player) || {!(alive ace_player)}) exitWith {};
_fnc_underCover = { _fnc_underCover = {
private ["_pos", "_unit"]; private ["_pos", "_unit"];
_unit = (_this select 0); _unit = (_this select 0);
@ -25,37 +25,31 @@ _fnc_underCover = {
_pos = eyePos _unit; _pos = eyePos _unit;
((positionCameraToWorld [0,0,1] select 2) < ((positionCameraToWorld [0,0,0] select 2) - 0.4)) || {(lineIntersects [_pos, _pos vectorAdd [0,0,15], _unit])} ((positionCameraToWorld [0,0,1] select 2) < ((positionCameraToWorld [0,0,0] select 2) - 0.4)) || {(lineIntersects [_pos, _pos vectorAdd [0,0,15], _unit])}
}; };
private ["_lastRain"]; if (isNull(findDisplay 312)) exitWith {
_lastRain = 0; if (GVAR(RainActive)) then {
while {alive ace_player} do { call FUNC(RemoveRainEffect);
sleep 0.5; };
if (isNull(findDisplay 312)) then { };
// Ignore if ace_player is under water // Ignore if ace_player is under water
if (!GVAR(EffectsActive) || {underwater ace_player}) exitWith{call FUNC(RemoveRainEffect);}; if (!GVAR(EffectsActive) || {underwater ace_player}) exitWith{call FUNC(RemoveRainEffect);};
if (_lastRain != rain) then { if (GVAR(RainLastRain) != rain) then {
call FUNC(RemoveRainEffect);
GVAR(RainLastRain) = rain;
// Rain is happening
if (GVAR(RainLastRain) > 0.05 && {!([ace_player] call _fnc_underCover)}) then {
GVAR(RainActive) = true;
GVAR(RainDrops) = "#particlesource" createVehicleLocal GetPos ace_player;
GVAR(RainDrops) setParticleClass "ACERainEffect";
GVAR(RainDrops) setDropInterval (0.07 * (1.1 - GVAR(RainLastRain)));
GVAR(RainDrops) attachTo [vehicle ace_player,[0,0,0]];
};
}else{
if (GVAR(RainLastRain) > 0.05) then {
if (GVAR(RainActive) && {[ace_player] call _fnc_underCover}) exitWith {
call FUNC(RemoveRainEffect); call FUNC(RemoveRainEffect);
_lastRain = rain;
// Rain is happening
if (_lastRain > 0.05 && {!([ace_player] call _fnc_underCover)}) then {
GVAR(RainActive) = true;
GVAR(RainDrops) = "#particlesource" createVehicleLocal GetPos ace_player;
GVAR(RainDrops) setParticleClass "ACERainEffect";
GVAR(RainDrops) setDropInterval (0.07 * (1.1 - _lastRain));
GVAR(RainDrops) attachTo [vehicle ace_player,[0,0,0]];
};
}else{
if (_lastRain > 0.05) then {
if (GVAR(RainActive) && {[ace_player] call _fnc_underCover}) exitWith {
call FUNC(RemoveRainEffect);
};
if (!GVAR(RainActive)) then {
_lastRain = -1;
};
};
}; };
}else{ if (!GVAR(RainActive)) then {
if (GVAR(RainActive)) then { GVAR(RainLastRain) = -1;
call FUNC(RemoveRainEffect);
}; };
}; };
}; };

View File

@ -20,3 +20,4 @@ if (!isNull (GVAR(RainDrops))) then {
deleteVehicle (GVAR(RainDrops)); deleteVehicle (GVAR(RainDrops));
}; };
GVAR(RainActive) = false; GVAR(RainActive) = false;
GVAR(RainLastLevel) = 0;