2015-01-11 16:42:31 +00:00
|
|
|
/*
|
2015-02-02 09:04:53 +00:00
|
|
|
* Author: Garth 'L-H' de Wet
|
|
|
|
* 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:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
*ace_player addEventHandler ["Fired", {[_this select 0, _this select 1] call ace_goggles_fnc_dustHandler;}];
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
2015-01-18 21:50:45 +00:00
|
|
|
#include "script_component.hpp"
|
2015-05-28 05:18:45 +00:00
|
|
|
private ["_bullets", "_position", "_surface", "_weapon", "_cloudType", "_unit"];
|
2015-01-19 08:34:49 +00:00
|
|
|
EXPLODE_2_PVT(_this,_unit,_weapon);
|
|
|
|
if (_unit != ace_player) exitWith {true};
|
2015-01-11 16:42:31 +00:00
|
|
|
_cloudType = "";
|
|
|
|
|
2015-01-19 08:34:49 +00:00
|
|
|
if (rain > 0.1) exitWith {true};
|
|
|
|
if ((stance _unit) != "PRONE") exitWith {true};
|
2015-01-11 16:42:31 +00:00
|
|
|
|
|
|
|
if (isClass(configFile >> "CfgWeapons" >> _weapon >> "GunParticles" >> "FirstEffect")) then {
|
2015-04-06 16:22:43 +00:00
|
|
|
_cloudType = getText(configFile >> "CfgWeapons" >> _weapon >> "GunParticles" >> "FirstEffect" >> "effectName");
|
2015-01-11 16:42:31 +00:00
|
|
|
} else {
|
2015-04-06 16:22:43 +00:00
|
|
|
if (isClass(configFile >> "CfgWeapons" >> _weapon >> "GunParticles" >> "effect1")) then {
|
|
|
|
_cloudType = getText(configFile >> "CfgWeapons" >> _weapon >> "GunParticles" >> "effect1" >> "effectName");
|
|
|
|
};
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
if (_cloudType == "") exitWith {true};
|
|
|
|
|
2015-01-19 08:34:49 +00:00
|
|
|
_position = getPosATL _unit;
|
2015-01-11 16:42:31 +00:00
|
|
|
|
|
|
|
if (surfaceIsWater _position) exitWith {};
|
|
|
|
if ((_position select 2) > 0.2) exitWith {};
|
|
|
|
|
|
|
|
_surface = surfaceType _position;
|
|
|
|
|
2015-05-28 05:18:45 +00:00
|
|
|
if (_surface != GVAR(surfaceCache)) then {
|
|
|
|
GVAR(surfaceCache) = _surface;
|
|
|
|
_surface = ([_surface, "#"] call CBA_fnc_split) select 1;
|
|
|
|
GVAR(surfaceCacheIsDust) = getNumber (ConfigFile >> "CfgSurfaces" >> _surface >> "dust") >= 0.1;
|
|
|
|
};
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-05-28 05:18:45 +00:00
|
|
|
if (!GVAR(surfaceCacheIsDust)) exitWith {};
|
2015-01-11 16:42:31 +00:00
|
|
|
|
|
|
|
_bullets = GETDUSTT(DBULLETS);
|
|
|
|
|
2015-05-21 16:42:44 +00:00
|
|
|
if ((ACE_diagTime - GETDUSTT(DTIME)) > 1) then {
|
2015-04-06 16:22:43 +00:00
|
|
|
_bullets = 0;
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
_bullets = _bullets + 1;
|
|
|
|
SETDUST(DBULLETS,_bullets);
|
2015-05-21 16:42:44 +00:00
|
|
|
SETDUST(DTIME,ACE_diagTime);
|
2015-01-11 16:42:31 +00:00
|
|
|
|
|
|
|
if (GETDUSTT(DAMOUNT) < 2) then {
|
2015-04-06 16:22:43 +00:00
|
|
|
private "_bulletsRequired";
|
|
|
|
_bulletsRequired = 100;
|
|
|
|
if (isNumber (ConfigFile >> _cloudType >> "ACE_Goggles_BulletCount")) then {
|
|
|
|
_bulletsRequired = getNumber (ConfigFile >> _cloudType >> "ACE_Goggles_BulletCount");
|
|
|
|
};
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-04-06 16:22:43 +00:00
|
|
|
if (_bulletsRequired <= _bullets) then {
|
|
|
|
SETDUST(DACTIVE,true);
|
|
|
|
call FUNC(applyDust);
|
|
|
|
};
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|
|
|
|
true
|