From 39b9df656ea3af124a39f09d98fb0036cfc06d6f Mon Sep 17 00:00:00 2001 From: Filip Maciejewski Date: Tue, 18 Jun 2019 20:02:43 +0200 Subject: [PATCH 1/4] Move unflip action condition to single function --- addons/unflipping/CfgFunctions.hpp | 1 + addons/unflipping/XEH_preInitClient.sqf | 4 +-- .../functions/fn_addUnflipActionLocal.sqf | 7 ++--- .../functions/fn_canUnflipLocal.sqf | 27 +++++++++++++++++++ .../functions/fn_hasToolKitRequired.sqf | 4 +-- 5 files changed, 33 insertions(+), 10 deletions(-) create mode 100644 addons/unflipping/functions/fn_canUnflipLocal.sqf diff --git a/addons/unflipping/CfgFunctions.hpp b/addons/unflipping/CfgFunctions.hpp index 5873568..a5b61a2 100644 --- a/addons/unflipping/CfgFunctions.hpp +++ b/addons/unflipping/CfgFunctions.hpp @@ -8,6 +8,7 @@ class CfgFunctions file = "vet\unflipping\functions"; class addUnflipActionLocal {}; + class canUnflipLocal {}; class unflipAction {}; class unflipRequiredAmount {}; class unflipVehicle {}; diff --git a/addons/unflipping/XEH_preInitClient.sqf b/addons/unflipping/XEH_preInitClient.sqf index 556f850..6cbaa4b 100644 --- a/addons/unflipping/XEH_preInitClient.sqf +++ b/addons/unflipping/XEH_preInitClient.sqf @@ -66,10 +66,8 @@ if (isClass(configFile >> "CfgPatches" >> "ace_main")) then { }, { [_player, _target, []] call ACE_common_fnc_canInteractWith - && !canMove _target - && {alive _target && (vehicle _player) isEqualTo _player} && {!(_target isKindOf "Boxloader_Pallet_base")} - && {[_player] call vet_unflipping_fnc_hasToolKitRequired} + && {[_player, _target] call vet_unflipping_fnc_canUnflipLocal} } ] call ACE_interact_menu_fnc_createAction; ["LandVehicle", 0, ["ACE_MainActions"], _unflipAction, true] call ACE_interact_menu_fnc_addActionToClass; diff --git a/addons/unflipping/functions/fn_addUnflipActionLocal.sqf b/addons/unflipping/functions/fn_addUnflipActionLocal.sqf index 22baec7..ecd6416 100644 --- a/addons/unflipping/functions/fn_addUnflipActionLocal.sqf +++ b/addons/unflipping/functions/fn_addUnflipActionLocal.sqf @@ -3,7 +3,7 @@ File: fn_addUnflipAction.sqf Date: 2019-04-01 - Last Update: 2019-04-08 + Last Update: 2019-06-18 License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html Description: @@ -33,10 +33,7 @@ private _action = [ true, "", " - !canMove _target - && {alive _target - && {vehicle _this) isEqualTo _this} - && {[_this] call vet_unflipping_fnc_hasToolKitRequired} + [_this, _target] call vet_unflipping_fnc_canUnflipLocal ", // _target, _this, _originalTarget 8 ]; diff --git a/addons/unflipping/functions/fn_canUnflipLocal.sqf b/addons/unflipping/functions/fn_canUnflipLocal.sqf new file mode 100644 index 0000000..5f3dc2a --- /dev/null +++ b/addons/unflipping/functions/fn_canUnflipLocal.sqf @@ -0,0 +1,27 @@ +/* + vet_unflipping_fnc_canUnflipLocal + + File: fn_canUnflipLocal.sqf + Date: 2019-06-18 + Last Update: 2019-06-18 + License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html + + Description: + Checks if unit can unflip the target. + + Parameter(s): + _unit - Unit to check [OBJECT, defaults to objNull] + _target - Vehicle that is unflipped [OBJECT, defaults to objNull] + + Returns: + Target can be unflipped [BOOL] +*/ +params [ + ["_unit", objNull, [objNull]], + ["_target", objNull, [objNull]] +]; + +!canMove _target +&& {alive _target} +&& {(vehicle _unit) isEqualTo _unit} +&& {_unit call vet_unflipping_fnc_hasToolKitRequired} diff --git a/addons/unflipping/functions/fn_hasToolKitRequired.sqf b/addons/unflipping/functions/fn_hasToolKitRequired.sqf index 5fd89ac..aceed27 100644 --- a/addons/unflipping/functions/fn_hasToolKitRequired.sqf +++ b/addons/unflipping/functions/fn_hasToolKitRequired.sqf @@ -3,7 +3,7 @@ File: fn_hasToolKitRequired.sqf Date: 2019-03-18 - Last Update: 2019-04-18 + Last Update: 2019-06-18 License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html Description: @@ -13,7 +13,7 @@ _unit - Unit to check [OBJECT, defaults to objNull] Returns: - NOTHING + Can unflip [BOOL] */ params [ ["_unit", objNull, [objNull]] From 7be104a837c1066f0b3532f186397c46310fede7 Mon Sep 17 00:00:00 2001 From: Filip Maciejewski Date: Tue, 18 Jun 2019 20:04:05 +0200 Subject: [PATCH 2/4] Add functions and setting for repair vehicle check --- addons/unflipping/CfgFunctions.hpp | 4 ++- .../functions/fn_isRepairVehicle.sqf | 33 +++++++++++++++++++ .../fn_isServiceVehicleNearRequired.sqf | 29 ++++++++++++++++ addons/unflipping/initSettings.sqf | 20 ++++++++--- addons/unflipping/stringtable.xml | 4 +++ 5 files changed, 84 insertions(+), 6 deletions(-) create mode 100644 addons/unflipping/functions/fn_isRepairVehicle.sqf create mode 100644 addons/unflipping/functions/fn_isServiceVehicleNearRequired.sqf diff --git a/addons/unflipping/CfgFunctions.hpp b/addons/unflipping/CfgFunctions.hpp index a5b61a2..0c60d79 100644 --- a/addons/unflipping/CfgFunctions.hpp +++ b/addons/unflipping/CfgFunctions.hpp @@ -9,10 +9,12 @@ class CfgFunctions class addUnflipActionLocal {}; class canUnflipLocal {}; + class hasToolKitRequired {}; + class isRepairVehicle {}; + class isServiceVehicleNearRequired {}; class unflipAction {}; class unflipRequiredAmount {}; class unflipVehicle {}; - class hasToolKitRequired {}; }; class debug diff --git a/addons/unflipping/functions/fn_isRepairVehicle.sqf b/addons/unflipping/functions/fn_isRepairVehicle.sqf new file mode 100644 index 0000000..2b5fbf7 --- /dev/null +++ b/addons/unflipping/functions/fn_isRepairVehicle.sqf @@ -0,0 +1,33 @@ +/* + vet_unflipping_fnc_isRepairVehicle + + File: fn_isRepairVehicle.sqf + Date: 2019-06-18 + Last Update: 2019-06-18 + License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html + + Description: + Checks if vehicle is an repair vehicle. + + Parameter(s): + _vehicle - Vehicle to check [OBJECT, defaults to objNull] + + Returns: + Is vehicle an repair vehicle [BOOL] +*/ +params [ + ["_vehicle", objNull, [objNull]] +]; + +if (_vehicle isKindOf "CAManBase") exitWith {false}; + + +if (isClass(configFile >> "CfgPatches" >> "ace_repair")) then { + // Value can be integer or boolean + private _value = _vehicle getVariable ["ACE_isRepairVehicle", getNumber (configFile >> "CfgVehicles" >> typeOf _vehicle >> "ace_repair_canRepair")]; + // return + _value in [1, true] +} else { + // return + (getRepairCargo _vehicle) > 0 +}; diff --git a/addons/unflipping/functions/fn_isServiceVehicleNearRequired.sqf b/addons/unflipping/functions/fn_isServiceVehicleNearRequired.sqf new file mode 100644 index 0000000..4c7f4bc --- /dev/null +++ b/addons/unflipping/functions/fn_isServiceVehicleNearRequired.sqf @@ -0,0 +1,29 @@ +/* + vet_unflipping_fnc_isServiceVehicleNearRequired + + File: fn_isServiceVehicleNearRequired..sqf + Date: 2019-06-18 + Last Update: 2019-06-18 + License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html + + Description: + Checks if the service vehicle is required, and whether or not it is nearby. + + Parameter(s): + _unit - Unit to check [OBJECT, defaults to objNull] + _target - Vehicle that is unflipped [OBJECT, defaults to objNull] + + Returns: + Function reached the end [BOOL] +*/ +params [ + ["_unit", objNull, [objNull]], + ["_target", objNull, [objNull]] +]; + +if !(vet_unflipping_require_serviceVehicle) exitWith {true}; + +private _nearObjects = nearestObjects [_unit, ["Air", "LandVehicle", "Slingload_base_F"], 20]; + +// return +_nearObjects findIf {alive _x && {_x call vet_unflipping_fnc_isRepairVehicle}} != -1 diff --git a/addons/unflipping/initSettings.sqf b/addons/unflipping/initSettings.sqf index e48f32f..08b7873 100644 --- a/addons/unflipping/initSettings.sqf +++ b/addons/unflipping/initSettings.sqf @@ -9,7 +9,7 @@ [0, 100000, 3000, 0], true, {} -] call CBA_Settings_fnc_init; +] call CBA_fnc_addSetting; [ "vet_unflipping_unit_man_limit", @@ -19,7 +19,7 @@ [1, 100, 7, 0], true, {} -] call CBA_Settings_fnc_init; +] call CBA_fnc_addSetting; [ "vet_unflipping_time", @@ -29,7 +29,7 @@ [1, 600, 5, 0], true, {} -] call CBA_Settings_fnc_init; +] call CBA_fnc_addSetting; [ "vet_unflipping_vehicle_mass_limit", @@ -39,7 +39,7 @@ [0, 100000, 100000, 0], true, {} -] call CBA_Settings_fnc_init; +] call CBA_fnc_addSetting; [ "vet_unflipping_require_toolkit", @@ -49,4 +49,14 @@ false, true, {} -] call CBA_Settings_fnc_init; +] call CBA_fnc_addSetting; + +[ + "vet_unflipping_require_serviceVehicle", + "CHECKBOX", + [localize "STR_vet_unflipping_require_serviceVehicle", localize "STR_vet_unflipping_require_serviceVehicle"], + SETTINGS_CAT, + false, + true, + {} +] call CBA_fnc_addSetting; diff --git a/addons/unflipping/stringtable.xml b/addons/unflipping/stringtable.xml index 6f14d9e..f5f87e6 100644 --- a/addons/unflipping/stringtable.xml +++ b/addons/unflipping/stringtable.xml @@ -92,6 +92,10 @@ Un kit de herramientas es requerido para voltear vehículos 需要携带工具包才能翻正载具 + + Require repair vehicle to unflip vehicle + Wymagaj pojazdu naprawczego do odwracania pojazdów + From 3b0b0b44efc98c15b94ddddfb83c2f55c0bd9a25 Mon Sep 17 00:00:00 2001 From: Filip Maciejewski Date: Thu, 18 Jul 2019 16:07:26 +0200 Subject: [PATCH 3/4] Service vehicle search radius depends on target size --- .../unflipping/functions/fn_isServiceVehicleNearRequired.sqf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/unflipping/functions/fn_isServiceVehicleNearRequired.sqf b/addons/unflipping/functions/fn_isServiceVehicleNearRequired.sqf index 4c7f4bc..a706111 100644 --- a/addons/unflipping/functions/fn_isServiceVehicleNearRequired.sqf +++ b/addons/unflipping/functions/fn_isServiceVehicleNearRequired.sqf @@ -3,7 +3,7 @@ File: fn_isServiceVehicleNearRequired..sqf Date: 2019-06-18 - Last Update: 2019-06-18 + Last Update: 2019-07-18 License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html Description: @@ -23,7 +23,7 @@ params [ if !(vet_unflipping_require_serviceVehicle) exitWith {true}; -private _nearObjects = nearestObjects [_unit, ["Air", "LandVehicle", "Slingload_base_F"], 20]; +private _nearObjects = nearestObjects [_target, ["Air", "LandVehicle", "Slingload_base_F"], 5 + sizeOf typeOf _target]; // return _nearObjects findIf {alive _x && {_x call vet_unflipping_fnc_isRepairVehicle}} != -1 From 15a2d3e5d97a894a9635e91383c9e55885ba91a0 Mon Sep 17 00:00:00 2001 From: Filip Maciejewski Date: Thu, 18 Jul 2019 16:07:34 +0200 Subject: [PATCH 4/4] Enable service vehicle checks --- addons/unflipping/functions/fn_canUnflipLocal.sqf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/unflipping/functions/fn_canUnflipLocal.sqf b/addons/unflipping/functions/fn_canUnflipLocal.sqf index 5f3dc2a..b047794 100644 --- a/addons/unflipping/functions/fn_canUnflipLocal.sqf +++ b/addons/unflipping/functions/fn_canUnflipLocal.sqf @@ -3,7 +3,7 @@ File: fn_canUnflipLocal.sqf Date: 2019-06-18 - Last Update: 2019-06-18 + Last Update: 2019-07-18 License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html Description: @@ -25,3 +25,4 @@ params [ && {alive _target} && {(vehicle _unit) isEqualTo _unit} && {_unit call vet_unflipping_fnc_hasToolKitRequired} +&& {[_unit, _target] call vet_unflipping_fnc_isServiceVehicleNearRequired}