diff --git a/.hemtt/missions/test.Stratis/mission.sqm b/.hemtt/missions/test.Stratis/mission.sqm index d484f2e..14cb1c5 100644 Binary files a/.hemtt/missions/test.Stratis/mission.sqm and b/.hemtt/missions/test.Stratis/mission.sqm differ diff --git a/.hemtt/missions/~test.stratis/mission.sqm b/.hemtt/missions/~test.stratis/mission.sqm new file mode 100644 index 0000000..445979b Binary files /dev/null and b/.hemtt/missions/~test.stratis/mission.sqm differ diff --git a/.hemtt/project.toml b/.hemtt/project.toml index 4c8c4ff..e48cd9d 100644 --- a/.hemtt/project.toml +++ b/.hemtt/project.toml @@ -24,6 +24,7 @@ workshop = [ "463939057", # ACE "2369477168", # Advanced Developer Tools "3058335345", # TBD Mortars + "843577117", # RHSUSAF ] mission = "test.Stratis" diff --git a/addons/m119/XEH_PREP.hpp b/addons/m119/XEH_PREP.hpp index 0c253c5..f51f69c 100644 --- a/addons/m119/XEH_PREP.hpp +++ b/addons/m119/XEH_PREP.hpp @@ -13,3 +13,6 @@ PREP(canLoad); PREP(canUnload); PREP(load); PREP(unload); +PREP(canBeTowed); +PREP(tow); +PREP(detach); diff --git a/addons/m119/XEH_postInit.sqf b/addons/m119/XEH_postInit.sqf index 421c54b..637df1e 100644 --- a/addons/m119/XEH_postInit.sqf +++ b/addons/m119/XEH_postInit.sqf @@ -1 +1,45 @@ #include "script_component.hpp" + +// Array of all towable vehicles and the offsets +GVAR(towingList) = [ + ["B_Truck_01.*", [0.025, -4.7, -0.8], -0.21], + ["B_MRAP_01.*", [0.01, -4.33, -0.8], -0.14], + ["rhsusf_M977A4.*", [-0.05, -4.8, -0.8], -0.14], + ["rhsusf_M1117.*", [0.03, -2.72, -0.9], -0.14], + ["rhsusf_M1078.*", [-0.03, -2.77, -0.98], -0.16], + ["rhsusf_M1083.*", [-0.01, -3.32, -0.98], -0.16], + ["rhsusf_M1084.*", [-0.03, -3.82, -0.88], -0.155], + ["rhsusf_M1220.*", [-0.04, -3.4, -1.44], -0.195], + ["rhsusf_M1230.*", [-0.04, -3.6, -2.02], -0.195], + ["rhsusf_M1232.*", [-0.04, -3.52, -0.37], -0.335], + ["rhsusf_M1237.*", [-0.04, -4.37, -0.44], -0.334], + ["rhsusf_m1240a1_usarmy_.*", [0.01, -3.1, -1.78], -0.25], + ["rhsusf_m1240a1.*", [0.01, -3.76, -1.78], -0.25], + ["rhsusf_m1025.*", [-0.065, -2.48, -1.17], -0.12], + ["rhsusf_m1043.*", [-0.065, -2.48, -1.17], -0.12], + ["rhsusf_m1045.*", [-0.065, -2.48, -0.98], -0.12], + ["rhsusf_m998.*", [0, -2.4, -0.88], -0.115], + ["rhsusf_m1151.*", [-0.05, -2.53, -0.7], -0.1], + ["rhsusf_m1152.*", [-0.05, -2.52, -0.7], -0.105], + ["rhsusf_m113d.*", [0.37, -1.93, -1.69], -0.035] +]; + +[QGVAR(detached), { + private _arty = _this#0; + [_arty, true, [0, 1.2, 0], 0, true] call ace_dragging_fnc_setDraggable; +}] call CBA_fnc_addEventHandler; + +[QGVAR(towed), { + private _arty = _this#0; + [_arty, false] call ace_dragging_fnc_setDraggable; +}] call CBA_fnc_addEventHandler; + +[QGVAR(tow), { + params ["_arty", "_veh", "_offX", "_offY", "_offZ", "_offRot"]; + private _offset = _arty selectionPosition "towing_point"; + private _offset = [_offset#0 + _offX, _offset#1 + _offY, _offZ]; + _arty attachTo [_veh, _offset]; + _arty setDir -180; + _arty animateSource ["rest_rotation_source", _offRot]; + _arty setPosWorld getPosWorld _arty; +}] call CBA_fnc_addEventHandler; diff --git a/addons/m119/functions/fnc_canBeTowed.sqf b/addons/m119/functions/fnc_canBeTowed.sqf new file mode 100644 index 0000000..c397f2f --- /dev/null +++ b/addons/m119/functions/fnc_canBeTowed.sqf @@ -0,0 +1,54 @@ +/* + FILE: fnc_canBeTowed.sqf + + Name: tbd_m119_m119_fnc_canBeTowed + + Author(s): + ilbinek + + Description: + Check if the M119 can be towed + + Parameters: + _arty - object - M119 to be checked + + Returns: + bool - true if the M119 can be towed + + Examples: + > [_arty] call tbd_m119_m119_fnc_canBeTowed; + + Public: + No +*/ + +#include "..\script_component.hpp" + +params ["_arty"]; + +// check if being towed +if (_arty getVariable [QGVAR(towed), false]) exitWith {false}; + +// Check if folded +if !(_arty getVariable [QGVAR(folded), false]) exitWith {false}; + +// Get pos of the towing point +private _pos = _arty modelToWorld (_arty selectionPosition ["towing_point", "Memory"]); +private _radius = TOW_RADIUS; +private _vehicles = _pos nearEntities _radius; + + +private _canBeTowed = false; +{ + private _veh = _x; + private _class = typeOf _veh; + { + if (_class regexMatch _x#0) then { + private _p = _veh modelToWorldVisual [_x#1#0, _x#1#1, _x#1#2]; + if (_p distance _pos < ATTACH_RADIUS) exitWith { _canBeTowed = true;}; + }; + } forEach GVAR(towingList); + if (_canBeTowed) exitWith {}; +} forEach _vehicles; + +_canBeTowed diff --git a/addons/m119/functions/fnc_detach.sqf b/addons/m119/functions/fnc_detach.sqf new file mode 100644 index 0000000..2495c0f --- /dev/null +++ b/addons/m119/functions/fnc_detach.sqf @@ -0,0 +1,38 @@ +/* + FILE: fnc_detach.sqf + + Name: tbd_m119_m119_fnc_detach + + Author(s): + ilbinek + + Description: + Detach the M119 from the object + + Parameters: + _arty - object - M119 to detach + + Returns: + Nothing + + Examples: + > [_arty] call tbd_m119_m119_fnc_detach; + + Public: + No +*/ + +#include "..\script_component.hpp" + +params ["_arty"]; + +_arty setVariable [QGVAR(towed), false, false]; + +[QGVAR(detached), [_arty], QGVAR(towJIP)] call CBA_fnc_globalEventJIP; +_arty animateSource ["rest_rotation_source", 0, 10]; + +detach _arty; + +_pos = getPos _arty; +_pos set [2, 0]; +_arty setPos _pos diff --git a/addons/m119/functions/fnc_tow.sqf b/addons/m119/functions/fnc_tow.sqf new file mode 100644 index 0000000..711fb86 --- /dev/null +++ b/addons/m119/functions/fnc_tow.sqf @@ -0,0 +1,54 @@ +/* + FILE: fnc_tow.sqf + + Name: tbd_m119_m119_fnc_tow + + Author(s): + ilbinek + + Description: + Start towing the M119 howitzer + + Parameters: + _arty - object - M119 to be towed + + Returns: + Nothing + + Examples: + > [_arty] call tbd_m119_m119_fnc_tow; + + Public: + No +*/ + +#include "..\script_component.hpp" + +params ["_arty"]; + +if (!([_arty] call FUNC(canBeTowed))) exitWith {}; + +// Find the vehicle I need to attach to +// Get pos of the towing point +private _pos = _arty modelToWorld (_arty selectionPosition ["towing_point", "Memory"]); +private _radius = TOW_RADIUS; +private _vehicles = _pos nearEntities _radius; + +private _canBeTowed = false; +{ + private _veh = _x; + private _class = typeOf _veh; + { + if (_class regexMatch _x#0) then { + 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; + }; + }; + } forEach GVAR(towingList); + if (_canBeTowed) exitWith {}; +} forEach _vehicles; + +_arty setVariable [QGVAR(towed), true, true]; +[QGVAR(towed), [_vasil], QGVAR(towJIP)] call CBA_fnc_globalEventJIP; diff --git a/addons/m119/script_component.hpp b/addons/m119/script_component.hpp index ae76a3c..747eed1 100644 --- a/addons/m119/script_component.hpp +++ b/addons/m119/script_component.hpp @@ -38,3 +38,6 @@ #define TBD_MORTARS_105mm_ROUND_HE_CHARGE_MAG_5 tbd_mortars_105mm_round_he_charge_mag_5 #define TBD_MORTARS_105mm_ROUND_HE_CHARGE_MAG_6 tbd_mortars_105mm_round_he_charge_mag_6 #define TBD_MORTARS_105mm_ROUND_HE_CHARGE_MAG_7 tbd_mortars_105mm_round_he_charge_mag_7 + +#define TOW_RADIUS 10 +#define ATTACH_RADIUS 2 \ No newline at end of file diff --git a/addons/m119/stringtable.xml b/addons/m119/stringtable.xml index 8d2f8a4..487de82 100644 --- a/addons/m119/stringtable.xml +++ b/addons/m119/stringtable.xml @@ -36,5 +36,15 @@ Vybít Разрядить + + Tow + Zaháknout + Прицепить + + + Detach + Odpojit + Отсоединить + diff --git a/addons/m119/tbd_m119/CfgVehicles.hpp b/addons/m119/tbd_m119/CfgVehicles.hpp index 10010c4..b5ff3ea 100644 --- a/addons/m119/tbd_m119/CfgVehicles.hpp +++ b/addons/m119/tbd_m119/CfgVehicles.hpp @@ -229,6 +229,8 @@ class CfgVehicles { class ACE_Actions: ACE_Actions { class ACE_MainActions: ACE_MainActions { + selection = "interact"; + class TBD_Fold { distance = 2.5; condition = QUOTE([ARR_1(_target)] call FUNC(canFold)); @@ -337,6 +339,24 @@ class CfgVehicles { statement = QUOTE([ARR_2(_target,0)] call FUNC(unload)); icon = "x\tbd_mortars\addons\main\data\unload.paa"; }; + + class TBD_Tow { + selection = "towing_point"; + distance = 2.5; + condition = QUOTE([ARR_1(_target)] call FUNC(canBeTowed)); + showDisabled = 0; + displayName = CSTRING(TOW); + statement = QUOTE([ARR_1(_target)] call FUNC(tow)); + }; + + class TBD_Detach { + selection = "towing_point"; + distance = 2.5; + condition = QUOTE(_target getVariable [ARR_2(QUOTE(QGVAR(towed)),false)]); + showDisabled = 0; + displayName = CSTRING(DETACH); + statement = QUOTE([ARR_1(_target)] call FUNC(detach)); + }; }; }; };