2015-07-10 22:09:20 +00:00
|
|
|
/*
|
|
|
|
* Author: joko // Jonas
|
2016-02-06 21:17:27 +00:00
|
|
|
* Handle fire of local launchers. Called from the unified fired EH only for the local player.
|
2015-07-10 22:09:20 +00:00
|
|
|
*
|
2015-08-30 05:35:58 +00:00
|
|
|
* Arguments:
|
2016-02-06 21:17:27 +00:00
|
|
|
* None. Parameters inherited from EFUNC(common,firedEH)
|
2015-07-10 22:09:20 +00:00
|
|
|
*
|
2016-06-18 09:50:41 +00:00
|
|
|
* Return Value:
|
2015-07-10 22:09:20 +00:00
|
|
|
* None
|
2016-01-16 14:04:22 +00:00
|
|
|
*
|
2016-02-06 21:17:27 +00:00
|
|
|
* Example:
|
2016-01-16 14:04:22 +00:00
|
|
|
* [player, "launch_RPG32_F", "launch_RPG32_F", "Single", "R_PG32V_F", "RPG32_F", projectile] call ace_overpressure_fnc_firedEHBB;
|
|
|
|
*
|
|
|
|
* Public: No
|
2015-07-10 22:09:20 +00:00
|
|
|
*/
|
2015-08-30 05:49:12 +00:00
|
|
|
#include "script_component.hpp"
|
2016-01-16 14:04:22 +00:00
|
|
|
|
2016-02-06 21:17:27 +00:00
|
|
|
//IGNORE_PRIVATE_WARNING ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_vehicle", "_gunner", "_turret"];
|
|
|
|
TRACE_10("firedEH:",_unit, _weapon, _muzzle, _mode, _ammo, _magazine, _projectile, _vehicle, _gunner, _turret);
|
2015-08-30 05:35:58 +00:00
|
|
|
|
2015-08-30 22:05:55 +00:00
|
|
|
// Bake variable name and check if the variable exists, call the caching function otherwise
|
2016-01-16 14:04:22 +00:00
|
|
|
private _varName = format [QGVAR(values%1%2%3), _weapon, _ammo, _magazine];
|
2016-02-06 21:17:27 +00:00
|
|
|
private _var = if (isNil _varName) then {
|
|
|
|
[_weapon, _ammo, _magazine] call FUNC(cacheOverPressureValues);
|
2015-08-30 05:35:58 +00:00
|
|
|
} else {
|
2016-02-06 21:17:27 +00:00
|
|
|
missionNameSpace getVariable _varName;
|
2015-08-30 05:35:58 +00:00
|
|
|
};
|
2016-09-04 14:44:22 +00:00
|
|
|
_var params ["_backblastAngle","_backblastRange","_backblastDamage"];
|
2016-02-06 21:17:27 +00:00
|
|
|
TRACE_3("cache",_backblastAngle,_backblastRange,_backblastDamage);
|
|
|
|
|
|
|
|
if (_backblastDamage <= 0) exitWith {};
|
|
|
|
|
|
|
|
private _position = getPosASL _projectile;
|
|
|
|
private _direction = [0, 0, 0] vectorDiff (vectorDir _projectile);
|
|
|
|
|
|
|
|
// Damage to others
|
|
|
|
private _affected = (ASLtoAGL _position) nearEntities ["CAManBase", _backblastRange];
|
|
|
|
|
|
|
|
// Let each client handle their own affected units
|
2016-05-24 13:13:11 +00:00
|
|
|
["ace_overpressure", [_unit, _position, _direction, _weapon, _magazine, _ammo], _affected] call CBA_fnc_targetEvent;
|
2016-02-06 21:17:27 +00:00
|
|
|
|
|
|
|
// Damage to the firer
|
|
|
|
private _distance = 2 * ([_position, _direction, _backblastRange, _unit] call FUNC(getDistance));
|
2015-08-30 05:35:58 +00:00
|
|
|
|
2016-02-06 21:17:27 +00:00
|
|
|
TRACE_1("Distance",_distance);
|
|
|
|
|
|
|
|
if (_distance < _backblastRange) then {
|
|
|
|
private _alpha = sqrt (1 - _distance / _backblastRange);
|
|
|
|
private _beta = sqrt 0.5;
|
|
|
|
|
|
|
|
private _damage = _alpha * _beta * _backblastDamage;
|
|
|
|
[_damage * 100] call BIS_fnc_bloodEffect;
|
|
|
|
|
2016-12-09 19:48:54 +00:00
|
|
|
if (isClass (configFile >> "CfgPatches" >> "ACE_Medical")) then {
|
2016-02-06 21:17:27 +00:00
|
|
|
[_unit, _damage, "body", "backblast"] call EFUNC(medical,addDamageToUnit);
|
|
|
|
} else {
|
2018-01-07 00:24:44 +00:00
|
|
|
TRACE_1("",isDamageAllowed _unit);
|
|
|
|
if (!isDamageAllowed _unit) exitWith {}; // Skip damage if not allowed
|
2016-02-06 21:17:27 +00:00
|
|
|
_unit setDamage (damage _unit + _damage);
|
|
|
|
};
|
2015-08-30 05:35:58 +00:00
|
|
|
};
|
2016-02-06 21:17:27 +00:00
|
|
|
|
|
|
|
// Draw debug lines
|
|
|
|
#ifdef DEBUG_MODE_FULL
|
|
|
|
[ _position,
|
|
|
|
_position vectorAdd (_direction vectorMultiply _backblastRange),
|
|
|
|
[1,1,0,1]
|
|
|
|
] call EFUNC(common,addLineToDebugDraw);
|
|
|
|
|
|
|
|
private _ref = _direction call EFUNC(common,createOrthonormalReference);
|
|
|
|
[ _position,
|
|
|
|
_position vectorAdd (_direction vectorMultiply _backblastRange) vectorAdd ((_ref select 1) vectorMultiply _backblastRange * tan _backblastAngle),
|
|
|
|
[1,1,0,1]
|
|
|
|
] call EFUNC(common,addLineToDebugDraw);
|
|
|
|
[ _position,
|
|
|
|
_position vectorAdd (_direction vectorMultiply _backblastRange) vectorDiff ((_ref select 1) vectorMultiply _backblastRange * tan _backblastAngle),
|
|
|
|
[1,1,0,1]
|
|
|
|
] call EFUNC(common,addLineToDebugDraw);
|
|
|
|
[ _position,
|
|
|
|
_position vectorAdd (_direction vectorMultiply _backblastRange) vectorAdd ((_ref select 2) vectorMultiply _backblastRange * tan _backblastAngle),
|
|
|
|
[1,1,0,1]
|
|
|
|
] call EFUNC(common,addLineToDebugDraw);
|
|
|
|
[ _position,
|
|
|
|
_position vectorAdd (_direction vectorMultiply _backblastRange) vectorDiff ((_ref select 2) vectorMultiply _backblastRange * tan _backblastAngle),
|
|
|
|
[1,1,0,1]
|
|
|
|
] call EFUNC(common,addLineToDebugDraw);
|
|
|
|
|
|
|
|
[ _position,
|
|
|
|
_position vectorAdd (_direction vectorMultiply ((_distance/2) min _backblastRange)),
|
|
|
|
[1,0,0,1]
|
|
|
|
] call EFUNC(common,addLineToDebugDraw);
|
|
|
|
#endif
|