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
|
|
|
*
|
|
|
|
* Handle fire of local launchers
|
|
|
|
*
|
|
|
|
* Argument:
|
|
|
|
* 0: Unit that fired (Object)
|
|
|
|
* 1: Weapon fired (String)
|
|
|
|
* 2: Muzzle (String)
|
|
|
|
* 3: Mode (String)
|
|
|
|
* 4: Ammo (String)
|
|
|
|
* 5: Magazine (String)
|
|
|
|
* 6: Projectile (Object)
|
|
|
|
*
|
|
|
|
* Return value:
|
|
|
|
* None
|
|
|
|
*/
|
|
|
|
//#define DEBUG_MODE_FULL
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
|
|
|
EXPLODE_7_PVT(_this,_firer,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile);
|
|
|
|
|
|
|
|
// Prevent AI from causing backblast damage
|
|
|
|
if !([_firer] call EFUNC(common,isPlayer)) exitWith {};
|
|
|
|
|
2015-02-15 16:14:09 +00:00
|
|
|
private ["_position", "_direction"];
|
|
|
|
|
2015-01-25 03:59:20 +00:00
|
|
|
_position = getPosASL _projectile;
|
|
|
|
_direction = [0, 0, 0] vectorDiff (vectorDir _projectile);
|
|
|
|
|
2015-02-15 16:14:09 +00:00
|
|
|
private ["_backblastAngle", "_backblastRange", "_backblastDamage"];
|
2015-01-25 03:59:20 +00:00
|
|
|
|
2015-02-15 16:14:09 +00:00
|
|
|
_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
|
|
|
|
|
|
|
// Damage to others
|
2015-02-15 16:14:09 +00:00
|
|
|
private "_affected";
|
2015-01-25 03:59:20 +00:00
|
|
|
_affected = getPos _projectile nearEntities ["CAManBase", _backblastRange];
|
|
|
|
|
2015-02-15 16:14:09 +00:00
|
|
|
// Let each client handle their own affected units
|
2015-02-15 17:11:50 +00:00
|
|
|
["overpressure", _affected, [_firer, _position, _direction, _weapon]] call EFUNC(common,targetEvent);
|
2015-01-25 03:59:20 +00:00
|
|
|
|
|
|
|
// Damage to the firer
|
2015-02-15 16:14:09 +00:00
|
|
|
private "_distance";
|
2015-01-25 03:59:20 +00:00
|
|
|
_distance = [_position, _direction, _backblastRange] call FUNC(getDistance);
|
2015-02-15 16:14:09 +00:00
|
|
|
|
|
|
|
TRACE_1("Distance",_distance);
|
2015-01-25 03:59:20 +00:00
|
|
|
|
|
|
|
if (_distance < _backblastRange) 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 0.5;
|
|
|
|
|
2015-04-02 20:56:23 +00:00
|
|
|
_damage = _alpha * _beta * _backblastDamage;
|
2015-01-25 03:59:20 +00:00
|
|
|
[_damage * 100] call BIS_fnc_bloodEffect;
|
|
|
|
|
2015-04-02 20:56:23 +00:00
|
|
|
if (isClass (configFile >> "CfgPatches" >> "ACE_Medical") && {([_firer] call EFUNC(medical,hasMedicalEnabled))}) then {
|
|
|
|
[_firer, "HitBody", [_firer, "body", ((_firer getHitPointDamage "HitBody") + _damage), _firer, "backblast"] call EFUNC(medical,handleDamage)] call EFUNC(medical,setHitPointDamage);
|
2015-01-25 03:59:20 +00:00
|
|
|
} else {
|
|
|
|
_firer setDamage (damage _firer + _damage);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
// Draw debug lines
|
|
|
|
#ifdef DEBUG_MODE_FULL
|
|
|
|
[ _position,
|
|
|
|
_position vectorAdd (_direction vectorMultiply _backblastRange),
|
|
|
|
[1,1,0,1]
|
|
|
|
] call EFUNC(common,addLineToDebugDraw);
|
|
|
|
|
2015-02-15 16:14:09 +00:00
|
|
|
private "_ref";
|
2015-01-25 03:59:20 +00:00
|
|
|
_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 min _backblastRange)),
|
|
|
|
[1,0,0,1]
|
|
|
|
] call EFUNC(common,addLineToDebugDraw);
|
2015-02-15 16:14:09 +00:00
|
|
|
#endif
|