2015-01-25 03:59:20 +00:00
|
|
|
/*
|
2015-02-15 16:14:09 +00:00
|
|
|
* Author: commy2 and CAA-Picard
|
2015-01-25 03:59:20 +00:00
|
|
|
*
|
|
|
|
* Calculate and apply backblast damage to potentially affected local units
|
|
|
|
*
|
|
|
|
* Argument:
|
|
|
|
* 0: Unit that fired (Object)
|
|
|
|
* 1: Pos ASL of the projectile (Array)
|
|
|
|
* 2: Direction of the projectile (Array)
|
|
|
|
* 3: Weapon fired (String)
|
|
|
|
*
|
|
|
|
* Return value:
|
|
|
|
* None
|
|
|
|
*/
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
|
|
|
EXPLODE_4_PVT(_this,_firer,_posASL,_direction,_weapon);
|
|
|
|
|
2015-02-15 16:14:09 +00:00
|
|
|
private ["_backblastAngle", "_backblastRange", "_backblastDamage"];
|
|
|
|
|
|
|
|
_backblastAngle = getNumber (configFile >> "CfgWeapons" >> _weapon >> QGVAR(angle)) / 2;
|
|
|
|
_backblastRange = getNumber (configFile >> "CfgWeapons" >> _weapon >> QGVAR(range));
|
|
|
|
_backblastDamage = getNumber (configFile >> "CfgWeapons" >> _weapon >> QGVAR(damage));
|
|
|
|
|
2015-01-25 03:59:20 +00:00
|
|
|
TRACE_4("Parameters:",_backblastAngle,_backblastRange,_backblastDamage,_weapon);
|
|
|
|
|
2015-02-15 16:14:09 +00:00
|
|
|
private "_pos";
|
2015-01-25 03:59:20 +00:00
|
|
|
_pos = _posASL;
|
|
|
|
if (!surfaceIsWater _pos) then {
|
|
|
|
_pos = ASLtoATL _pos;
|
|
|
|
};
|
|
|
|
|
|
|
|
{
|
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-01-25 03:59:20 +00:00
|
|
|
if (_angle < _backblastAngle && {_distance < _backblastRange} && {!lineIntersects _line} && {!terrainIntersectASL _line2}) then {
|
2015-02-15 16:14:09 +00:00
|
|
|
private ["_alpha", "_beta", "_damage"];
|
|
|
|
|
2015-01-25 03:59:20 +00:00
|
|
|
_alpha = sqrt (1 - _distance / _backblastRange);
|
|
|
|
_beta = sqrt (1 - _angle / _backblastAngle);
|
|
|
|
|
|
|
|
_damage = 2 * _alpha * _beta * _backblastDamage;
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
|
|
// TODO: Sort this interaction with medical
|
|
|
|
if (isClass (configFile >> "CfgPatches" >> "ACE_Medical")) then {
|
2015-02-15 16:14:09 +00:00
|
|
|
[_x, "HitBody", ([_x, "", (_x getHitPointDamage "HitBody") + _damage, objNull, objNull] call EFUNC(medical,handleDamage))] call EFUNC(medical,setHitPointDamage);
|
|
|
|
_x spawn {
|
2015-01-25 03:59:20 +00:00
|
|
|
sleep 0.5;
|
|
|
|
[_this, "", 0, objNull, objNull] call EFUNC(medical,handleDamage);
|
|
|
|
};
|
|
|
|
} else {
|
2015-02-15 16:14:09 +00:00
|
|
|
_x setDamage (damage _x + _damage);
|
2015-01-25 03:59:20 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2015-02-15 16:14:09 +00:00
|
|
|
} forEach (_pos nearEntities ["CAManBase", _backblastRange]);
|