Converted Goggles to use ACE/CBA macros.

This commit is contained in:
Garth L-H de Wet 2015-01-18 23:50:45 +02:00
parent 0f04d0dfb1
commit fc18cb443f
38 changed files with 704 additions and 681 deletions

View File

@ -0,0 +1 @@
z\ace\addons\goggles

View File

@ -0,0 +1,10 @@
class Extended_PreInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_preInit));
};
};
class Extended_PostInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_postInit));
};
};

View File

@ -1,25 +0,0 @@
class CfgFunctions{
class ACE_Goggles{
class ACE_Goggles{
file="ACE_Goggles\functions";
class Init{postInit = 1;};
class ApplyGlassesEffect;
class RemoveGlassesEffect;
class ApplyDirtEffect;
class RemoveDirtEffect;
class isGogglesVisible;
class isDivingGoggles;
class ClearGlasses;
class CheckGoggles;
class GetExplosionIndex;
class RainEffect;
class RemoveRainEffect;
class DustHandler;
class ExternalCamera;
class isInRotorWash;
class OnEachFrame;
class ApplyDust;
class RemoveDustEffect;
};
};
};

View File

@ -0,0 +1,108 @@
/*
Name: XEH_postInit.sqf
Author: Garth de Wet (LH)
Description:
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.
Parameters:
Nothing
Returns:
Nothing
*/
#include "script_component.hpp"
if (!hasInterface) exitWith {};
if isNil(QGAR(UsePP)) then {
GVAR(UsePP) = true;
};
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;
GVAR(Effects) = GLASSESDEFAULT;
GVAR(Current) = "None";
GVAR(EyesDamageScript) = 0 spawn {};
GVAR(FrameEvent) = [false, [false,20]];
GVAR(PostProcessEyes_Enabled) = false;
GVAR(DustHandler) = 0 spawn {};
GVAR(RainDrops) = objNull;
FUNC(CheckGlasses) = {
if (GVAR(Current) != (goggles ace_player)) then {
GVAR(Current) = (goggles ace_player);
["GlassesChanged",[GVAR(Current)]] call CBA_fnc_localEvent;
};
};
ace_player addEventHandler ["Explosion", {
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 CBA_fnc_localEvent;};
GVAR(Effects) set [BROKEN, true];
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 CBA_fnc_localEvent;
};
}];
ace_player addEventHandler ["Killed",{
[] spawn {
sleep 2;
GVAR(PostProcessEyes) ppEffectEnable false;
GVAR(Effects) = GLASSESDEFAULT;
call FUNC(removeGlassesEffect);
GVAR(EffectsActive)=false;
ace_player setVariable ["ACE_EyesDamaged", false];
terminate GVAR(EyesDamageScript);
terminate GVAR(MainLoop);
terminate GVAR(DustHandler);
GVAR(MainLoop) = [] spawn FUNC(checkGoggles);
};
}];
ace_player addEventHandler ["Fired",{[_this select 0, _this select 1] call FUNC(dustHandler);}];
ace_player AddEventHandler ["Take",{call FUNC(checkGlasses);}];
ace_player AddEventHandler ["Put", {call FUNC(checkGlasses);}];
["GlassesChanged",{
GVAR(Effects) = GLASSESDEFAULT;
if (call FUNC(ExternalCamera)) exitWith {call FUNC(RemoveGlassesEffect)};
if (ace_player call FUNC(isGogglesVisible)) then {
(_this select 0) call FUNC(applyGlassesEffect);
} else {
call FUNC(removeGlassesEffect);
};
}] call CBA_fnc_addEventHandler;
["GlassesCracked",{
if (_this select 0 != ace_player) exitWith {};
ace_player setVariable ["ACE_EyesDamaged", true];
if !(scriptDone GVAR(EyesDamageScript)) then {
terminate GVAR(EyesDamageScript);
};
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) = [] spawn {
sleep 25;
GVAR(PostProcessEyes) ppEffectAdjust[1, 1, 0, [0,0,0,0], [1,1,1,1],[1,1,1,0]];
GVAR(PostProcessEyes) ppEffectCommit 5;
sleep 5;
GVAR(PostProcessEyes) ppEffectEnable false;
ace_player setVariable ["ACE_EyesDamaged", false];
};
}] call CBA_fnc_addEventHandler;
GVAR(MainLoop) = [] spawn FUNC(CheckGoggles);

View File

@ -0,0 +1,23 @@
#include "script_component.hpp"
PREP(applyDirtEffect);
PREP(applyDust);
PREP(applyGlassesEffect);
PREP(checkGoggles);
PREP(clearGlasses);
PREP(dustHandler);
PREP(externalCamera);
PREP(getExplosionIndex);
PREP(isDivingGoggles);
PREP(isGogglesVisible);
PREP(isInRotorWash);
PREP(onEachFrame);
PREP(rainEffect);
PREP(removeDirtEffect);
PREP(removeDustEffect);
PREP(removeGlassesEffect);
PREP(removeRainEffect);

View File

