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 vehicle weapons creating overpressure zones
|
|
|
|
*
|
2015-08-30 05:35:58 +00:00
|
|
|
* Arguments:
|
|
|
|
* 0: Unit that fired <OBJECT>
|
|
|
|
* 1: Weapon fired <STRING>
|
|
|
|
* 2: Muzzle <STRING>
|
|
|
|
* 3: Mode <STRING>
|
|
|
|
* 4: Ammo <STRING>
|
|
|
|
* 5: Magazine <STRING>
|
|
|
|
* 6: Projectile <OBJECT>
|
2015-01-25 03:59:20 +00:00
|
|
|
*
|
|
|
|
* Return value:
|
|
|
|
* None
|
2015-02-15 16:14:09 +00:00
|
|
|
*/
|
|
|
|
//#define DEBUG_MODE_FULL
|
2015-01-25 03:59:20 +00:00
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-08-30 05:35:58 +00:00
|
|
|
params ["_firer", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile"];
|
2015-02-15 17:11:50 +00:00
|
|
|
// Prevent AI from causing overpressure damage
|
2015-02-15 16:14:09 +00:00
|
|
|
if !([gunner _firer] call EFUNC(common,isPlayer)) exitWith {}; //@todo non-maingun turrets?
|
|
|
|
|
|
|
|
private ["_position", "_direction"];
|
2015-01-25 03:59:20 +00:00
|
|
|
|
|
|
|
_position = getPosASL _projectile;
|
|
|
|
_direction = vectorDir _projectile;
|
|
|
|
|
2015-08-30 05:35:58 +00:00
|
|
|
private ["_var", "_varName", "_dangerZoneAngle", "_dangerZoneRange", "_dangerZoneDamage"];
|
|
|
|
|
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["_dangerZoneAngle","_dangerZoneRange","_dangerZoneDamage"];
|
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", _dangerZoneRange];
|
2015-02-15 16:14:09 +00:00
|
|
|
|
2015-01-25 03:59:20 +00:00
|
|
|
// Let each client handle their own affected units
|
2015-08-30 05:35:58 +00:00
|
|
|
["overpressure", _affected, [_firer, _position, _direction, _weapon, _magazine, _ammo]] call EFUNC(common,targetEvent);
|
2015-01-25 03:59:20 +00:00
|
|
|
|
|
|
|
// Draw debug lines
|
|
|
|
#ifdef DEBUG_MODE_FULL
|
|
|
|
[ _position,
|
|
|
|
_position vectorAdd (_direction vectorMultiply _dangerZoneRange),
|
|
|
|
[1,0,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 _dangerZoneRange) vectorAdd ((_ref select 1) vectorMultiply _dangerZoneRange * tan _dangerZoneAngle),
|
|
|
|
[1,1,0,1]
|
|
|
|
] call EFUNC(common,addLineToDebugDraw);
|
|
|
|
[ _position,
|
|
|
|
_position vectorAdd (_direction vectorMultiply _dangerZoneRange) vectorDiff ((_ref select 1) vectorMultiply _dangerZoneRange * tan _dangerZoneAngle),
|
|
|
|
[1,1,0,1]
|
|
|
|
] call EFUNC(common,addLineToDebugDraw);
|
|
|
|
[ _position,
|
|
|
|
_position vectorAdd (_direction vectorMultiply _dangerZoneRange) vectorAdd ((_ref select 2) vectorMultiply _dangerZoneRange * tan _dangerZoneAngle),
|
|
|
|
[1,1,0,1]
|
|
|
|
] call EFUNC(common,addLineToDebugDraw);
|
|
|
|
[ _position,
|
|
|
|
_position vectorAdd (_direction vectorMultiply _dangerZoneRange) vectorDiff ((_ref select 2) vectorMultiply _dangerZoneRange * tan _dangerZoneAngle),
|
|
|
|
[1,1,0,1]
|
|
|
|
] call EFUNC(common,addLineToDebugDraw);
|
|
|
|
|
2015-02-15 16:14:09 +00:00
|
|
|
#endif
|