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;
|
||||
|
||||
// make sure to stack effect layers in correct order
|
||||
QGVAR(GogglesEffectsLayer) call BIS_fnc_RSCLayer;
|
||||
QGVAR(GogglesLayer) call BIS_fnc_RSCLayer;
|
||||
GVAR(GogglesEffectsLayer) = QGVAR(GogglesEffectsLayer) call BIS_fnc_RSCLayer;
|
||||
GVAR(GogglesLayer) = QGVAR(GogglesLayer) call BIS_fnc_RSCLayer;
|
||||
|
||||
if (isNil QGVAR(UsePP)) then {
|
||||
GVAR(UsePP) = true;
|
||||
|
@ -16,12 +16,11 @@ PREP(removeRainEffect);
|
||||
PREP(externalCamera);
|
||||
PREP(isDivingGoggles);
|
||||
PREP(isGogglesVisible);
|
||||
PREP(isInRotorWash);
|
||||
|
||||
// general
|
||||
PREP(clearGlasses);
|
||||
PREP(dustHandler);
|
||||
PREP(getExplosionIndex);
|
||||
PREP(isInRotorWash);
|
||||
|
||||
// eventhandlers
|
||||
PREP(handleExplosion);
|
||||
|
@ -31,7 +31,7 @@ if ([_unit] call FUNC(isGogglesVisible)) then {
|
||||
local _dirtImage = getText (configFile >> "CfgGlasses" >> goggles _unit >> "ACE_OverlayDirt");
|
||||
|
||||
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;
|
||||
};
|
||||
};
|
||||
|
@ -15,7 +15,7 @@
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
if (GVAR(showInThirdPerson)) exitWith {false};
|
||||
if (GVAR(showInThirdPerson)) exitWith {};
|
||||
if (call FUNC(ExternalCamera)) exitWith {};
|
||||
|
||||
private ["_unit", "_amount"];
|
||||
@ -23,7 +23,7 @@ private ["_unit", "_amount"];
|
||||
_unit = ACE_player;
|
||||
|
||||
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];
|
||||
|
||||
|
@ -42,7 +42,7 @@ if (_postProcessTintAmount != 0 && {GVAR(UsePP)}) then {
|
||||
_imagePath = getText (_config >> ["ACE_Overlay", "ACE_OverlayCracked"] select GETBROKEN);
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
|
@ -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"
|
||||
private "_effects";
|
||||
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 EFUNC(common,localEvent);};
|
||||
_effects = GETGLASSES(ace_player);
|
||||
_effects set [BROKEN, true];
|
||||
SETGLASSES(ace_player,_effects);
|
||||
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 EFUNC(common,localEvent);
|
||||
};
|
||||
|
||||
params ["_unit"];
|
||||
|
||||
if (_unit != ACE_player) exitWith {true};
|
||||
|
||||
call FUNC(applyDirtEffect);
|
||||
|
||||
if (GETBROKEN) exitWith {true};
|
||||
|
||||
private ["_config", "_effects"];
|
||||
|
||||
_config = configFile >> "CfgGlasses" >> goggles _unit;
|
||||
|
||||
if ((_this select 1) call FUNC(GetExplosionIndex) < getNumber (_config >> "ACE_Resistance")) exitWith {true};
|
||||
|
||||
if !([_unit] call FUNC(isGogglesVisible)) exitWith {
|
||||
["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"
|
||||
[_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"
|
||||
GVAR(PostProcessEyes) ppEffectEnable false;
|
||||
SETGLASSES(ace_player,GLASSESDEFAULT);
|
||||
call FUNC(removeGlassesEffect);
|
||||
GVAR(EffectsActive)=false;
|
||||
ace_player setVariable ["ACE_EyesDamaged", false];
|
||||
if (GVAR(EyesDamageScript) != -1) then {
|
||||
[GVAR(EyesDamageScript)] call CALLSTACK(cba_fnc_removePreFrameHandler);
|
||||
};
|
||||
if (GVAR(DustHandler) != -1) then {
|
||||
[GVAR(DustHandler)] call CALLSTACK(cba_fnc_removePerFrameHandler);
|
||||
GVAR(DustHandler) = -1;
|
||||
};
|
||||
|
||||
params ["_unit"];
|
||||
|
||||
if (_unit != ACE_player) exitWith {true};
|
||||
|
||||
GVAR(PostProcessEyes) ppEffectEnable false;
|
||||
|
||||
SETGLASSES(_unit,GLASSESDEFAULT);
|
||||
|
||||
call FUNC(removeGlassesEffect);
|
||||
|
||||
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