From 6afc0a9df03ff7fbceda1cf9ee5fb456b64afe48 Mon Sep 17 00:00:00 2001 From: Timi007 Date: Wed, 22 Jan 2025 15:11:12 +0100 Subject: [PATCH 01/11] Fix L-C11ME --- addons/common/gui.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/common/gui.hpp b/addons/common/gui.hpp index 9a0c4493b..2dcbd5027 100644 --- a/addons/common/gui.hpp +++ b/addons/common/gui.hpp @@ -53,10 +53,10 @@ class GVAR(RscCheckbox): RscCheckBox { y = 0; w = QUOTE(POS_W(1)); h = QUOTE(POS_H(1)); - soundClick[] = {"\a3\ui_f\data\sound\rscbutton\soundclick", 0.09, 1}; - soundEnter[] = {"\a3\ui_f\data\sound\rscbutton\soundenter", 0.09, 1}; - soundEscape[] = {"\a3\ui_f\data\sound\rscbutton\soundescape", 0.09, 1}; - soundPush[] = {"\a3\ui_f\data\sound\rscbutton\soundpush", 0.09, 1}; + soundClick[] = {"\a3\ui_f\data\sound\rscbutton\soundclick.wss", 0.09, 1}; + soundEnter[] = {"\a3\ui_f\data\sound\rscbutton\soundenter.wss", 0.09, 1}; + soundEscape[] = {"\a3\ui_f\data\sound\rscbutton\soundescape.wss", 0.09, 1}; + soundPush[] = {"\a3\ui_f\data\sound\rscbutton\soundpush.wss", 0.09, 1}; }; class GVAR(RscCombo): RscCombo { From 1d573871b93a7d82a95c3594a365f9324c056e67 Mon Sep 17 00:00:00 2001 From: Timi007 Date: Wed, 22 Jan 2025 15:16:12 +0100 Subject: [PATCH 02/11] Apply L-S24 --- .../functions/fnc_applyProperties.sqf | 10 ++++----- .../functions/fnc_createMarker.sqf | 2 +- addons/cover_map/functions/fnc_create.sqf | 22 +++++++++---------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/addons/area_markers/functions/fnc_applyProperties.sqf b/addons/area_markers/functions/fnc_applyProperties.sqf index 7ad34b3f6..d79d117cb 100644 --- a/addons/area_markers/functions/fnc_applyProperties.sqf +++ b/addons/area_markers/functions/fnc_applyProperties.sqf @@ -21,23 +21,23 @@ private _marker = _ctrlConfigure getVariable [QGVAR(marker), ""]; private _sizeA = parseNumber ctrlText (_ctrlConfigure controlsGroupCtrl IDC_CONFIGURE_SIZE_A); private _sizeB = parseNumber ctrlText (_ctrlConfigure controlsGroupCtrl IDC_CONFIGURE_SIZE_B); -_marker setMarkerSize [_sizeA, _sizeB]; +_marker setMarkerSizeLocal [_sizeA, _sizeB]; private _ctrlRotationSlider = _ctrlConfigure controlsGroupCtrl IDC_CONFIGURE_ROTATION_SLIDER; private _rotation = sliderPosition _ctrlRotationSlider; -_marker setMarkerDir _rotation; +_marker setMarkerDirLocal _rotation; private _ctrlShape = _ctrlConfigure controlsGroupCtrl IDC_CONFIGURE_SHAPE; private _shape = ["RECTANGLE", "ELLIPSE"] select lbCurSel _ctrlShape; -_marker setMarkerShape _shape; +_marker setMarkerShapeLocal _shape; private _ctrlBrush = _ctrlConfigure controlsGroupCtrl IDC_CONFIGURE_BRUSH; private _brush = _ctrlBrush lbData lbCurSel _ctrlBrush; -_marker setMarkerBrush _brush; +_marker setMarkerBrushLocal _brush; private _ctrlColor = _ctrlConfigure controlsGroupCtrl IDC_CONFIGURE_COLOR; private _color = _ctrlColor lbData lbCurSel _ctrlColor; -_marker setMarkerColor _color; +_marker setMarkerColorLocal _color; private _ctrlAlphaSlider = _ctrlConfigure controlsGroupCtrl IDC_CONFIGURE_ALPHA_SLIDER; private _alpha = sliderPosition _ctrlAlphaSlider; diff --git a/addons/area_markers/functions/fnc_createMarker.sqf b/addons/area_markers/functions/fnc_createMarker.sqf index 5b61293ef..2b025c8d4 100644 --- a/addons/area_markers/functions/fnc_createMarker.sqf +++ b/addons/area_markers/functions/fnc_createMarker.sqf @@ -21,7 +21,7 @@ params ["_position", ["_shape", "RECTANGLE"]]; private _marker = createMarker [format [QGVAR(%1), GVAR(nextID)], _position]; -_marker setMarkerShape _shape; +_marker setMarkerShapeLocal _shape; _marker setMarkerSize [50, 50]; GVAR(nextID) = GVAR(nextID) + 1; diff --git a/addons/cover_map/functions/fnc_create.sqf b/addons/cover_map/functions/fnc_create.sqf index a1b6fc6a8..0a04e0386 100644 --- a/addons/cover_map/functions/fnc_create.sqf +++ b/addons/cover_map/functions/fnc_create.sqf @@ -51,10 +51,10 @@ _size params [ ]; private _markerCover = createMarker [format [QGVAR(cover_%1), _x], _coverPos]; - _markerCover setMarkerShape "RECTANGLE"; - _markerCover setMarkerBrush "Solid"; - _markerCover setMarkerColor "ColorBlack"; - _markerCover setMarkerSize [_sizeMarker, SIZE_OUT - _sizeA]; + _markerCover setMarkerShapeLocal "RECTANGLE"; + _markerCover setMarkerBrushLocal "Solid"; + _markerCover setMarkerColorLocal "ColorBlack"; + _markerCover setMarkerSizeLocal [_sizeMarker, SIZE_OUT - _sizeA]; _markerCover setMarkerDir _direction; private _dotPos = [ @@ -63,16 +63,16 @@ _size params [ ]; private _markerDot = createMarker [format [QGVAR(dot_%1), _x], _dotPos]; - _markerDot setMarkerColor "ColorBlack"; - _markerDot setMarkerType "mil_box_noShadow"; - _markerDot setMarkerSize [0.75, 0.75]; + _markerDot setMarkerColorLocal "ColorBlack"; + _markerDot setMarkerTypeLocal "mil_box_noShadow"; + _markerDot setMarkerSizeLocal [0.75, 0.75]; _markerDot setMarkerDir _direction; } forEach [0, 90, 180, 270]; // Create border marker private _markerBorder = createMarker [QGVAR(border), [_centerX, _centerY]]; -_markerBorder setMarkerShape "RECTANGLE"; -_markerBorder setMarkerBrush "Border"; -_markerBorder setMarkerColor "ColorBlack"; -_markerBorder setMarkerSize [_sizeX, _sizeY]; +_markerBorder setMarkerShapeLocal "RECTANGLE"; +_markerBorder setMarkerBrushLocal "Border"; +_markerBorder setMarkerColorLocal "ColorBlack"; +_markerBorder setMarkerSizeLocal [_sizeX, _sizeY]; _markerBorder setMarkerDir _angle; From 9b3427d078b9557853fd885a1ca2e585017ab278 Mon Sep 17 00:00:00 2001 From: Timi007 Date: Wed, 22 Jan 2025 15:19:18 +0100 Subject: [PATCH 03/11] Apply L-S18 --- addons/ai/functions/fnc_canThrowGrenade.sqf | 2 +- addons/ai/functions/fnc_garrison.sqf | 2 +- addons/ai/functions/fnc_searchBuilding.sqf | 4 ++-- addons/common/functions/fnc_displayCuratorLoad.sqf | 2 +- addons/common/functions/fnc_serializeObjects.sqf | 2 +- addons/context_actions/functions/fnc_teleportZeus.sqf | 2 +- addons/editor/initKeybinds.inc.sqf | 2 +- addons/modules/functions/fnc_moduleTeleportPlayers.sqf | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/addons/ai/functions/fnc_canThrowGrenade.sqf b/addons/ai/functions/fnc_canThrowGrenade.sqf index 6d7cfdae6..888acc0ef 100644 --- a/addons/ai/functions/fnc_canThrowGrenade.sqf +++ b/addons/ai/functions/fnc_canThrowGrenade.sqf @@ -21,7 +21,7 @@ params [["_unit", objNull, [objNull]], ["_magazine", "", [""]]]; alive _unit && {!isPlayer _unit} -&& {vehicle _unit == _unit} +&& {isNull objectParent _unit} && {_unit isKindOf "CAManBase"} && {lifeState _unit in ["HEALTHY", "INJURED"]} && {!(_unit call EFUNC(common,isSwimming))} diff --git a/addons/ai/functions/fnc_garrison.sqf b/addons/ai/functions/fnc_garrison.sqf index ca92bd99d..7dbcdc7ad 100644 --- a/addons/ai/functions/fnc_garrison.sqf +++ b/addons/ai/functions/fnc_garrison.sqf @@ -42,7 +42,7 @@ if (_topDown) then { }; { - if (vehicle _x != _x) then { + if (!isNull objectParent _x) then { moveOut _x; }; } forEach _units; diff --git a/addons/ai/functions/fnc_searchBuilding.sqf b/addons/ai/functions/fnc_searchBuilding.sqf index 5bec9e5f0..96c44bdda 100644 --- a/addons/ai/functions/fnc_searchBuilding.sqf +++ b/addons/ai/functions/fnc_searchBuilding.sqf @@ -42,7 +42,7 @@ private _groupState = [formation _group, behaviour _leader, speedMode _group, co private _stances = []; { - if (alive _x && {vehicle _x == _x} && {!isPlayer _x}) then { + if (alive _x && {isNull objectParent _x} && {!isPlayer _x}) then { _stances pushBack [_x, unitPos _x]; [QEGVAR(common,setUnitPos), [_x, "UP"], _x] call CBA_fnc_targetEvent; }; @@ -54,7 +54,7 @@ private _stances = []; // Refresh units in case some died or left/joined the group private _units = units _group select { - alive _x && {vehicle _x == _x} && {!isPlayer _x} + alive _x && {isNull objectParent _x} && {!isPlayer _x} }; // Exit the search if the group has no units left diff --git a/addons/common/functions/fnc_displayCuratorLoad.sqf b/addons/common/functions/fnc_displayCuratorLoad.sqf index a0a06dfed..4f0543a56 100644 --- a/addons/common/functions/fnc_displayCuratorLoad.sqf +++ b/addons/common/functions/fnc_displayCuratorLoad.sqf @@ -18,7 +18,7 @@ params ["_display"]; // Remove "Gear" animation when entering Zeus -if (GVAR(disableGearAnim) && {vehicle player == player}) then { +if (GVAR(disableGearAnim) && {isNull objectParent player}) then { [{player switchMove _this}, animationState player] call CBA_fnc_execNextFrame; }; diff --git a/addons/common/functions/fnc_serializeObjects.sqf b/addons/common/functions/fnc_serializeObjects.sqf index ae3d31ae1..bb896138a 100644 --- a/addons/common/functions/fnc_serializeObjects.sqf +++ b/addons/common/functions/fnc_serializeObjects.sqf @@ -23,7 +23,7 @@ params [["_objects", [], [[]]], ["_centerPos", nil, [[]], [2, 3]], ["_includeWay // Filter destroyed objects and any objects that are attached to or "part of" another // The data for these objects will be included in the parent object's data -_objects = _objects select {alive _x && {vehicle _x == _x} && {isNull attachedTo _x} && {isNull ropeAttachedTo _x}}; +_objects = _objects select {alive _x && {isNull objectParent _x} && {isNull attachedTo _x} && {isNull ropeAttachedTo _x}}; _objects = _objects arrayIntersect _objects; // Find the center position of all objects if one is not given diff --git a/addons/context_actions/functions/fnc_teleportZeus.sqf b/addons/context_actions/functions/fnc_teleportZeus.sqf index 172a037ec..71efdb4b0 100644 --- a/addons/context_actions/functions/fnc_teleportZeus.sqf +++ b/addons/context_actions/functions/fnc_teleportZeus.sqf @@ -18,7 +18,7 @@ if (_hoveredEntity isEqualType objNull && {_hoveredEntity isKindOf "AllVehicles"} && {!(_hoveredEntity isKindOf "CAManBase")}) then { [[player], _hoveredEntity] call EFUNC(common,teleportIntoVehicle); } else { - if (vehicle player != player) then { + if (!isNull objectParent player) then { moveOut player; }; diff --git a/addons/editor/initKeybinds.inc.sqf b/addons/editor/initKeybinds.inc.sqf index 4b211ee57..d4fe93ae7 100644 --- a/addons/editor/initKeybinds.inc.sqf +++ b/addons/editor/initKeybinds.inc.sqf @@ -245,7 +245,7 @@ [[ELSTRING(main,DisplayName), LSTRING(AIControl)], QGVAR(toggleAIPATH), [LSTRING(ToggleAIPATH), LSTRING(ToggleAIPATH_Description)], { if (!isNull curatorCamera && {!GETMVAR(RscDisplayCurator_search,false)}) then { { - if (!isPlayer _x && {_x == vehicle _x || {_x == driver vehicle _x}}) then { + if (!isPlayer _x && {isNull objectParent _x || {_x == driver vehicle _x}}) then { private _isPathEnabled = _x checkAIFeature "PATH"; private _eventName = [QEGVAR(common,enableAI), QEGVAR(common,disableAI)] select _isPathEnabled; [_eventName, [_x, "PATH"], _x] call CBA_fnc_globalEvent; diff --git a/addons/modules/functions/fnc_moduleTeleportPlayers.sqf b/addons/modules/functions/fnc_moduleTeleportPlayers.sqf index 2f9e73cae..3f6dc224b 100644 --- a/addons/modules/functions/fnc_moduleTeleportPlayers.sqf +++ b/addons/modules/functions/fnc_moduleTeleportPlayers.sqf @@ -59,7 +59,7 @@ params ["_logic"]; } else { // Need special handling for players in vehicles // Without this they are teleported back inside the vehicle - if (_x isKindOf "CAManBase" && {vehicle _x != _x}) then { + if (_x isKindOf "CAManBase" && {!isNull objectParent _x}) then { [QGVAR(teleportOutOfVehicle), [_x, _position], _x] call CBA_fnc_targetEvent; } else { _x setVehiclePosition [_position, [], 0, "NONE"]; From c867d9de6674868f4a4ee0c7aeeaea6bc9142ae2 Mon Sep 17 00:00:00 2001 From: Timi007 Date: Wed, 22 Jan 2025 15:26:10 +0100 Subject: [PATCH 04/11] Ignore L-S17 --- .hemtt/lints.toml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.hemtt/lints.toml b/.hemtt/lints.toml index 09ce4a735..b583bdbf6 100644 --- a/.hemtt/lints.toml +++ b/.hemtt/lints.toml @@ -2,3 +2,15 @@ options.ignore = [ "addPublicVariableEventHandler", # Alt syntax is broken, we are using main syntax ] + +[sqf.var_all_caps] +options.ignore = [ + # Debug MACROS + "ZEN_RECOMPILES", + "ZEN_PREP_RECOMPILE", + "ZEN_PFH_COUNTER", + "ZEN_COUNTERS", + + # External variables + "AR_SUPPORTED_VEHICLES" +] From e676144fd738f1a2f127421406aabeac0e16efaf Mon Sep 17 00:00:00 2001 From: Timi007 Date: Wed, 22 Jan 2025 15:52:21 +0100 Subject: [PATCH 05/11] Move AI control keybinds to own file --- addons/editor/XEH_preInit.sqf | 1 + addons/editor/initKeybinds.inc.sqf | 131 -------------------- addons/editor/initKeybindsAIControl.inc.sqf | 130 +++++++++++++++++++ 3 files changed, 131 insertions(+), 131 deletions(-) create mode 100644 addons/editor/initKeybindsAIControl.inc.sqf diff --git a/addons/editor/XEH_preInit.sqf b/addons/editor/XEH_preInit.sqf index 6bdbfac2a..d886869e1 100644 --- a/addons/editor/XEH_preInit.sqf +++ b/addons/editor/XEH_preInit.sqf @@ -8,6 +8,7 @@ PREP_RECOMPILE_END; #include "initSettings.inc.sqf" #include "initKeybinds.inc.sqf" +#include "initKeybindsAIControl.inc.sqf" GVAR(clipboard) = []; GVAR(includeCrew) = true; diff --git a/addons/editor/initKeybinds.inc.sqf b/addons/editor/initKeybinds.inc.sqf index d4fe93ae7..34ec3f46d 100644 --- a/addons/editor/initKeybinds.inc.sqf +++ b/addons/editor/initKeybinds.inc.sqf @@ -133,134 +133,3 @@ true // handled }; }, {}, [DIK_U, [false, false, false]]] call CBA_fnc_addKeybind; // Default: U - -[[ELSTRING(main,DisplayName), LSTRING(AIControl)], QGVAR(ejectPassengers), [LSTRING(EjectPassengers), LSTRING(EjectPassengers_Description)], { - if (!isNull curatorCamera && {!GETMVAR(RscDisplayCurator_search,false)}) then { - { - [_x] call EFUNC(common,ejectPassengers); - } forEach SELECTED_OBJECTS; - - true // handled, prevents vanilla eject - }; -}, {}, [DIK_G, [false, true, false]]] call CBA_fnc_addKeybind; // Default: CTRL + G - -[[ELSTRING(main,DisplayName), LSTRING(AIControl)], QGVAR(deployCountermeasures), [LSTRING(DeployCountermeasures), LSTRING(DeployCountermeasures_Description)], { - if (!isNull curatorCamera && {!GETMVAR(RscDisplayCurator_search,false)}) then { - { - [_x] call EFUNC(common,deployCountermeasures); - } forEach SELECTED_OBJECTS; - - true // handled - }; -}, {}, [DIK_C, [true, false, false]]] call CBA_fnc_addKeybind; // Default: SHIFT + C - -[[ELSTRING(main,DisplayName), LSTRING(AIControl)], QGVAR(watchCursor), [LSTRING(WatchCursor), LSTRING(WatchCursor_Description)], { - if (!isNull curatorCamera && {!GETMVAR(RscDisplayCurator_search,false)}) then { - curatorMouseOver params ["_type", "_target"]; - - if (_type != "OBJECT") then { - _target = ASLToAGL ([] call EFUNC(common,getPosFromScreen)); - }; - - { - if (!isNull group _x && {!isPlayer _x}) then { - // Cancel if target is self - private _isSelf = _x isEqualTo _target; - private _target = [_target, objNull] select _isSelf; - [_x, _target] call EFUNC(common,forceWatch); - if (_isSelf) then {continue}; - - [[ - ["ICON", [_target, "\a3\ui_f\data\igui\cfg\simpletasks\types\scout_ca.paa"]], - ["LINE", [_x, _target]] - ], 3, _x] call EFUNC(common,drawHint); - }; - } forEach SELECTED_OBJECTS; - - true // handled - }; -}, {}, [0, [false, false, false]]] call CBA_fnc_addKeybind; // Default: Unbound - -[[ELSTRING(main,DisplayName), LSTRING(AIControl)], QGVAR(watchCuratorCamera), [LSTRING(WatchCuratorCamera), LSTRING(WatchCuratorCamera_Description)], { - if (!isNull curatorCamera && {!GETMVAR(RscDisplayCurator_search,false)}) then { - private _position = ASLToAGL getPosASL curatorCamera; - - { - if (!isNull group _x && {!isPlayer _x}) then { - [_x, _position] call EFUNC(common,forceWatch); - - [[ - ["ICON", [_position, "\a3\ui_f\data\igui\cfg\simpletasks\types\scout_ca.paa"]], - ["LINE", [_x, _position]] - ], 3, _x] call EFUNC(common,drawHint); - }; - } forEach SELECTED_OBJECTS; - - true // handled - }; -}, {}, [0, [false, false, false]]] call CBA_fnc_addKeybind; // Default: Unbound - -[[ELSTRING(main,DisplayName), LSTRING(AIControl)], QGVAR(forceFire), [LSTRING(ForceFire), LSTRING(ForceFire_Description)], { - if (!isNull curatorCamera && {!GETMVAR(RscDisplayCurator_search,false)}) then { - private _units = SELECTED_OBJECTS select {!isPlayer _x && {!isNull group _x}}; - [QEGVAR(common,forceFire), [_units, CBA_clientID]] call CBA_fnc_globalEvent; - - true // handled - }; -}, { - [QEGVAR(common,forceFire), [[], CBA_clientID]] call CBA_fnc_globalEvent; -}, [0, [false, false, false]]] call CBA_fnc_addKeybind; // Default: Unbound - -[[ELSTRING(main,DisplayName), LSTRING(AIControl)], QGVAR(toggleLaser), [LSTRING(ToggleLaser), LSTRING(ToggleLaser_Description)], { - if (!isNull curatorCamera && {!GETMVAR(RscDisplayCurator_search,false)}) then { - { - if (!isNull group _x && {!isPlayer _x}) then { - [_x] call EFUNC(common,setVehicleLaserState); - }; - } forEach SELECTED_OBJECTS; - - true // handled - }; -}, {}, [0, [false, false, false]]] call CBA_fnc_addKeybind; // Default: Unbound - -[[ELSTRING(main,DisplayName), LSTRING(AIControl)], QGVAR(moveToCursor), [LSTRING(MoveToCursor), LSTRING(MoveToCursor_Description)], { - if (!isNull curatorCamera && {!GETMVAR(RscDisplayCurator_search,false)}) then { - private _position = ASLToAGL ([] call EFUNC(common,getPosFromScreen)); - - { - if (!isNull driver _x && {!isPlayer _x}) then { - [QEGVAR(common,doMove), [_x, _position], _x] call CBA_fnc_targetEvent; - - [[ - ["ICON", [_position, "\a3\ui_f\data\igui\cfg\simpletasks\types\walk_ca.paa"]], - ["LINE", [_x, _position]] - ], 3, _x] call EFUNC(common,drawHint); - }; - } forEach SELECTED_OBJECTS; - - true // handled - }; -}, {}, [0, [false, false, false]]] call CBA_fnc_addKeybind; // Default: Unbound - -[[ELSTRING(main,DisplayName), LSTRING(AIControl)], QGVAR(toggleAIPATH), [LSTRING(ToggleAIPATH), LSTRING(ToggleAIPATH_Description)], { - if (!isNull curatorCamera && {!GETMVAR(RscDisplayCurator_search,false)}) then { - { - if (!isPlayer _x && {isNull objectParent _x || {_x == driver vehicle _x}}) then { - private _isPathEnabled = _x checkAIFeature "PATH"; - private _eventName = [QEGVAR(common,enableAI), QEGVAR(common,disableAI)] select _isPathEnabled; - [_eventName, [_x, "PATH"], _x] call CBA_fnc_globalEvent; - - private _icon = [ - "\a3\3den\Data\Displays\Display3DEN\PanelRight\modeWaypoints_ca.paa", - "\a3\3den\Data\CfgWaypoints\hold_ca.paa" - ] select _isPathEnabled; - - [[ - ["ICON", [_x, _icon]] - ], 3, _x] call EFUNC(common,drawHint); - }; - } forEach SELECTED_OBJECTS; - - true // handled - }; -}, {}, [0, [false, false, false]]] call CBA_fnc_addKeybind; // Default: Unbound diff --git a/addons/editor/initKeybindsAIControl.inc.sqf b/addons/editor/initKeybindsAIControl.inc.sqf new file mode 100644 index 000000000..d22ca5ac8 --- /dev/null +++ b/addons/editor/initKeybindsAIControl.inc.sqf @@ -0,0 +1,130 @@ +[[ELSTRING(main,DisplayName), LSTRING(AIControl)], QGVAR(ejectPassengers), [LSTRING(EjectPassengers), LSTRING(EjectPassengers_Description)], { + if (!isNull curatorCamera && {!GETMVAR(RscDisplayCurator_search,false)}) then { + { + [_x] call EFUNC(common,ejectPassengers); + } forEach SELECTED_OBJECTS; + + true // handled, prevents vanilla eject + }; +}, {}, [DIK_G, [false, true, false]]] call CBA_fnc_addKeybind; // Default: CTRL + G + +[[ELSTRING(main,DisplayName), LSTRING(AIControl)], QGVAR(deployCountermeasures), [LSTRING(DeployCountermeasures), LSTRING(DeployCountermeasures_Description)], { + if (!isNull curatorCamera && {!GETMVAR(RscDisplayCurator_search,false)}) then { + { + [_x] call EFUNC(common,deployCountermeasures); + } forEach SELECTED_OBJECTS; + + true // handled + }; +}, {}, [DIK_C, [true, false, false]]] call CBA_fnc_addKeybind; // Default: SHIFT + C + +[[ELSTRING(main,DisplayName), LSTRING(AIControl)], QGVAR(watchCursor), [LSTRING(WatchCursor), LSTRING(WatchCursor_Description)], { + if (!isNull curatorCamera && {!GETMVAR(RscDisplayCurator_search,false)}) then { + curatorMouseOver params ["_type", "_target"]; + + if (_type != "OBJECT") then { + _target = ASLToAGL ([] call EFUNC(common,getPosFromScreen)); + }; + + { + if (!isNull group _x && {!isPlayer _x}) then { + // Cancel if target is self + private _isSelf = _x isEqualTo _target; + private _target = [_target, objNull] select _isSelf; + [_x, _target] call EFUNC(common,forceWatch); + if (_isSelf) then {continue}; + + [[ + ["ICON", [_target, "\a3\ui_f\data\igui\cfg\simpletasks\types\scout_ca.paa"]], + ["LINE", [_x, _target]] + ], 3, _x] call EFUNC(common,drawHint); + }; + } forEach SELECTED_OBJECTS; + + true // handled + }; +}, {}, [0, [false, false, false]]] call CBA_fnc_addKeybind; // Default: Unbound + +[[ELSTRING(main,DisplayName), LSTRING(AIControl)], QGVAR(watchCuratorCamera), [LSTRING(WatchCuratorCamera), LSTRING(WatchCuratorCamera_Description)], { + if (!isNull curatorCamera && {!GETMVAR(RscDisplayCurator_search,false)}) then { + private _position = ASLToAGL getPosASL curatorCamera; + + { + if (!isNull group _x && {!isPlayer _x}) then { + [_x, _position] call EFUNC(common,forceWatch); + + [[ + ["ICON", [_position, "\a3\ui_f\data\igui\cfg\simpletasks\types\scout_ca.paa"]], + ["LINE", [_x, _position]] + ], 3, _x] call EFUNC(common,drawHint); + }; + } forEach SELECTED_OBJECTS; + + true // handled + }; +}, {}, [0, [false, false, false]]] call CBA_fnc_addKeybind; // Default: Unbound + +[[ELSTRING(main,DisplayName), LSTRING(AIControl)], QGVAR(forceFire), [LSTRING(ForceFire), LSTRING(ForceFire_Description)], { + if (!isNull curatorCamera && {!GETMVAR(RscDisplayCurator_search,false)}) then { + private _units = SELECTED_OBJECTS select {!isPlayer _x && {!isNull group _x}}; + [QEGVAR(common,forceFire), [_units, CBA_clientID]] call CBA_fnc_globalEvent; + + true // handled + }; +}, { + [QEGVAR(common,forceFire), [[], CBA_clientID]] call CBA_fnc_globalEvent; +}, [0, [false, false, false]]] call CBA_fnc_addKeybind; // Default: Unbound + +[[ELSTRING(main,DisplayName), LSTRING(AIControl)], QGVAR(toggleLaser), [LSTRING(ToggleLaser), LSTRING(ToggleLaser_Description)], { + if (!isNull curatorCamera && {!GETMVAR(RscDisplayCurator_search,false)}) then { + { + if (!isNull group _x && {!isPlayer _x}) then { + [_x] call EFUNC(common,setVehicleLaserState); + }; + } forEach SELECTED_OBJECTS; + + true // handled + }; +}, {}, [0, [false, false, false]]] call CBA_fnc_addKeybind; // Default: Unbound + +[[ELSTRING(main,DisplayName), LSTRING(AIControl)], QGVAR(moveToCursor), [LSTRING(MoveToCursor), LSTRING(MoveToCursor_Description)], { + if (!isNull curatorCamera && {!GETMVAR(RscDisplayCurator_search,false)}) then { + private _position = ASLToAGL ([] call EFUNC(common,getPosFromScreen)); + + { + if (!isNull driver _x && {!isPlayer _x}) then { + [QEGVAR(common,doMove), [_x, _position], _x] call CBA_fnc_targetEvent; + + [[ + ["ICON", [_position, "\a3\ui_f\data\igui\cfg\simpletasks\types\walk_ca.paa"]], + ["LINE", [_x, _position]] + ], 3, _x] call EFUNC(common,drawHint); + }; + } forEach SELECTED_OBJECTS; + + true // handled + }; +}, {}, [0, [false, false, false]]] call CBA_fnc_addKeybind; // Default: Unbound + +[[ELSTRING(main,DisplayName), LSTRING(AIControl)], QGVAR(toggleAIPATH), [LSTRING(ToggleAIPATH), LSTRING(ToggleAIPATH_Description)], { + if (!isNull curatorCamera && {!GETMVAR(RscDisplayCurator_search,false)}) then { + { + if (!isPlayer _x && {isNull objectParent _x || {_x == driver vehicle _x}}) then { + private _isPathEnabled = _x checkAIFeature "PATH"; + private _eventName = [QEGVAR(common,enableAI), QEGVAR(common,disableAI)] select _isPathEnabled; + [_eventName, [_x, "PATH"], _x] call CBA_fnc_globalEvent; + + private _icon = [ + "\a3\3den\Data\Displays\Display3DEN\PanelRight\modeWaypoints_ca.paa", + "\a3\3den\Data\CfgWaypoints\hold_ca.paa" + ] select _isPathEnabled; + + [[ + ["ICON", [_x, _icon]] + ], 3, _x] call EFUNC(common,drawHint); + }; + } forEach SELECTED_OBJECTS; + + true // handled + }; +}, {}, [0, [false, false, false]]] call CBA_fnc_addKeybind; // Default: Unbound From 85f1f6c8af8f269738a6c55e9ed42e114f6c6f79 Mon Sep 17 00:00:00 2001 From: Timi007 Date: Wed, 22 Jan 2025 15:53:07 +0100 Subject: [PATCH 06/11] Make category into var --- addons/editor/initKeybindsAIControl.inc.sqf | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/addons/editor/initKeybindsAIControl.inc.sqf b/addons/editor/initKeybindsAIControl.inc.sqf index d22ca5ac8..a188e69cd 100644 --- a/addons/editor/initKeybindsAIControl.inc.sqf +++ b/addons/editor/initKeybindsAIControl.inc.sqf @@ -1,4 +1,6 @@ -[[ELSTRING(main,DisplayName), LSTRING(AIControl)], QGVAR(ejectPassengers), [LSTRING(EjectPassengers), LSTRING(EjectPassengers_Description)], { +private _category = [ELSTRING(main,DisplayName), LSTRING(AIControl)]; + +[_category, QGVAR(ejectPassengers), [LSTRING(EjectPassengers), LSTRING(EjectPassengers_Description)], { if (!isNull curatorCamera && {!GETMVAR(RscDisplayCurator_search,false)}) then { { [_x] call EFUNC(common,ejectPassengers); @@ -8,7 +10,7 @@ }; }, {}, [DIK_G, [false, true, false]]] call CBA_fnc_addKeybind; // Default: CTRL + G -[[ELSTRING(main,DisplayName), LSTRING(AIControl)], QGVAR(deployCountermeasures), [LSTRING(DeployCountermeasures), LSTRING(DeployCountermeasures_Description)], { +[_category, QGVAR(deployCountermeasures), [LSTRING(DeployCountermeasures), LSTRING(DeployCountermeasures_Description)], { if (!isNull curatorCamera && {!GETMVAR(RscDisplayCurator_search,false)}) then { { [_x] call EFUNC(common,deployCountermeasures); @@ -18,7 +20,7 @@ }; }, {}, [DIK_C, [true, false, false]]] call CBA_fnc_addKeybind; // Default: SHIFT + C -[[ELSTRING(main,DisplayName), LSTRING(AIControl)], QGVAR(watchCursor), [LSTRING(WatchCursor), LSTRING(WatchCursor_Description)], { +[_category, QGVAR(watchCursor), [LSTRING(WatchCursor), LSTRING(WatchCursor_Description)], { if (!isNull curatorCamera && {!GETMVAR(RscDisplayCurator_search,false)}) then { curatorMouseOver params ["_type", "_target"]; @@ -45,7 +47,7 @@ }; }, {}, [0, [false, false, false]]] call CBA_fnc_addKeybind; // Default: Unbound -[[ELSTRING(main,DisplayName), LSTRING(AIControl)], QGVAR(watchCuratorCamera), [LSTRING(WatchCuratorCamera), LSTRING(WatchCuratorCamera_Description)], { +[_category, QGVAR(watchCuratorCamera), [LSTRING(WatchCuratorCamera), LSTRING(WatchCuratorCamera_Description)], { if (!isNull curatorCamera && {!GETMVAR(RscDisplayCurator_search,false)}) then { private _position = ASLToAGL getPosASL curatorCamera; @@ -64,7 +66,7 @@ }; }, {}, [0, [false, false, false]]] call CBA_fnc_addKeybind; // Default: Unbound -[[ELSTRING(main,DisplayName), LSTRING(AIControl)], QGVAR(forceFire), [LSTRING(ForceFire), LSTRING(ForceFire_Description)], { +[_category, QGVAR(forceFire), [LSTRING(ForceFire), LSTRING(ForceFire_Description)], { if (!isNull curatorCamera && {!GETMVAR(RscDisplayCurator_search,false)}) then { private _units = SELECTED_OBJECTS select {!isPlayer _x && {!isNull group _x}}; [QEGVAR(common,forceFire), [_units, CBA_clientID]] call CBA_fnc_globalEvent; @@ -75,7 +77,7 @@ [QEGVAR(common,forceFire), [[], CBA_clientID]] call CBA_fnc_globalEvent; }, [0, [false, false, false]]] call CBA_fnc_addKeybind; // Default: Unbound -[[ELSTRING(main,DisplayName), LSTRING(AIControl)], QGVAR(toggleLaser), [LSTRING(ToggleLaser), LSTRING(ToggleLaser_Description)], { +[_category, QGVAR(toggleLaser), [LSTRING(ToggleLaser), LSTRING(ToggleLaser_Description)], { if (!isNull curatorCamera && {!GETMVAR(RscDisplayCurator_search,false)}) then { { if (!isNull group _x && {!isPlayer _x}) then { @@ -87,7 +89,7 @@ }; }, {}, [0, [false, false, false]]] call CBA_fnc_addKeybind; // Default: Unbound -[[ELSTRING(main,DisplayName), LSTRING(AIControl)], QGVAR(moveToCursor), [LSTRING(MoveToCursor), LSTRING(MoveToCursor_Description)], { +[_category, QGVAR(moveToCursor), [LSTRING(MoveToCursor), LSTRING(MoveToCursor_Description)], { if (!isNull curatorCamera && {!GETMVAR(RscDisplayCurator_search,false)}) then { private _position = ASLToAGL ([] call EFUNC(common,getPosFromScreen)); @@ -106,7 +108,7 @@ }; }, {}, [0, [false, false, false]]] call CBA_fnc_addKeybind; // Default: Unbound -[[ELSTRING(main,DisplayName), LSTRING(AIControl)], QGVAR(toggleAIPATH), [LSTRING(ToggleAIPATH), LSTRING(ToggleAIPATH_Description)], { +[_category, QGVAR(toggleAIPATH), [LSTRING(ToggleAIPATH), LSTRING(ToggleAIPATH_Description)], { if (!isNull curatorCamera && {!GETMVAR(RscDisplayCurator_search,false)}) then { { if (!isPlayer _x && {isNull objectParent _x || {_x == driver vehicle _x}}) then { From 69afdbf1e77afea034e9f26c4a818193c8a0d4c5 Mon Sep 17 00:00:00 2001 From: Timi007 Date: Thu, 27 Feb 2025 15:45:52 +0100 Subject: [PATCH 07/11] Add keybinds for switching AI stance --- addons/editor/XEH_PREP.hpp | 1 + addons/editor/functions/fnc_setUnitPos.sqf | 43 +++++++++++++++++++++ addons/editor/initKeybindsAIControl.inc.sqf | 40 +++++++++++++++++++ addons/editor/stringtable.xml | 32 +++++++++++++++ 4 files changed, 116 insertions(+) create mode 100644 addons/editor/functions/fnc_setUnitPos.sqf diff --git a/addons/editor/XEH_PREP.hpp b/addons/editor/XEH_PREP.hpp index ba8e181f0..bffc8de27 100644 --- a/addons/editor/XEH_PREP.hpp +++ b/addons/editor/XEH_PREP.hpp @@ -15,3 +15,4 @@ PREP(handleSideButtons); PREP(handleTreeButtons); PREP(handleUnload); PREP(pingCurators); +PREP(setUnitPos); diff --git a/addons/editor/functions/fnc_setUnitPos.sqf b/addons/editor/functions/fnc_setUnitPos.sqf new file mode 100644 index 000000000..2b5aad88b --- /dev/null +++ b/addons/editor/functions/fnc_setUnitPos.sqf @@ -0,0 +1,43 @@ +#include "..\script_component.hpp" +/* + * Authors: Timi007 + * Sets the stance of a unit and shows an icon as hint. + * + * Arguments: + * 0: Unit + * 1: Stance ("UP", "MIDDLE", "DOWN", "AUTO") + * + * Return Value: + * Handled + * + * Example: + * [cursorObject, "UP"] call zen_editor_fnc_setUnitPos + * + * Public: No + */ + +params ["_unit", "_stance"]; + +if ( + isNull _unit || + {isPlayer _unit} || + {!alive _unit} || + {!isNull objectParent _unit} || + {unitPos _unit == _stance} +) exitWith {false}; + +[QEGVAR(common,setUnitPos), [_unit, _stance], _unit] call CBA_fnc_targetEvent; + +private _white = [1, 1, 1, 1]; +private _iconProperties = switch (_stance) do { + case "UP": {[_unit, "\a3\3DEN\Data\Attributes\Stance\up_ca.paa", _white, 1.5]}; + case "MIDDLE": {[_unit, "\a3\3DEN\Data\Attributes\Stance\middle_ca.paa", _white, 1.5]}; + case "DOWN": {[_unit, "\a3\3DEN\Data\Attributes\Stance\down_ca.paa", _white, 1.5]}; + case "AUTO": {[_unit, "\a3\3DEN\Data\Attributes\default_ca.paa", _white, 1]}; +}; + +[[ + ["ICON", _iconProperties] +], 3, _unit] call EFUNC(common,drawHint); + +true diff --git a/addons/editor/initKeybindsAIControl.inc.sqf b/addons/editor/initKeybindsAIControl.inc.sqf index a188e69cd..c9ceca08f 100644 --- a/addons/editor/initKeybindsAIControl.inc.sqf +++ b/addons/editor/initKeybindsAIControl.inc.sqf @@ -130,3 +130,43 @@ private _category = [ELSTRING(main,DisplayName), LSTRING(AIControl)]; true // handled }; }, {}, [0, [false, false, false]]] call CBA_fnc_addKeybind; // Default: Unbound + +[_category, QGVAR(setUnitPosUp), [LSTRING(SetUnitPosUp), LSTRING(SetUnitPosUp_Description)], { + if (!isNull curatorCamera && {!GETMVAR(RscDisplayCurator_search,false)}) then { + { + [_x, "UP"] call FUNC(setUnitPos); + } forEach SELECTED_OBJECTS; + + true // handled + }; +}, {}, [DIK_1, [false, false, false]]] call CBA_fnc_addKeybind; // Default: 1 + +[_category, QGVAR(setUnitPosMiddle), [LSTRING(SetUnitPosMiddle), LSTRING(SetUnitPosMiddle_Description)], { + if (!isNull curatorCamera && {!GETMVAR(RscDisplayCurator_search,false)}) then { + { + [_x, "MIDDLE"] call FUNC(setUnitPos); + } forEach SELECTED_OBJECTS; + + true // handled + }; +}, {}, [DIK_2, [false, false, false]]] call CBA_fnc_addKeybind; // Default: 2 + +[_category, QGVAR(setUnitPosDown), [LSTRING(SetUnitPosDown), LSTRING(SetUnitPosDown_Description)], { + if (!isNull curatorCamera && {!GETMVAR(RscDisplayCurator_search,false)}) then { + { + [_x, "DOWN"] call FUNC(setUnitPos); + } forEach SELECTED_OBJECTS; + + true // handled + }; +}, {}, [DIK_3, [false, false, false]]] call CBA_fnc_addKeybind; // Default: 3 + +[_category, QGVAR(setUnitPosAuto), [LSTRING(SetUnitPosAuto), LSTRING(SetUnitPosAuto_Description)], { + if (!isNull curatorCamera && {!GETMVAR(RscDisplayCurator_search,false)}) then { + { + [_x, "AUTO"] call FUNC(setUnitPos); + } forEach SELECTED_OBJECTS; + + true // handled + }; +}, {}, [DIK_4, [false, false, false]]] call CBA_fnc_addKeybind; // Default: 4 diff --git a/addons/editor/stringtable.xml b/addons/editor/stringtable.xml index 4efbba05d..238775630 100644 --- a/addons/editor/stringtable.xml +++ b/addons/editor/stringtable.xml @@ -438,5 +438,37 @@ Makes selected AI units start or stop moving. Does not affect aiming or shooting. Similar to "Hold Position" in RTS games. 選択した AI ユニットの移動を開始または停止します。 照準や射撃には影響しません。 RTS ゲームの「ホールド ポジション」に似ています。 + + Switch stance to standing + Haltung auf aufrecht umschalten + + + Switch the stance of all selected units to standing. + Haltung aller ausgewählten Einheiten auf aufrecht umschalten. + + + Switch stance to crouch + Haltung auf geduckt umschalten + + + Switch the stance of all selected units to crouch. + Haltung aller ausgewählten Einheiten auf geduckt umschalten. + + + Switch stance to prone + Haltung auf liegend umschalten + + + Switch the stance of all selected units to prone. + Haltung aller ausgewählten Einheiten auf liegend umschalten. + + + Switch stance to automatic + Haltung auf automatisch umschalten + + + Switch the stance of all selected units to automatic. + Haltung aller ausgewählten Einheiten auf automatisch umschalten. + From 37ba2a48f7ba1ac32abeaed64ce988f217841c00 Mon Sep 17 00:00:00 2001 From: Timi007 Date: Thu, 27 Feb 2025 17:18:41 +0100 Subject: [PATCH 08/11] Add fade out effect --- addons/common/functions/fnc_drawHint.sqf | 46 +++++++++++++++++----- addons/editor/functions/fnc_setUnitPos.sqf | 2 +- 2 files changed, 38 insertions(+), 10 deletions(-) diff --git a/addons/common/functions/fnc_drawHint.sqf b/addons/common/functions/fnc_drawHint.sqf index 448364b68..9290e6092 100644 --- a/addons/common/functions/fnc_drawHint.sqf +++ b/addons/common/functions/fnc_drawHint.sqf @@ -35,6 +35,7 @@ * 2: ID (default: "") * - an ID is generated when an empty string is given. * - in the case of an OBJECT, the hash value is used. + * 3: Duration of fade out (in seconds). Fade out will occur within show duration (default: 0) * * Return Value: * ID @@ -50,7 +51,8 @@ params [ ["_elements", [], [[]]], ["_duration", 0, [0]], - ["_id", "", ["", objNull]] + ["_id", "", ["", objNull]], + ["_fadeOut", 0, [0]] ]; private _ctrlMap = findDisplay IDD_RSCDISPLAYCURATOR displayCtrl IDC_RSCDISPLAYCURATOR_MAINMAP; @@ -126,14 +128,23 @@ private _lines = []; // Add event handlers to draw the hint elements private _fnc_draw2D = { params ["_ctrlMap"]; - _thisArgs params ["_icons", "_lines"]; + _thisArgs params ["_icons", "_lines", "_endTime", "_fadeOutTime"]; + + // No drawing if in screenshot mode + if (call EFUNC(common,isInScreenshotMode)) exitWith {}; + + private _time = CBA_missionTime; { _x params ["_position", "_icon", "_color", "_scale", "_angle", "_text", "_shadow", "_textSize", "_font", "_align"]; if (_position isEqualTo objNull) then {continue}; - _ctrlMap drawIcon [_icon, _color, _position, _scale * MAP_ICON_SIZE, _scale * MAP_ICON_SIZE, _angle, _text, _shadow, _textSize, _font, _align]; + // Handle fade out + private _a = linearConversion [_fadeOutTime, _endTime, _time, _color select 3, 0, true]; + private _newColor = (_color select [0, 3]) + [_a]; + + _ctrlMap drawIcon [_icon, _newColor, _position, _scale * MAP_ICON_SIZE, _scale * MAP_ICON_SIZE, _angle, _text, _shadow, _textSize, _font, _align]; } forEach _icons; { @@ -141,15 +152,20 @@ private _fnc_draw2D = { if (objNull in [_begPos, _endPos]) then {continue}; - _ctrlMap drawLine [_begPos, _endPos, _color]; + // Handle fade out + private _a = linearConversion [_fadeOutTime, _endTime, _time, _color select 3, 0, true]; + private _newColor = (_color select [0, 3]) + [_a]; + + _ctrlMap drawLine [_begPos, _endPos, _newColor]; } forEach _lines; }; private _fnc_draw3D = { - _thisArgs params ["_icons", "_lines", "_endTime", "_id"]; + _thisArgs params ["_icons", "_lines", "_endTime", "_fadeOutTime", "_id"]; // Exit if the Zeus display is closed or hint duration is complete - if (isNull curatorCamera || {CBA_missionTime >= _endTime}) exitWith { + private _time = CBA_missionTime; + if (isNull curatorCamera || {_time >= _endTime}) exitWith { GVAR(drawHintMap) deleteAt _id params ["_id2D", "_id3D"]; private _ctrlMap = findDisplay IDD_RSCDISPLAYCURATOR displayCtrl IDC_RSCDISPLAYCURATOR_MAINMAP; @@ -169,7 +185,11 @@ private _fnc_draw3D = { _position = unitAimPositionVisual _position; }; - drawIcon3D [_icon, _color, _position, _scale, _scale, _angle, _text, _shadow, _textSize, _font, _align]; + // Handle fade out + private _a = linearConversion [_fadeOutTime, _endTime, _time, _color select 3, 0, true]; + private _newColor = (_color select [0, 3]) + [_a]; + + drawIcon3D [_icon, _newColor, _position, _scale, _scale, _angle, _text, _shadow, _textSize, _font, _align]; } forEach _icons; { @@ -185,11 +205,19 @@ private _fnc_draw3D = { _endPos = unitAimPositionVisual _endPos; }; - drawLine3D [_begPos, _endPos, _color]; + // Handle fade out + private _a = linearConversion [_fadeOutTime, _endTime, _time, _color select 3, 0, true]; + private _newColor = (_color select [0, 3]) + [_a]; + + drawLine3D [_begPos, _endPos, _newColor]; } forEach _lines; }; -private _args = [_icons, _lines, CBA_missionTime + _duration, _id]; +private _endTime = CBA_missionTime + _duration; +// Fade out will be performed within show duration; clip _fadeout value between 0 and duration. +private _fadeOutTime = _endTime - ((_fadeOut min _duration) max 0); + +private _args = [_icons, _lines, _endTime, _fadeOutTime, _id]; private _id2D = [_ctrlMap, "Draw", _fnc_draw2D, _args] call CBA_fnc_addBISEventHandler; private _id3D = [missionNamespace, "Draw3D", _fnc_draw3D, _args] call CBA_fnc_addBISEventHandler; GVAR(drawHintMap) set [_id, [_id2D, _id3D]]; diff --git a/addons/editor/functions/fnc_setUnitPos.sqf b/addons/editor/functions/fnc_setUnitPos.sqf index 2b5aad88b..9e1adb392 100644 --- a/addons/editor/functions/fnc_setUnitPos.sqf +++ b/addons/editor/functions/fnc_setUnitPos.sqf @@ -38,6 +38,6 @@ private _iconProperties = switch (_stance) do { [[ ["ICON", _iconProperties] -], 3, _unit] call EFUNC(common,drawHint); +], 3, _unit, 1] call EFUNC(common,drawHint); true From c18d0e713b553961c9cb17b2586b68c97f23533c Mon Sep 17 00:00:00 2001 From: Timi007 Date: Sat, 1 Mar 2025 14:41:54 +0100 Subject: [PATCH 09/11] Use FUNC --- addons/common/functions/fnc_drawHint.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/common/functions/fnc_drawHint.sqf b/addons/common/functions/fnc_drawHint.sqf index 9290e6092..56ed86d60 100644 --- a/addons/common/functions/fnc_drawHint.sqf +++ b/addons/common/functions/fnc_drawHint.sqf @@ -131,7 +131,7 @@ private _fnc_draw2D = { _thisArgs params ["_icons", "_lines", "_endTime", "_fadeOutTime"]; // No drawing if in screenshot mode - if (call EFUNC(common,isInScreenshotMode)) exitWith {}; + if (call FUNC(isInScreenshotMode)) exitWith {}; private _time = CBA_missionTime; From 7b17cb5d06509a779a1707fd3b8be997cc396733 Mon Sep 17 00:00:00 2001 From: Timi007 Date: Thu, 6 Mar 2025 23:41:23 +0100 Subject: [PATCH 10/11] Apply changes from code review --- addons/common/functions/fnc_drawHint.sqf | 4 +- addons/editor/XEH_PREP.hpp | 2 +- addons/editor/functions/fnc_setUnitPos.sqf | 43 ------------------ addons/editor/functions/fnc_switchStance.sqf | 46 ++++++++++++++++++++ addons/editor/initKeybindsAIControl.inc.sqf | 24 ++++------ addons/editor/stringtable.xml | 8 ++-- 6 files changed, 61 insertions(+), 66 deletions(-) delete mode 100644 addons/editor/functions/fnc_setUnitPos.sqf create mode 100644 addons/editor/functions/fnc_switchStance.sqf diff --git a/addons/common/functions/fnc_drawHint.sqf b/addons/common/functions/fnc_drawHint.sqf index 56ed86d60..2c68fde58 100644 --- a/addons/common/functions/fnc_drawHint.sqf +++ b/addons/common/functions/fnc_drawHint.sqf @@ -1,6 +1,6 @@ #include "script_component.hpp" /* - * Author: Ampersand, mharis001 + * Author: Ampersand, mharis001, Timi007 * Draws a hint that contains icon and line elements in 2D (Zeus display map) * and 3D (in world) for the given duration. * @@ -35,7 +35,7 @@ * 2: ID (default: "") * - an ID is generated when an empty string is given. * - in the case of an OBJECT, the hash value is used. - * 3: Duration of fade out (in seconds). Fade out will occur within show duration (default: 0) + * 3: Fade Out Duration (in seconds). Fade out will occur within show duration (default: 0) * * Return Value: * ID diff --git a/addons/editor/XEH_PREP.hpp b/addons/editor/XEH_PREP.hpp index bffc8de27..459c9b49b 100644 --- a/addons/editor/XEH_PREP.hpp +++ b/addons/editor/XEH_PREP.hpp @@ -15,4 +15,4 @@ PREP(handleSideButtons); PREP(handleTreeButtons); PREP(handleUnload); PREP(pingCurators); -PREP(setUnitPos); +PREP(switchStance); diff --git a/addons/editor/functions/fnc_setUnitPos.sqf b/addons/editor/functions/fnc_setUnitPos.sqf deleted file mode 100644 index 9e1adb392..000000000 --- a/addons/editor/functions/fnc_setUnitPos.sqf +++ /dev/null @@ -1,43 +0,0 @@ -#include "..\script_component.hpp" -/* - * Authors: Timi007 - * Sets the stance of a unit and shows an icon as hint. - * - * Arguments: - * 0: Unit - * 1: Stance ("UP", "MIDDLE", "DOWN", "AUTO") - * - * Return Value: - * Handled - * - * Example: - * [cursorObject, "UP"] call zen_editor_fnc_setUnitPos - * - * Public: No - */ - -params ["_unit", "_stance"]; - -if ( - isNull _unit || - {isPlayer _unit} || - {!alive _unit} || - {!isNull objectParent _unit} || - {unitPos _unit == _stance} -) exitWith {false}; - -[QEGVAR(common,setUnitPos), [_unit, _stance], _unit] call CBA_fnc_targetEvent; - -private _white = [1, 1, 1, 1]; -private _iconProperties = switch (_stance) do { - case "UP": {[_unit, "\a3\3DEN\Data\Attributes\Stance\up_ca.paa", _white, 1.5]}; - case "MIDDLE": {[_unit, "\a3\3DEN\Data\Attributes\Stance\middle_ca.paa", _white, 1.5]}; - case "DOWN": {[_unit, "\a3\3DEN\Data\Attributes\Stance\down_ca.paa", _white, 1.5]}; - case "AUTO": {[_unit, "\a3\3DEN\Data\Attributes\default_ca.paa", _white, 1]}; -}; - -[[ - ["ICON", _iconProperties] -], 3, _unit, 1] call EFUNC(common,drawHint); - -true diff --git a/addons/editor/functions/fnc_switchStance.sqf b/addons/editor/functions/fnc_switchStance.sqf new file mode 100644 index 000000000..6427770a3 --- /dev/null +++ b/addons/editor/functions/fnc_switchStance.sqf @@ -0,0 +1,46 @@ +#include "..\script_component.hpp" +/* + * Authors: Timi007 + * Sets the stance of the units and shows an icon as hint. + * + * Arguments: + * 0: Unit(s) + * 1: Stance ("UP", "MIDDLE", "DOWN", "AUTO") + * + * Return Value: + * None + * + * Example: + * [cursorObject, "UP"] call zen_editor_fnc_switchStance + * + * Public: No + */ + +params [["_units", [], [objNull, []]], ["_stance", "AUTO", [""]]]; + +if (_units isEqualType objNull) then { + _units = [_units]; +}; + +private _color = [1, 1, 1, 1]; +private _iconProperties = switch (_stance) do { + case "UP": {["\a3\3DEN\Data\Attributes\Stance\up_ca.paa", _color, 1.5]}; + case "MIDDLE": {["\a3\3DEN\Data\Attributes\Stance\middle_ca.paa", _color, 1.5]}; + case "DOWN": {["\a3\3DEN\Data\Attributes\Stance\down_ca.paa", _color, 1.5]}; + case "AUTO": {["\a3\3DEN\Data\Attributes\default_ca.paa", _color, 1]}; +}; + +{ + if ( + !alive _x + || {isPlayer _x} + || {!isNull objectParent _x} + || {unitPos _x == _stance} + ) then {continue}; + + [QEGVAR(common,setUnitPos), [_x, _stance], _x] call CBA_fnc_targetEvent; + + [[ + ["ICON", [_x] + _iconProperties] + ], 3, _x, 1] call EFUNC(common,drawHint); +} forEach _units; diff --git a/addons/editor/initKeybindsAIControl.inc.sqf b/addons/editor/initKeybindsAIControl.inc.sqf index c9ceca08f..66dc02d59 100644 --- a/addons/editor/initKeybindsAIControl.inc.sqf +++ b/addons/editor/initKeybindsAIControl.inc.sqf @@ -133,40 +133,32 @@ private _category = [ELSTRING(main,DisplayName), LSTRING(AIControl)]; [_category, QGVAR(setUnitPosUp), [LSTRING(SetUnitPosUp), LSTRING(SetUnitPosUp_Description)], { if (!isNull curatorCamera && {!GETMVAR(RscDisplayCurator_search,false)}) then { - { - [_x, "UP"] call FUNC(setUnitPos); - } forEach SELECTED_OBJECTS; + [SELECTED_OBJECTS, "UP"] call FUNC(switchStance); true // handled }; -}, {}, [DIK_1, [false, false, false]]] call CBA_fnc_addKeybind; // Default: 1 +}, {}, [0, [false, false, false]]] call CBA_fnc_addKeybind; // Default: Unbound [_category, QGVAR(setUnitPosMiddle), [LSTRING(SetUnitPosMiddle), LSTRING(SetUnitPosMiddle_Description)], { if (!isNull curatorCamera && {!GETMVAR(RscDisplayCurator_search,false)}) then { - { - [_x, "MIDDLE"] call FUNC(setUnitPos); - } forEach SELECTED_OBJECTS; + [SELECTED_OBJECTS, "MIDDLE"] call FUNC(switchStance); true // handled }; -}, {}, [DIK_2, [false, false, false]]] call CBA_fnc_addKeybind; // Default: 2 +}, {}, [0, [false, false, false]]] call CBA_fnc_addKeybind; // Default: Unbound [_category, QGVAR(setUnitPosDown), [LSTRING(SetUnitPosDown), LSTRING(SetUnitPosDown_Description)], { if (!isNull curatorCamera && {!GETMVAR(RscDisplayCurator_search,false)}) then { - { - [_x, "DOWN"] call FUNC(setUnitPos); - } forEach SELECTED_OBJECTS; + [SELECTED_OBJECTS, "DOWN"] call FUNC(switchStance); true // handled }; -}, {}, [DIK_3, [false, false, false]]] call CBA_fnc_addKeybind; // Default: 3 +}, {}, [0, [false, false, false]]] call CBA_fnc_addKeybind; // Default: Unbound [_category, QGVAR(setUnitPosAuto), [LSTRING(SetUnitPosAuto), LSTRING(SetUnitPosAuto_Description)], { if (!isNull curatorCamera && {!GETMVAR(RscDisplayCurator_search,false)}) then { - { - [_x, "AUTO"] call FUNC(setUnitPos); - } forEach SELECTED_OBJECTS; + [SELECTED_OBJECTS, "AUTO"] call FUNC(switchStance); true // handled }; -}, {}, [DIK_4, [false, false, false]]] call CBA_fnc_addKeybind; // Default: 4 +}, {}, [0, [false, false, false]]] call CBA_fnc_addKeybind; // Default: Unbound diff --git a/addons/editor/stringtable.xml b/addons/editor/stringtable.xml index 06e2a7efa..e449a9d6c 100644 --- a/addons/editor/stringtable.xml +++ b/addons/editor/stringtable.xml @@ -476,7 +476,7 @@ Permet aux unités IA sélectionnées de commencer ou d'arrêter de se déplacer. N'affecte pas la visée ou le tir. Semblable à la fonction « Maintenir la position » dans les jeux RTS. - Switch stance to standing + Switch Stance to Standing Haltung auf aufrecht umschalten @@ -484,7 +484,7 @@ Haltung aller ausgewählten Einheiten auf aufrecht umschalten. - Switch stance to crouch + Switch Stance to Crouch Haltung auf geduckt umschalten @@ -492,7 +492,7 @@ Haltung aller ausgewählten Einheiten auf geduckt umschalten. - Switch stance to prone + Switch Stance to Prone Haltung auf liegend umschalten @@ -500,7 +500,7 @@ Haltung aller ausgewählten Einheiten auf liegend umschalten. - Switch stance to automatic + Switch Stance to Automatic Haltung auf automatisch umschalten From 4be62f68d461e74d4f111a633b9c2c9585e81a40 Mon Sep 17 00:00:00 2001 From: Timi007 Date: Thu, 6 Mar 2025 23:42:37 +0100 Subject: [PATCH 11/11] Fix docs --- addons/common/functions/fnc_drawHint.sqf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/common/functions/fnc_drawHint.sqf b/addons/common/functions/fnc_drawHint.sqf index 2c68fde58..fa96a9704 100644 --- a/addons/common/functions/fnc_drawHint.sqf +++ b/addons/common/functions/fnc_drawHint.sqf @@ -35,7 +35,8 @@ * 2: ID (default: "") * - an ID is generated when an empty string is given. * - in the case of an OBJECT, the hash value is used. - * 3: Fade Out Duration (in seconds). Fade out will occur within show duration (default: 0) + * 3: Fade Out Duration (in seconds) (default: 0) + * - will occur within show duration. * * Return Value: * ID