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
|
|
|
|
*
|
|
|
|
* Argument:
|
2015-08-30 05:35:58 +00:00
|
|
|
* 0: Unit that fired <OBJECT>
|
|
|
|
* 1: Pos ASL of the projectile <ARRAY>
|
|
|
|
* 2: Direction of the projectile <ARRAY>
|
|
|
|
* 3: Weapon fired <STRING>
|
|
|
|
* 4: Magazine <STRING>
|
|
|
|
* 5: Ammo <STRING>
|
2015-01-25 03:59:20 +00:00
|
|
|
*
|
|
|
|
* Return value:
|
|
|
|
* None
|
|
|
|
*/
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-07-17 19:26:18 +00:00
|
|
|
private ["_var","_overpressureAngle", "_overpressureRange", "_overpressureDamage"];
|
2015-08-30 05:35:58 +00:00
|
|
|
params ["_firer", "_posASL", "_direction", "_weapon", "_magazine", "_ammo"];
|
|
|
|
|
2015-08-30 22:05:55 +00:00
|
|
|
// Bake variable name and check if the variable exists, call the caching function otherwise
|
2015-08-30 05:35:58 +00:00
|
|
|
_varName = format [QGVAR(values%1%2%3), _weapon, _ammo, _magazine];
|
2015-07-17 19:26:18 +00:00
|
|
|
_var = if (isNil _varName) then {
|
2015-08-30 21:40:53 +00:00
|
|
|
[_weapon, _ammo, _magazine] call FUNC(cacheOverPressureValues);
|
2015-07-17 19:26:18 +00:00
|
|
|
} else {
|
|
|
|
missionNameSpace getVariable _varName;
|
|
|
|
};
|
|
|
|
_var params["_overpressureAngle","_overpressureRange","_overpressureDamage"];
|
2015-02-15 16:14:09 +00:00
|
|
|
|
2015-02-15 17:11:50 +00:00
|
|
|
TRACE_4("Parameters:",_overpressureAngle,_overpressureRange,_overpressureDamage,_weapon);
|
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 {
|
|
|
|
private ["_targetPositionASL", "_relativePosition", "_axisDistance", "_distance", "_angle", "_line", "_line2"];
|
2015-01-25 03:59:20 +00:00
|
|
|
|
2015-02-15 16:14:09 +00:00
|
|
|
_targetPositionASL = eyePos _x;
|
2015-01-25 03:59:20 +00:00
|
|
|
_relativePosition = _targetPositionASL vectorDiff _posASL;
|
|
|
|
_axisDistance = _relativePosition vectorDotProduct _direction;
|
|
|
|
_distance = vectorMagnitude _relativePosition;
|
|
|
|
_angle = acos (_axisDistance / _distance);
|
|
|
|
|
2015-02-15 16:14:09 +00:00
|
|
|
_line = [_posASL, _targetPositionASL, _firer, _x];
|
2015-01-25 03:59:20 +00:00
|
|
|
_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
|
|
|
private ["_alpha", "_beta", "_damage"];
|
|
|
|
|
2015-02-15 17:11:50 +00:00
|
|
|
_alpha = sqrt (1 - _distance / _overpressureRange);
|
|
|
|
_beta = sqrt (1 - _angle / _overpressureAngle);
|
2015-01-25 03:59:20 +00:00
|
|
|
|
2015-04-02 20:56:23 +00:00
|
|
|
_damage = _alpha * _beta * _overpressureDamage;
|
2015-01-25 03:59:20 +00:00
|
|
|
|
|
|
|
// If the target is the ACE_player
|
2015-02-15 16:14:09 +00:00
|
|
|
if (_x == ACE_player) then {[_damage * 100] call BIS_fnc_bloodEffect};
|
2015-01-25 03:59:20 +00:00
|
|
|
|
2015-04-02 20:56:23 +00:00
|
|
|
if (isClass (configFile >> "CfgPatches" >> "ACE_Medical") && {([_x] call EFUNC(medical,hasMedicalEnabled))}) then {
|
2015-09-19 09:52:35 +00:00
|
|
|
[_x, "body", ((_x getvariable [QEGVAR(medical,bodyPartStatus), [0,0,0,0,0,0]]) select 1) + _damage, _firer, "backblast", 0] call EFUNC(medical,handleDamage);
|
2015-01-25 03:59:20 +00:00
|
|
|
} else {
|
2015-02-15 16:14:09 +00:00
|
|
|
_x setDamage (damage _x + _damage);
|
2015-01-25 03:59:20 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2015-11-11 19:24:27 +00:00
|
|
|
} forEach ((ASLtoAGL _posASL) nearEntities ["CAManBase", _overpressureRange]);
|