@ -1,21 +1,22 @@
#include "script_component.hpp"
#define COLOUR 8.0 #define COLOUR 8.0
class CfgPatches { class CfgPatches {
class ACE_Goggles { class ADDON {
units[] = {}; units[] = {};
weapons[] = {}; weapons[] = {};
requiredVersion = 0.60; requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {ACE_Core}; requiredAddons[] = {"ace_common"};
version = "0.95";
versionStr = "0.95";
versionAr[] = {0,95,0};
author[] = {"Garth 'L-H' de Wet"}; author[] = {"Garth 'L-H' de Wet"};
authorUrl = "https://github.com/CorruptedHeart"; authorUrl = "http://garth.snakebiteink.co.za/";
VERSION_CONFIG;
}; };
}; };
#include "CfgFunctions.hpp" #include "CfgEventHandlers.hpp"
#define COMBAT_GOGGLES ACE_Overlay="ACE_Goggles\textures\HUD\CombatGoggles.paa"; \
ACE_OverlayCracked = "ACE_Goggles\textures\HUD\CombatGogglesCracked.paa"; \ #define COMBAT_GOGGLES ACE_Overlay = QUOTE(PATHTOF(textures\HUD\CombatGoggles.paa)); \
ACE_OverlayCracked = QUOTE(PATHTOF(textures\HUD\CombatGogglesCracked.paa)); \
ACE_Resistance = 2; \ ACE_Resistance = 2; \
ACE_Protection = 1; ACE_Protection = 1;
@ -25,10 +26,10 @@ class CfgGlasses {
ACE_TintAmount=0; ACE_TintAmount=0;
ACE_Overlay = ""; ACE_Overlay = "";
ACE_OverlayDirt = "A3\Ui_f\data\igui\rsctitles\HealthTextures\dust_upper_ca.paa"; ACE_OverlayDirt = "A3\Ui_f\data\igui\rsctitles\HealthTextures\dust_upper_ca.paa";
ACE_OverlayCracked = "ACE_Goggles\textures\HUD\Cracked.paa"; ACE_OverlayCracked = QUOTE(PATHTOF(textures\HUD\Cracked.paa));
ACE_Resistance = 0; ACE_Resistance = 0;
ACE_Protection = 0; ACE_Protection = 0;
ACE_DustPath = "ACE_Goggles\textures\fx\dust\%1.paa"; ACE_DustPath = QUOTE(PATHTOF(textures\fx\dust\%1.paa));
}; };
class G_Combat:None { class G_Combat:None {
@ -36,8 +37,8 @@ class CfgGlasses {
}; };
class G_Diving { class G_Diving {
ACE_Overlay="ACE_Goggles\textures\HUD\DivingGoggles.paa"; ACE_Overlay = QUOTE(PATHTOF(textures\HUD\DivingGoggles.paa));
ACE_OverlayCracked = "ACE_Goggles\textures\HUD\DivingGogglesCracked.paa"; ACE_OverlayCracked = QUOTE(PATHTOF(textures\HUD\DivingGogglesCracked.paa));
ACE_Resistance = 2; ACE_Resistance = 2;
ACE_Protection = 1; ACE_Protection = 1;
}; };
@ -202,22 +203,17 @@ class CfgGlasses {
#include "RscTitles.hpp" #include "RscTitles.hpp"
class CfgMovesBasic class CfgMovesBasic {
{ class ManActions {
class ManActions
{
GestureWipeFace[] = {"GestureWipeFace", "gesture"}; GestureWipeFace[] = {"GestureWipeFace", "gesture"};
}; };
}; };
class CfgGesturesMale class CfgGesturesMale {
{ class States {
class States
{
class GestureFreezeStand; class GestureFreezeStand;
class GestureWipeFace: GestureFreezeStand class GestureWipeFace: GestureFreezeStand {
{ file = QUOTE(PATHTOF(anim\WipeGlasses.rtm));
file = "\ACE_Goggles\anim\WipeGlasses.rtm";
canPullTrigger = 0; canPullTrigger = 0;
}; };
}; };
@ -247,11 +243,12 @@ class SniperCloud {
ACE_Goggles_BulletCount = 1; ACE_Goggles_BulletCount = 1;
}; };
class ACE_Core_Default_Keys { class ACE_Default_Keys {
class wipeGlasses { class wipeGlasses {
displayName = $STR_ACE_Goggles_WipeGlasses; displayName = $STR_ACE_Goggles_WipeGlasses;
condition = "!(player getVariable['ACE_isUnconscious', false])"; //condition = QUOTE(!(GETVAR(ace_player,isUnconscious,false)));
statement = "call ACE_Goggles_fnc_ClearGlasses;"; condition = "true";
statement = QUOTE(call FUNC(clearGlasses););
key = 20; // T key = 20; // T
shift = 1; shift = 1;
control = 1; control = 1;
@ -259,7 +256,7 @@ class ACE_Core_Default_Keys {
}; };
}; };
class ACE_Core_Options { class ACE_Options {
class showInThirdPerson { class showInThirdPerson {
displayName = $STR_ACE_Goggles_ShowInThirdPerson; displayName = $STR_ACE_Goggles_ShowInThirdPerson;
default = 0; default = 0;

View File

@ -6,8 +6,7 @@
//Base Classes// //Base Classes//
//////////////// ////////////////
class RscPicture class RscPicture {
{
access = 0; access = 0;
idc = -1; idc = -1;
type = CT_STATIC; type = CT_STATIC;

View File

@ -1,32 +0,0 @@
/*
Name: ACE_Goggles_fnc_ApplyDirtEffect
Author: Garth de Wet (LH)
Description:
Adds dirt effect to the glasses.
Parameters:
Nothing
Returns:
BOOLEAN - True if succeeded false if not
Example:
call ACE_Goggles_fnc_ApplyDirtEffect;
*/
#include "\ACE_Goggles\script.sqf"
if (cameraOn != player || call ACE_Goggles_fnc_ExternalCamera) exitWith{false};
private "_dirtImage";
ACE_Goggles_Effects set [DIRT, true];
if (player call ACE_Goggles_fnc_isGogglesVisible) then{
_dirtImage = getText(ConfigFile >> "CfgGlasses" >> goggles player >> "ACE_OverlayDirt");
if (_dirtImage != "") then {
100 cutRsc["RscACE_GogglesEffects", "PLAIN",0.1, false];
(uiNamespace getVariable ["ACE_Goggles_DisplayEffects", displayNull] displayCtrl 10660) ctrlSetText _dirtImage;
};
};
true

View File

@ -1,52 +0,0 @@
/*
Author: Garth de Wet (LH)
Description:
Performs rain checks and checks to see whether glasses effects have been applied or not.
Checks for external camera and removes effects.
Parameters:
Nothing
Returns:
Nothing
Example:
[] execVM "ACE_Goggles\functions\fn_CheckGoggles.sqf";
*/
#include "\ACE_Goggles\script.sqf"
waitUntil {sleep 0.46;alive player};
call ACE_Goggles_fnc_CheckGlasses;
["ACE_Goggles_RotorWash", "OnEachFrame", {call ACE_Goggles_fnc_OnEachFrame;}] call BIS_fnc_addStackedEventHandler;
[] spawn ACE_Goggles_fnc_RainEffect;
while {alive player} do {
sleep 1;
if (true) then {
// Detect if curator interface is open and disable effects
if (!isNull(findDisplay 312)) exitWith {
if (ACE_Goggles_EffectsActive) then {
call ACE_Goggles_fnc_RemoveGlassesEffect;
};
};
call ACE_Goggles_fnc_CheckGlasses;
if !(player call ACE_Goggles_fnc_isGogglesVisible) exitWith {
if (ACE_Goggles_EffectsActive) then {
call ACE_Goggles_fnc_RemoveGlassesEffect;
};
};
if (call ACE_Goggles_fnc_ExternalCamera) exitWith {
if (ACE_Goggles_EffectsActive) then {
call ACE_Goggles_fnc_RemoveGlassesEffect;
};
};
if !(ACE_Goggles_EffectsActive) then {
(goggles player) call ACE_Goggles_fnc_ApplyGlassesEffect;
} else {
if ((goggles player) call ACE_Goggles_fnc_isDivingGoggles && {underwater player}) then {
call ACE_Goggles_fnc_RemoveRainEffect;
call ACE_Goggles_fnc_RemoveDirtEffect;
call ACE_Goggles_fnc_RemoveDustEffect;
};
};
};
};

View File

@ -1,39 +0,0 @@
/*
Name: ACE_Goggles_fnc_ClearGlasses
Author: Garth de Wet (LH)
Description:
Clears all dirt, rain, dust from glasses.
Removes glasses effect (PP, overlay) and then puts it back.
Parameters:
Nothing
Returns:
Nothing
Example:
call ACE_Goggles_fnc_ClearGlasses;
*/
#include "\ACE_Goggles\script.sqf"
private "_broken";
_broken = GETBROKEN;
ACE_Goggles_Effects = GLASSESDEFAULT;
ACE_Goggles_Effects set [BROKEN, _broken];
if ((stance player) != "PRONE") then {
player playActionNow "gestureWipeFace";
};
null = [] spawn {
sleep 0.3;
if (cameraView == "INTERNAL") then {
addCamShake [5, 1.75, 2];
};
};
call ACE_Goggles_fnc_RemoveDirtEffect;
call ACE_Goggles_fnc_RemoveRainEffect;
call ACE_Goggles_fnc_RemoveDustEffect;

View File

@ -1,28 +0,0 @@
/*
Name: ACE_Goggles_fnc_GetExplosionIndex
Author: Garth de Wet (LH)
Description:
Turns 0-1 damage into a rating system of 0-3
Parameters:
0: NUMBER - The amount of damage
Returns:
NUMBER (the rating) [0-3]
Example:
_rating = 0.05 call ACE_Goggles_fnc_GetExplosionIndex
*/
private ["_effect", "_effectIndex"];
_effect = _this;
_effectIndex = switch true do {
case (_effect <= 0.04): {0};
case (_effect <= 0.06): {1};
case (_effect <= 0.09): {2};
default {3};
};
_effectIndex

View File

@ -1,111 +0,0 @@
/*
Name: ACE_Goggles_fnc_Init
Author: Garth de Wet (LH)
Description:
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.
Parameters:
Nothing
Returns:
Nothing
Example:
call ACE_Goggles_fnc_Init;
*/
if (!hasInterface) exitWith {};
#include "\ACE_Goggles\script.sqf"
if isNil("ACE_Goggles_UsePP") then {
ACE_Goggles_UsePP = true;
};
ACE_Goggles_PostProcess = ppEffectCreate ["ColorCorrections", 1995];
ACE_Goggles_PostProcessEyes = ppEffectCreate ["ColorCorrections", 1992];
ACE_Goggles_PostProcessEyes ppEffectAdjust[1, 1, 0, [0,0,0,0], [0,0,0,1],[1,1,1,0]];
ACE_Goggles_PostProcessEyes ppEffectCommit 0;
ACE_Goggles_PostProcessEyes ppEffectEnable false;
ACE_Goggles_EffectsActive = false;
ACE_Goggles_Effects = GLASSESDEFAULT;
ACE_Goggles_Current = "None";
ACE_Goggles_EyesDamageScript = 0 spawn {};
ACE_Goggles_FrameEvent = [false, [false,20]];
ACE_Goggles_PostProcessEyes_Enabled = false;
ACE_Goggles_DustHandler = 0 spawn {};
ACE_Goggles_RainDrops = objNull;
ACE_Goggles_fnc_CheckGlasses = {
if (ACE_Goggles_Current != (goggles player)) then {
ACE_Goggles_Current = (goggles player);
["GlassesChanged",[ACE_Goggles_Current]] call CBA_fnc_localEvent;
};
};
player addEventHandler ["Explosion", {
if (alive player) then {
call ACE_Goggles_fnc_ApplyDirtEffect;
if (GETBROKEN) exitWith {};
if (((_this select 1) call ACE_Goggles_fnc_GetExplosionIndex) < getNumber(ConfigFile >> "CfgGlasses" >> ACE_Goggles_Current >> "ACE_Resistance")) exitWith {};
if !(player call ACE_Goggles_fnc_isGogglesVisible) exitWith {["GlassesCracked",[player]] call CBA_fnc_localEvent;};
ACE_Goggles_Effects set [BROKEN, true];
if (getText(ConfigFile >> "CfgGlasses" >> ACE_Goggles_Current >> "ACE_OverlayCracked") != "" && {cameraOn == player}) then {
if (call ACE_Goggles_fnc_ExternalCamera) exitWith {};
if (isNull(GLASSDISPLAY)) then {
150 cutRsc["RscACE_Goggles", "PLAIN",1, false];
};
(GLASSDISPLAY displayCtrl 10650) ctrlSetText getText(ConfigFile >> "CfgGlasses" >> ACE_Goggles_Current >> "ACE_OverlayCracked");
};
["GlassesCracked",[player]] call CBA_fnc_localEvent;
};
}];
player addEventHandler ["Killed",{
[] spawn {
sleep 2;
ACE_Goggles_PostProcessEyes ppEffectEnable false;
ACE_Goggles_Effects = GLASSESDEFAULT;
call ACE_Goggles_fnc_RemoveGlassesEffect;
ACE_Goggles_EffectsActive=false;
player setVariable ["ACE_EyesDamaged", false];
terminate ACE_Goggles_EyesDamageScript;
terminate ACE_Goggles_MainLoop;
terminate ACE_Goggles_DustHandler;
ACE_Goggles_MainLoop = [] spawn ACE_Goggles_fnc_CheckGoggles;
};
}];
player addEventHandler ["Fired",{[_this select 0, _this select 1] call ACE_Goggles_fnc_DustHandler;}];
player AddEventHandler ["Take",{call ACE_Goggles_fnc_CheckGlasses;}];
player AddEventHandler ["Put", {call ACE_Goggles_fnc_CheckGlasses;}];
["GlassesChanged",{
ACE_Goggles_Effects = GLASSESDEFAULT;
if (call ACE_Goggles_fnc_ExternalCamera) exitWith {call ACE_Goggles_fnc_RemoveGlassesEffect};
if (player call ACE_Goggles_fnc_isGogglesVisible) then {
(_this select 0) call ACE_Goggles_fnc_ApplyGlassesEffect;
} else {
call ACE_Goggles_fnc_RemoveGlassesEffect;
};
}] call CBA_fnc_addEventHandler;
["GlassesCracked",{
if (_this select 0 != player) exitWith {};
player setVariable ["ACE_EyesDamaged", true];
if !(scriptDone ACE_Goggles_EyesDamageScript) then {
terminate ACE_Goggles_EyesDamageScript;
};
ACE_Goggles_PostProcessEyes ppEffectAdjust[1, 1, 0, [0,0,0,0], [0.5,0.5,0.5,0.5],[1,1,1,0]];
ACE_Goggles_PostProcessEyes ppEffectCommit 0;
ACE_Goggles_PostProcessEyes ppEffectEnable true;
ACE_Goggles_EyesDamageScript = [] spawn {
sleep 25;
ACE_Goggles_PostProcessEyes ppEffectAdjust[1, 1, 0, [0,0,0,0], [1,1,1,1],[1,1,1,0]];
ACE_Goggles_PostProcessEyes ppEffectCommit 5;
sleep 5;
ACE_Goggles_PostProcessEyes ppEffectEnable false;
player setVariable ["ACE_EyesDamaged", false];
};
}] call CBA_fnc_addEventHandler;
ACE_Goggles_MainLoop = [] spawn ACE_Goggles_fnc_CheckGoggles;

View File

@ -1,80 +0,0 @@
/*
Name: ACE_Goggles_fnc_OnEachFrame
Author: Garth de Wet (LH)
Description:
Runs every frame checking for helicopters.
Parameters:
Nothing
Returns:
Nothing
Example:
["ACE_Goggles_RotorWash", "OnEachFrame", "call ACE_Goggles_fnc_OnEachFrame;"] call BIS_fnc_addStackedEventHandler;
*/
#include "\ACE_Goggles\script.sqf"
if (isNull(player)) then {
["ACE_Goggles_RotorWash", "OnEachFrame"] call BIS_fnc_removeStackedEventHandler;
};
ACE_Goggles_FrameEvent set [0, !(ACE_Goggles_FrameEvent select 0)];
if (ACE_Goggles_FrameEvent select 0) exitWith {
if (vehicle player != player && {!([player] call ACE_Core_fnc_isTurnedOut)}) exitWith {(ACE_Goggles_FrameEvent select 1) set [0, false]; };
ACE_Goggles_FrameEvent set [1, ([player] call ACE_Goggles_fnc_isInRotorWash)];
};
private ["_rotorWash","_safe"];
_rotorWash = ACE_Goggles_FrameEvent select 1;
_safe = false;
if !(_rotorWash select 0) exitWith {
if (ACE_Goggles_PostProcessEyes_Enabled) then {
ACE_Goggles_PostProcessEyes_Enabled = false;
if (!scriptDone (ACE_Goggles_DustHandler)) then {
terminate ACE_Goggles_DustHandler;
};
ACE_Goggles_DustHandler = [] spawn {
ACE_Goggles_PostProcessEyes ppEffectAdjust [1, 1, 0, [0,0,0,0], [0,0,0,1],[1,1,1,0]];
ACE_Goggles_PostProcessEyes ppEffectCommit 2;
sleep 2;
ACE_Goggles_PostProcessEyes ppEffectEnable false;
};
};
};
if ((headgear player) != "") then {
_safe = (getNumber (ConfigFile >> "CfgWeapons" >> (headgear player) >> "ACE_Protection") == 1);
};
if !(_safe) then {
if !(player call ACE_Goggles_fnc_isGogglesVisible) exitWith{};
if (GETDUSTT(DAMOUNT) < 2) then {
if (!GETDUSTT(DACTIVE)) then {
SETDUST(DACTIVE,true);
call ACE_Goggles_fnc_ApplyDust;
} else {
if ((_rotorWash select 1) > 0.5) then {
call ACE_Goggles_fnc_ApplyDust;
};
};
};
_safe = (getNumber (ConfigFile >> "CfgGlasses" >> ACE_Goggles_Current >> "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 (!scriptDone (ACE_Goggles_DustHandler)) then {
terminate ACE_Goggles_DustHandler;
};
if !(player getVariable ["ACE_EyesDamaged", false]) then {
ACE_Goggles_PostProcessEyes_Enabled = true;
ACE_Goggles_PostProcessEyes ppEffectAdjust [1, 1, 0, [0,0,0,0], [_scale,_scale,_scale,_scale],[1,1,1,0]];
ACE_Goggles_PostProcessEyes ppEffectCommit 0.5;
ACE_Goggles_PostProcessEyes ppEffectEnable true;
};
};

View File

@ -1,61 +0,0 @@
/*
Name: ACE_Goggles_fnc_RainEffect
Author: Garth de Wet (LH)
Description:
Parameters:
Nothing
Returns:
Nothing
Example:
[] spawn ACE_Goggles_fnc_RainEffect;
*/
#include "\ACE_Goggles\script.sqf"
ACE_Goggles_RainDrops = objNull;
ACE_Goggles_Rain_Active = false;
_fnc_underCover = {
private ["_pos", "_unit"];
_unit = (_this select 0);
if (vehicle _unit != _unit && {!([_unit] call ACE_Core_fnc_isTurnedOut)}) exitWith {true};
_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])}
};
private ["_lastRain"];
_lastRain = 0;
while {alive player} do {
sleep 0.5;
if (isNull(findDisplay 312)) then {
// Ignore if player is under water
if (!ACE_Goggles_EffectsActive || {underwater player}) exitWith{call ACE_Goggles_fnc_RemoveRainEffect;};
if (_lastRain != rain) then {
call ACE_Goggles_fnc_RemoveRainEffect;
_lastRain = rain;
// Rain is happening
if (_lastRain > 0.05 && {!([player] call _fnc_underCover)}) then {
ACE_Goggles_Rain_Active = true;
ACE_Goggles_RainDrops = "#particlesource" createVehicleLocal GetPos player;
ACE_Goggles_RainDrops setParticleClass "ACERainEffect";
ACE_Goggles_RainDrops setDropInterval (0.07 * (1.1 - _lastRain));
ACE_Goggles_RainDrops attachTo [vehicle player,[0,0,0]];
};
}else{
if (_lastRain > 0.05) then {
if (ACE_Goggles_Rain_Active && {[player] call _fnc_underCover}) exitWith {
call ACE_Goggles_fnc_RemoveRainEffect;
};
if (!ACE_Goggles_Rain_Active) then {
_lastRain = -1;
};
};
};
}else{
if (ACE_Goggles_Rain_Active) then {
call ACE_Goggles_fnc_RemoveRainEffect;
};
};
};

View File

@ -1,20 +0,0 @@
/*
Name: ACE_Goggles_fnc_RemoveDirtEffect
Author: Garth de Wet (LH)
Description:
Removes dirt from the glasses.
Parameters:
Nothing
Returns:
Nothing
Example:
call ACE_Goggles_fnc_RemoveDirtEffect;
*/
if (!isNull(uiNamespace getVariable ["ACE_Goggles_DisplayEffects", displayNull])) then {
(uiNamespace getVariable ["ACE_Goggles_DisplayEffects", displayNull] displayCtrl 10660) ctrlSetText "";
};

View File

@ -1,20 +0,0 @@
/*
Name: ACE_Goggles_fnc_RemoveDustEffect
Author: Garth de Wet (LH)
Description:
Removes dust from the glasses.
Parameters:
Nothing
Returns:
Nothing
Example:
call ACE_Goggles_fnc_RemoveDustEffect;
*/
if (!isNull(uiNamespace getVariable ["ACE_Goggles_DisplayEffects", displayNull])) then {
(uiNamespace getVariable ["ACE_Goggles_DisplayEffects", displayNull] displayCtrl 10662) ctrlSetText "";
};

View File

@ -1,29 +0,0 @@
/*
Name: ACE_Goggles_fnc_RemoveGlassesEffect
Author: Garth de Wet (LH)
Description:
Removes the glasses effect from the screen, removes dirt effect, removes rain effect,
removes dust effect. Does not reset array (glasses will still be broken, dirty, ect.)
Parameters:
Nothing
Returns:
Nothing
Example:
call ACE_Goggles_fnc_RemoveGlassesEffect;
*/
#include "\ACE_Goggles\script.sqf"
ACE_Goggles_EffectsActive = false;
ACE_Goggles_PostProcess ppEffectEnable false;
if (!isNull(GLASSDISPLAY)) then {
GLASSDISPLAY closeDisplay 0;
};
call ACE_Goggles_fnc_RemoveDirtEffect;
call ACE_Goggles_fnc_RemoveRainEffect;
call ACE_Goggles_fnc_RemoveDustEffect;

View File

@ -1,21 +0,0 @@
/*
Name: ACE_Goggles_fnc_RemoveRainEffect
Author: Garth de Wet (LH)
Description:
Removes rain effects from the screen. Resets the rain array.
Parameters:
Nothing
Returns:
Nothing
Example:
call ACE_Goggles_fnc_RemoveRainEffect;
*/
if (!isNull (ACE_Goggles_RainDrops)) then {
deleteVehicle (ACE_Goggles_RainDrops);
};
ACE_Goggles_Rain_Active = false;

View File

@ -0,0 +1,33 @@
/*
ApplyDirtEffect
Author: Garth de Wet (LH)
Description:
Adds dirt effect to the glasses.
Parameters:
Nothing
Returns:
BOOLEAN - True if succeeded false if not
Example:
call FUNC(ApplyDirtEffect);
*/
#include "script_component.hpp"
if (cameraOn != ace_player || {call FUNC(externalCamera)}) exitWith{false};
private "_dirtImage";
GVAR(Effects) set [DIRT, true];
if (ace_player call FUNC(isGogglesVisible)) then{
_dirtImage = getText(ConfigFile >> "CfgGlasses" >> goggles ace_player >> "ACE_OverlayDirt");
if (_dirtImage != "") then {
100 cutRsc["RscACE_GogglesEffects", "PLAIN",0.1, false];
(GETUVAR(GVAR(DisplayEffects),displayNull) displayCtrl 10660) ctrlSetText _dirtImage;
};
};
true

View File

@ -1,5 +1,5 @@
/* /*
Name: ACE_Goggles_fnc_ApplyDust Name: fnc_applyDust.sqf
Author: Garth de Wet (LH) Author: Garth de Wet (LH)
@ -13,31 +13,31 @@
Nothing Nothing
Example 1: Example 1:
call ACE_Goggles_fnc_ApplyDust; call FUNC(ApplyDust);
*/ */
#include "\ACE_Goggles\script.sqf" #include "script_component.hpp"
if (call ACE_Goggles_fnc_ExternalCamera) exitWith {}; if (call FUNC(ExternalCamera)) exitWith {};
if (player call ACE_Goggles_fnc_isGogglesVisible) exitWith { if (ace_player call FUNC(isGogglesVisible)) exitWith {
100 cutRsc["RscACE_GogglesEffects", "PLAIN",2,false]; 100 cutRsc["RscACE_GogglesEffects", "PLAIN",2,false];
(uiNamespace getVariable ["ACE_Goggles_DisplayEffects", displayNull] displayCtrl 10662) ctrlSetText format[getText(ConfigFile >> "CfgGlasses" >> ACE_Goggles_Current >> "ACE_DustPath"), GETDUSTT(DAMOUNT)+1]; (uiNamespace getVariable ["ACE_Goggles_DisplayEffects", displayNull] displayCtrl 10662) ctrlSetText format[getText(ConfigFile >> "CfgGlasses" >> GVAR(Current) >> "ACE_DustPath"), GETDUSTT(DAMOUNT)+1];
SETDUST(DAMOUNT,CLAMP(GETDUSTT(DAMOUNT)+1,0,1)); SETDUST(DAMOUNT,CLAMP(GETDUSTT(DAMOUNT)+1,0,1));
SETDUST(DBULLETS,0); SETDUST(DBULLETS,0);
}; };
if (player getVariable ["ACE_EyesDamaged", false]) exitWith {SETDUST(DACTIVE,false);SETDUST(DBULLETS,0);SETDUST(DAMOUNT,0);}; if (GETVAR(ace_player,ACE_EyesDamaged,false)) exitWith {SETDUST(DACTIVE,false);SETDUST(DBULLETS,0);SETDUST(DAMOUNT,0);};
SETDUST(DAMOUNT,CLAMP(GETDUSTT(DAMOUNT)+1,0,2)); SETDUST(DAMOUNT,CLAMP(GETDUSTT(DAMOUNT)+1,0,2));
private "_amount"; private "_amount";
_amount = 1 - (GETDUSTT(DAMOUNT) * 0.125); _amount = 1 - (GETDUSTT(DAMOUNT) * 0.125);
ACE_Goggles_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]];
ACE_Goggles_PostProcessEyes ppEffectCommit 1; GVAR(PostProcessEyes) ppEffectCommit 1;
ACE_Goggles_PostProcessEyes ppEffectEnable true; GVAR(PostProcessEyes) ppEffectEnable true;
if !(scriptDone ACE_Goggles_DustHandler) then { if !(scriptDone GVAR(DustHandler)) then {
terminate ACE_Goggles_DustHandler; terminate GVAR(DustHandler);
}; };
SETDUST(DBULLETS,0); SETDUST(DBULLETS,0);
ACE_Goggles_DustHandler = [3] spawn { GVAR(DustHandler) = [3] spawn {
private ["_loop", "_timeToSleep"]; private ["_loop", "_timeToSleep"];
_timeToSleep = _this select 0; _timeToSleep = _this select 0;
_loop = true; _loop = true;
@ -51,13 +51,13 @@ ACE_Goggles_DustHandler = [3] spawn {
SETDUST(DAMOUNT,CLAMP(GETDUSTT(DAMOUNT)-1,0,2)); SETDUST(DAMOUNT,CLAMP(GETDUSTT(DAMOUNT)-1,0,2));
private "_amount"; private "_amount";
_amount = 1 - (GETDUSTT(DAMOUNT) * 0.125); _amount = 1 - (GETDUSTT(DAMOUNT) * 0.125);
if !(player getVariable ["ACE_EyesDamaged", false]) then { if !(ace_player getVariable ["ACE_EyesDamaged", false]) then {
ACE_Goggles_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]];
ACE_Goggles_PostProcessEyes ppEffectCommit 1; GVAR(PostProcessEyes) ppEffectCommit 1;
sleep 1; sleep 1;
}; };
if (GETDUSTT(DAMOUNT) <= 0) then { if (GETDUSTT(DAMOUNT) <= 0) then {
ACE_Goggles_PostProcessEyes ppEffectEnable false; GVAR(PostProcessEyes) ppEffectEnable false;
SETDUST(DACTIVE,false); SETDUST(DACTIVE,false);
SETDUST(DBULLETS,0); SETDUST(DBULLETS,0);
_loop = false; _loop = false;

View File

@ -1,5 +1,5 @@
/* /*
Name: ACE_Goggles_fnc_ApplyGlassesEffect Name: fnc_ApplyGlassesEffect.sqf
Author: Garth de Wet (LH) Author: Garth de Wet (LH)
@ -15,23 +15,23 @@
Nothing Nothing
Example: Example:
(goggles player) call ACE_Goggles_fnc_ApplyGlassesEffect; (goggles ace_player) call FUNC(ApplyGlassesEffect);
*/ */
#include "\ACE_Goggles\script.sqf" #include "script_component.hpp"
private["_postProcessColour", "_postProcessTintAmount", "_glassesClassname", "_glassImagePath"]; private["_postProcessColour", "_postProcessTintAmount", "_glassesClassname", "_glassImagePath"];
_glassesClassname = _this; _glassesClassname = _this;
_postProcessColour = getArray(configFile >> "CfgGlasses" >> _glassesClassname >> "ACE_Color"); _postProcessColour = getArray(configFile >> "CfgGlasses" >> _glassesClassname >> "ACE_Color");
_postProcessTintAmount = getNumber(configFile >> "CfgGlasses" >> _glassesClassname >> "ACE_TintAmount"); _postProcessTintAmount = getNumber(configFile >> "CfgGlasses" >> _glassesClassname >> "ACE_TintAmount");
call ACE_Goggles_fnc_RemoveGlassesEffect; call FUNC(removeGlassesEffect);
ACE_Goggles_EffectsActive = true; GVAR(EffectsActive) = true;
if (_postProcessTintAmount != 0 && {ACE_Goggles_UsePP}) then { if (_postProcessTintAmount != 0 && {GVAR(UsePP)}) then {
_postProcessColour set [3, _postProcessTintAmount/100]; _postProcessColour set [3, _postProcessTintAmount/100];
ACE_Goggles_PostProcess ppEffectAdjust[0.9, 1.1, 0.004, _postProcessColour, [0,0,0,1],[0,0,0,0]]; GVAR(PostProcess) ppEffectAdjust[0.9, 1.1, 0.004, _postProcessColour, [0,0,0,1],[0,0,0,0]];
ACE_Goggles_PostProcess ppEffectCommit 0; GVAR(PostProcess) ppEffectCommit 0;
ACE_Goggles_PostProcess ppEffectEnable true; GVAR(PostProcess) ppEffectEnable true;
}; };
_glassImagePath = getText(configFile >> "CfgGlasses" >> _glassesClassname >> "ACE_Overlay"); _glassImagePath = getText(configFile >> "CfgGlasses" >> _glassesClassname >> "ACE_Overlay");
@ -44,10 +44,10 @@ if (_glassImagePath != "") then {
}; };
if GETDIRT then { if GETDIRT then {
call ACE_Goggles_fnc_ApplyDirtEffect; call FUNC(applyDirtEffect);
}; };
if GETDUSTT(DACTIVE) then { if GETDUSTT(DACTIVE) then {
SETDUST(DAMOUNT,CLAMP(GETDUSTT(DAMOUNT)-1,0,2)); SETDUST(DAMOUNT,CLAMP(GETDUSTT(DAMOUNT)-1,0,2));
call ACE_Goggles_fnc_ApplyDust; call FUNC(applyDust);
}; };

View File

@ -0,0 +1,51 @@
/*
Author: Garth de Wet (LH)
Description:
Performs rain checks and checks to see whether glasses effects have been applied or not.
Checks for external camera and removes effects.
Parameters:
Nothing
Returns:
Nothing
Example:
[] execVM "ACE_Goggles\functions\fn_CheckGoggles.sqf";
*/
#include "script_component.hpp"
call FUNC(checkGlasses);
[QGVAR(RotorWash), "OnEachFrame", {call FUNC(onEachFrame);}] call CALLSTACK(BIS_fnc_addStackedEventHandler);
[] spawn FUNC(rainEffect);
while {alive ace_player} do {
sleep 1;
if (true) then {
// 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 {
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);
};
};
};
};

View File

@ -0,0 +1,39 @@
/*
Name: fnc_clearGlasses.sqf
Author: Garth de Wet (LH)
Description:
Clears all dirt, rain, dust from glasses.
Removes glasses effect (PP, overlay) and then puts it back.
Parameters:
Nothing
Returns:
Nothing
Example:
call FUNC(ClearGlasses);
*/
#include "script_component.hpp"
private "_broken";
_broken = GETBROKEN;
GVAR(Effects) = GLASSESDEFAULT;
GVAR(Effects) set [BROKEN, _broken];
if ((stance ace_player) != "PRONE") then {
ace_player playActionNow "gestureWipeFace";
};
null = [] spawn {
sleep 0.3;
if (cameraView == "INTERNAL") then {
addCamShake [5, 1.75, 2];
};
};
call FUNC(removeDirtEffect);
call FUNC(removeRainEffect);
call FUNC(removeDustEffect);

View File

@ -1,5 +1,5 @@
/* /*
Name: ACE_Goggles_fnc_DustHandler fnc_DustHandler.sqf
Author: Garth de Wet (LH) Author: Garth de Wet (LH)
@ -14,16 +14,16 @@
Nothing Nothing
Example: Example:
player addEventHandler ["Fired", {[_this select 0, _this select 1] call ACE_Goggles_fnc_DustHandler;}]; ace_player addEventHandler ["Fired", {[_this select 0, _this select 1] call FUNC(DustHandler;}];
See http://community.bistudio.com/wiki/ArmA_3:_Event_Handlers#Fired See http://community.bistudio.com/wiki/ArmA_3:_Event_Handlers#Fired
*/ */
#include "\ACE_Goggles\script.sqf" #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 = "";
if ((_this select 0) != player) exitWith {true}; if ((_this select 0) != ace_player) exitWith {true};
if (isClass(configFile >> "CfgWeapons" >> _weapon >> "GunParticles" >> "FirstEffect")) then { if (isClass(configFile >> "CfgWeapons" >> _weapon >> "GunParticles" >> "FirstEffect")) then {
_cloudType = getText(configFile >> "CfgWeapons" >> _weapon >> "GunParticles" >> "FirstEffect" >> "effectName"); _cloudType = getText(configFile >> "CfgWeapons" >> _weapon >> "GunParticles" >> "FirstEffect" >> "effectName");
@ -35,9 +35,9 @@ if (isClass(configFile >> "CfgWeapons" >> _weapon >> "GunParticles" >> "FirstEff
if (_cloudType == "") exitWith {true}; if (_cloudType == "") exitWith {true};
if (rain > 0.1) exitWith {true}; if (rain > 0.1) exitWith {true};
if ((stance player) != "PRONE") exitWith {true}; if ((stance ace_player) != "PRONE") exitWith {true};
_position = getPosATL player; _position = getPosATL ace_player;
if (surfaceIsWater _position) exitWith {}; if (surfaceIsWater _position) exitWith {};
if ((_position select 2) > 0.2) exitWith {}; if ((_position select 2) > 0.2) exitWith {};
@ -69,7 +69,7 @@ if (GETDUSTT(DAMOUNT) < 2) then {
if (_bulletsRequired <= _bullets) then { if (_bulletsRequired <= _bullets) then {
SETDUST(DACTIVE,true); SETDUST(DACTIVE,true);
call ACE_Goggles_fnc_ApplyDust; call FUNC(applyDust);
}; };
}; };
true true

View File

@ -1,5 +1,5 @@
/* /*
Name: ACE_Goggles_fnc_ExternalCamera fnc_ExternalCamera.sqf
Author: Garth de Wet (LH) Author: Garth de Wet (LH)
@ -13,7 +13,8 @@
Boolean - whether the camera is in external view or not. Boolean - whether the camera is in external view or not.
Example: Example:
call ACE_Goggles_fnc_ExternalCamera; call FUNC(ExternalCamera);
*/ */
if (profileNamespace getVariable ["ACE_showInThirdPerson", false]) exitWith { false }; #include "script_component.hpp"
if (GETVAR(profileNamespace,ACE_showInThirdPerson,false)) exitWith { false };
(cameraView == "External") (cameraView == "External")

View File

@ -0,0 +1,27 @@
/*
fnc_getExplosionIndex.sqf
Author: Garth de Wet (LH)
Description:
Turns 0-1 damage into a rating system of 0-3
Parameters:
0: NUMBER - The amount of damage
Returns:
NUMBER (the rating) [0-3]
Example:
_rating = 0.05 call FUNC(GetExplosionIndex);
*/
private ["_effectIndex"];
_effectIndex = switch true do {
case (_this <= 0.04): {0};
case (_this <= 0.06): {1};
case (_this <= 0.09): {2};
default {3};
};
_effectIndex

View File

@ -1,5 +1,5 @@
/* /*
Name: ACE_Goggles_fnc_isDivingGoggles fnc_isDivingGoggles.sqf
Author: Garth de Wet (LH) Author: Garth de Wet (LH)
@ -13,8 +13,9 @@
Boolean - whether diving goggles are worn Boolean - whether diving goggles are worn
Example: Example:
(goggles player) call ACE_Goggles_fnc_isDivingGoggles; (goggles ace_player) call FUNC(isDivingGoggles);
*/ */
#include "script_component.hpp"
private ["_result", "_glasses"]; private ["_result", "_glasses"];
_glasses = _this; _glasses = _this;
_result = _glasses == "G_Diving"; _result = _glasses == "G_Diving";

View File

@ -1,5 +1,5 @@
/* /*
Name: ACE_Goggles_fnc_isGogglesVisible fnc_isGogglesVisible.sqf
Author: Garth de Wet (LH) Author: Garth de Wet (LH)
@ -13,8 +13,9 @@
BOOL - Whether the goggles are visible or not. BOOL - Whether the goggles are visible or not.
Example: Example:
_visible = player call ACE_Goggles_fnc_isGogglesVisible; _visible = ace_player call FUNC(isGogglesVisible);
*/ */
#include "script_component.hpp"
private ["_currentGlasses", "_result", "_unit"]; private ["_currentGlasses", "_result", "_unit"];
_unit = _this; _unit = _this;
@ -26,12 +27,12 @@ if ((vehicle _unit) != _unit) exitWith {(cameraView != "GUNNER")};
if (_currentGlasses != "") then { if (_currentGlasses != "") then {
_position =(getPosASLW _unit); _position =(getPosASLW _unit);
if (surfaceIsWater _position && {((_position select 2) < 0.25)}) exitWith { if (surfaceIsWater _position && {((_position select 2) < 0.25)}) exitWith {
_result = (_currentGlasses call ACE_Goggles_fnc_isDivingGoggles); _result = (_currentGlasses call FUNC(isDivingGoggles));
}; };
if (getNumber (ConfigFile >> "CfgGlasses" >> _currentGlasses >> "ACE_Resistance") == 0) exitWith { if (getNumber (ConfigFile >> "CfgGlasses" >> _currentGlasses >> "ACE_Resistance") == 0) exitWith {
_result = false; _result = false;
}; };
_result = !(_currentGlasses call ACE_Goggles_fnc_isDivingGoggles); _result = !(_currentGlasses call FUNC(isDivingGoggles));
}; };
_result _result

View File

@ -1,5 +1,5 @@
/* /*
Name: ACE_Goggles_fnc_isInRotorWash fnc_isInRotorWash.sqf
Author: Garth de Wet (LH) Author: Garth de Wet (LH)
@ -16,9 +16,10 @@
1 - number - Amount of rotor wash. 1 - number - Amount of rotor wash.
Example: Example:
if (([player, 10] call ACE_Goggles_fnc_isInRotorWash) select 0) then { hint "Rotor wash"; }; if (([ace_player, 10] call FUNC(isInRotorWash)) select 0) then { hint "Rotor wash"; };
if (([player] call ACE_Goggles_fnc_isInRotorWash) select 0) then { hint "Rotor wash"; }; if (([ace_player] call FUNC(isInRotorWash)) select 0) then { hint "Rotor wash"; };
*/ */
#include "script_component.hpp"
private ["_heli", "_unit", "_result", "_radius"]; private ["_heli", "_unit", "_result", "_radius"];
_unit = _this select 0; _unit = _this select 0;
_radius = 15; _radius = 15;
@ -41,6 +42,7 @@ _heli = (getPosATL _unit) nearEntities [["Helicopter"], _radius];
}; };
}; };
}; };
false
} count _heli; } count _heli;
_result _result

