Files
m119/addons/m119/functions/fnc_fired.sqf
Sotirios Pupakis 95ae949b98 Cluster fix - LG should be fixed too but weird behaviour
Possible error with LG ammo in TBD Mortars and not here, need to investigate
2024-05-31 03:45:27 +02:00

76 lines
2.0 KiB
Plaintext

/*
FILE: fnc_fired.sqf
Name: tbd_m119_m119_fnc_fired
Author(s):
ilbinek
Description:
Fired EH for the M119. This script is called when the M119 is fired. It animates the recoil of the M119.
Parameters:
_arty - object - M119 that fired
Returns:
Nothing
Examples:
> [_arty] call tbd_m119_m119_fnc_fired;
Public:
No
*/
#include "..\script_component.hpp"
params ["_arty", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"];
_arty animateSource ["recoil_rest_source", 0.5, 5];
_arty animateSource ["recoil_barrel_source", 2, 20];
[{params ["_arty"]; _arty animateSource ["recoil_barrel_source", 0];}, [_arty], 0.3] call CBA_fnc_waitAndExecute;
[{params ["_arty"]; _arty animateSource ["recoil_rest_source", 0, 0.2];}, [_arty], 0.1] call CBA_fnc_waitAndExecute;
_arty setVariable [QGVAR(fired), true, true];
private _mags = _arty magazinesTurret [0];
{
_arty removeMagazinesTurret [_x, [0]];
} forEach _mags;
_arty animateSource ["magazine_hide_source", 1, true];
_arty animateSource ["magazine_load_source", 0, true];
// Server only - TODO Test and move up
if (!isServer) exitWith {};
// "Temp" fix for cluster and laser guided because BI?
if (_ammo in ["tbd_mortars_105mm_shell_ammo_dpicm" /*"tbd_mortars_105mm_shell_ammo_laser"*/]) then {
// wait 5 seconds to let the ammo get high enough
[{
params ["_projectile"];
if (isNull _projectile) exitWith {};
// Check the height of the projectile
private _pos = getPosATL _projectile;
if (_pos select 2 < 200) exitWith {};
// Start a PFH that will
[{
params ["_projectile", "_handle"];
if (isNull _projectile) exitWith {
[_handle] call CBA_fnc_removePerFrameHandler;
};
// Check the height of the projectile
private _pos = getPosATL _projectile;
if (_pos select 2 < 200) exitWith {
// Trigger the ammo
triggerAmmo _projectile;
[_handle] call CBA_fnc_removePerFrameHandler;
};
},
0,
_projectile] call CBA_fnc_addPerFrameHandler;
}, [_projectile], 5] call CBA_fnc_waitAndExecute;
};