mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
more goggles code cleanup
This commit is contained in:
parent
62349f685c
commit
8d5ce1dbe2
@ -13,8 +13,8 @@ if (!hasInterface) exitWith {};
|
|||||||
[20, [true, true, false]], false] call CBA_fnc_addKeybind;
|
[20, [true, true, false]], false] call CBA_fnc_addKeybind;
|
||||||
|
|
||||||
// make sure to stack effect layers in correct order
|
// make sure to stack effect layers in correct order
|
||||||
QGVAR(GogglesEffectsLayer) call BIS_fnc_RSCLayer;
|
GVAR(GogglesEffectsLayer) = QGVAR(GogglesEffectsLayer) call BIS_fnc_RSCLayer;
|
||||||
QGVAR(GogglesLayer) call BIS_fnc_RSCLayer;
|
GVAR(GogglesLayer) = QGVAR(GogglesLayer) call BIS_fnc_RSCLayer;
|
||||||
|
|
||||||
if (isNil QGVAR(UsePP)) then {
|
if (isNil QGVAR(UsePP)) then {
|
||||||
GVAR(UsePP) = true;
|
GVAR(UsePP) = true;
|
||||||
|
@ -16,12 +16,11 @@ PREP(removeRainEffect);
|
|||||||
PREP(externalCamera);
|
PREP(externalCamera);
|
||||||
PREP(isDivingGoggles);
|
PREP(isDivingGoggles);
|
||||||
PREP(isGogglesVisible);
|
PREP(isGogglesVisible);
|
||||||
|
PREP(isInRotorWash);
|
||||||
|
|
||||||
// general
|
// general
|
||||||
PREP(clearGlasses);
|
PREP(clearGlasses);
|
||||||
PREP(dustHandler);
|
|
||||||
PREP(getExplosionIndex);
|
PREP(getExplosionIndex);
|
||||||
PREP(isInRotorWash);
|
|
||||||
|
|
||||||
// eventhandlers
|
// eventhandlers
|
||||||
PREP(handleExplosion);
|
PREP(handleExplosion);
|
||||||
|
@ -31,7 +31,7 @@ if ([_unit] call FUNC(isGogglesVisible)) then {
|
|||||||
local _dirtImage = getText (configFile >> "CfgGlasses" >> goggles _unit >> "ACE_OverlayDirt");
|
local _dirtImage = getText (configFile >> "CfgGlasses" >> goggles _unit >> "ACE_OverlayDirt");
|
||||||
|
|
||||||
if (_dirtImage != "") then {
|
if (_dirtImage != "") then {
|
||||||
(QGVAR(GogglesEffectsLayer) call BIS_fnc_RSCLayer) cutRsc ["RscACE_GogglesEffects", "PLAIN", 0.1, false];
|
GVAR(GogglesEffectsLayer) cutRsc ["RscACE_GogglesEffects", "PLAIN", 0.1, false];
|
||||||
(GETUVAR(GVAR(DisplayEffects),displayNull) displayCtrl 10660) ctrlSetText _dirtImage;
|
(GETUVAR(GVAR(DisplayEffects),displayNull) displayCtrl 10660) ctrlSetText _dirtImage;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
if (GVAR(showInThirdPerson)) exitWith {false};
|
if (GVAR(showInThirdPerson)) exitWith {};
|
||||||
if (call FUNC(ExternalCamera)) exitWith {};
|
if (call FUNC(ExternalCamera)) exitWith {};
|
||||||
|
|
||||||
private ["_unit", "_amount"];
|
private ["_unit", "_amount"];
|
||||||
@ -23,7 +23,7 @@ private ["_unit", "_amount"];
|
|||||||
_unit = ACE_player;
|
_unit = ACE_player;
|
||||||
|
|
||||||
if ([_unit] call FUNC(isGogglesVisible)) exitWith {
|
if ([_unit] call FUNC(isGogglesVisible)) exitWith {
|
||||||
(QGVAR(GogglesEffectsLayer) call BIS_fnc_RSCLayer) cutRsc ["RscACE_GogglesEffects", "PLAIN", 2, false];
|
GVAR(GogglesEffectsLayer) cutRsc ["RscACE_GogglesEffects", "PLAIN", 2, false];
|
||||||
|
|
||||||
((GETUVAR(GVAR(DisplayEffects),displayNull)) displayCtrl 10662) ctrlSetText format [getText (configFile >> "CfgGlasses" >> goggles _unit >> "ACE_DustPath"), GETDUSTT(DAMOUNT) + 1];
|
((GETUVAR(GVAR(DisplayEffects),displayNull)) displayCtrl 10662) ctrlSetText format [getText (configFile >> "CfgGlasses" >> goggles _unit >> "ACE_DustPath"), GETDUSTT(DAMOUNT) + 1];
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ if (_postProcessTintAmount != 0 && {GVAR(UsePP)}) then {
|
|||||||
_imagePath = getText (_config >> ["ACE_Overlay", "ACE_OverlayCracked"] select GETBROKEN);
|
_imagePath = getText (_config >> ["ACE_Overlay", "ACE_OverlayCracked"] select GETBROKEN);
|
||||||
|
|
||||||
if (_imagePath != "") then {
|
if (_imagePath != "") then {
|
||||||
(QGVAR(GogglesLayer) call BIS_fnc_RSCLayer) cutRsc ["RscACE_Goggles", "PLAIN", 1, false];
|
GVAR(GogglesLayer) cutRsc ["RscACE_Goggles", "PLAIN", 1, false];
|
||||||
(GLASSDISPLAY displayCtrl 10650) ctrlSetText _imagePath;
|
(GLASSDISPLAY displayCtrl 10650) ctrlSetText _imagePath;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,88 +0,0 @@
|
|||||||
/*
|
|
||||||
* Author: Garth 'L-H' de Wet, commy2
|
|
||||||
* Determines whether to place dust on the goggles, based on calibre of weapon fired and other requirements.
|
|
||||||
*
|
|
||||||
* Arguments:
|
|
||||||
* 0: Unit <OBJECT>
|
|
||||||
* 1: Weapon <STRING>
|
|
||||||
*
|
|
||||||
* Return Value:
|
|
||||||
* Function is handled? <BOOL>
|
|
||||||
*
|
|
||||||
* Public: No
|
|
||||||
*/
|
|
||||||
#include "script_component.hpp"
|
|
||||||
|
|
||||||
params ["_unit", "_weapon"];
|
|
||||||
|
|
||||||
if (_unit != ACE_player) exitWith {true};
|
|
||||||
|
|
||||||
// no dust in rain
|
|
||||||
if (rain > 0.1) exitWith {true};
|
|
||||||
|
|
||||||
// effect only aplies when lying on the ground
|
|
||||||
if (stance _unit != "PRONE") exitWith {true};
|
|
||||||
|
|
||||||
private ["_position", "_particleConfig", "_cloudType", "_surface", "_bullets"];
|
|
||||||
|
|
||||||
// check if the unit really is on the ground and not in a building
|
|
||||||
_position = getPosATL _unit;
|
|
||||||
|
|
||||||
if (_position select 2 > 0.2) exitWith {true};
|
|
||||||
|
|
||||||
// get weapon dust effect
|
|
||||||
_particleConfig = configFile >> "CfgWeapons" >> _weapon >> "GunParticles";
|
|
||||||
|
|
||||||
_cloudType = "";
|
|
||||||
|
|
||||||
if (isClass (_particleConfig >> "FirstEffect")) then { // @todo read this with custom / non-standard config classnames
|
|
||||||
_cloudType = getText (_particleConfig >> "FirstEffect" >> "effectName");
|
|
||||||
} else {
|
|
||||||
if (isClass (_particleConfig >> "effect1")) then {
|
|
||||||
_cloudType = getText (_particleConfig >> "effect1" >> "effectName");
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
// quit if the weapon causes no dust effect
|
|
||||||
if (_cloudType == "") exitWith {true};
|
|
||||||
|
|
||||||
// get if the surface is dusty
|
|
||||||
if (surfaceIsWater _position) exitWith {true};
|
|
||||||
|
|
||||||
_surface = surfaceType _position select [1]; // cuts of the leading #
|
|
||||||
|
|
||||||
if (_surface != GVAR(surfaceCache)) then {
|
|
||||||
GVAR(surfaceCache) = _surface;
|
|
||||||
GVAR(surfaceCacheIsDust) = getNumber (configFile >> "CfgSurfaces" >> _surface >> "dust") >= 0.1;
|
|
||||||
};
|
|
||||||
|
|
||||||
// quit if surface isn't dusty
|
|
||||||
if (!GVAR(surfaceCacheIsDust)) exitWith {true};
|
|
||||||
|
|
||||||
// increment dust value with type bullet
|
|
||||||
_bullets = GETDUSTT(DBULLETS);
|
|
||||||
|
|
||||||
if (ACE_diagTime - GETDUSTT(DTIME) > 1) then {
|
|
||||||
_bullets = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
_bullets = _bullets + 1;
|
|
||||||
|
|
||||||
SETDUST(DBULLETS,_bullets);
|
|
||||||
SETDUST(DTIME,ACE_diagTime);
|
|
||||||
|
|
||||||
// apply dust effect if the amount of fired bullets is over the threshold
|
|
||||||
if (GETDUSTT(DAMOUNT) < 2) then {
|
|
||||||
local _bulletsRequired = 100;
|
|
||||||
|
|
||||||
if (isNumber (configFile >> _cloudType >> QGVAR(BulletCount))) then {
|
|
||||||
_bulletsRequired = getNumber (configFile >> _cloudType >> QGVAR(BulletCount));
|
|
||||||
};
|
|
||||||
|
|
||||||
if (_bullets > _bulletsRequired) then {
|
|
||||||
SETDUST(DACTIVE,true);
|
|
||||||
call FUNC(applyDustEffect);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
true
|
|
@ -1,19 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* Author: Garth 'L-H' de Wet, commy2
|
||||||
|
* Handles explosions.
|
||||||
|
*
|
||||||
|
* Arguments:
|
||||||
|
* 0: Unit <OBJECT>
|
||||||
|
*
|
||||||
|
* Return Value:
|
||||||
|
* Function is handled? <BOOL>
|
||||||
|
*
|
||||||
|
* Public: No
|
||||||
|
*/
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
private "_effects";
|
|
||||||
if (alive ace_player) then {
|
params ["_unit"];
|
||||||
call FUNC(applyDirtEffect);
|
|
||||||
if (GETBROKEN) exitWith {};
|
if (_unit != ACE_player) exitWith {true};
|
||||||
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);};
|
call FUNC(applyDirtEffect);
|
||||||
_effects = GETGLASSES(ace_player);
|
|
||||||
_effects set [BROKEN, true];
|
if (GETBROKEN) exitWith {true};
|
||||||
SETGLASSES(ace_player,_effects);
|
|
||||||
if (getText(ConfigFile >> "CfgGlasses" >> GVAR(Current) >> "ACE_OverlayCracked") != "" && {cameraOn == ace_player}) then {
|
private ["_config", "_effects"];
|
||||||
if (call FUNC(ExternalCamera)) exitWith {};
|
|
||||||
if (isNull(GLASSDISPLAY)) then {
|
_config = configFile >> "CfgGlasses" >> goggles _unit;
|
||||||
150 cutRsc["RscACE_Goggles", "PLAIN",1, false];
|
|
||||||
};
|
if ((_this select 1) call FUNC(GetExplosionIndex) < getNumber (_config >> "ACE_Resistance")) exitWith {true};
|
||||||
(GLASSDISPLAY displayCtrl 10650) ctrlSetText getText(ConfigFile >> "CfgGlasses" >> GVAR(Current) >> "ACE_OverlayCracked");
|
|
||||||
};
|
if !([_unit] call FUNC(isGogglesVisible)) exitWith {
|
||||||
["GlassesCracked",[ace_player]] call EFUNC(common,localEvent);
|
["GlassesCracked", [_unit]] call EFUNC(common,localEvent);
|
||||||
};
|
true
|
||||||
|
};
|
||||||
|
|
||||||
|
_effects = GETGLASSES(_unit);
|
||||||
|
_effects set [BROKEN, true];
|
||||||
|
|
||||||
|
SETGLASSES(_unit,_effects);
|
||||||
|
|
||||||
|
if (getText (_config >> "ACE_OverlayCracked") != "") then {
|
||||||
|
if (GVAR(showInThirdPerson)) exitWith {};
|
||||||
|
if (call FUNC(ExternalCamera)) exitWith {};
|
||||||
|
|
||||||
|
if (isNull (GLASSDISPLAY)) then {
|
||||||
|
GVAR(GogglesLayer) cutRsc ["RscACE_Goggles", "PLAIN", 1, false];
|
||||||
|
};
|
||||||
|
|
||||||
|
(GLASSDISPLAY displayCtrl 10650) ctrlSetText getText (_config >> "ACE_OverlayCracked");
|
||||||
|
};
|
||||||
|
|
||||||
|
["GlassesCracked", [_unit]] call EFUNC(common,localEvent);
|
||||||
|
true
|
||||||
|
@ -1,2 +1,88 @@
|
|||||||
|
/*
|
||||||
|
* Author: Garth 'L-H' de Wet, commy2
|
||||||
|
* Determines whether to place dust on the goggles, based on calibre of weapon fired and other requirements.
|
||||||
|
*
|
||||||
|
* Arguments:
|
||||||
|
* 0: Unit <OBJECT>
|
||||||
|
* 1: Weapon <STRING>
|
||||||
|
*
|
||||||
|
* Return Value:
|
||||||
|
* Function is handled? <BOOL>
|
||||||
|
*
|
||||||
|
* Public: No
|
||||||
|
*/
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
[_this select 0, _this select 1] call FUNC(dustHandler);
|
|
||||||
|
params ["_unit", "_weapon"];
|
||||||
|
|
||||||
|
if (_unit != ACE_player) exitWith {true};
|
||||||
|
|
||||||
|
// no dust in rain
|
||||||
|
if (rain > 0.1) exitWith {true};
|
||||||
|
|
||||||
|
// effect only aplies when lying on the ground
|
||||||
|
if (stance _unit != "PRONE") exitWith {true};
|
||||||
|
|
||||||
|
private ["_position", "_particleConfig", "_cloudType", "_surface", "_bullets"];
|
||||||
|
|
||||||
|
// check if the unit really is on the ground and not in a building
|
||||||
|
_position = getPosATL _unit;
|
||||||
|
|
||||||
|
if (_position select 2 > 0.2) exitWith {true};
|
||||||
|
|
||||||
|
// get weapon dust effect
|
||||||
|
_particleConfig = configFile >> "CfgWeapons" >> _weapon >> "GunParticles";
|
||||||
|
|
||||||
|
_cloudType = "";
|
||||||
|
|
||||||
|
if (isClass (_particleConfig >> "FirstEffect")) then { // @todo read this with custom / non-standard config classnames
|
||||||
|
_cloudType = getText (_particleConfig >> "FirstEffect" >> "effectName");
|
||||||
|
} else {
|
||||||
|
if (isClass (_particleConfig >> "effect1")) then {
|
||||||
|
_cloudType = getText (_particleConfig >> "effect1" >> "effectName");
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
// quit if the weapon causes no dust effect
|
||||||
|
if (_cloudType == "") exitWith {true};
|
||||||
|
|
||||||
|
// get if the surface is dusty
|
||||||
|
if (surfaceIsWater _position) exitWith {true};
|
||||||
|
|
||||||
|
_surface = surfaceType _position select [1]; // cuts of the leading #
|
||||||
|
|
||||||
|
if (_surface != GVAR(surfaceCache)) then {
|
||||||
|
GVAR(surfaceCache) = _surface;
|
||||||
|
GVAR(surfaceCacheIsDust) = getNumber (configFile >> "CfgSurfaces" >> _surface >> "dust") >= 0.1;
|
||||||
|
};
|
||||||
|
|
||||||
|
// quit if surface isn't dusty
|
||||||
|
if (!GVAR(surfaceCacheIsDust)) exitWith {true};
|
||||||
|
|
||||||
|
// increment dust value with type bullet
|
||||||
|
_bullets = GETDUSTT(DBULLETS);
|
||||||
|
|
||||||
|
if (ACE_diagTime - GETDUSTT(DTIME) > 1) then {
|
||||||
|
_bullets = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
_bullets = _bullets + 1;
|
||||||
|
|
||||||
|
SETDUST(DBULLETS,_bullets);
|
||||||
|
SETDUST(DTIME,ACE_diagTime);
|
||||||
|
|
||||||
|
// apply dust effect if the amount of fired bullets is over the threshold
|
||||||
|
if (GETDUSTT(DAMOUNT) < 2) then {
|
||||||
|
local _bulletsRequired = 100;
|
||||||
|
|
||||||
|
if (isNumber (configFile >> _cloudType >> QGVAR(BulletCount))) then {
|
||||||
|
_bulletsRequired = getNumber (configFile >> _cloudType >> QGVAR(BulletCount));
|
||||||
|
};
|
||||||
|
|
||||||
|
if (_bullets > _bulletsRequired) then {
|
||||||
|
SETDUST(DACTIVE,true);
|
||||||
|
call FUNC(applyDustEffect);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
true
|
||||||
|
@ -1,13 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* Author: Garth 'L-H' de Wet, commy2
|
||||||
|
* Handles the player dying.
|
||||||
|
*
|
||||||
|
* Arguments:
|
||||||
|
* 0: Unit <OBJECT>
|
||||||
|
*
|
||||||
|
* Return Value:
|
||||||
|
* Function is handled? <BOOL>
|
||||||
|
*
|
||||||
|
* Public: No
|
||||||
|
*/
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
GVAR(PostProcessEyes) ppEffectEnable false;
|
|
||||||
SETGLASSES(ace_player,GLASSESDEFAULT);
|
params ["_unit"];
|
||||||
call FUNC(removeGlassesEffect);
|
|
||||||
GVAR(EffectsActive)=false;
|
if (_unit != ACE_player) exitWith {true};
|
||||||
ace_player setVariable ["ACE_EyesDamaged", false];
|
|
||||||
if (GVAR(EyesDamageScript) != -1) then {
|
GVAR(PostProcessEyes) ppEffectEnable false;
|
||||||
[GVAR(EyesDamageScript)] call CALLSTACK(cba_fnc_removePreFrameHandler);
|
|
||||||
};
|
SETGLASSES(_unit,GLASSESDEFAULT);
|
||||||
if (GVAR(DustHandler) != -1) then {
|
|
||||||
[GVAR(DustHandler)] call CALLSTACK(cba_fnc_removePerFrameHandler);
|
call FUNC(removeGlassesEffect);
|
||||||
GVAR(DustHandler) = -1;
|
|
||||||
};
|
GVAR(EffectsActive) = false;
|
||||||
|
|
||||||
|
_unit setVariable ["ACE_EyesDamaged", false];
|
||||||
|
|
||||||
|
[GVAR(DustHandler)] call CBA_fnc_removePerFrameHandler;
|
||||||
|
GVAR(DustHandler) = -1;
|
||||||
|
|
||||||
|
true
|
||||||
|
Loading…
Reference in New Issue
Block a user