2015-01-14 20:40:37 +00:00
|
|
|
/*
|
2015-02-14 06:39:01 +00:00
|
|
|
* Author: KoffeinFlummi
|
|
|
|
* Creates the flashbang effect and knock out AI units.
|
|
|
|
*
|
|
|
|
* Arguments:
|
2016-02-03 23:53:24 +00:00
|
|
|
* 0: The flashBang position ASL <ARRAY>
|
2015-02-14 06:39:01 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
2015-08-13 20:36:58 +00:00
|
|
|
* None
|
2015-02-14 06:39:01 +00:00
|
|
|
*
|
|
|
|
* Example:
|
2016-02-03 23:53:24 +00:00
|
|
|
* [[0,0,0]] call ace_grenades_fnc_flashbangExplosionEH
|
2015-02-14 06:39:01 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
2015-01-17 06:39:46 +00:00
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2016-02-03 23:53:24 +00:00
|
|
|
params ["_grenadePosASL"];
|
|
|
|
TRACE_1("params",_grenadePosASL);
|
2015-01-17 06:39:46 +00:00
|
|
|
|
2016-02-03 23:53:24 +00:00
|
|
|
private _affected = (ASLtoAGL _grenadePosASL) nearEntities ["CAManBase", 20];
|
2015-01-17 06:39:46 +00:00
|
|
|
|
|
|
|
{
|
2015-09-26 20:39:12 +00:00
|
|
|
if (local _x && {alive _x}) then {
|
2015-02-14 06:39:01 +00:00
|
|
|
|
2016-02-03 23:53:24 +00:00
|
|
|
private _strength = 1 - (((getPosASL _x) vectorDistance _grenadePosASL) min 15) / 15;
|
2015-02-14 06:39:01 +00:00
|
|
|
|
2016-02-03 23:53:24 +00:00
|
|
|
TRACE_3("FlashBangEffect Start",_x,((getPosASL _x) vectorDistance _grenadePosASL),_strength);
|
2015-04-10 02:58:45 +00:00
|
|
|
|
2015-02-14 06:39:01 +00:00
|
|
|
if (_x != ACE_player) then {
|
|
|
|
//must be AI
|
2015-04-12 02:48:12 +00:00
|
|
|
[_x, true] call EFUNC(common,disableAI);
|
2015-09-26 20:39:12 +00:00
|
|
|
|
|
|
|
_x setSkill (skill _x / 50);
|
2015-02-14 06:39:01 +00:00
|
|
|
|
|
|
|
[{
|
2015-08-13 20:36:58 +00:00
|
|
|
params ["_unit"];
|
2015-09-26 20:39:12 +00:00
|
|
|
|
2015-04-12 02:48:12 +00:00
|
|
|
//Make sure we don't enable AI for unconscious units
|
2015-09-26 20:42:47 +00:00
|
|
|
if !(_unit getVariable ["ace_isUnconscious", false]) then {
|
2015-04-12 02:48:12 +00:00
|
|
|
[_unit, false] call EFUNC(common,disableAI);
|
|
|
|
};
|
2015-09-26 20:39:12 +00:00
|
|
|
|
2015-02-14 06:39:01 +00:00
|
|
|
_unit setSkill (skill _unit * 50);
|
2015-09-26 20:42:47 +00:00
|
|
|
}, [_x], 7 * _strength] call EFUNC(common,waitAndExecute);
|
2015-02-14 06:39:01 +00:00
|
|
|
} else {
|
|
|
|
//Do effects for player
|
|
|
|
// is there line of sight to the grenade?
|
2016-01-06 21:42:02 +00:00
|
|
|
private _eyePos = eyePos ACE_player; //PositionASL
|
2015-02-14 06:39:01 +00:00
|
|
|
_posGrenade set [2, (_posGrenade select 2) + 0.2]; // compensate for grenade glitching into ground
|
2015-04-10 02:58:45 +00:00
|
|
|
|
2015-04-12 02:42:57 +00:00
|
|
|
//Check for line of sight (check 4 points in case grenade is stuck in an object or underground)
|
2016-01-06 21:42:02 +00:00
|
|
|
private _losCount = {
|
2016-02-03 23:53:24 +00:00
|
|
|
!lineIntersects [_grenadePosASL vectorAdd _x, _eyePos, ACE_player]
|
2015-08-13 20:36:58 +00:00
|
|
|
} count [[0,0,0], [0,0,0.2], [0.1, 0.1, 0.1], [-0.1, -0.1, 0.1]];
|
2015-08-15 01:25:27 +00:00
|
|
|
|
2015-04-12 02:42:57 +00:00
|
|
|
TRACE_1("Line of sight count (out of 4)",_losCount);
|
2015-04-27 21:07:31 +00:00
|
|
|
if (_losCount <= 1) then {
|
2015-02-14 06:39:01 +00:00
|
|
|
_strength = _strength / 10;
|
|
|
|
};
|
|
|
|
|
2015-09-26 20:39:12 +00:00
|
|
|
// add ace_hearing ear ringing sound effect
|
|
|
|
if (isClass (configFile >> "CfgPatches" >> "ACE_Hearing") && {_strength > 0}) then {
|
2016-02-16 19:02:25 +00:00
|
|
|
[20 * _strength] call EFUNC(hearing,earRinging);
|
2015-02-14 06:39:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// account for people looking away by slightly
|
|
|
|
// reducing the effect for visual effects.
|
2016-01-06 21:42:02 +00:00
|
|
|
private _eyeDir = (positionCameraToWorld [0,0,1] vectorDiff positionCameraToWorld [0,0,0]);
|
|
|
|
private _dirToUnitVector = _eyePos vectorFromTo _posGrenade;
|
|
|
|
private _angleDiff = acos (_eyeDir vectorDotProduct _dirToUnitVector);
|
2015-02-14 06:39:01 +00:00
|
|
|
|
2015-09-26 20:39:12 +00:00
|
|
|
// from 0-45deg, full effect
|
2015-04-10 02:58:45 +00:00
|
|
|
if (_angleDiff > 45) then {
|
|
|
|
_strength = _strength - _strength * ((_angleDiff - 45) / 120);
|
|
|
|
};
|
2015-02-14 06:39:01 +00:00
|
|
|
|
2015-04-12 02:42:57 +00:00
|
|
|
TRACE_1("Final strength for player",_strength);
|
2015-02-14 06:39:01 +00:00
|
|
|
|
2015-09-26 20:39:12 +00:00
|
|
|
// add ace_medical pain effect:
|
|
|
|
if (isClass (configFile >> "CfgPatches" >> "ACE_Medical") && {_strength > 0.1}) then {
|
|
|
|
[ACE_player, _strength / 2] call EFUNC(medical,adjustPainLevel);
|
2015-04-10 03:00:03 +00:00
|
|
|
};
|
|
|
|
|
2015-02-14 06:39:01 +00:00
|
|
|
// create flash to illuminate environment
|
2016-02-03 23:53:24 +00:00
|
|
|
private _light = "#lightpoint" createVehicleLocal _grenadePosASL;
|
|
|
|
_light setPosASL _grenadePosASL;
|
2016-01-06 21:42:02 +00:00
|
|
|
|
2015-02-14 06:39:01 +00:00
|
|
|
_light setLightBrightness 200;
|
|
|
|
_light setLightAmbient [1,1,1];
|
|
|
|
_light setLightColor [1,1,1];
|
|
|
|
_light setLightDayLight true;
|
|
|
|
|
2015-09-26 20:39:12 +00:00
|
|
|
// delete the light after 0.1 seconds
|
2015-02-14 06:39:01 +00:00
|
|
|
[{
|
2015-08-15 01:25:27 +00:00
|
|
|
params ["_light"];
|
2015-02-14 06:39:01 +00:00
|
|
|
deleteVehicle _light;
|
2015-07-11 02:39:35 +00:00
|
|
|
}, [_light], 0.1] call EFUNC(common,waitAndExecute);
|
2015-02-14 06:39:01 +00:00
|
|
|
|
|
|
|
// blind player
|
2015-09-26 20:39:12 +00:00
|
|
|
if (hasInterface && {_strength > 0.1}) then {
|
2015-02-14 06:39:01 +00:00
|
|
|
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;
|
|
|
|
|
2015-10-21 20:52:21 +00:00
|
|
|
//PARTIALRECOVERY - start decreasing effect over time
|
2015-02-14 06:39:01 +00:00
|
|
|
[{
|
2015-08-13 20:36:58 +00:00
|
|
|
params ["_strength"];
|
2015-09-26 20:39:12 +00:00
|
|
|
|
2015-02-14 06:39:01 +00:00
|
|
|
GVAR(flashbangPPEffectCC) ppEffectAdjust [1,1,0,[1,1,1,0],[0,0,0,1],[0,0,0,0]];
|
|
|
|
GVAR(flashbangPPEffectCC) ppEffectCommit (10 * _strength);
|
2015-09-26 20:39:12 +00:00
|
|
|
}, [_strength], 7 * _strength] call EFUNC(common,waitAndExecute);
|
2015-02-14 06:39:01 +00:00
|
|
|
|
|
|
|
//FULLRECOVERY - end effect
|
|
|
|
[{
|
|
|
|
GVAR(flashbangPPEffectCC) ppEffectEnable false;
|
2015-09-26 20:39:12 +00:00
|
|
|
}, [], 17 * _strength] call EFUNC(common,waitAndExecute);
|
2015-02-14 06:39:01 +00:00
|
|
|
};
|
|
|
|
};
|
2015-01-17 06:39:46 +00:00
|
|
|
};
|
2015-08-13 20:36:58 +00:00
|
|
|
true
|
|
|
|
} count _affected;
|