2018-09-17 19:19:29 +00:00
|
|
|
#include "script_component.hpp"
|
2015-01-25 03:59:20 +00:00
|
|
|
/*
|
2015-03-24 04:18:00 +00:00
|
|
|
* Author: commy2 and esteldunedain
|
2015-01-25 03:59:20 +00:00
|
|
|
* Calculate and apply backblast damage to potentially affected local units
|
2016-01-16 14:04:22 +00:00
|
|
|
* Handles the "overpressure" event.
|
2015-01-25 03:59:20 +00:00
|
|
|
*
|
2016-06-18 09:50:41 +00:00
|
|
|
* Arguments:
|
2015-08-30 05:35:58 +00:00
|
|
|
* 0: Unit that fired <OBJECT>
|
|
|
|
* 1: Pos ASL of the projectile <ARRAY>
|
2016-01-16 14:04:22 +00:00
|
|
|
* 2: Direction of the projectile (reversed for launcher backblast) <ARRAY>
|
2015-08-30 05:35:58 +00:00
|
|
|
* 3: Weapon fired <STRING>
|
|
|
|
* 4: Magazine <STRING>
|
|
|
|
* 5: Ammo <STRING>
|
2015-01-25 03:59:20 +00:00
|
|
|
*
|
2016-06-18 09:50:41 +00:00
|
|
|
* Return Value:
|
2015-01-25 03:59:20 +00:00
|
|
|
* None
|
2016-01-16 14:04:22 +00:00
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [tank, [1727.57,5786.15,7.24899], [-0.982474,-0.185998,-0.0122501], "cannon_125mm", "24Rnd_125mm_APFSDS_T_Green", "Sh_125mm_APFSDS_T_Green"] call ace_overpressure_fnc_overpressureDamage
|
|
|
|
*
|
|
|
|
* Public: No
|
2015-01-25 03:59:20 +00:00
|
|
|
*/
|
|
|
|
|
2015-08-30 05:35:58 +00:00
|
|
|
params ["_firer", "_posASL", "_direction", "_weapon", "_magazine", "_ammo"];
|
|
|
|
|
2022-08-01 17:32:02 +00:00
|
|
|
// Retrieve overpressure values
|
|
|
|
private _opValues = [_weapon, _ammo, _magazine] call FUNC(getOverPressureValues);
|
|
|
|
|
|
|
|
_opValues params ["_overpressureAngle", "_overpressureRange", "_overpressureDamage"];
|
2016-01-16 14:04:22 +00:00
|
|
|
TRACE_3("cache",_overpressureAngle,_overpressureRange,_overpressureDamage);
|
2015-01-25 03:59:20 +00:00
|
|
|
|
|
|
|
{
|
2015-02-15 16:14:09 +00:00
|
|
|
if (local _x && {_x != _firer} && {vehicle _x == _x}) then {
|
2016-01-16 14:04:22 +00:00
|
|
|
private _targetPositionASL = eyePos _x;
|
|
|
|
private _relativePosition = _targetPositionASL vectorDiff _posASL;
|
|
|
|
private _axisDistance = _relativePosition vectorDotProduct _direction;
|
|
|
|
private _distance = vectorMagnitude _relativePosition;
|
|
|
|
private _angle = acos (_axisDistance / _distance);
|
2015-01-25 03:59:20 +00:00
|
|
|
|
2016-01-16 14:04:22 +00:00
|
|
|
private _line = [_posASL, _targetPositionASL, _firer, _x];
|
|
|
|
private _line2 = [_posASL, _targetPositionASL];
|
2015-02-15 16:14:09 +00:00
|
|
|
TRACE_4("Affected:",_x,_axisDistance,_distance,_angle);
|
|
|
|
|
2015-02-15 17:11:50 +00:00
|
|
|
if (_angle < _overpressureAngle && {_distance < _overpressureRange} && {!lineIntersects _line} && {!terrainIntersectASL _line2}) then {
|
2015-02-15 16:14:09 +00:00
|
|
|
|
2016-01-16 14:04:22 +00:00
|
|
|
private _alpha = sqrt (1 - _distance / _overpressureRange);
|
|
|
|
private _beta = sqrt (1 - _angle / _overpressureAngle);
|
2015-01-25 03:59:20 +00:00
|
|
|
|
2016-01-16 14:04:22 +00:00
|
|
|
private _damage = _alpha * _beta * _overpressureDamage;
|
2016-12-22 19:29:05 +00:00
|
|
|
TRACE_1("",_damage);
|
2015-01-25 03:59:20 +00:00
|
|
|
|
2020-02-07 19:27:40 +00:00
|
|
|
TRACE_1("",isDamageAllowed _x);
|
|
|
|
if (isDamageAllowed _x && {_x getVariable [QEGVAR(medical,allowDamage), true]}) then {
|
2022-01-30 17:56:20 +00:00
|
|
|
// If the target is the ACE_player
|
|
|
|
if (_x isEqualTo ACE_player) then {
|
|
|
|
[_damage * 100] call BIS_fnc_bloodEffect
|
|
|
|
};
|
|
|
|
if (["ACE_Medical"] call EFUNC(common,isModLoaded)) then {
|
2020-02-07 19:27:40 +00:00
|
|
|
[_x, _damage, "body", "backblast", _firer] call EFUNC(medical,addDamageToUnit);
|
|
|
|
} else {
|
|
|
|
_x setDamage (damage _x + _damage);
|
|
|
|
};
|
2015-01-25 03:59:20 +00:00
|
|
|
};
|
2016-01-16 14:04:22 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG_MODE_FULL
|
|
|
|
//Shows damage lines in green
|
|
|
|
[ _posASL,
|
|
|
|
_targetPositionASL,
|
|
|
|
[0,1,0,1]
|
|
|
|
] call EFUNC(common,addLineToDebugDraw);
|
|
|
|
#endif
|
2015-01-25 03:59:20 +00:00
|
|
|
};
|
|
|
|
};
|
2015-11-11 19:24:27 +00:00
|
|
|
} forEach ((ASLtoAGL _posASL) nearEntities ["CAManBase", _overpressureRange]);
|