/*
	FILE: fnc_eject.sqf

	Name: tbd_m119_m119_fnc_eject

	Author(s):
		ilbinek

	Description:
		Open the M119 breech

	Parameters:
		_arty	- object	- M119 to spawn the spent casing

	Returns:
		Nothing
	
	Examples:
		> [_arty] call tbd_m119_m119_fnc_eject;

	Public:
		No
*/

#include "..\script_component.hpp"

params ["_arty"];

// tbd_mortars_105mm_casing_spent
private _spawnPoint = _arty modelToWorldVisual (_arty selectionPosition ["casing_spawn", "Memory"]);
private _dirAndUp = _arty selectionVectorDirAndUp ["casing_spawn", "Memory"];

_dirAndUp set [0, _arty vectorModelToWorld _dirAndUp#0];
_dirAndUp set [1, _arty vectorModelToWorld _dirAndUp#1];

// Spawn a new magazine at this position
private _casing = createVehicle ["tbd_mortars_105mm_casing_spent", _spawnPoint, [], 0, "CAN_COLLIDE"];
_casing setVectorDirAndUp _dirAndUp;

_casing allowDamage false;

// Add vertical force to the magazine
[{params ["_casing"]; _casing addForce [_casing vectorModelToWorld [0, -100, 0], [0, 0, 0]];}, [_casing]] call CBA_fnc_execNextFrame;
