diff --git a/addons/grenades/CfgAmmo.hpp b/addons/grenades/CfgAmmo.hpp index 17a6744ac7..7b0a24740d 100644 --- a/addons/grenades/CfgAmmo.hpp +++ b/addons/grenades/CfgAmmo.hpp @@ -83,7 +83,7 @@ class CfgAmmo { SmokeShellSoundLoop1[] = {"A3\Sounds_F\weapons\smokeshell\smoke_loop1",0.125893,1,70}; SmokeShellSoundLoop2[] = {"A3\Sounds_F\weapons\smokeshell\smoke_loop2",0.125893,1,70}; timeToLive = 60; - fuseDistance = 2.3; //todo should this be explosionTime - model = PATHTOF(\models\ACE_m84_thrown.p3d); + fuseDistance = 2.3; + model = PATHTOF(models\ACE_m84_thrown.p3d); }; }; diff --git a/addons/grenades/CfgMagazines.hpp b/addons/grenades/CfgMagazines.hpp index 75b1dfd616..5775302d2c 100644 --- a/addons/grenades/CfgMagazines.hpp +++ b/addons/grenades/CfgMagazines.hpp @@ -44,8 +44,8 @@ class CfgMagazines { displayname = "$STR_ACE_Grenades_M84_Name"; descriptionshort = "$STR_ACE_Grenades_M84_Description"; displayNameShort = "M84"; - model = PATHTOF(\models\ACE_m84.p3d); - picture = PATHTOF(\UI\ACE_m84_x_ca.paa); + model = PATHTOF(models\ACE_m84.p3d); + picture = PATHTOF(UI\ACE_m84_x_ca.paa); }; class 3Rnd_UGL_FlareGreen_F; diff --git a/addons/grenades/XEH_preInit.sqf b/addons/grenades/XEH_preInit.sqf index 99ed6478fa..f6f1eb6ffe 100644 --- a/addons/grenades/XEH_preInit.sqf +++ b/addons/grenades/XEH_preInit.sqf @@ -1,5 +1,9 @@ #include "script_component.hpp" PREP(flashbangEffect); +PREP(flashbangExplosionEH); +PREP(flashbangThrownFuze); PREP(nextMode); PREP(throwGrenade); + +[QGVAR(flashbangExplosionEvent), { _this call DFUNC(flashbangExplosionEH) }] call EFUNC(common,addNetEventHandler); diff --git a/addons/grenades/functions/fn_flashbangEffect.sqf b/addons/grenades/functions/fn_flashbangEffect.sqf deleted file mode 100644 index ab3501a1ea..0000000000 --- a/addons/grenades/functions/fn_flashbangEffect.sqf +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Author: KoffeinFlummi - * - * Creates the flashbang effect locally/knocks out AI units. - * - * Arguments: - * 0: The unit (Object) - * 1: The grenade (Object) - * - * Return Value: - * None - */ - -#include "script_component.hpp" - -_this spawn { - _unit = _this select 0; - _grenade = _this select 1; - - if (damage _unit >= 1) exitWith {}; - - _strength = 1 - ((_unit distance _grenade) min 15) / 15; - - if !(isPlayer _unit) exitWith { - _unit disableAI "MOVE"; - _unit disableAI "ANIM"; - _unit disableAI "AUTOTARGET"; - _unit disableAI "TARGET"; - _unit disableAI "FSM"; - _unit setSkill (skill _unit / 50); - - sleep (7 * _strength); - - _unit enableAI "MOVE"; - _unit enableAI "ANIM"; - _unit enableAI "AUTOTARGET"; - _unit enableAI "TARGET"; - _unit enableAI "FSM"; - _unit setSkill (skill _unit * 50); - }; - - // is there line of sight to the grenade? - _posGrenade = getPosASL _grenade; - _posGrenade set [2, (_posGrenade select 2) + 0.2]; // compensate for grenade glitching into ground - if (lineIntersects [_posGrenade, getPosASL _unit, _grenade, _unit]) then { - _strength = _strength / 10; - }; - - // beeeeeeeeeeeeeeeeeeeeeeeeeeeeep - if (isClass (configFile >> "CfgPatches" >> "ACE_Hearing") and _strength > 0) then { - [_unit, 0.5 + (_strength / 2)] call ACE_Hearing_fnc_earRinging; - }; - - // account for people looking away by slightly - // reducing the effect for visual effects. - _posUnit = getPos _unit; - _posGrenade = getPos _grenade; - _angleGrenade = ((_posGrenade select 0) - (_posUnit select 0)) atan2 ((_posGrenade select 1) - (_posUnit select 1)); - _angleGrenade = (_angleGrenade + 360) % 360; - - _angleView = (eyeDirection player select 0) atan2 (eyeDirection player select 1); - _angleView = (_angleView + 360) % 360; - - _angleDiff = 180 - abs (abs (_angleGrenade - _angleView) - 180); - _angleDiff = ((_angleDiff - 45) max 0); - - _strength = _strength - _strength * (_angleDiff / 135); - - // create flash to illuminate environment - _light = "#lightpoint" createVehicleLocal getPos _grenade; - _light setLightBrightness 200; - _light setLightAmbient [1,1,1]; - _light setLightColor [1,1,1]; - _light setLightDayLight true; - - // blind player - if (_strength > 0.1) then { - GVAR(flashbangPPEffectCC) ppEffectEnable true; - GVAR(flashbangPPEffectCC) ppEffectAdjust [1,1,(0.8 + _strength) min 1,[1,1,1,0],[0,0,0,1],[0,0,0,0]]; - GVAR(flashbangPPEffectCC) ppEffectCommit 0.01; - }; - - sleep 0.1; - deleteVehicle _light; - sleep (7 * _strength); - - if (_strength > 0.1) then { - GVAR(flashbangPPEffectCC) ppEffectAdjust [1,1,0,[1,1,1,0],[0,0,0,1],[0,0,0,0]]; - GVAR(flashbangPPEffectCC) ppEffectCommit (10 * _strength); - - sleep (10 * _strength); - - GVAR(flashbangPPEffectCC) ppEffectEnable false; - }; -}; diff --git a/addons/grenades/functions/fnc_flashbangEffectStages.sqf b/addons/grenades/functions/fnc_flashbangEffectStages.sqf new file mode 100644 index 0000000000..8ab4d09f94 --- /dev/null +++ b/addons/grenades/functions/fnc_flashbangEffectStages.sqf @@ -0,0 +1,14 @@ +/* + * Author: KoffeinFlummi + * + * Creates the flashbang effect locally/knocks out AI units. + * + * Arguments: + * 0: The unit (Object) + * 1: The grenade (Object) + * + * Return Value: + * None + */ + +#include "script_component.hpp" diff --git a/addons/grenades/functions/fnc_flashbangExplosionEH.sqf b/addons/grenades/functions/fnc_flashbangExplosionEH.sqf new file mode 100644 index 0000000000..528c3fef7c --- /dev/null +++ b/addons/grenades/functions/fnc_flashbangExplosionEH.sqf @@ -0,0 +1,89 @@ +#include "script_component.hpp" + +#define EFFECT_STAGE_RESETAI 0 +#define EFFECT_STAGE_DELETELIGHT 1 + +_unit = _this select 0; +_grenade = _this select 1; + +if (!local _unit) exitWith {}; +if (!alive _unit) exitWith {}; +if (damage _unit >= 1) exitWith {}; + +_strength = 1 - ((_unit distance _grenade) min 15) / 15; + +if (_unit != ACE_player) exitWith { + //must be AI + _unit disableAI "MOVE"; + _unit disableAI "ANIM"; + _unit disableAI "AUTOTARGET"; + _unit disableAI "TARGET"; + _unit disableAI "FSM"; + _unit setSkill (skill _unit / 50); + + sleep (7 * _strength); + + _unit enableAI "MOVE"; + _unit enableAI "ANIM"; + _unit enableAI "AUTOTARGET"; + _unit enableAI "TARGET"; + _unit enableAI "FSM"; + _unit setSkill (skill _unit * 50); +}; + +// is there line of sight to the grenade? +_posGrenade = getPosASL _grenade; +_posGrenade set [2, (_posGrenade select 2) + 0.2]; // compensate for grenade glitching into ground +if (lineIntersects [_posGrenade, getPosASL _unit, _grenade, _unit]) then { + _strength = _strength / 10; +}; + +// beeeeeeeeeeeeeeeeeeeeeeeeeeeeep +if (isClass (configFile >> "CfgPatches" >> "ACE_Hearing") and _strength > 0) then { + [_unit, 0.5 + (_strength / 2)] call EFUNC(hearing,earRinging); +}; + +// account for people looking away by slightly +// reducing the effect for visual effects. +_posUnit = getPos _unit; +_posGrenade = getPos _grenade; +_angleGrenade = ((_posGrenade select 0) - (_posUnit select 0)) atan2 ((_posGrenade select 1) - (_posUnit select 1)); +_angleGrenade = (_angleGrenade + 360) % 360; + +_angleView = (eyeDirection player select 0) atan2 (eyeDirection player select 1); +_angleView = (_angleView + 360) % 360; + +_angleDiff = 180 - abs (abs (_angleGrenade - _angleView) - 180); +_angleDiff = ((_angleDiff - 45) max 0); + +_strength = _strength - _strength * (_angleDiff / 135); + +// create flash to illuminate environment +_light = "#lightpoint" createVehicleLocal getPos _grenade; +_light setLightBrightness 200; +_light setLightAmbient [1,1,1]; +_light setLightColor [1,1,1]; +_light setLightDayLight true; + +// blind player +if (_strength > 0.1) then { + GVAR(flashbangPPEffectCC) ppEffectEnable true; + GVAR(flashbangPPEffectCC) ppEffectAdjust [1,1,(0.8 + _strength) min 1,[1,1,1,0],[0,0,0,1],[0,0,0,0]]; + GVAR(flashbangPPEffectCC) ppEffectCommit 0.01; +}; + +[] spawn { + sleep 0.1; + deleteVehicle _light; +}; + +sleep (7 * _strength); + +if (_strength > 0.1) then { + GVAR(flashbangPPEffectCC) ppEffectAdjust [1,1,0,[1,1,1,0],[0,0,0,1],[0,0,0,0]]; + GVAR(flashbangPPEffectCC) ppEffectCommit (10 * _strength); + + sleep (10 * _strength); + + GVAR(flashbangPPEffectCC) ppEffectEnable false; +}; diff --git a/addons/grenades/functions/fnc_flashbangExplosion.sqf b/addons/grenades/functions/fnc_flashbangThrownFuze.sqf similarity index 79% rename from addons/grenades/functions/fnc_flashbangExplosion.sqf rename to addons/grenades/functions/fnc_flashbangThrownFuze.sqf index 5d047ddcbd..ce08ed466d 100644 --- a/addons/grenades/functions/fnc_flashbangExplosion.sqf +++ b/addons/grenades/functions/fnc_flashbangThrownFuze.sqf @@ -1,3 +1,5 @@ +//Waits for the grenade fuze to trigger and 'explode' + #include "script_component.hpp" _projectile = (_this select 0) select 0; @@ -14,6 +16,6 @@ if (alive _projectile) then { _affected = _projectile nearEntities ["CAManBase", 50]; { // [[_x, _projectile], "ACE_Grenades_fnc_flashbangEffect", _x] call ACE_Core_fnc_execRemoteFnc; - // [[_x, _projectile], "ACE_Grenades_fnc_flashbangEffect", _x] call ACE_Core_fnc_execRemoteFnc; + [QGVAR(flashbangExplosionEvent), [_x, _projectile]] call EFUNC(common,globalEvent); } forEach _affected; }; \ No newline at end of file diff --git a/addons/grenades/functions/fn_nextMode.sqf b/addons/grenades/functions/fnc_nextMode.sqf similarity index 100% rename from addons/grenades/functions/fn_nextMode.sqf rename to addons/grenades/functions/fnc_nextMode.sqf diff --git a/addons/grenades/functions/fn_throwGrenade.sqf b/addons/grenades/functions/fnc_throwGrenade.sqf similarity index 83% rename from addons/grenades/functions/fn_throwGrenade.sqf rename to addons/grenades/functions/fnc_throwGrenade.sqf index 36dc08ce1a..e725ebd426 100644 --- a/addons/grenades/functions/fn_throwGrenade.sqf +++ b/addons/grenades/functions/fnc_throwGrenade.sqf @@ -55,7 +55,7 @@ if (_mode != 0) then { }; if (typeOf _projectile == "ACE_G_M84") then { - // _fuzeTime = (configFile >> "CfgAmmo" >> typeOf _projectile >> "fuseDistance"); - _fuzeTime = (configFile >> "CfgAmmo" >> typeOf _projectile >> "explosionTime"); //@toDo pretty sure this should be explosionTime not fuseDistance + _fuzeTime = getNumber (configFile >> "CfgAmmo" >> typeOf _projectile >> "fuseDistance"); + // _fuzeTime = getNumber (configFile >> "CfgAmmo" >> typeOf _projectile >> "explosionTime"); //@toDo pretty sure this should be explosionTime not fuseDistance [FUNC(flashbangThrownFuze), 0, [_projectile, (time + _fuzeTime)]] call CBA_fnc_addPerFrameHandler; };