diff --git a/addons/unflipping/CfgFunctions.hpp b/addons/unflipping/CfgFunctions.hpp index 5873568..0c60d79 100644 --- a/addons/unflipping/CfgFunctions.hpp +++ b/addons/unflipping/CfgFunctions.hpp @@ -8,10 +8,13 @@ class CfgFunctions file = "vet\unflipping\functions"; 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/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..b047794 --- /dev/null +++ b/addons/unflipping/functions/fn_canUnflipLocal.sqf @@ -0,0 +1,28 @@ +/* + vet_unflipping_fnc_canUnflipLocal + + File: fn_canUnflipLocal.sqf + Date: 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: + 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} +&& {[_unit, _target] call vet_unflipping_fnc_isServiceVehicleNearRequired} 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]] 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..a706111 --- /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-07-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 [_target, ["Air", "LandVehicle", "Slingload_base_F"], 5 + sizeOf typeOf _target]; + +// 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 +