Flashbangs - pass pos instead of obj reference

Fix #3205
This commit is contained in:
PabstMirror 2016-02-03 17:53:24 -06:00
parent 4612652f8c
commit 7fc84c60dd
3 changed files with 15 additions and 12 deletions

View File

@ -3,28 +3,29 @@
* Creates the flashbang effect and knock out AI units.
*
* Arguments:
* 0: The grenade <OBJECT>
* 0: The flashBang position ASL <ARRAY>
*
* Return Value:
* None
*
* Example:
* [theGrenade] call ace_grenades_fnc_flashbangExplosionEH
* [[0,0,0]] call ace_grenades_fnc_flashbangExplosionEH
*
* Public: No
*/
#include "script_component.hpp"
params ["_grenade"];
params ["_grenadePosASL"];
TRACE_1("params",_grenadePosASL);
private _affected = _grenade nearEntities ["CAManBase", 20];
private _affected = (ASLtoAGL _grenadePosASL) nearEntities ["CAManBase", 20];
{
if (local _x && {alive _x}) then {
private _strength = 1 - ((_x distance _grenade) min 15) / 15;
private _strength = 1 - (((getPosASL _x) vectorDistance _grenadePosASL) min 15) / 15;
TRACE_3("FlashBangEffect Start",_x,(_x distance _grenade),_strength);
TRACE_3("FlashBangEffect Start",_x,((getPosASL _x) vectorDistance _grenadePosASL),_strength);
if (_x != ACE_player) then {
//must be AI
@ -45,13 +46,12 @@ private _affected = _grenade nearEntities ["CAManBase", 20];
} else {
//Do effects for player
// is there line of sight to the grenade?
private _posGrenade = getPosASL _grenade;
private _eyePos = eyePos ACE_player; //PositionASL
_posGrenade set [2, (_posGrenade select 2) + 0.2]; // compensate for grenade glitching into ground
//Check for line of sight (check 4 points in case grenade is stuck in an object or underground)
private _losCount = {
!lineIntersects [_posGrenade vectorAdd _x, _eyePos, _grenade, ACE_player]
!lineIntersects [_grenadePosASL vectorAdd _x, _eyePos, ACE_player]
} count [[0,0,0], [0,0,0.2], [0.1, 0.1, 0.1], [-0.1, -0.1, 0.1]];
TRACE_1("Line of sight count (out of 4)",_losCount);
@ -83,7 +83,8 @@ private _affected = _grenade nearEntities ["CAManBase", 20];
};
// create flash to illuminate environment
private _light = "#lightpoint" createVehicleLocal getPos _grenade;
private _light = "#lightpoint" createVehicleLocal _grenadePosASL;
_light setPosASL _grenadePosASL;
_light setLightBrightness 200;
_light setLightAmbient [1,1,1];

View File

@ -16,11 +16,13 @@
#include "script_component.hpp"
params ["_projectile"];
TRACE_1("params",_projectile);
if (alive _projectile) then {
playSound3D ["A3\Sounds_F\weapons\Explosion\explosion_mine_1.wss", _projectile, false, getPosASL _projectile, 5, 1.2, 400];
private _affected = _projectile nearEntities ["CAManBase", 50];
private _affected = _projectile nearEntities ["CAManBase", 20];
TRACE_2("people hit",_affected,getPosASL _projectile);
["flashbangExplosion", _affected, [_projectile]] call EFUNC(common,targetEvent);
["flashbangExplosion", _affected, [getPosASL _projectile]] call EFUNC(common,targetEvent);
};

View File

@ -37,7 +37,7 @@ if (local _unit) then {
if (getNumber (_config >> QGVAR(flashbang)) == 1) then {
private _fuzeTime = getNumber (_config >> "explosionTime");
[FUNC(flashbangThrownFuze), [_projectile], _fuzeTime, 0] call EFUNC(common,waitAndExecute);
[FUNC(flashbangThrownFuze), [_projectile], _fuzeTime] call EFUNC(common,waitAndExecute);
};
};