From 2373204b02017045600032192716f2b976014f69 Mon Sep 17 00:00:00 2001 From: AndreasBrostrom Date: Mon, 1 Jul 2024 09:58:17 +0200 Subject: [PATCH] Added new repair action --- cScripts/CfgFunctions.hpp | 1 + cScripts/functions/init/fn_init_vehicle.sqf | 3 ++ .../vehicle/fn_vehicle_addRepairAction.sqf | 45 +++++++++++++------ .../fn_vehicle_addRepairRefuelAction.sqf | 39 ++++++++++++++++ .../vehicle/fn_vehicle_addStagingActions.sqf | 2 +- 5 files changed, 75 insertions(+), 15 deletions(-) create mode 100644 cScripts/functions/vehicle/fn_vehicle_addRepairRefuelAction.sqf diff --git a/cScripts/CfgFunctions.hpp b/cScripts/CfgFunctions.hpp index 601233a2b..9207ba900 100644 --- a/cScripts/CfgFunctions.hpp +++ b/cScripts/CfgFunctions.hpp @@ -183,6 +183,7 @@ class cScripts { class vehicle_addRegearAction {}; class vehicle_addRepairAction {}; + class vehicle_addRepairRefuelAction {}; class vehicle_addCosmeticSelection {}; class vehicle_addPylonSelection {}; diff --git a/cScripts/functions/init/fn_init_vehicle.sqf b/cScripts/functions/init/fn_init_vehicle.sqf index bcfdfffba..4e219f95e 100644 --- a/cScripts/functions/init/fn_init_vehicle.sqf +++ b/cScripts/functions/init/fn_init_vehicle.sqf @@ -37,6 +37,9 @@ if !(EGVAR(Settings,enableVehicleSystem)) exitWith {}; INFO_2("VehicleInit", "Applying Client Init: (%1 [%2])...", _vehicle, typeOf _vehicle); _vehicle call EFUNC(vehicle,addFunctions); _vehicle call EFUNC(vehicle,addStagingActions); + + [_vehicle, 300] call EFUNC(vehicle,addRepairRefuelAction); + INFO_2("VehicleInit", "Init applied to %1 [%2]", _vehicle, typeOf _vehicle); }, true, ["man"], true] call CBA_fnc_addClassEventHandler; diff --git a/cScripts/functions/vehicle/fn_vehicle_addRepairAction.sqf b/cScripts/functions/vehicle/fn_vehicle_addRepairAction.sqf index c65d4777c..0a8a70796 100644 --- a/cScripts/functions/vehicle/fn_vehicle_addRepairAction.sqf +++ b/cScripts/functions/vehicle/fn_vehicle_addRepairAction.sqf @@ -1,7 +1,7 @@ #include "..\script_component.hpp"; /* * Author: CPL.Brostrom.A - * This function add a repair action to a vehicle inside of a staging zone. + * This function add a repair action to a vehicle * * Arguments: * 0: Vehicle @@ -15,23 +15,40 @@ * Public: No */ -params [["_vehicle", objNull, [objNull]]]; +params [ + ["_vehicle", objNull, [objNull]], + ["_duration", 0, [0]] +]; if (isNull _vehicle) exitWith {}; + +private _lable = "Fully repair vehicle"; private _icon = "\A3\ui_f\data\igui\cfg\actions\repair_ca.paa" call FUNC(getIcon); -private _condition = { call FUNC(checkStagingZone) }; -private _stagingCat = [QEGVAR(Actions_Vehicle,Repair), "Repair and Refuel", _icon, { +private _condition = { true }; + +private _action = { params ["_vehicle", "_caller", "_params"]; - ["", _vehicle] call ace_repair_fnc_doFullRepair; - _vehicle setFuel 1; - [ - [], - ["Vehicle have been refueld and repaired."], - [""], - [""] - ] call CBA_fnc_notify; -}, _condition] call ace_interact_menu_fnc_createAction; -[_vehicle, 1, ["ACE_SelfActions", QEGVAR(Actions_Vehicle,Main_Cat)], _stagingCat] call ace_interact_menu_fnc_addActionToObject; + + ["Fully repairing vehicle", _duration, {_condition}, { + ["", _vehicle] call ace_repair_fnc_doFullRepair; + [ + [], + ["Vehicle have been repaired."], + [""], + [""] + ] call CBA_fnc_notify; + },{ + [ + [], + ["Failed to repair vehicle."], + [""], + [""] + ] call CBA_fnc_notify; + }] call CBA_fnc_progressBar; +}; + +private _stagingCat = [QEGVAR(Actions_Vehicle,Repair), _lable, _icon, _action, _condition] call ace_interact_menu_fnc_createAction; +[_vehicle, 1, ["ACE_MainActions"], _stagingCat] call ace_interact_menu_fnc_addActionToObject; diff --git a/cScripts/functions/vehicle/fn_vehicle_addRepairRefuelAction.sqf b/cScripts/functions/vehicle/fn_vehicle_addRepairRefuelAction.sqf new file mode 100644 index 000000000..a11387024 --- /dev/null +++ b/cScripts/functions/vehicle/fn_vehicle_addRepairRefuelAction.sqf @@ -0,0 +1,39 @@ +#include "..\script_component.hpp"; +/* + * Author: CPL.Brostrom.A + * This function add a repair action to a vehicle inside of a staging zone. + * + * Arguments: + * 0: Vehicle + * + * Return Value: + * nothing + * + * Example: + * [_vehicle] call cScripts_fnc_vehicle_addRepairRefuelAction + * + * Public: No + */ + +params [ + ["_vehicle", objNull, [objNull]], + ["_duration", 0, [0]] +]; + +if (isNull _vehicle) exitWith {}; + +private _icon = "\A3\ui_f\data\igui\cfg\actions\repair_ca.paa" call FUNC(getIcon); + +private _condition = { call FUNC(checkStagingZone) }; +private _stagingCat = [QEGVAR(Actions_Vehicle,RefuelRepair), "Repair and Refuel", _icon, { + params ["_vehicle", "_caller", "_params"]; + ["", _vehicle] call ace_repair_fnc_doFullRepair; + _vehicle setFuel 1; + [ + [], + ["Vehicle have been refueld and repaired."], + [""], + [""] + ] call CBA_fnc_notify; +}, _condition] call ace_interact_menu_fnc_createAction; +[_vehicle, 1, ["ACE_SelfActions", QEGVAR(Actions_Vehicle,Main_Cat)], _stagingCat] call ace_interact_menu_fnc_addActionToObject; \ No newline at end of file diff --git a/cScripts/functions/vehicle/fn_vehicle_addStagingActions.sqf b/cScripts/functions/vehicle/fn_vehicle_addStagingActions.sqf index 598340e1e..739a7ff5c 100644 --- a/cScripts/functions/vehicle/fn_vehicle_addStagingActions.sqf +++ b/cScripts/functions/vehicle/fn_vehicle_addStagingActions.sqf @@ -32,7 +32,7 @@ private _stagingCat = [QEGVAR(Actions_Vehicle,Cosmetic_Cat), "Vehicle Cosmetics" [_vehicle, 1, ["ACE_SelfActions", QEGVAR(Actions_Vehicle,Main_Cat)], _stagingCat] call ace_interact_menu_fnc_addActionToObject; [_vehicle] call EFUNC(vehicle,addRegearAction); -[_vehicle] call EFUNC(vehicle,addRepairAction); +[_vehicle] call EFUNC(vehicle,addRepairRefuelAction); [_vehicle] call EFUNC(vehicle,addCosmeticSelection); [_vehicle] call EFUNC(vehicle,setupPylonCategories);