From 8187be67829b981cfa37e48c32f8655549a55f0d Mon Sep 17 00:00:00 2001 From: Sotirios Pupakis Date: Tue, 6 Aug 2024 01:32:51 +0200 Subject: [PATCH] Fixed towing wrong orientation and locked even after unfold --- addons/m119/XEH_postInit.sqf | 39 ++++++++++++++++++++++++++++ addons/m119/functions/fnc_detach.sqf | 2 +- addons/m119/functions/fnc_fold.sqf | 19 +------------- addons/m119/functions/fnc_tow.sqf | 2 +- addons/m119/functions/fnc_unfold.sqf | 15 +---------- 5 files changed, 43 insertions(+), 34 deletions(-) diff --git a/addons/m119/XEH_postInit.sqf b/addons/m119/XEH_postInit.sqf index 7210df0..5d9b290 100644 --- a/addons/m119/XEH_postInit.sqf +++ b/addons/m119/XEH_postInit.sqf @@ -54,3 +54,42 @@ GVAR(towingList) = [ _arty setPosWorld getPosWorld _arty; }] call CBA_fnc_addEventHandler; +[QGVAR(fold), { + params ["_arty"]; + + if !([_arty] call FUNC(canFold)) exitWith {}; + + _arty lock true; + + // animate + private _curTur = _arty animationPhase "mainTurret"; + private _curGun = _arty animationPhase "mainGun"; + + _arty animateSource ["plate_back_source", 0, true]; + _arty animateSource ["plate_front_source", 1, true]; + _arty animateSource ["mainTurretT_source", -_curTur]; + _arty animateSource ["mainGunT_source", -_curGun + 0.1]; + _arty animateSource ["hydraulicsT_source", -_curGun + 0.1]; + _arty animateSource ["howitzer_rotation_source", 0, true]; + + _arty setVariable [QGVAR(folded), true, true]; + _arty enableRopeAttach true; +}] call CBA_fnc_addEventHandler;; + +[QGVAR(unfold), { + params ["_arty"]; + + if !([_arty] call FUNC(canUnfold)) exitWith {}; + + _arty lock false; + + // animate + _arty animateSource ["plate_back_source", 1, true]; + _arty animateSource ["plate_front_source", 0, true]; + _arty animateSource ["mainTurretT_source", 0]; + _arty animateSource ["mainGunT_source", 0]; + _arty animateSource ["hydraulicsT_source", 0]; + + _arty setVariable [QGVAR(folded), false, true]; + _arty enableRopeAttach true; +}] call CBA_fnc_addEventHandler; diff --git a/addons/m119/functions/fnc_detach.sqf b/addons/m119/functions/fnc_detach.sqf index 2495c0f..a63e426 100644 --- a/addons/m119/functions/fnc_detach.sqf +++ b/addons/m119/functions/fnc_detach.sqf @@ -26,7 +26,7 @@ params ["_arty"]; -_arty setVariable [QGVAR(towed), false, false]; +_arty setVariable [QGVAR(towed), false, true]; [QGVAR(detached), [_arty], QGVAR(towJIP)] call CBA_fnc_globalEventJIP; _arty animateSource ["rest_rotation_source", 0, 10]; diff --git a/addons/m119/functions/fnc_fold.sqf b/addons/m119/functions/fnc_fold.sqf index b4a7b1d..ec0b26a 100644 --- a/addons/m119/functions/fnc_fold.sqf +++ b/addons/m119/functions/fnc_fold.sqf @@ -25,21 +25,4 @@ #include "..\script_component.hpp" params ["_arty"]; - -if !([_arty] call FUNC(canFold)) exitWith {}; - -_arty lock true; - -// animate -private _curTur = _arty animationPhase "mainTurret"; -private _curGun = _arty animationPhase "mainGun"; - -_arty animateSource ["plate_back_source", 0, true]; -_arty animateSource ["plate_front_source", 1, true]; -_arty animateSource ["mainTurretT_source", -_curTur]; -_arty animateSource ["mainGunT_source", -_curGun + 0.1]; -_arty animateSource ["hydraulicsT_source", -_curGun + 0.1]; -_arty animateSource ["howitzer_rotation_source", 0, true]; - -_arty setVariable [QGVAR(folded), true, true]; -_arty enableRopeAttach true; +[QGVAR(fold), [_arty], _arty] call CBA_fnc_targetEvent; diff --git a/addons/m119/functions/fnc_tow.sqf b/addons/m119/functions/fnc_tow.sqf index 49fb8ef..d10b9ff 100644 --- a/addons/m119/functions/fnc_tow.sqf +++ b/addons/m119/functions/fnc_tow.sqf @@ -43,7 +43,7 @@ private _canBeTowed = false; private _p = _veh modelToWorldVisual [_x#1#0, _x#1#1, _x#1#2]; if (_p distance _pos < ATTACH_RADIUS) exitWith { _canBeTowed = true; - [QGVAR(tow), [_arty, _veh, _x#1#0, _x#1#1, _x#1#2, _x#2]] call CBA_fnc_serverEvent; + [QGVAR(tow), [_arty, _veh, _x#1#0, _x#1#1, _x#1#2, _x#2], _arty] call CBA_fnc_targetEvent; }; }; } forEach GVAR(towingList); diff --git a/addons/m119/functions/fnc_unfold.sqf b/addons/m119/functions/fnc_unfold.sqf index 5197755..40a4a1d 100644 --- a/addons/m119/functions/fnc_unfold.sqf +++ b/addons/m119/functions/fnc_unfold.sqf @@ -25,17 +25,4 @@ #include "..\script_component.hpp" params ["_arty"]; - -if !([_arty] call FUNC(canUnfold)) exitWith {}; - -_arty lock false; - -// animate -_arty animateSource ["plate_back_source", 1, true]; -_arty animateSource ["plate_front_source", 0, true]; -_arty animateSource ["mainTurretT_source", 0]; -_arty animateSource ["mainGunT_source", 0]; -_arty animateSource ["hydraulicsT_source", 0]; - -_arty setVariable [QGVAR(folded), false, true]; -_arty enableRopeAttach true; +[QGVAR(unfold), [_arty], _arty] call CBA_fnc_targetEvent;