From ccd7b9cdebbc12b9dca03be4e67cbc55b535fad1 Mon Sep 17 00:00:00 2001 From: Sotirios Pupakis Date: Mon, 22 Apr 2024 16:16:17 +0200 Subject: [PATCH] folding --- addons/m119/XEH_PREP.hpp | 4 ++ addons/m119/functions/fnc_canCloseBreech.sqf | 2 +- addons/m119/functions/fnc_canFold.sqf | 33 +++++++++++++++ addons/m119/functions/fnc_canOpenBreech.sqf | 2 +- addons/m119/functions/fnc_canUnfold.sqf | 32 +++++++++++++++ addons/m119/functions/fnc_fold.sqf | 43 ++++++++++++++++++++ addons/m119/functions/fnc_init.sqf | 1 + addons/m119/functions/fnc_unfold.sqf | 40 ++++++++++++++++++ addons/m119/tbd_m119/CfgVehicles.hpp | 37 ++++++++++++++++- addons/m119/tbd_m119/model.cfg | 7 ++++ 10 files changed, 198 insertions(+), 3 deletions(-) create mode 100644 addons/m119/functions/fnc_canFold.sqf create mode 100644 addons/m119/functions/fnc_canUnfold.sqf create mode 100644 addons/m119/functions/fnc_fold.sqf create mode 100644 addons/m119/functions/fnc_unfold.sqf diff --git a/addons/m119/XEH_PREP.hpp b/addons/m119/XEH_PREP.hpp index bfe4ee7..6c9efe1 100644 --- a/addons/m119/XEH_PREP.hpp +++ b/addons/m119/XEH_PREP.hpp @@ -3,3 +3,7 @@ PREP(canOpenBreech); PREP(canCloseBreech); PREP(openBreech); PREP(closeBreech); +PREP(canFold); +PREP(canUnfold); +PREP(fold); +PREP(unfold); diff --git a/addons/m119/functions/fnc_canCloseBreech.sqf b/addons/m119/functions/fnc_canCloseBreech.sqf index 18a8053..05a4483 100644 --- a/addons/m119/functions/fnc_canCloseBreech.sqf +++ b/addons/m119/functions/fnc_canCloseBreech.sqf @@ -14,7 +14,7 @@ _arty - object - M119 to be canCloseBreeched Returns: - Nothing + bool - true if the breech can be closed, false otherwise Examples: > [_arty] call tbd_m119_m119_fnc_canCloseBreech; diff --git a/addons/m119/functions/fnc_canFold.sqf b/addons/m119/functions/fnc_canFold.sqf new file mode 100644 index 0000000..506483c --- /dev/null +++ b/addons/m119/functions/fnc_canFold.sqf @@ -0,0 +1,33 @@ +/* + FILE: fnc_canFold.sqf + + Name: tbd_m119_m119_fnc_canFold + + Author(s): + ilbinek + + Description: + Check if the M119 can be folded + + Parameters: + _arty - object - M119 to be checked + + Returns: + bool - true if the M119 can be folded, false otherwise + + Examples: + > [_arty] call tbd_m119_m119_fnc_canFold; + + Public: + No +*/ + +#include "..\script_component.hpp" + +params ["_arty"]; + +if (_arty getVariable [QGVAR(folded), false]) exitWith {false}; + +if (count crew _arty > 0) exitWith {false}; + +true diff --git a/addons/m119/functions/fnc_canOpenBreech.sqf b/addons/m119/functions/fnc_canOpenBreech.sqf index 82dd5ae..31193e3 100644 --- a/addons/m119/functions/fnc_canOpenBreech.sqf +++ b/addons/m119/functions/fnc_canOpenBreech.sqf @@ -14,7 +14,7 @@ _arty - object - M119 to be canCloseBreeched Returns: - Nothing + bool - true if the breech can be opened, false otherwise Examples: > [_arty] call tbd_m119_m119_fnc_canOpenBreech; diff --git a/addons/m119/functions/fnc_canUnfold.sqf b/addons/m119/functions/fnc_canUnfold.sqf new file mode 100644 index 0000000..499acb6 --- /dev/null +++ b/addons/m119/functions/fnc_canUnfold.sqf @@ -0,0 +1,32 @@ +/* + FILE: fnc_canUnFold.sqf + + Name: tbd_m119_m119_fnc_canUnFold + + Author(s): + ilbinek + + Description: + Check if the M119 can be unfolded + + Parameters: + _arty - object - M119 to be checked + + Returns: + bool - true if the M119 can be unfolded, false otherwise + + Examples: + > [_arty] call tbd_m119_m119_fnc_canUnFold; + + Public: + No +*/ + +#include "..\script_component.hpp" + +params ["_arty"]; + +if !(_arty getVariable [QGVAR(folded), false]) exitWith {false}; +if (_arty getVariable [QGVAR(towed), false]) exitWith {false}; + +true diff --git a/addons/m119/functions/fnc_fold.sqf b/addons/m119/functions/fnc_fold.sqf new file mode 100644 index 0000000..9b0dfd7 --- /dev/null +++ b/addons/m119/functions/fnc_fold.sqf @@ -0,0 +1,43 @@ +/* + FILE: fnc_fold.sqf + + Name: tbd_m119_m119_fnc_fold + + Author(s): + ilbinek + + Description: + Fold the M119 + + Parameters: + _arty - object - M119 to be folded + + Returns: + Nothing + + Examples: + > [_arty] call tbd_m119_m119_fnc_fold; + + Public: + No +*/ + +#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]; +_arty animateSource ["plate_front_source", 1]; +_arty animateSource ["mainTurretT_source", -_curTur]; +_arty animateSource ["mainGunT_source", -_curGun + 0.1]; + +_arty setVariable [QGVAR(folded), true, true]; +_arty setMass 750; diff --git a/addons/m119/functions/fnc_init.sqf b/addons/m119/functions/fnc_init.sqf index 9ce2f42..4373581 100644 --- a/addons/m119/functions/fnc_init.sqf +++ b/addons/m119/functions/fnc_init.sqf @@ -30,4 +30,5 @@ params ["_arty"]; _arty setVariable [QGVAR(folded), false, true]; _arty setVariable [QGVAR(breech), false, true]; _arty setVariable [QGVAR(loaded), false, true]; +_arty setVariable [QGVAR(towed), false, true]; _arty setVariable [QGVAR(fired), false, true]; diff --git a/addons/m119/functions/fnc_unfold.sqf b/addons/m119/functions/fnc_unfold.sqf new file mode 100644 index 0000000..ccf9fbc --- /dev/null +++ b/addons/m119/functions/fnc_unfold.sqf @@ -0,0 +1,40 @@ +/* + FILE: fnc_unfold.sqf + + Name: tbd_m119_m119_fnc_unfold + + Author(s): + ilbinek + + Description: + Fold the M119 + + Parameters: + _arty - object - M119 to be unfolded + + Returns: + Nothing + + Examples: + > [_arty] call tbd_m119_m119_fnc_unfold; + + Public: + No +*/ + +#include "..\script_component.hpp" + +params ["_arty"]; + +if !([_arty] call FUNC(canUnfold)) exitWith {}; + +_arty lock false; + +// animate +_arty animateSource ["plate_back_source", 1]; +_arty animateSource ["plate_front_source", 0]; +_arty animateSource ["mainTurretT_source", 0]; +_arty animateSource ["mainGunT_source", 0]; + +_arty setVariable [QGVAR(folded), false, true]; +_arty setMass 350000; diff --git a/addons/m119/tbd_m119/CfgVehicles.hpp b/addons/m119/tbd_m119/CfgVehicles.hpp index 316d2fe..55f0604 100644 --- a/addons/m119/tbd_m119/CfgVehicles.hpp +++ b/addons/m119/tbd_m119/CfgVehicles.hpp @@ -111,7 +111,6 @@ class CfgVehicles { ace_dragging_ignoreWeight = 1; class AnimationSources { - class carriage_rotation_source { source = "user"; initPhase = 0; @@ -129,31 +128,37 @@ class CfgVehicles { initPhase = 0; animPeriod = 1; }; + class leftwheel_source { source = "user"; initPhase = 0; animPeriod = 1; }; + class trigger_source { source = "user"; initPhase = 0; animPeriod = 1; }; + class plate_back_source { source = "user"; initPhase = 1; animPeriod = 1; }; + class plate_front_source { source = "user"; initPhase = 0; animPeriod = 1; }; + class recoil_rest_source { source = "user"; initPhase = 0; animPeriod = 1; }; + class recoil_barrel_source { source = "user"; initPhase = 0; @@ -174,11 +179,13 @@ class CfgVehicles { animPeriod = 0.5; }; + class hydraulics_source { source = "user"; initPhase = 0; animPeriod = 1; }; + class small_wheel_source { source = "user"; initPhase = 0; @@ -201,9 +208,37 @@ class CfgVehicles { initPhase = 1; animPeriod = 0; }; + + class mainTurretT_source { + source = "user"; + initPhase = 0; + animPeriod = 1; + }; + + class mainGunT_source { + source = "user"; + initPhase = 0; + animPeriod = 1; + }; }; class ACE_Actions: ACE_Actions { + class ACE_MainActions: ACE_MainActions { + class TBD_Fold { + distance = 2.5; + condition = QUOTE([ARR_1(_target)] call FUNC(canFold)); + displayName = CSTRING(fold); + statement = QUOTE([ARR_1(_target)] call FUNC(fold)); + }; + + class TBD_Unfold { + distance = 2.5; + condition = QUOTE([ARR_1(_target)] call FUNC(canUnfold)); + displayName = CSTRING(unfold); + statement = QUOTE([ARR_1(_target)] call FUNC(unfold)); + }; + }; + class TBD_OpenBreech { selection = "int_handle_breech"; distance = 1.5; diff --git a/addons/m119/tbd_m119/model.cfg b/addons/m119/tbd_m119/model.cfg index 30b3e4c..37170c3 100644 --- a/addons/m119/tbd_m119/model.cfg +++ b/addons/m119/tbd_m119/model.cfg @@ -101,6 +101,9 @@ class Animations memory = 1; }; + class MainTurretT: MainTurret { + source = "mainTurretT_source"; + }; class rotation_handle_horizontal { type = "rotation"; @@ -151,6 +154,10 @@ class Animations angle1 = "rad +360"; }; + class MainGunT: MainGun { + source = "mainGunT_source" + }; + class recoil_rest { type="translation";