Skip to content

Commit

Permalink
Goggles - Add API to crack glasses (#10648)
Browse files Browse the repository at this point in the history
Co-authored-by: johnb432 <[email protected]>
  • Loading branch information
DartRuffian and johnb432 authored Jan 13, 2025
1 parent a17d6fe commit a54c4da
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 23 deletions.
1 change: 1 addition & 0 deletions addons/goggles/XEH_PREP.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

// effects
PREP(applyCrackEffect);
PREP(applyDirtEffect);
PREP(applyDustEffect);
PREP(applyGlassesEffect);
Expand Down
47 changes: 47 additions & 0 deletions addons/goggles/functions/fnc_applyCrackEffect.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#include "..\script_component.hpp"
/*
* Authors: DartRuffian
* Adds cracked glass effect to glasses.
*
* Arguments:
* None
*
* Return Value:
* Succeeded <BOOL>
*
* Example:
* _applied = [] call ace_goggles_fnc_applyCrackEffect
*
* Public: Yes
*/

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
};

scopeName "main";

private _effects = GETGLASSES(_unit);
_effects set [BROKEN, true];

SETGLASSES(_unit,_effects);

if (getText (_config >> "ACE_OverlayCracked") != "") then {
if ([] call FUNC(externalCamera)) exitWith {
false breakOut "main";
};
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
25 changes: 2 additions & 23 deletions addons/goggles/functions/fnc_handleExplosion.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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);

0 comments on commit a54c4da

Please sign in to comment.