From 5afc73926fdc861928c54b1fe00f0e323ceedbd2 Mon Sep 17 00:00:00 2001 From: DartRuffian Date: Mon, 13 Jan 2025 10:54:23 -0600 Subject: [PATCH 1/6] Add API function to crack glasses --- addons/goggles/XEH_PREP.hpp | 1 + .../functions/fnc_applyCrackEffect.sqf | 44 +++++++++++++++++++ .../goggles/functions/fnc_handleExplosion.sqf | 25 +---------- 3 files changed, 47 insertions(+), 23 deletions(-) create mode 100644 addons/goggles/functions/fnc_applyCrackEffect.sqf diff --git a/addons/goggles/XEH_PREP.hpp b/addons/goggles/XEH_PREP.hpp index fdbb4f9fef6..1716bdf58d5 100644 --- a/addons/goggles/XEH_PREP.hpp +++ b/addons/goggles/XEH_PREP.hpp @@ -1,5 +1,6 @@ // effects +PREP(applyCrackEffect); PREP(applyDirtEffect); PREP(applyDustEffect); PREP(applyGlassesEffect); diff --git a/addons/goggles/functions/fnc_applyCrackEffect.sqf b/addons/goggles/functions/fnc_applyCrackEffect.sqf new file mode 100644 index 00000000000..8f3c77ddf17 --- /dev/null +++ b/addons/goggles/functions/fnc_applyCrackEffect.sqf @@ -0,0 +1,44 @@ +#include "..\script_component.hpp" +/* + * Authors: DartRuffian + * Adds cracked glass effect to glasses. + * + * Arguments: + * None + * + * Return Value: + * Succeeded + * + * Example: + * _applied = [] call ace_goggles_fnc_applyCrackEffect + * + * Public: Yes + */ + +if ([] call FUNC(externalCamera)) exitWith { false }; +if (GETBROKEN) exitWith { true }; + +private _unit = ACE_player; +private _config = configFile >> "CfgGlasses" >> goggles _unit; + +if !(_unit call FUNC(isGogglesVisible)) exitWith { + ["ace_glassesCracked", [_unit]] call CBA_fnc_localEvent; + true +}; + +private _effects = GETGLASSES(_unit); +_effects set [BROKEN, true]; + +SETGLASSES(_unit,_effects); + +if (getText (_config >> "ACE_OverlayCracked") != "") then { + + if (isNull (GLASSDISPLAY)) then { + GVAR(GogglesLayer) cutRsc ["RscACE_Goggles", "PLAIN", 1, false, false]; + }; + + (GLASSDISPLAY displayCtrl IDC_GOGGLES_OVERLAY) ctrlSetText getText (_config >> "ACE_OverlayCracked"); +}; + +["ace_glassesCracked", [_unit]] call CBA_fnc_localEvent; +true diff --git a/addons/goggles/functions/fnc_handleExplosion.sqf b/addons/goggles/functions/fnc_handleExplosion.sqf index b7340a44cb1..351c15ded78 100644 --- a/addons/goggles/functions/fnc_handleExplosion.sqf +++ b/addons/goggles/functions/fnc_handleExplosion.sqf @@ -25,27 +25,6 @@ if (GETBROKEN) exitWith {true}; private _config = configFile >> "CfgGlasses" >> goggles _unit; -if ((_this select 1) call FUNC(GetExplosionIndex) < getNumber (_config >> "ACE_Resistance")) exitWith {true}; +if ((_this select 1) call FUNC(getExplosionIndex) < getNumber (_config >> "ACE_Resistance")) exitWith {true}; -if !([_unit] call FUNC(isGogglesVisible)) exitWith { - ["ace_glassesCracked", [_unit]] call CBA_fnc_localEvent; - true -}; - -private _effects = GETGLASSES(_unit); -_effects set [BROKEN, true]; - -SETGLASSES(_unit,_effects); - -if (getText (_config >> "ACE_OverlayCracked") != "") then { - if (call FUNC(ExternalCamera)) exitWith {}; - - if (isNull (GLASSDISPLAY)) then { - GVAR(GogglesLayer) cutRsc ["RscACE_Goggles", "PLAIN", 1, false, false]; - }; - - (GLASSDISPLAY displayCtrl IDC_GOGGLES_OVERLAY) ctrlSetText getText (_config >> "ACE_OverlayCracked"); -}; - -["ace_glassesCracked", [_unit]] call CBA_fnc_localEvent; -true +[] call FUNC(applyCrackEffect); From 4cc2d08bb06249d3b238fe70d02ed08e0a7e3abb Mon Sep 17 00:00:00 2001 From: DartRuffian Date: Mon, 13 Jan 2025 11:06:39 -0600 Subject: [PATCH 2/6] Crack glasses in third person --- addons/goggles/functions/fnc_applyCrackEffect.sqf | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/addons/goggles/functions/fnc_applyCrackEffect.sqf b/addons/goggles/functions/fnc_applyCrackEffect.sqf index 8f3c77ddf17..eca3ce018a1 100644 --- a/addons/goggles/functions/fnc_applyCrackEffect.sqf +++ b/addons/goggles/functions/fnc_applyCrackEffect.sqf @@ -15,7 +15,6 @@ * Public: Yes */ -if ([] call FUNC(externalCamera)) exitWith { false }; if (GETBROKEN) exitWith { true }; private _unit = ACE_player; @@ -32,7 +31,7 @@ _effects set [BROKEN, true]; SETGLASSES(_unit,_effects); if (getText (_config >> "ACE_OverlayCracked") != "") then { - + if ([] call FUNC(externalCamera)) exitWith { false }; if (isNull (GLASSDISPLAY)) then { GVAR(GogglesLayer) cutRsc ["RscACE_Goggles", "PLAIN", 1, false, false]; }; From be7e1c17f83d693e0621fb30ea30503eb6e6ba1f Mon Sep 17 00:00:00 2001 From: Dart <59131299+DartRuffian@users.noreply.github.com> Date: Mon, 13 Jan 2025 13:51:38 -0600 Subject: [PATCH 3/6] Fix false return --- addons/goggles/functions/fnc_applyCrackEffect.sqf | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/goggles/functions/fnc_applyCrackEffect.sqf b/addons/goggles/functions/fnc_applyCrackEffect.sqf index eca3ce018a1..f6de10cdb99 100644 --- a/addons/goggles/functions/fnc_applyCrackEffect.sqf +++ b/addons/goggles/functions/fnc_applyCrackEffect.sqf @@ -16,6 +16,7 @@ */ if (GETBROKEN) exitWith { true }; +scopeName "main"; private _unit = ACE_player; private _config = configFile >> "CfgGlasses" >> goggles _unit; @@ -31,7 +32,9 @@ _effects set [BROKEN, true]; SETGLASSES(_unit,_effects); if (getText (_config >> "ACE_OverlayCracked") != "") then { - if ([] call FUNC(externalCamera)) exitWith { false }; + if ([] call FUNC(externalCamera)) exitWith { + false breakout "main"; + }; if (isNull (GLASSDISPLAY)) then { GVAR(GogglesLayer) cutRsc ["RscACE_Goggles", "PLAIN", 1, false, false]; }; From d1190392618fb9b036de5f9850bba2b1202c3209 Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Mon, 13 Jan 2025 12:22:58 -0800 Subject: [PATCH 4/6] Update addons/goggles/functions/fnc_applyCrackEffect.sqf --- addons/goggles/functions/fnc_applyCrackEffect.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/goggles/functions/fnc_applyCrackEffect.sqf b/addons/goggles/functions/fnc_applyCrackEffect.sqf index f6de10cdb99..7d2ef02848c 100644 --- a/addons/goggles/functions/fnc_applyCrackEffect.sqf +++ b/addons/goggles/functions/fnc_applyCrackEffect.sqf @@ -33,7 +33,7 @@ SETGLASSES(_unit,_effects); if (getText (_config >> "ACE_OverlayCracked") != "") then { if ([] call FUNC(externalCamera)) exitWith { - false breakout "main"; + false breakOut "main"; }; if (isNull (GLASSDISPLAY)) then { GVAR(GogglesLayer) cutRsc ["RscACE_Goggles", "PLAIN", 1, false, false]; From d7afdceea699fdf7624ef9126073d94b0b1869d8 Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Mon, 13 Jan 2025 12:23:43 -0800 Subject: [PATCH 5/6] Update addons/goggles/functions/fnc_applyCrackEffect.sqf --- addons/goggles/functions/fnc_applyCrackEffect.sqf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/goggles/functions/fnc_applyCrackEffect.sqf b/addons/goggles/functions/fnc_applyCrackEffect.sqf index 7d2ef02848c..7ca9c38cd14 100644 --- a/addons/goggles/functions/fnc_applyCrackEffect.sqf +++ b/addons/goggles/functions/fnc_applyCrackEffect.sqf @@ -16,8 +16,6 @@ */ if (GETBROKEN) exitWith { true }; -scopeName "main"; - private _unit = ACE_player; private _config = configFile >> "CfgGlasses" >> goggles _unit; @@ -26,6 +24,8 @@ if !(_unit call FUNC(isGogglesVisible)) exitWith { true }; +scopeName "main"; + private _effects = GETGLASSES(_unit); _effects set [BROKEN, true]; From 964b38f9831a3be58e4dd858e82d2e1593daab7a Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Mon, 13 Jan 2025 12:24:04 -0800 Subject: [PATCH 6/6] Update addons/goggles/functions/fnc_applyCrackEffect.sqf --- addons/goggles/functions/fnc_applyCrackEffect.sqf | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/goggles/functions/fnc_applyCrackEffect.sqf b/addons/goggles/functions/fnc_applyCrackEffect.sqf index 7ca9c38cd14..da2dda74e55 100644 --- a/addons/goggles/functions/fnc_applyCrackEffect.sqf +++ b/addons/goggles/functions/fnc_applyCrackEffect.sqf @@ -16,6 +16,7 @@ */ if (GETBROKEN) exitWith { true }; + private _unit = ACE_player; private _config = configFile >> "CfgGlasses" >> goggles _unit;