View File

@ -0,0 +1,80 @@
/*
fnc_onEachFrame.sqf
Author: Garth de Wet (LH)
Description:
Runs every frame checking for helicopters.
Parameters:
Nothing
Returns:
Nothing
Example:
["ACE_Goggles_RotorWash", "OnEachFrame", "call FUNC(OnEachFrame);"] call BIS_fnc_addStackedEventHandler;
*/
#include "script_component.hpp"
if (isNull(ace_player)) then {
[QGVAR(RotorWash), "OnEachFrame"] call CALLSTACK(BIS_fnc_removeStackedEventHandler);
};
GVAR(FrameEvent) set [0, !(GVAR(FrameEvent) select 0)];
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]; };
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 (!scriptDone (GVAR(DustHandler))) then {
terminate GVAR(DustHandler);
};
GVAR(DustHandler) = [] spawn {
GVAR(PostProcessEyes) ppEffectAdjust [1, 1, 0, [0,0,0,0], [0,0,0,1],[1,1,1,0]];
GVAR(PostProcessEyes) ppEffectCommit 2;
sleep 2;
GVAR(PostProcessEyes) ppEffectEnable false;
};
};
};
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(ApplyDust);
} else {
if ((_rotorWash select 1) > 0.5) then {
call FUNC(ApplyDust);
};
};
};
_safe = (getNumber (ConfigFile >> "CfgGlasses" >> GVAR(Current) >> "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 (!scriptDone (GVAR(DustHandler))) then {
terminate GVAR(DustHandler);
};
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;
};
};

