mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Improve flashbang effects. Make sure the light effect is rendered even if the grenade explodes further than 20m from the player. Increase the amount of hearing damage.
This commit is contained in:
parent
95532ea521
commit
648a0259ec
@ -18,105 +18,115 @@
|
||||
params ["_grenadePosASL"];
|
||||
TRACE_1("params",_grenadePosASL);
|
||||
|
||||
private _affected = (ASLtoAGL _grenadePosASL) nearEntities ["CAManBase", 20];
|
||||
// Create flash to illuminate environment
|
||||
if (hasInterface) then {
|
||||
private _light = "#lightpoint" createVehicleLocal ASLtoAGL _grenadePosASL;
|
||||
_light setPosASL _grenadePosASL;
|
||||
|
||||
_light setLightBrightness 20;
|
||||
_light setLightAmbient [1,1,1];
|
||||
_light setLightColor [1,1,1];
|
||||
_light setLightDayLight true;
|
||||
|
||||
// Reduce the light after 0.1 seconds
|
||||
[{
|
||||
params ["_light"];
|
||||
_light setLightBrightness 5;
|
||||
// Delete the light after 0.2 more seconds
|
||||
[{
|
||||
params ["_light"];
|
||||
deleteVehicle _light;
|
||||
}, [_light], 0.2] call EFUNC(common,waitAndExecute);
|
||||
}, [_light], 0.1] call EFUNC(common,waitAndExecute);
|
||||
};
|
||||
|
||||
// Affect local AI
|
||||
// @todo: Affect units in static weapons, turned out, etc
|
||||
private _affected = (ASLtoAGL _grenadePosASL) nearEntities ["CAManBase", 20];
|
||||
_affected = _affected - [ACE_player];
|
||||
{
|
||||
if (local _x && {alive _x}) then {
|
||||
|
||||
private _strength = 1 - (((getPosASL _x) vectorDistance _grenadePosASL) min 15) / 15;
|
||||
|
||||
TRACE_3("FlashBangEffect Start",_x,((getPosASL _x) vectorDistance _grenadePosASL),_strength);
|
||||
|
||||
if (_x != ACE_player) then {
|
||||
//must be AI
|
||||
[_x, true] call EFUNC(common,disableAI);
|
||||
[_x, true] call EFUNC(common,disableAI);
|
||||
|
||||
_x setSkill (skill _x / 50);
|
||||
_x setSkill (skill _x / 50);
|
||||
|
||||
[{
|
||||
params ["_unit"];
|
||||
[{
|
||||
params ["_unit"];
|
||||
|
||||
//Make sure we don't enable AI for unconscious units
|
||||
if !(_unit getVariable ["ace_isUnconscious", false]) then {
|
||||
[_unit, false] call EFUNC(common,disableAI);
|
||||
};
|
||||
|
||||
_unit setSkill (skill _unit * 50);
|
||||
}, [_x], 7 * _strength] call EFUNC(common,waitAndExecute);
|
||||
} else {
|
||||
//Do effects for player
|
||||
// is there line of sight to the 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 [_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);
|
||||
if (_losCount <= 1) then {
|
||||
_strength = _strength / 10;
|
||||
//Make sure we don't enable AI for unconscious units
|
||||
if !(_unit getVariable ["ace_isUnconscious", false]) then {
|
||||
[_unit, false] call EFUNC(common,disableAI);
|
||||
};
|
||||
|
||||
// add ace_hearing ear ringing sound effect
|
||||
if (isClass (configFile >> "CfgPatches" >> "ACE_Hearing") && {_strength > 0}) then {
|
||||
[_x, 20 * _strength] call EFUNC(hearing,earRinging);
|
||||
};
|
||||
|
||||
// account for people looking away by slightly
|
||||
// reducing the effect for visual effects.
|
||||
private _eyeDir = (positionCameraToWorld [0,0,1] vectorDiff positionCameraToWorld [0,0,0]);
|
||||
private _dirToUnitVector = _eyePos vectorFromTo _posGrenade;
|
||||
private _angleDiff = acos (_eyeDir vectorDotProduct _dirToUnitVector);
|
||||
|
||||
// from 0-45deg, full effect
|
||||
if (_angleDiff > 45) then {
|
||||
_strength = _strength - _strength * ((_angleDiff - 45) / 120);
|
||||
};
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
// create flash to illuminate environment
|
||||
private _light = "#lightpoint" createVehicleLocal _grenadePosASL;
|
||||
_light setPosASL _grenadePosASL;
|
||||
|
||||
_light setLightBrightness 200;
|
||||
_light setLightAmbient [1,1,1];
|
||||
_light setLightColor [1,1,1];
|
||||
_light setLightDayLight true;
|
||||
|
||||
// delete the light after 0.1 seconds
|
||||
[{
|
||||
params ["_light"];
|
||||
deleteVehicle _light;
|
||||
}, [_light], 0.1] call EFUNC(common,waitAndExecute);
|
||||
|
||||
// blind player
|
||||
if (hasInterface && {_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;
|
||||
|
||||
//PARTIALRECOVERY - start decreasing effect over time
|
||||
[{
|
||||
params ["_strength"];
|
||||
|
||||
GVAR(flashbangPPEffectCC) ppEffectAdjust [1,1,0,[1,1,1,0],[0,0,0,1],[0,0,0,0]];
|
||||
GVAR(flashbangPPEffectCC) ppEffectCommit (10 * _strength);
|
||||
}, [_strength], 7 * _strength] call EFUNC(common,waitAndExecute);
|
||||
|
||||
//FULLRECOVERY - end effect
|
||||
[{
|
||||
GVAR(flashbangPPEffectCC) ppEffectEnable false;
|
||||
}, [], 17 * _strength] call EFUNC(common,waitAndExecute);
|
||||
};
|
||||
};
|
||||
_unit setSkill (skill _unit * 50);
|
||||
}, [_x], 7 * _strength] call EFUNC(common,waitAndExecute);
|
||||
};
|
||||
true
|
||||
} count _affected;
|
||||
|
||||
// Affect local player, independently of distance (all effects except light finish at 15m)
|
||||
if (hasInterface && {!isNull ACE_player} && {alive ACE_player}) then {
|
||||
// Do effects for player
|
||||
// is there line of sight to the grenade?
|
||||
private _eyePos = eyePos ACE_player; //PositionASL
|
||||
_grenadePosASL set [2, (_grenadePosASL select 2) + 0.2]; // compensate for grenade glitching into ground
|
||||
|
||||
private _strength = 1 - ((_eyePos vectorDistance _grenadePosASL) min 15) / 15;
|
||||
|
||||
//Check for line of sight (check 4 points in case grenade is stuck in an object or underground)
|
||||
private _losCount = {
|
||||
!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);
|
||||
if (_losCount <= 1) then {
|
||||
_strength = _strength / 10;
|
||||
};
|
||||
|
||||
// add ace_hearing ear ringing sound effect
|
||||
if (isClass (configFile >> "CfgPatches" >> "ACE_Hearing") && {_strength > 0}) then {
|
||||
[_x, 40 * _strength] call EFUNC(hearing,earRinging);
|
||||
};
|
||||
|
||||
// account for people looking away by slightly
|
||||
// reducing the effect for visual effects.
|
||||
private _eyeDir = ((AGLtoASL positionCameraToWorld [0,0,1]) vectorDiff (AGLtoASL positionCameraToWorld [0,0,0]));
|
||||
private _dirToUnitVector = _eyePos vectorFromTo _posGrenade;
|
||||
private _angleDiff = acos (_eyeDir vectorDotProduct _dirToUnitVector);
|
||||
|
||||
// from 0-45deg, full effect
|
||||
if (_angleDiff > 45) then {
|
||||
_strength = _strength - _strength * ((_angleDiff - 45) / 120);
|
||||
};
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
// 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;
|
||||
|
||||
//PARTIALRECOVERY - start decreasing effect over time
|
||||
[{
|
||||
params ["_strength"];
|
||||
|
||||
GVAR(flashbangPPEffectCC) ppEffectAdjust [1,1,0,[1,1,1,0],[0,0,0,1],[0,0,0,0]];
|
||||
GVAR(flashbangPPEffectCC) ppEffectCommit (10 * _strength);
|
||||
}, [_strength], 7 * _strength] call EFUNC(common,waitAndExecute);
|
||||
|
||||
//FULLRECOVERY - end effect
|
||||
[{
|
||||
GVAR(flashbangPPEffectCC) ppEffectEnable false;
|
||||
}, [], 17 * _strength] call EFUNC(common,waitAndExecute);
|
||||
};
|
||||
};
|
||||
true
|
||||
|
@ -21,8 +21,5 @@ 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", 20];
|
||||
TRACE_2("people hit",_affected,getPosASL _projectile);
|
||||
|
||||
["flashbangExplosion", _affected, [getPosASL _projectile]] call EFUNC(common,targetEvent);
|
||||
["flashbangExplosion", [getPosASL _projectile]] call EFUNC(common,globalEvent);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user