ACE3/addons/goggles/functions/fnc_handleFired.sqf

88 lines
2.6 KiB
Plaintext
Raw Normal View History

#include "..\script_component.hpp"
2015-09-29 20:24:25 +00:00
/*
* Author: Garth 'L-H' de Wet, commy2
2016-02-06 20:16:10 +00:00
* Determines whether to place dust on the goggles, based on calibre of weapon fired and other requirements. Called from the unified fired EH only for the local player.
2015-09-29 20:24:25 +00:00
*
* Arguments:
2016-02-06 20:20:30 +00:00
* None. Parameters inherited from EFUNC(common,firedEH)
2015-09-29 20:24:25 +00:00
*
* Return Value:
* Function is handled? <BOOL>
*
* Example:
* call ace_goggles_fnc_handleFired
*
2015-09-29 20:24:25 +00:00
* Public: No
*/
2016-02-06 20:16:10 +00:00
//IGNORE_PRIVATE_WARNING ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_vehicle", "_gunner", "_turret"];
TRACE_10("firedEH:",_unit, _weapon, _muzzle, _mode, _ammo, _magazine, _projectile, _vehicle, _gunner, _turret);
2015-09-29 20:24:25 +00:00
// no dust in rain
if (rain > 0.1) exitWith {true};
// effect only aplies when lying on the ground
if (stance _unit != "PRONE") exitWith {true};
// check if the unit really is on the ground and not in a building
private _position = getPosATL _unit;
2015-09-29 20:24:25 +00:00
if (_position select 2 > 0.2) exitWith {true};
// get weapon dust effect
private _particleConfig = configFile >> "CfgWeapons" >> _weapon >> "GunParticles";
2015-09-29 20:24:25 +00:00
private _cloudType = "";
2015-09-29 20:24:25 +00:00
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};
private _surface = surfaceType _position select [1]; // cuts of the leading #
2015-09-29 20:24:25 +00:00
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
private _bullets = GETDUSTT(DBULLETS);
2015-09-29 20:24:25 +00:00
2016-03-02 10:01:39 +00:00
if (diag_tickTime - GETDUSTT(DTIME) > 1) then {
2015-09-29 20:24:25 +00:00
_bullets = 0;
};
_bullets = _bullets + 1;
SETDUST(DBULLETS,_bullets);
2016-03-02 10:01:39 +00:00
SETDUST(DTIME,diag_tickTime);
2015-09-29 20:24:25 +00:00
// apply dust effect if the amount of fired bullets is over the threshold
if (GETDUSTT(DAMOUNT) < 2) then {
2015-11-17 16:43:07 +00:00
private _bulletsRequired = 100;
2015-09-29 20:24:25 +00:00
if (isNumber (configFile >> _cloudType >> QGVAR(BulletCount))) then {
_bulletsRequired = getNumber (configFile >> _cloudType >> QGVAR(BulletCount));
};
if (_bullets > _bulletsRequired) then {
SETDUST(DACTIVE,true);
call FUNC(applyDustEffect);
};
};
true