View File

@ -0,0 +1,61 @@
/*
fnc_rainEffect.sqf
Author: Garth de Wet (LH)
Description:
Parameters:
Nothing
Returns:
Nothing
Example:
[] spawn FUNC(RainEffect);
*/
#include "script_component.hpp"
GVAR(RainDrops) = objNull;
GVAR(RainActive) = false;
_fnc_underCover = {
private ["_pos", "_unit"];
_unit = (_this select 0);
if (vehicle _unit != _unit && {!([_unit] call EFUNC(common,isTurnedOut))}) exitWith {true};
_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])}
};
private ["_lastRain"];
_lastRain = 0;
while {alive ace_player} do {
sleep 0.5;
if (isNull(findDisplay 312)) then {
// Ignore if ace_player is under water
if (!GVAR(EffectsActive) || {underwater ace_player}) exitWith{call FUNC(RemoveRainEffect);};
if (_lastRain != rain) then {
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 {
call FUNC(RemoveRainEffect);
};
};
};

View File

@ -0,0 +1,21 @@
/*
fnc_removeDirtEffect.sqf
Author: Garth de Wet (LH)
Description:
Removes dirt from the glasses.
Parameters:
Nothing
Returns:
Nothing
Example:
call FUNC(RemoveDirtEffect);
*/
#include "script_component.hpp"
if (!isNull(GETUVAR(GVAR(DisplayEffects),displayNull))) then {
(GETUVAR(GVAR(DisplayEffects),displayNull) displayCtrl 10660) ctrlSetText "";
};

View File

@ -0,0 +1,21 @@
/*
fnc_removeDustEffect.sqf
Author: Garth de Wet (LH)
Description:
Removes dust from the glasses.
Parameters:
Nothing
Returns:
Nothing
Example:
call FUNC(RemoveDustEffect);
*/
#include "script_component.hpp"
if (!isNull(GETUVAR(GVAR(DisplayEffects),displayNull))) then {
(GETUVAR(GVAR(DisplayEffects),displayNull) displayCtrl 10662) ctrlSetText "";
};

View File

@ -0,0 +1,29 @@
/*
RemoveGlassesEffect
Author: Garth de Wet (LH)
Description:
Removes the glasses effect from the screen, removes dirt effect, removes rain effect,
removes dust effect. Does not reset array (glasses will still be broken, dirty, ect.)
Parameters:
Nothing
Returns:
Nothing
Example:
call FUNC(RemoveGlassesEffect);
*/
#include "script_component.hpp"
GVAR(EffectsActive) = false;
GVAR(PostProcess) ppEffectEnable false;
if (!isNull(GLASSDISPLAY)) then {
GLASSDISPLAY closeDisplay 0;
};
call FUNC(removeDirtEffect);
call FUNC(removeRainEffect);
call FUNC(removeDustEffect);

View File

@ -0,0 +1,22 @@
/*
RemoveRainEffect
Author: Garth de Wet (LH)
Description:
Removes rain effects from the screen. Resets the rain array.
Parameters:
Nothing
Returns:
Nothing
Example:
call FUNC(RemoveRainEffect);
*/
#include "script_component.hpp"
if (!isNull (GVAR(RainDrops))) then {
deleteVehicle (GVAR(RainDrops));
};
GVAR(RainActive) = false;

View File

@ -0,0 +1 @@
#include "\z\ace\addons\goggles\script_component.hpp"

View File

@ -1,21 +0,0 @@
#define GLASSESDEFAULT [false,[false,0,0,0],false]
#define DIRT 0
#define DUST 1
#define BROKEN 2
#define GETDIRT (ACE_Goggles_Effects select DIRT)
#define GETDUST (ACE_Goggles_Effects select DUST)
#define GETBROKEN (ACE_Goggles_Effects select BROKEN)
#define GETDUSTT(type) ((ACE_Goggles_Effects select DUST) select type)
#define SETDUST(type,value) (ACE_Goggles_Effects select DUST) set [type, value]
#define DACTIVE 0
#define DTIME 1
#define DBULLETS 2
#define DAMOUNT 3
#define GLASSDISPLAY (uiNamespace getVariable ["ACE_Goggles_Display", displayNull])
#define CLAMP(x,low,high) (if(x > high)then{high}else{if(x < low)then{low}else{x}})

View File

@ -0,0 +1,34 @@
#define COMPONENT goggles
#include "\z\ace\addons\main\script_mod.hpp"
#ifdef DEBUG_ENABLED_GOGGLES
#define DEBUG_MODE_FULL
#endif
#ifdef DEBUG_SETTINGS_GOGGLES
#define DEBUG_SETTINGS DEBUG_SETTINGS_GOGGLES
#endif
#include "\z\ace\addons\main\script_macros.hpp"
// MACROS
#define GLASSESDEFAULT [false,[false,0,0,0],false]
#define DIRT 0
#define DUST 1
#define BROKEN 2
#define GETDIRT (GVAR(Effects) select DIRT)
#define GETDUST (GVAR(Effects) select DUST)
#define GETBROKEN (GVAR(Effects) select BROKEN)
#define GETDUSTT(type) ((GVAR(Effects) select DUST) select type)
#define SETDUST(type,value) (GVAR(Effects) select DUST) set [type,value]
#define DACTIVE 0
#define DTIME 1
#define DBULLETS 2
#define DAMOUNT 3
#define GLASSDISPLAY (GETUVAR(GVAR(Display),displayNull))
#define CLAMP(x,low,high) (if(x > high)then{high}else{if(x < low)then{low}else{x}})