Grenade Cleanup

This commit is contained in:
PabstMirror 2015-08-14 20:25:27 -05:00
parent e160a62599
commit 7c276d9d25

View File

@ -15,7 +15,7 @@
*/
#include "script_component.hpp"
private ["_affected", "_strength", "_posGrenade", "_posUnit", "_angleGrenade", "_angleView", "_angleDiff", "_light", "_losCount", "_dirToUnitVector", "_eyeDir", "_eyePos"];
private ["_affected", "_strength", "_posGrenade", "_angleDiff", "_light", "_losCount", "_dirToUnitVector", "_eyeDir", "_eyePos"];
params ["_grenade"];
_affected = _grenade nearEntities ["CAManBase", 20];
@ -47,14 +47,11 @@ _affected = _grenade nearEntities ["CAManBase", 20];
_eyePos = eyePos ACE_player; //PositionASL
_posGrenade set [2, (_posGrenade select 2) + 0.2]; // compensate for grenade glitching into ground
_losCount = 0;
//Check for line of sight (check 4 points in case grenade is stuck in an object or underground)
{
if (!lineIntersects [(_posGrenade vectorAdd _x), _eyePos, _grenade, ACE_player]) then {
_losCount = _losCount + 1;
};
true
_losCount = {
(!lineIntersects [(_posGrenade vectorAdd _x), _eyePos, _grenade, 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);
if (_losCount <= 1) then {
_strength = _strength / 10;
@ -78,7 +75,6 @@ _affected = _grenade nearEntities ["CAManBase", 20];
TRACE_1("Final strength for player",_strength);
//Add ace_medical pain effect:
if ((isClass (configFile >> "CfgPatches" >> "ACE_Medical")) && {_strength > 0.1}) then {
[ACE_player, (_strength / 2)] call EFUNC(medical,adjustPainLevel);
@ -93,7 +89,7 @@ _affected = _grenade nearEntities ["CAManBase", 20];
//Delete the light after 0.1 seconds
[{
params ["light"];
params ["_light"];
deleteVehicle _light;
}, [_light], 0.1] call EFUNC(common,waitAndExecute);