Skip to content

Commit

Permalink
Merge pull request #22 from veteran29/repair-vehicle-requirement
Browse files Browse the repository at this point in the history
Repair vehicle requirement
  • Loading branch information
veteran29 authored Jul 18, 2019
2 parents a88640a + 15a2d3e commit 0453d4d
Show file tree
Hide file tree
Showing 9 changed files with 118 additions and 16 deletions.
5 changes: 4 additions & 1 deletion addons/unflipping/CfgFunctions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions addons/unflipping/XEH_preInitClient.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 2 additions & 5 deletions addons/unflipping/functions/fn_addUnflipActionLocal.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
];
Expand Down
28 changes: 28 additions & 0 deletions addons/unflipping/functions/fn_canUnflipLocal.sqf
Original file line number Diff line number Diff line change
@@ -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}
4 changes: 2 additions & 2 deletions addons/unflipping/functions/fn_hasToolKitRequired.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -13,7 +13,7 @@
_unit - Unit to check [OBJECT, defaults to objNull]
Returns:
NOTHING
Can unflip [BOOL]
*/
params [
["_unit", objNull, [objNull]]
Expand Down
33 changes: 33 additions & 0 deletions addons/unflipping/functions/fn_isRepairVehicle.sqf
Original file line number Diff line number Diff line change
@@ -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
};
29 changes: 29 additions & 0 deletions addons/unflipping/functions/fn_isServiceVehicleNearRequired.sqf
Original file line number Diff line number Diff line change
@@ -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
20 changes: 15 additions & 5 deletions addons/unflipping/initSettings.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[0, 100000, 3000, 0],
true,
{}
] call CBA_Settings_fnc_init;
] call CBA_fnc_addSetting;

[
"vet_unflipping_unit_man_limit",
Expand All @@ -19,7 +19,7 @@
[1, 100, 7, 0],
true,
{}
] call CBA_Settings_fnc_init;
] call CBA_fnc_addSetting;

[
"vet_unflipping_time",
Expand All @@ -29,7 +29,7 @@
[1, 600, 5, 0],
true,
{}
] call CBA_Settings_fnc_init;
] call CBA_fnc_addSetting;

[
"vet_unflipping_vehicle_mass_limit",
Expand All @@ -39,7 +39,7 @@
[0, 100000, 100000, 0],
true,
{}
] call CBA_Settings_fnc_init;
] call CBA_fnc_addSetting;

[
"vet_unflipping_require_toolkit",
Expand All @@ -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;
4 changes: 4 additions & 0 deletions addons/unflipping/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@
<Spanish>Un kit de herramientas es requerido para voltear vehículos</Spanish>
<Chinesesimp>需要携带工具包才能翻正载具</Chinesesimp>
</Key>
<Key ID="STR_vet_unflipping_require_serviceVehicle">
<Original>Require repair vehicle to unflip vehicle</Original>
<Polish>Wymagaj pojazdu naprawczego do odwracania pojazdów</Polish>
</Key>

<!-- Actions -->
<Key ID="STR_vet_unflipping_act">
Expand Down

0 comments on commit 0453d4d

Please sign in to comment.