From d8b1735ea4d0d40d3ef4571e5295caeb5bf5a6a0 Mon Sep 17 00:00:00 2001 From: Andreas Brostrom Date: Fri, 17 Sep 2021 13:15:04 +0200 Subject: [PATCH] added ability to add flag to to M1A1 --- cScripts/CfgFunctions.hpp | 3 ++ .../vehicle/fn_vehicle_addFlagAction.sqf | 47 +++++++++++++++++++ .../vehicle/fn_vehicle_addFunctions.sqf | 4 ++ 3 files changed, 54 insertions(+) create mode 100644 cScripts/functions/vehicle/fn_vehicle_addFlagAction.sqf diff --git a/cScripts/CfgFunctions.hpp b/cScripts/CfgFunctions.hpp index f885e7b4d..9d82a07d4 100644 --- a/cScripts/CfgFunctions.hpp +++ b/cScripts/CfgFunctions.hpp @@ -149,6 +149,9 @@ class cScripts { class vehicle_addPylonSelection {}; class vehicle_setupPylonCategories {}; + + // Other + class vehicle_addFlagAction {}; }; class modules { file = "cScripts\functions\modules"; diff --git a/cScripts/functions/vehicle/fn_vehicle_addFlagAction.sqf b/cScripts/functions/vehicle/fn_vehicle_addFlagAction.sqf new file mode 100644 index 000000000..b3981e214 --- /dev/null +++ b/cScripts/functions/vehicle/fn_vehicle_addFlagAction.sqf @@ -0,0 +1,47 @@ +#include "..\script_component.hpp"; +/* + * Author: CPL.Brostrom.A + * This function adds a takedown and put up flag action to the given vehicle. + * + * Arguments: + * 0: Vehicle + * + * Return Value: + * nothing + * + * Example: + * [this] call cScripts_fnc_vehicle_addFlagAction; + * + * Public: No + */ + +params [["_vehicle", objNull, [objNull]]]; + +if (isNull _vehicle) exitWith {}; + +private _icon = "iconLogic" call FUNC(getIcon); + +private _addCondition = { + params ["_vehicle", "_caller", "_params"]; + !(_vehicle getVariable [QEGVAR(Vehicle,hasFlag), false]) && isTurnedOut _caller; +}; +private _putFlag = [QEGVAR(Actions_Vehicle,PutFlag), "Put up flag", _icon, { + params ["_vehicle", "_caller", "_params"]; + private _flagTexture = "z\cav\addons\flag\data\flag_01_ca.paa"; //"\A3\Data_F\Flags\Flag_red_CO.paa" + _vehicle forceFlagTexture _flagTexture; + _vehicle setVariable [QEGVAR(Vehicle,hasFlag), true]; + +}, _addCondition] call ace_interact_menu_fnc_createAction; +[_vehicle, 1, ["ACE_SelfActions"], _putFlag] call ace_interact_menu_fnc_addActionToObject; + + +private _remCondition = { + params ["_vehicle", "_caller", "_params"]; + _vehicle getVariable [QEGVAR(Vehicle,hasFlag), false] && isTurnedOut _caller; +}; +private _takeFlag = [QEGVAR(Actions_Vehicle,TakeFlag), "Take down flag", _icon, { + params ["_vehicle", "_caller", "_params"]; + _vehicle forceFlagTexture ""; + _vehicle setVariable [QEGVAR(Vehicle,hasFlag), false]; +}, _remCondition] call ace_interact_menu_fnc_createAction; +[_vehicle, 1, ["ACE_SelfActions"], _takeFlag] call ace_interact_menu_fnc_addActionToObject; diff --git a/cScripts/functions/vehicle/fn_vehicle_addFunctions.sqf b/cScripts/functions/vehicle/fn_vehicle_addFunctions.sqf index de5d52c43..fa0c7613a 100644 --- a/cScripts/functions/vehicle/fn_vehicle_addFunctions.sqf +++ b/cScripts/functions/vehicle/fn_vehicle_addFunctions.sqf @@ -76,6 +76,10 @@ if (_vehicle iskindOf "Truck_01_base_F") then { }; }; +if (_vehicle iskindOf "rhsusf_m1a1tank_base") then { + [_vehicle] call FUNC(vehicle_addFlagAction); +}; + if (_vehicle iskindOf "rhsusf_stryker_base") then { switch (_vehicleType) do { case "MED": {_vehicle setVariable ["ace_medical_isMedicalVehicle", true, true];};