2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2022-03-07 18:25:55 +00:00
|
|
|
/*
|
2022-09-08 12:41:52 +00:00
|
|
|
* Author: GhostIsSpooky, veteran29
|
2022-03-07 18:25:55 +00:00
|
|
|
* Handler for 'detonation' of a local punji trap. Workaround for local-only ammo hit event.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Punji trap <OBJECT>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [trap] call ace_compat_sog_fnc_handlePunjiTrapTrigger
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
params ["_trap"];
|
2024-01-01 01:45:01 +00:00
|
|
|
if (!(["ace_medical"] call EFUNC(common,isModLoaded))) exitWith {};
|
2022-03-07 18:25:55 +00:00
|
|
|
|
|
|
|
private _radius = getNumber (configOf _trap >> "indirectHitRange");
|
2022-09-08 12:41:52 +00:00
|
|
|
private _affectedUnits = _trap nearEntities ["CAManBase", _radius];
|
|
|
|
|
|
|
|
private _spikesOffset = [configOf _trap >> QGVAR(spikesOffset), "ARRAY", [0,0,0]] call CBA_fnc_getConfigEntry;
|
|
|
|
if (_spikesOffset isNotEqualTo [0,0,0]) then {
|
|
|
|
private _spikesPos = _trap modelToWorld _spikesOffset;
|
|
|
|
private _spikesCheckSelection = getText (configOf _trap >> QGVAR(spikesCheckSelection));
|
|
|
|
private _spikesCheckRadius = getNumber (configOf _trap >> QGVAR(spikesCheckRadius));
|
|
|
|
|
|
|
|
TRACE_3("Using spikes offset for affected units",_spikesOffset,_spikesCheckSelection,_spikesCheckRadius);
|
|
|
|
|
|
|
|
_affectedUnits = _affectedUnits select {
|
|
|
|
private _distance = _spikesPos distance (_x modelToWorld (_x selectionPosition _spikesCheckSelection));
|
|
|
|
|
|
|
|
_distance <= _spikesCheckRadius // return
|
|
|
|
};
|
|
|
|
};
|
2022-03-07 18:25:55 +00:00
|
|
|
|
|
|
|
if (_affectedUnits isEqualTo []) exitWith {};
|
|
|
|
|
|
|
|
[QGVAR(handlePunjiTrapDamage), [_trap, _affectedUnits], _affectedUnits] call CBA_fnc_targetEvent;
|