diff --git a/addons/aar/events/fn_eventVehicleFired.sqf b/addons/aar/events/fn_eventVehicleFired.sqf index 526b48f..a17190d 100644 --- a/addons/aar/events/fn_eventVehicleFired.sqf +++ b/addons/aar/events/fn_eventVehicleFired.sqf @@ -17,4 +17,4 @@ private _arr = ["object", ]; _arr call anrop_aar_fnc_sendEvent; -[_projectile, _side] spawn anrop_aar_fnc_trackProjectile; +[_projectile, _side] call anrop_aar_fnc_trackProjectile; diff --git a/addons/aar/functions/fn_trackProjectile.sqf b/addons/aar/functions/fn_trackProjectile.sqf index fa1a95c..093b0e6 100644 --- a/addons/aar/functions/fn_trackProjectile.sqf +++ b/addons/aar/functions/fn_trackProjectile.sqf @@ -1,34 +1,22 @@ params ["_projectile", "_side"]; private _id = format ["%1", _projectile]; -private _position = getPosASL _projectile; -private _dir = direction _projectile; - private _simulation = getText (configFile >> "cfgAmmo" >> typeOf _projectile >> "simulation"); -private _lastTime = time; - -waitUntil { - if !(isNull _projectile) then { - _dir = direction _projectile; - _position = getPosASL _projectile; - - if (time >= (_lastTime + 1)) then { - _lastTime = time; +[{ + params ["_args", "_handle"]; + _args params ["_projectile", "_id", "_side", "_simulation"]; - private _arr = ["object", - ["type", ["string", "ProjectilePosition"]], - ["projectile", [_id, ([_position, _dir] call anrop_aar_fnc_serializePosition), _side, _simulation] call anrop_aar_fnc_serializeProjectile] - ]; - _arr call anrop_aar_fnc_sendEvent; - }; + if (isNull _projectile) exitWith { + _handle call CBA_fnc_removePerFrameHandler; }; - isNull _projectile; -}; + _dir = direction _projectile; + _position = getPosASL _projectile; -private _arr = ["object", - ["type", ["string", "ProjectileDestroyed"]], - ["projectile", [_id, ([_position, _dir] call anrop_aar_fnc_serializePosition), _side, _simulation] call anrop_aar_fnc_serializeProjectile] -]; -_arr call anrop_aar_fnc_sendEvent; + private _arr = ["object", + ["type", ["string", "ProjectilePosition"]], + ["projectile", [_id, ([_position, _dir] call anrop_aar_fnc_serializePosition), _side, _simulation] call anrop_aar_fnc_serializeProjectile] + ]; + _arr call anrop_aar_fnc_sendEvent; +}, 1, [_projectile, _id, _side, _simulation]] call CBA_fnc_addPerFrameHandler;