diff --git a/.hemtt/missions/test.Stratis/mission.sqm b/.hemtt/missions/test.Stratis/mission.sqm index 130ebbd..8d2c35f 100644 Binary files a/.hemtt/missions/test.Stratis/mission.sqm and b/.hemtt/missions/test.Stratis/mission.sqm differ diff --git a/addons/m119/XEH_PREP.hpp b/addons/m119/XEH_PREP.hpp index 43db6e2..1a465be 100644 --- a/addons/m119/XEH_PREP.hpp +++ b/addons/m119/XEH_PREP.hpp @@ -18,3 +18,5 @@ PREP(tow); PREP(detach); PREP(rotateLeft); PREP(rotateRight); +PREP(projectileHeightCheck); +PREP(handleLGShell); diff --git a/addons/m119/functions/fnc_fired.sqf b/addons/m119/functions/fnc_fired.sqf index 4ae1f10..0820ff7 100644 --- a/addons/m119/functions/fnc_fired.sqf +++ b/addons/m119/functions/fnc_fired.sqf @@ -46,34 +46,15 @@ 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 { - private _alt = [200, 600] select (_ammo isEqualTo "tbd_mortars_105mm_shell_ammo_laser"); - systemChat format ["%1", _alt]; - // wait 5 seconds to let the ammo get high enough - [{ - params ["_projectile", "_alt"]; - if (isNull _projectile) exitWith {}; - // Check the height of the projectile - private _pos = getPosATL _projectile; - if (_pos select 2 < _alt) exitWith {}; - - // Start a PFH that will + if (_ammo isEqualTo "tbd_mortars_105mm_shell_ammo_dpicm") then { [{ - params ["_args", "_handle"]; - _args params ["_projectile", "_alt"]; - if (isNull _projectile) exitWith { - [_handle] call CBA_fnc_removePerFrameHandler; - }; - - // Check the height of the projectile - private _pos = getPosATL _projectile; - systemChat format ["%1", _pos select 2]; - if (_pos select 2 < _alt) exitWith { - // Trigger the ammo - triggerAmmo _projectile; - [_handle] call CBA_fnc_removePerFrameHandler; - }; - }, - 0, - [_projectile, _alt]] call CBA_fnc_addPerFrameHandler; - }, [_projectile, _alt], 5] call CBA_fnc_waitAndExecute; + params ["_projectile"]; + triggerAmmo _projectile; + }, + [_projectile], + _arty getVariable [QGVAR(DPICM_FUSE_TIMER), 99999]] call CBA_fnc_waitAndExecute; + } else { + // Start projectile height check + [_projectile, _arty getVariable [QGVAR(LASER_CODE), 1111]] call FUNC(projectileHeightCheck); + }; }; diff --git a/addons/m119/functions/fnc_handleLGShell.sqf b/addons/m119/functions/fnc_handleLGShell.sqf new file mode 100644 index 0000000..5adb8a6 --- /dev/null +++ b/addons/m119/functions/fnc_handleLGShell.sqf @@ -0,0 +1,71 @@ +/* + FILE: fnc_handleLGShell.sqf + + Name: tbd_m119_m119_fnc_handleLGShell + + Author(s): + ilbinek + + Description: + Handles the LG shell fired - pretty much a workaround for the fact that Arma is bad game + + Parameters: + _arty - object - M119 that fired + + Returns: + Nothing + + Examples: + > [_arty] call tbd_m119_m119_fnc_handleLGShell; + + Public: + No +*/ + +#include "..\script_component.hpp" + +params ["_projectile", "_laserCode"]; + +private _laserMaxDetectionrange = 1000; +private _laserWavelength = [1550, 1550]; +private _seekerCone = 20; + +// Create PFH that handles all the guiding +[{ + params ["_args", "_handle"]; + _args params ["_projectile", "_laserCode", "_laserMaxDetectionrange", "_laserWavelength", "_seekerCone"]; + + if (!alive _projectile) exitWith { + [_handle] call CBA_fnc_removePerFrameHandler; + }; + + private _result = [ + getPosASL _projectile, + vectorDir _projectile, + _seekerCone, + _laserMaxDetectionrange, + _laserWavelength, + _laserCode, + _projectile + ] call ace_laser_fnc_seekerFindLaserSpot; + + // Get the ASL position of the spot + private _spot = _result#0; + + if (isNil "_spot") exitWith {}; + + private _frameTime = diag_deltaTime; + private _position = getPosASL _projectile; + (_projectile call BIS_fnc_getPitchBank) params ["_pitch", "_bank"]; + private _vectToTarget = _position vectorFromTo _spot; + private _vectToTargetDiff = _vectToTarget vectorDiff (vectorNormalized (velocity _projectile)); + private _vectorModelSpace = _projectile vectorWorldToModel _vectToTargetDiff; + private _angleX = asin (_vectorModelSpace # 0); + private _angleY = asin (_vectorModelSpace # 2); + + private _turnRate = 24 * _frameTime; // turn rate is dependant on projectile velocity + _projectile setDir (getDir _projectile) + (_angleX min _turnRate max - _turnRate); + [_projectile, _pitch + (_angleY min _turnRate max -_turnRate), 0] call BIS_fnc_setPitchBank; +}, +0, +[_projectile, _laserCode, _laserMaxDetectionrange, _laserWavelength, _seekerCone]] call CBA_fnc_addPerFrameHandler; diff --git a/addons/m119/functions/fnc_load.sqf b/addons/m119/functions/fnc_load.sqf index 8618dbb..b1a6cf5 100644 --- a/addons/m119/functions/fnc_load.sqf +++ b/addons/m119/functions/fnc_load.sqf @@ -71,7 +71,17 @@ switch (_shell) do { // Delete closest private _veh = nearestObjects [player, [_shell], 3]; { - if (typeOf _x == _shell) exitWith {deleteVehicle _x}; + if (typeOf _x == _shell) exitWith { + if (_x isKindOf QUOTE(TBD_MORTARS_105mm_ROUND_DPICM_CHARGE_1)) then { + private _timer = _x getVariable ["tbd_mortars_105mm_dpicm_fuse_timer", 99999]; + _arty setVariable [QGVAR(DPICM_FUSE_TIMER), _timer, true]; + }; + if (_x isKindOf QUOTE(TBD_MORTARS_105mm_ROUND_LASER_CHARGE_1)) then { + private _code = _x getVariable ["tbd_mortars_105mm_laser_code", 1111]; + _arty setVariable [QGVAR(LASER_CODE), _code, true]; + }; + deleteVehicle _x + }; } forEach _veh; if ("laser" in _shell) exitWith { @@ -94,3 +104,7 @@ if ("dpicm" in _shell) exitWith { _arty animateSource ["magazine_load_source", 0, true]; _arty animateSource ["magazine_hide_source", 0, true]; _arty animateSource ["magazine_load_source", 0.36, 0.2]; + + + +["cba_xeh_deleted","ace_dragging_candrag","ace_common_effect_blockdamage","ace_interact_menu_atcache_ace_mainactions","cba_xeh_incomingmissile","cba_xeh_getin","ace_dragging_carryposition","ace_dragging_originalmass","ace_common_statuseffect_object","ace_dragging_carrydirection_temp","cba_xeh_local","cba_xeh_isprocessed","cba_xeh_init","cba_xeh_initpost","cba_xeh_fired","ace_dragging_dragposition","cba_xeh_engine","cba_xeh_respawn","ace_dragging_dragdirection","ace_dragging_cancarry","ace_interact_menu_atcache_ace_dragging_drop","ace_common_lockstatus","cba_xeh_killed","ace_dragging_carrydirection","ace_interact_menu_atcache_ace_dragging_drop_carry","cba_xeh_getout","cba_xeh_isinitialized","ace_dragging_ignoreweightdrag","ace_common_owner","tbd_mortars_105mm_dpicm_fuse_timer","ace_dragging_ignoreweightcarry"] \ No newline at end of file diff --git a/addons/m119/functions/fnc_projectileHeightCheck.sqf b/addons/m119/functions/fnc_projectileHeightCheck.sqf new file mode 100644 index 0000000..5d8c2fb --- /dev/null +++ b/addons/m119/functions/fnc_projectileHeightCheck.sqf @@ -0,0 +1,47 @@ +/* + FILE: fnc_projectileHeightCheck.sqf.sqf + + Name: tbd_m119_m119_fnc_projectileHeightCheck.sqf + + 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: + _projectile - object - The projectile + + Returns: + Nothing + + Examples: + > [_projectile] call tbd_m119_m119_fnc_projectileHeightCheck.sqf; + + Public: + No +*/ + +#include "..\script_component.hpp" + +params ["_projectile", "_laserCode"]; +GVAR(projectileHeightCheck) = 0; +[{ + params ["_args", "_handle"]; + _args params ["_projectile", "_laserCode"]; + + if (isNull _projectile) exitWith { + [_handle] call CBA_fnc_removePerFrameHandler; + }; + + private _pos = getPosASL _projectile; + private _height = _pos select 2; + if (_height < GVAR(projectileHeightCheck)) then { + [_projectile, _laserCode] call FUNC(handleLGShell); + [_handle] call CBA_fnc_removePerFrameHandler; + }; + + GVAR(projectileHeightCheck) = _height; +}, +0, +[_projectile, _laserCode]] call CBA_fnc_addPerFrameHandler;