From ed8266121cce9c86388f23aedd0888a74eb538c1 Mon Sep 17 00:00:00 2001 From: Steve Zhao Date: Tue, 10 Jan 2023 09:22:54 -0500 Subject: [PATCH 1/9] add settings to toggle attributes --- addons/attributes/XEH_preInit.sqf | 1 + addons/attributes/initAttributes.sqf | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/addons/attributes/XEH_preInit.sqf b/addons/attributes/XEH_preInit.sqf index 0bd28810d..abd6dae3f 100644 --- a/addons/attributes/XEH_preInit.sqf +++ b/addons/attributes/XEH_preInit.sqf @@ -23,5 +23,6 @@ GVAR(previousMarkerColors) = [] call CBA_fnc_createNamespace; // Initialize the core/default attributes #include "initAttributes.sqf" +#include "initSettings.sqf" ADDON = true; diff --git a/addons/attributes/initAttributes.sqf b/addons/attributes/initAttributes.sqf index 24038252d..b1725013a 100644 --- a/addons/attributes/initAttributes.sqf +++ b/addons/attributes/initAttributes.sqf @@ -140,7 +140,7 @@ } forEach call EFUNC(common,getSelectedVehicles); }, {locked _entity}, - {alive _entity && {_entity isKindOf "LandVehicle" || {_entity isKindOf "Air"} || {_entity isKindOf "Ship"}}} + {GVAR(enableVehicleLock) && {alive _entity} && {_entity isKindOf "LandVehicle" || {_entity isKindOf "Air"} || {_entity isKindOf "Ship"}}} ] call FUNC(addAttribute); [ @@ -236,7 +236,7 @@ { _entity getVariable [QGVAR(respawnPos), []] param [0, sideEmpty] }, - {alive _entity && {canMove _entity} && {_entity isKindOf "AllVehicles"} && {!(_entity isKindOf "Animal")}} + {GVAR(enableRespawn) && {alive _entity} && {canMove _entity} && {_entity isKindOf "AllVehicles"} && {!(_entity isKindOf "Animal")}} ] call FUNC(addAttribute); [ @@ -285,7 +285,7 @@ _respawnID }, - {_entity isKindOf "LandVehicle" || {_entity isKindOf "Air"} || {_entity isKindOf "Ship"}} + {GVAR(enableRespawn) && {_entity isKindOf "LandVehicle" || {_entity isKindOf "Air"} || {_entity isKindOf "Ship"}}} ] call FUNC(addAttribute); [ From d182e45ebd57ccec40aaa67acc3b038b5f6a42c6 Mon Sep 17 00:00:00 2001 From: Steve Zhao Date: Tue, 10 Jan 2023 09:23:01 -0500 Subject: [PATCH 2/9] add speed limit attribute --- addons/attributes/initAttributes.sqf | 15 +++++++++++++++ addons/attributes/initSettings.sqf | 26 ++++++++++++++++++++++++++ addons/attributes/stringtable.xml | 24 ++++++++++++++++++++++++ 3 files changed, 65 insertions(+) create mode 100644 addons/attributes/initSettings.sqf diff --git a/addons/attributes/initAttributes.sqf b/addons/attributes/initAttributes.sqf index b1725013a..3129fe877 100644 --- a/addons/attributes/initAttributes.sqf +++ b/addons/attributes/initAttributes.sqf @@ -83,6 +83,21 @@ {alive _entity && {_entity call EFUNC(common,getVehicleAmmo) != -1}} ] call FUNC(addAttribute); +[ + "Object", + [LSTRING(SpeedLimit), LSTRING(SpeedLimit_Tooltip)], + QGVAR(slider), + [-50, 500, 5, false, 0], + { + { + [QEGVAR(common,limitSpeed), [_entity, _value], _entity] call CBA_fnc_targetEvent; + _entity setVariable [QGVAR(SpeedLimit), _value, true]; + } forEach call EFUNC(common,getSelectedVehicles); + }, + {_entity getVariable [QGVAR(SpeedLimit), 0]}, + {GVAR(enableSpeedLimit) && {alive _entity} && {!isPlayer driver _entity} && {_entity isKindOf "LandVehicle" || {_entity isKindOf "Air"} || {_entity isKindOf "Ship"}}} +] call FUNC(addAttribute); + [ "Object", "STR_3DEN_Object_Attribute_Rank_displayName", diff --git a/addons/attributes/initSettings.sqf b/addons/attributes/initSettings.sqf new file mode 100644 index 000000000..6865a41a6 --- /dev/null +++ b/addons/attributes/initSettings.sqf @@ -0,0 +1,26 @@ +[ + QGVAR(enableVehicleLock), + "CHECKBOX", + [LSTRING(EnableVehicleLock), LSTRING(EnableVehicleLock_Description)], + [ELSTRING(main,DisplayName), "str_3den_display3den_menubar_attributes_text"], + true, + false +] call CBA_fnc_addSetting; + +[ + QGVAR(enableRespawn), + "CHECKBOX", + [LSTRING(EnableRespawn), LSTRING(EnableRespawn_Description)], + [ELSTRING(main,DisplayName), "str_3den_display3den_menubar_attributes_text"], + true, + false +] call CBA_fnc_addSetting; + +[ + QGVAR(enableSpeedLimit), + "CHECKBOX", + [LSTRING(EnableSpeedLimit), LSTRING(EnableSpeedLimit_Description)], + [ELSTRING(main,DisplayName), "str_3den_display3den_menubar_attributes_text"], + false, + false +] call CBA_fnc_addSetting; diff --git a/addons/attributes/stringtable.xml b/addons/attributes/stringtable.xml index ae0ef148d..f523bf787 100644 --- a/addons/attributes/stringtable.xml +++ b/addons/attributes/stringtable.xml @@ -105,6 +105,12 @@ 狀態 Stati + + Speed Limit + + + Limit the maximum speed of the vehicle in km/h + Local Exec. This code will be executed in the unscheduled environment on this machine only. Lokale Ausführung. Dieser Code wird in der unscheduled Environment für nur die lokale Maschine ausgeführt. @@ -368,5 +374,23 @@ 打開所選實體的Zeus屬性顯示。當選擇多個實體時(即由於選擇了一個小組),將使用懸停的實體。 Apre la visualizzazione degli attributi di Zeus per l'entità selezionata.\nQuando vengono selezionate più entità (ad es. a causa della selezione di un gruppo), verrà utilizzata l'entità al passaggio del mouse. + + Respawn + + + Enables the RespawnVehicle and RespawnPosition attributes in the Zeus attributes display + + + Vehicle Speed Limit + + + Enables the Vehicle Speed Limit attribute in the Zeus attributes display + + + Vehicle Lock + + + Enables the Vehicle Lock attribute in the Zeus attributes display + From 361bdd4f26ca1edbfe054baf0a6f9160e6c0ea26 Mon Sep 17 00:00:00 2001 From: Steve Zhao Date: Thu, 16 Mar 2023 15:25:37 -0400 Subject: [PATCH 3/9] split out toggle settlings --- addons/attributes/initAttributes.sqf | 6 +++--- addons/attributes/initSettings.sqf | 22 ++-------------------- addons/attributes/stringtable.xml | 18 ------------------ 3 files changed, 5 insertions(+), 41 deletions(-) diff --git a/addons/attributes/initAttributes.sqf b/addons/attributes/initAttributes.sqf index 968a0e617..5b53d232d 100644 --- a/addons/attributes/initAttributes.sqf +++ b/addons/attributes/initAttributes.sqf @@ -155,7 +155,7 @@ } forEach call EFUNC(common,getSelectedVehicles); }, {locked _entity}, - {GVAR(enableVehicleLock) && {alive _entity} && {_entity isKindOf "LandVehicle" || {_entity isKindOf "Air"} || {_entity isKindOf "Ship"}}} + {alive _entity} && {_entity isKindOf "LandVehicle" || {_entity isKindOf "Air"} || {_entity isKindOf "Ship"}} ] call FUNC(addAttribute); [ @@ -264,7 +264,7 @@ { _entity getVariable [QGVAR(respawnPos), []] param [0, sideEmpty] }, - {GVAR(enableRespawn) && {alive _entity} && {canMove _entity} && {_entity isKindOf "AllVehicles"} && {!(_entity isKindOf "Animal")}} + {alive _entity} && {canMove _entity} && {_entity isKindOf "AllVehicles"} && {!(_entity isKindOf "Animal")} ] call FUNC(addAttribute); [ @@ -313,7 +313,7 @@ _respawnID }, - {GVAR(enableRespawn) && {_entity isKindOf "LandVehicle" || {_entity isKindOf "Air"} || {_entity isKindOf "Ship"}}} + {_entity isKindOf "LandVehicle" || {_entity isKindOf "Air"} || {_entity isKindOf "Ship"}} ] call FUNC(addAttribute); [ diff --git a/addons/attributes/initSettings.sqf b/addons/attributes/initSettings.sqf index 6865a41a6..30f6bbef4 100644 --- a/addons/attributes/initSettings.sqf +++ b/addons/attributes/initSettings.sqf @@ -1,26 +1,8 @@ -[ - QGVAR(enableVehicleLock), - "CHECKBOX", - [LSTRING(EnableVehicleLock), LSTRING(EnableVehicleLock_Description)], - [ELSTRING(main,DisplayName), "str_3den_display3den_menubar_attributes_text"], - true, - false -] call CBA_fnc_addSetting; - -[ - QGVAR(enableRespawn), - "CHECKBOX", - [LSTRING(EnableRespawn), LSTRING(EnableRespawn_Description)], - [ELSTRING(main,DisplayName), "str_3den_display3den_menubar_attributes_text"], - true, - false -] call CBA_fnc_addSetting; - [ QGVAR(enableSpeedLimit), "CHECKBOX", - [LSTRING(EnableSpeedLimit), LSTRING(EnableSpeedLimit_Description)], + [LSTRING(SpeedLimit), LSTRING(EnableAttribute_Description)], [ELSTRING(main,DisplayName), "str_3den_display3den_menubar_attributes_text"], - false, + true, false ] call CBA_fnc_addSetting; diff --git a/addons/attributes/stringtable.xml b/addons/attributes/stringtable.xml index f523bf787..3d0c5de6b 100644 --- a/addons/attributes/stringtable.xml +++ b/addons/attributes/stringtable.xml @@ -374,23 +374,5 @@ 打開所選實體的Zeus屬性顯示。當選擇多個實體時(即由於選擇了一個小組),將使用懸停的實體。 Apre la visualizzazione degli attributi di Zeus per l'entità selezionata.\nQuando vengono selezionate più entità (ad es. a causa della selezione di un gruppo), verrà utilizzata l'entità al passaggio del mouse. - - Respawn - - - Enables the RespawnVehicle and RespawnPosition attributes in the Zeus attributes display - - - Vehicle Speed Limit - - - Enables the Vehicle Speed Limit attribute in the Zeus attributes display - - - Vehicle Lock - - - Enables the Vehicle Lock attribute in the Zeus attributes display - From 1183816c3fd153b3640ddcd389303ab61d2c14be Mon Sep 17 00:00:00 2001 From: Steve Zhao Date: Fri, 17 Mar 2023 19:58:12 -0400 Subject: [PATCH 4/9] separate speed ranges for land, heli plane --- addons/attributes/XEH_postInit.sqf | 11 +++++ addons/attributes/initAttributes.sqf | 56 +++++++++++++++++----- addons/attributes/initSettings.sqf | 4 +- addons/common/XEH_PREP.hpp | 1 + addons/common/XEH_postInit.sqf | 6 +++ addons/common/functions/fnc_setSpeed.sqf | 60 ++++++++++++++++++++++++ 6 files changed, 125 insertions(+), 13 deletions(-) create mode 100644 addons/common/functions/fnc_setSpeed.sqf diff --git a/addons/attributes/XEH_postInit.sqf b/addons/attributes/XEH_postInit.sqf index bb51ad160..076968c92 100644 --- a/addons/attributes/XEH_postInit.sqf +++ b/addons/attributes/XEH_postInit.sqf @@ -28,3 +28,14 @@ if (isServer) then { _unit enableAIFeature [_x, _abilities select _forEachIndex]; } forEach AI_ABILITIES; }] call CBA_fnc_addEventHandler; + +["CAManBase", "Local", { // If locality changes, forceSpeed must be reapplied. + params ["_entity", "_isLocal"]; + if (!_isLocal || {!alive _entity} || {!(_entity isKindOf "CAManBase")}) exitWith {}; + + private _setSpeed = _entity getVariable [QGVAR(setSpeed), 0]; + + if (_setSpeed != 0) then { + [_entity, _setSpeed] call FUNC(setSpeed); + }; +}, true, [], true] call CBA_fnc_addClassEventHandler; diff --git a/addons/attributes/initAttributes.sqf b/addons/attributes/initAttributes.sqf index 5b53d232d..1f393eb7a 100644 --- a/addons/attributes/initAttributes.sqf +++ b/addons/attributes/initAttributes.sqf @@ -83,19 +83,53 @@ {alive _entity && {_entity call EFUNC(common,getVehicleAmmo) != -1}} ] call FUNC(addAttribute); -[ +[ // Helicopter "Object", - [LSTRING(SpeedLimit), LSTRING(SpeedLimit_Tooltip)], + [ELSTRING(Modules,ModuleConvoyParameters_Speed), ELSTRING(Modules,ModuleConvoyParameters_Speed_Tooltip)], QGVAR(slider), - [-50, 500, 5, false, 0], + [-50, 200, 5, false, 0], { - { - [QEGVAR(common,limitSpeed), [_entity, _value], _entity] call CBA_fnc_targetEvent; - _entity setVariable [QGVAR(SpeedLimit), _value, true]; - } forEach call EFUNC(common,getSelectedVehicles); + private _vehicles = [] call EFUNC(common,getSelectedVehicles) select { + alive _x && {!isPlayer driver _x} && {_x isKindOf "Helicopter"} + }; + { _x setVariable [QGVAR(setSpeed), _value, true]; } forEach _vehicles; + [QEGVAR(common,setSpeed), [_vehicles, _value], _vehicles] call CBA_fnc_targetEvent; }, - {_entity getVariable [QGVAR(SpeedLimit), 0]}, - {GVAR(enableSpeedLimit) && {alive _entity} && {!isPlayer driver _entity} && {_entity isKindOf "LandVehicle" || {_entity isKindOf "Air"} || {_entity isKindOf "Ship"}}} + {_entity getVariable [QGVAR(setSpeed), 0]}, + {GVAR(enableSetSpeed) && {alive _entity} && {!isPlayer driver _entity} && {_entity isKindOf "Helicopter"}} +] call FUNC(addAttribute); + +[ // LandVehicle and Ship + "Object", + [ELSTRING(Modules,ModuleConvoyParameters_Speed), ELSTRING(Modules,ModuleConvoyParameters_Speed_Tooltip)], + QGVAR(slider), + [0, 100, 5, false, 0], + { + private _vehicles = [] call EFUNC(common,getSelectedVehicles) select { + alive _x && {!isPlayer driver _x} && {_x isKindOf "LandVehicle" || {_x isKindOf "Ship"}} + }; + { _x setVariable [QGVAR(setSpeed), _value, true]; } forEach _vehicles; + [QEGVAR(common,setSpeed), [_vehicles, _value], _vehicles] call CBA_fnc_targetEvent; + }, + {_entity getVariable [QGVAR(setSpeed), 0]}, + {GVAR(enableSetSpeed) && {alive _entity} && {!isPlayer driver _entity} && {_entity isKindOf "LandVehicle" || {_entity isKindOf "Ship"}}} + //{GVAR(enableSetSpeed) && {alive _entity} && {!isPlayer driver _entity} && {_entity isKindOf "LandVehicle" || {_entity isKindOf "Ship"}}} +] call FUNC(addAttribute); + +[ // Plane + "Object", + [ELSTRING(Modules,ModuleConvoyParameters_Speed), ELSTRING(Modules,ModuleConvoyParameters_Speed_Tooltip)], + QGVAR(slider), + [0, 1000, 5, false, 0], + { + private _vehicles = [] call EFUNC(common,getSelectedVehicles) select { + alive _x && {!isPlayer driver _x} && {_x isKindOf "Plane"} + }; + { _x setVariable [QGVAR(setSpeed), _value, true]; } forEach _vehicles; + [QEGVAR(common,setSpeed), [_vehicles, _value], _vehicles] call CBA_fnc_targetEvent; + }, + {_entity getVariable [QGVAR(setSpeed), 0]}, + {GVAR(enableSetSpeed) && {alive _entity} && {!isPlayer driver _entity} && {_entity isKindOf "Plane"}} ] call FUNC(addAttribute); [ @@ -155,7 +189,7 @@ } forEach call EFUNC(common,getSelectedVehicles); }, {locked _entity}, - {alive _entity} && {_entity isKindOf "LandVehicle" || {_entity isKindOf "Air"} || {_entity isKindOf "Ship"}} + {alive _entity && {_entity isKindOf "LandVehicle" || {_entity isKindOf "Air"} || {_entity isKindOf "Ship"}}} ] call FUNC(addAttribute); [ @@ -264,7 +298,7 @@ { _entity getVariable [QGVAR(respawnPos), []] param [0, sideEmpty] }, - {alive _entity} && {canMove _entity} && {_entity isKindOf "AllVehicles"} && {!(_entity isKindOf "Animal")} + {alive _entity && {canMove _entity} && {_entity isKindOf "AllVehicles"} && {!(_entity isKindOf "Animal")}} ] call FUNC(addAttribute); [ diff --git a/addons/attributes/initSettings.sqf b/addons/attributes/initSettings.sqf index 30f6bbef4..dda3f9619 100644 --- a/addons/attributes/initSettings.sqf +++ b/addons/attributes/initSettings.sqf @@ -1,7 +1,7 @@ [ - QGVAR(enableSpeedLimit), + QGVAR(enableSetSpeed), "CHECKBOX", - [LSTRING(SpeedLimit), LSTRING(EnableAttribute_Description)], + [LSTRING(SetSpeed), LSTRING(EnableAttribute_Description)], [ELSTRING(main,DisplayName), "str_3den_display3den_menubar_attributes_text"], true, false diff --git a/addons/common/XEH_PREP.hpp b/addons/common/XEH_PREP.hpp index 5fc2d6691..ffebaf4f8 100644 --- a/addons/common/XEH_PREP.hpp +++ b/addons/common/XEH_PREP.hpp @@ -65,6 +65,7 @@ PREP(serializeInventory); PREP(serializeObjects); PREP(setLampState); PREP(setMagazineAmmo); +PREP(setSpeed); PREP(setTurretAmmo); PREP(setVehicleAmmo); PREP(showMessage); diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf index dd77cdc26..f1bcbafec 100644 --- a/addons/common/XEH_postInit.sqf +++ b/addons/common/XEH_postInit.sqf @@ -208,6 +208,11 @@ _vehicle limitSpeed _speed; }] call CBA_fnc_addEventHandler; +[QGVAR(forceSpeed), { + params ["_vehicle", "_speed"]; + _vehicle forceSpeed _speed; +}] call CBA_fnc_addEventHandler; + [QGVAR(forceFollowRoad), { params ["_vehicle", "_mode"]; _vehicle forceFollowRoad _mode; @@ -330,6 +335,7 @@ [QGVAR(setLampState), LINKFUNC(setLampState)] call CBA_fnc_addEventHandler; [QGVAR(setMagazineAmmo), LINKFUNC(setMagazineAmmo)] call CBA_fnc_addEventHandler; [QGVAR(setTurretAmmo), LINKFUNC(setTurretAmmo)] call CBA_fnc_addEventHandler; +[QGVAR(setSpeed), LINKFUNC(setSpeed)] call CBA_fnc_addEventHandler; [QGVAR(showMessage), LINKFUNC(showMessage)] call CBA_fnc_addEventHandler; if (isServer) then { diff --git a/addons/common/functions/fnc_setSpeed.sqf b/addons/common/functions/fnc_setSpeed.sqf new file mode 100644 index 000000000..0bc5593b1 --- /dev/null +++ b/addons/common/functions/fnc_setSpeed.sqf @@ -0,0 +1,60 @@ +#include "script_component.hpp" +/* + * Author: Ampersand + * Sets the movement speed mode of the given vehicle(s). + * + * Arguments: + * 0: Vehicle + * 1: Speed (default: 0) + * Man: Speed modes + * Vehicles: km/h + * + * 2.12 | forceSpeed | limitSpeed + * _speed | neg zero pos | neg zero pos -(_man getSpeed "SLOW") + * -------|-------------------------|--------------------------------------------------------------------- + * man | reset stop yes | reset stop yes reverse, doesn't work if combat mode + * car | reset stop yes | reset reset yes + * tank | reset stop yes | reset reset yes + * heli | no-eff no-eff no-eff | reverse stop yes + * plane | reset reset yes | min min yes + * vtol | reset reset yes | min min yes + * boat | reset stop yes | reset stop yes + * + * Return Value: + * None + * + * Example: + * [_vehicle, 1] call zen_common_fnc_setSpeed + * + * Public: No + */ + +#define SPEED_RESET 0 +#define SPEED_FAST 1 +#define SPEED_NORMAL 2 +#define SPEED_SLOW 3 +#define SPEED_BACK 4 + +params ["_vehicle", "_speed"]; + +if (_vehicle isEqualType []) exitWith { + { + [_x, _speed] call FUNC(setSpeed); + } forEach _vehicle; +}; + +if (!local _vehicle) exitWith {}; + +if (_vehicle isKindOf "Helicopter") exitWith { + if (_speed == 0) exitWith { + _vehicle limitSpeed (getNumber (configOf _vehicle >> "maxSpeed")); // Reset + }; + _vehicle limitSpeed _speed; // Allow reverse +}; + +// Planes, LandVehicle, Ship +if (_speed == 0) then { + _speed = -1; // Reset +}; + +_vehicle forceSpeed (_speed / 3.6); From 0fd6c732b90b16326519a958a8808f12c3834eda Mon Sep 17 00:00:00 2001 From: Steve Zhao Date: Fri, 17 Mar 2023 20:24:11 -0400 Subject: [PATCH 5/9] remove unneeded --- addons/common/functions/fnc_setSpeed.sqf | 6 ------ 1 file changed, 6 deletions(-) diff --git a/addons/common/functions/fnc_setSpeed.sqf b/addons/common/functions/fnc_setSpeed.sqf index 0bc5593b1..fd040082b 100644 --- a/addons/common/functions/fnc_setSpeed.sqf +++ b/addons/common/functions/fnc_setSpeed.sqf @@ -29,12 +29,6 @@ * Public: No */ -#define SPEED_RESET 0 -#define SPEED_FAST 1 -#define SPEED_NORMAL 2 -#define SPEED_SLOW 3 -#define SPEED_BACK 4 - params ["_vehicle", "_speed"]; if (_vehicle isEqualType []) exitWith { From cbd9de159a2bcfac5de8bba22a3490f895856b75 Mon Sep 17 00:00:00 2001 From: Steve Zhao Date: Thu, 12 Oct 2023 13:48:43 -0400 Subject: [PATCH 6/9] tooltips --- addons/attributes/initAttributes.sqf | 21 +++++++++++++-------- addons/attributes/stringtable.xml | 8 ++++---- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/addons/attributes/initAttributes.sqf b/addons/attributes/initAttributes.sqf index a6c89b39f..112564b5f 100644 --- a/addons/attributes/initAttributes.sqf +++ b/addons/attributes/initAttributes.sqf @@ -83,12 +83,18 @@ {GVAR(enableAmmo) && {alive _entity} && {_entity call EFUNC(common,getVehicleAmmo) != -1}} ] call FUNC(addAttribute); +#define MAX_SPEED_HELI 300 [ // Helicopter "Object", - [ELSTRING(Modules,ModuleConvoyParameters_Speed), ELSTRING(Modules,ModuleConvoyParameters_Speed_Tooltip)], + [ELSTRING(Modules,ModuleConvoyParameters_Speed), LSTRING(SpeedLimit_Tooltip_Helicopter)], QGVAR(slider), - [-50, 200, 5, false, 0], + [-50, MAX_SPEED_HELI, 5, false, 0], { + if (_value == 0) then { + // There doesn't seem to be a way to remove this for a helicopter, so set to more than max + // 0 is not needed, use Toggle AI Path instead + _value = MAX_SPEED_HELI; + }; private _vehicles = [] call EFUNC(common,getSelectedVehicles) select { alive _x && {!isPlayer driver _x} && {_x isKindOf "Helicopter"} }; @@ -96,12 +102,12 @@ [QEGVAR(common,setSpeed), [_vehicles, _value], _vehicles] call CBA_fnc_targetEvent; }, {_entity getVariable [QGVAR(setSpeed), 0]}, - {GVAR(enableSetSpeed) && {alive _entity} && {!isPlayer driver _entity} && {_entity isKindOf "Helicopter"}} + {GVAR(enableSpeedLimit) && {alive _entity} && {!isPlayer driver _entity} && {_entity isKindOf "Helicopter"}} ] call FUNC(addAttribute); [ // LandVehicle and Ship "Object", - [ELSTRING(Modules,ModuleConvoyParameters_Speed), ELSTRING(Modules,ModuleConvoyParameters_Speed_Tooltip)], + [ELSTRING(Modules,ModuleConvoyParameters_Speed), LSTRING(SpeedLimit_Tooltip)], QGVAR(slider), [0, 100, 5, false, 0], { @@ -112,13 +118,12 @@ [QEGVAR(common,setSpeed), [_vehicles, _value], _vehicles] call CBA_fnc_targetEvent; }, {_entity getVariable [QGVAR(setSpeed), 0]}, - {GVAR(enableSetSpeed) && {alive _entity} && {!isPlayer driver _entity} && {_entity isKindOf "LandVehicle" || {_entity isKindOf "Ship"}}} - //{GVAR(enableSetSpeed) && {alive _entity} && {!isPlayer driver _entity} && {_entity isKindOf "LandVehicle" || {_entity isKindOf "Ship"}}} + {GVAR(enableSpeedLimit) && {alive _entity} && {!isPlayer driver _entity} && {_entity isKindOf "LandVehicle" || {_entity isKindOf "Ship"}}} ] call FUNC(addAttribute); [ // Plane "Object", - [ELSTRING(Modules,ModuleConvoyParameters_Speed), ELSTRING(Modules,ModuleConvoyParameters_Speed_Tooltip)], + [ELSTRING(Modules,ModuleConvoyParameters_Speed), LSTRING(SpeedLimit_Tooltip)], QGVAR(slider), [0, 1000, 5, false, 0], { @@ -129,7 +134,7 @@ [QEGVAR(common,setSpeed), [_vehicles, _value], _vehicles] call CBA_fnc_targetEvent; }, {_entity getVariable [QGVAR(setSpeed), 0]}, - {GVAR(enableSetSpeed) && {alive _entity} && {!isPlayer driver _entity} && {_entity isKindOf "Plane"}} + {GVAR(enableSpeedLimit) && {alive _entity} && {!isPlayer driver _entity} && {_entity isKindOf "Plane"}} ] call FUNC(addAttribute); [ diff --git a/addons/attributes/stringtable.xml b/addons/attributes/stringtable.xml index 998d4c657..b94092a84 100644 --- a/addons/attributes/stringtable.xml +++ b/addons/attributes/stringtable.xml @@ -121,11 +121,11 @@ 狀態 Stati - - Speed Limit - - Limit the maximum speed of the vehicle in km/h + Limit the maximum speed of the vehicle in km/h. Set to 0 to remove limit. + + + Limit the maximum speed of the vehicle in km/h. Set to 0 to remove limit. AI helicopters will fly in reverse. Local Exec. This code will be executed in the unscheduled environment on this machine only. From bd0a92a804b112ad3f17235c27b54f1e5190c685 Mon Sep 17 00:00:00 2001 From: Steve Zhao Date: Thu, 12 Oct 2023 13:49:18 -0400 Subject: [PATCH 7/9] toggle attribute setting --- addons/attributes/initSettings.sqf | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/addons/attributes/initSettings.sqf b/addons/attributes/initSettings.sqf index 960270a9f..1ccbaf719 100644 --- a/addons/attributes/initSettings.sqf +++ b/addons/attributes/initSettings.sqf @@ -45,6 +45,15 @@ false ] call CBA_fnc_addSetting; +[ + QGVAR(enableSpeedLimit), + "CHECKBOX", + ELSTRING(Modules,ModuleConvoyParameters_Speed), + [LSTRING(DisplayName), "STR_3DEN_Object_textPlural"], + true, + false +] call CBA_fnc_addSetting; + [ QGVAR(enableRank), "CHECKBOX", From 220b8c7ccaba9f365634e5e8c2d83ec33c10ca6d Mon Sep 17 00:00:00 2001 From: Steve Zhao Date: Fri, 13 Oct 2023 11:31:57 -0400 Subject: [PATCH 8/9] naming to SpeedLimit --- addons/attributes/initAttributes.sqf | 18 +++++++++--------- addons/common/XEH_PREP.hpp | 2 +- addons/common/XEH_postInit.sqf | 2 +- ...{fnc_setSpeed.sqf => fnc_setSpeedLimit.sqf} | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) rename addons/common/functions/{fnc_setSpeed.sqf => fnc_setSpeedLimit.sqf} (93%) diff --git a/addons/attributes/initAttributes.sqf b/addons/attributes/initAttributes.sqf index 112564b5f..a28521834 100644 --- a/addons/attributes/initAttributes.sqf +++ b/addons/attributes/initAttributes.sqf @@ -98,10 +98,10 @@ private _vehicles = [] call EFUNC(common,getSelectedVehicles) select { alive _x && {!isPlayer driver _x} && {_x isKindOf "Helicopter"} }; - { _x setVariable [QGVAR(setSpeed), _value, true]; } forEach _vehicles; - [QEGVAR(common,setSpeed), [_vehicles, _value], _vehicles] call CBA_fnc_targetEvent; + { _x setVariable [QGVAR(speedLimit), _value, true]; } forEach _vehicles; + [QEGVAR(common,setSpeedLimit), [_vehicles, _value], _vehicles] call CBA_fnc_targetEvent; }, - {_entity getVariable [QGVAR(setSpeed), 0]}, + {_entity getVariable [QGVAR(speedLimit), 0]}, {GVAR(enableSpeedLimit) && {alive _entity} && {!isPlayer driver _entity} && {_entity isKindOf "Helicopter"}} ] call FUNC(addAttribute); @@ -114,10 +114,10 @@ private _vehicles = [] call EFUNC(common,getSelectedVehicles) select { alive _x && {!isPlayer driver _x} && {_x isKindOf "LandVehicle" || {_x isKindOf "Ship"}} }; - { _x setVariable [QGVAR(setSpeed), _value, true]; } forEach _vehicles; - [QEGVAR(common,setSpeed), [_vehicles, _value], _vehicles] call CBA_fnc_targetEvent; + { _x setVariable [QGVAR(speedLimit), _value, true]; } forEach _vehicles; + [QEGVAR(common,setSpeedLimit), [_vehicles, _value], _vehicles] call CBA_fnc_targetEvent; }, - {_entity getVariable [QGVAR(setSpeed), 0]}, + {_entity getVariable [QGVAR(speedLimit), 0]}, {GVAR(enableSpeedLimit) && {alive _entity} && {!isPlayer driver _entity} && {_entity isKindOf "LandVehicle" || {_entity isKindOf "Ship"}}} ] call FUNC(addAttribute); @@ -130,10 +130,10 @@ private _vehicles = [] call EFUNC(common,getSelectedVehicles) select { alive _x && {!isPlayer driver _x} && {_x isKindOf "Plane"} }; - { _x setVariable [QGVAR(setSpeed), _value, true]; } forEach _vehicles; - [QEGVAR(common,setSpeed), [_vehicles, _value], _vehicles] call CBA_fnc_targetEvent; + { _x setVariable [QGVAR(speedLimit), _value, true]; } forEach _vehicles; + [QEGVAR(common,setSpeedLimit), [_vehicles, _value], _vehicles] call CBA_fnc_targetEvent; }, - {_entity getVariable [QGVAR(setSpeed), 0]}, + {_entity getVariable [QGVAR(speedLimit), 0]}, {GVAR(enableSpeedLimit) && {alive _entity} && {!isPlayer driver _entity} && {_entity isKindOf "Plane"}} ] call FUNC(addAttribute); diff --git a/addons/common/XEH_PREP.hpp b/addons/common/XEH_PREP.hpp index 369778dce..bda2aa67c 100644 --- a/addons/common/XEH_PREP.hpp +++ b/addons/common/XEH_PREP.hpp @@ -67,7 +67,7 @@ PREP(serializeInventory); PREP(serializeObjects); PREP(setLampState); PREP(setMagazineAmmo); -PREP(setSpeed); +PREP(setSpeedLimit); PREP(setTurretAmmo); PREP(setVehicleAmmo); PREP(setVehicleLaserState); diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf index 1750789c2..8881e5bfc 100644 --- a/addons/common/XEH_postInit.sqf +++ b/addons/common/XEH_postInit.sqf @@ -355,7 +355,7 @@ [QGVAR(loadMagazineInstantly), LINKFUNC(loadMagazineInstantly)] call CBA_fnc_addEventHandler; [QGVAR(setLampState), LINKFUNC(setLampState)] call CBA_fnc_addEventHandler; [QGVAR(setMagazineAmmo), LINKFUNC(setMagazineAmmo)] call CBA_fnc_addEventHandler; -[QGVAR(setSpeed), LINKFUNC(setSpeed)] call CBA_fnc_addEventHandler; +[QGVAR(setSpeedLimit), LINKFUNC(setSpeedLimit)] call CBA_fnc_addEventHandler; [QGVAR(setTurretAmmo), LINKFUNC(setTurretAmmo)] call CBA_fnc_addEventHandler; [QGVAR(setVehicleLaserState), LINKFUNC(setVehicleLaserState)] call CBA_fnc_addEventHandler; [QGVAR(showMessage), LINKFUNC(showMessage)] call CBA_fnc_addEventHandler; diff --git a/addons/common/functions/fnc_setSpeed.sqf b/addons/common/functions/fnc_setSpeedLimit.sqf similarity index 93% rename from addons/common/functions/fnc_setSpeed.sqf rename to addons/common/functions/fnc_setSpeedLimit.sqf index fd040082b..91870ffc7 100644 --- a/addons/common/functions/fnc_setSpeed.sqf +++ b/addons/common/functions/fnc_setSpeedLimit.sqf @@ -24,7 +24,7 @@ * None * * Example: - * [_vehicle, 1] call zen_common_fnc_setSpeed + * [_vehicle, 1] call zen_common_fnc_setSpeedLimit * * Public: No */ @@ -33,7 +33,7 @@ params ["_vehicle", "_speed"]; if (_vehicle isEqualType []) exitWith { { - [_x, _speed] call FUNC(setSpeed); + [_x, _speed] call FUNC(setSpeedLimit); } forEach _vehicle; }; From 0b7b802e922ff94cf55ba5289236a6de018ea805 Mon Sep 17 00:00:00 2001 From: Steve Zhao Date: Fri, 13 Oct 2023 11:33:17 -0400 Subject: [PATCH 9/9] handled in fnc_setSpeedLimit --- addons/attributes/XEH_postInit.sqf | 11 ----------- addons/attributes/initAttributes.sqf | 8 +------- 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/addons/attributes/XEH_postInit.sqf b/addons/attributes/XEH_postInit.sqf index 076968c92..bb51ad160 100644 --- a/addons/attributes/XEH_postInit.sqf +++ b/addons/attributes/XEH_postInit.sqf @@ -28,14 +28,3 @@ if (isServer) then { _unit enableAIFeature [_x, _abilities select _forEachIndex]; } forEach AI_ABILITIES; }] call CBA_fnc_addEventHandler; - -["CAManBase", "Local", { // If locality changes, forceSpeed must be reapplied. - params ["_entity", "_isLocal"]; - if (!_isLocal || {!alive _entity} || {!(_entity isKindOf "CAManBase")}) exitWith {}; - - private _setSpeed = _entity getVariable [QGVAR(setSpeed), 0]; - - if (_setSpeed != 0) then { - [_entity, _setSpeed] call FUNC(setSpeed); - }; -}, true, [], true] call CBA_fnc_addClassEventHandler; diff --git a/addons/attributes/initAttributes.sqf b/addons/attributes/initAttributes.sqf index a28521834..18cf5e953 100644 --- a/addons/attributes/initAttributes.sqf +++ b/addons/attributes/initAttributes.sqf @@ -83,18 +83,12 @@ {GVAR(enableAmmo) && {alive _entity} && {_entity call EFUNC(common,getVehicleAmmo) != -1}} ] call FUNC(addAttribute); -#define MAX_SPEED_HELI 300 [ // Helicopter "Object", [ELSTRING(Modules,ModuleConvoyParameters_Speed), LSTRING(SpeedLimit_Tooltip_Helicopter)], QGVAR(slider), - [-50, MAX_SPEED_HELI, 5, false, 0], + [-50, 300, 5, false, 0], { - if (_value == 0) then { - // There doesn't seem to be a way to remove this for a helicopter, so set to more than max - // 0 is not needed, use Toggle AI Path instead - _value = MAX_SPEED_HELI; - }; private _vehicles = [] call EFUNC(common,getSelectedVehicles) select { alive _x && {!isPlayer driver _x} && {_x isKindOf "Helicopter"} };