From f1653f1300694249ba33581a0e6b5d54fcf103f8 Mon Sep 17 00:00:00 2001 From: mharis001 <34453221+mharis001@users.noreply.github.com> Date: Mon, 20 Mar 2023 23:58:29 -0400 Subject: [PATCH 1/6] Improve Watch Cursor and Watch Curator Camera keybinds (#720) --- addons/common/XEH_PREP.hpp | 1 + addons/common/XEH_postInit.sqf | 21 +++++++++ addons/common/functions/fnc_forceWatch.sqf | 52 ++++++++++++++++++++++ addons/editor/initKeybinds.sqf | 4 +- 4 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 addons/common/functions/fnc_forceWatch.sqf diff --git a/addons/common/XEH_PREP.hpp b/addons/common/XEH_PREP.hpp index 5fc2d6691..9489a0a45 100644 --- a/addons/common/XEH_PREP.hpp +++ b/addons/common/XEH_PREP.hpp @@ -17,6 +17,7 @@ PREP(fireArtillery); PREP(fireVLS); PREP(fireWeapon); PREP(forceFire); +PREP(forceWatch); PREP(formatDegrees); PREP(getActiveTree); PREP(getAllTurrets); diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf index dd77cdc26..9467080a5 100644 --- a/addons/common/XEH_postInit.sqf +++ b/addons/common/XEH_postInit.sqf @@ -143,6 +143,27 @@ _unit doWatch _target; }] call CBA_fnc_addEventHandler; +[QGVAR(doTarget), { + params ["_unit", "_target", ["_reveal", true]]; + + if (_reveal) then { + if (_unit isEqualType objNull) then { + _unit = [_unit]; + }; + + { + _x reveal [_target, 4]; + } forEach _unit; + }; + + _unit doTarget _target; +}] call CBA_fnc_addEventHandler; + +[QGVAR(lockCameraTo), { + params ["_vehicle", "_target", "_turretPath", "_temporary"]; + _vehicle lockCameraTo [_target, _turretPath, _temporary]; +}] call CBA_fnc_addEventHandler; + [QGVAR(enableGunLights), { params ["_unit", "_mode"]; _unit enableGunLights _mode; diff --git a/addons/common/functions/fnc_forceWatch.sqf b/addons/common/functions/fnc_forceWatch.sqf new file mode 100644 index 000000000..e7e79089f --- /dev/null +++ b/addons/common/functions/fnc_forceWatch.sqf @@ -0,0 +1,52 @@ +#include "script_component.hpp" +/* + * Author: mharis001 + * Makes the given unit watch the specified target. + * + * Arguments: + * 0: Unit + * 1: Target (default: objNull) + * - When given objNull, the unit stops watching its current target. + * - Positions must be in AGL format. + * + * Return Value: + * None + * + * Example: + * [_unit, _target] call zen_common_fnc_forceWatch + * + * Public: No + */ + +params [["_unit", objNull, [objNull]], ["_target", objNull, [objNull, []], 3]]; + +[QGVAR(doWatch), [[_unit, gunner _unit], _target], _unit] call CBA_fnc_targetEvent; + +// If an object is given, make the unit target the object in addition to watching it +if (_target isEqualType objNull && {!isNull _target}) then { + [QGVAR(doTarget), [[_unit, gunner _unit], _target], _unit] call CBA_fnc_targetEvent; +}; + +// Make vehicles or units in vehicles watch target by locking their turret cameras onto it +private _vehicle = vehicle _unit; + +if ( + _unit isNotEqualTo _vehicle + || {_unit isKindOf "LandVehicle"} + || {_unit isKindOf "Air"} + || {_unit isKindOf "Ship"} +) then { + private _turretPaths = if (_unit isEqualTo _vehicle) then { + _vehicle call FUNC(getAllTurrets) + } else { + [_vehicle unitTurret _unit] + }; + + if (_target isEqualType []) then { + _target = AGLToASL _target; + }; + + { + [QGVAR(lockCameraTo), [_vehicle, _target, _x, false], _vehicle, _x] call CBA_fnc_turretEvent; + } forEach _turretPaths; +}; diff --git a/addons/editor/initKeybinds.sqf b/addons/editor/initKeybinds.sqf index 9c3a49a92..7670968d8 100644 --- a/addons/editor/initKeybinds.sqf +++ b/addons/editor/initKeybinds.sqf @@ -146,7 +146,7 @@ // Cancel if target is self private _isSelf = _x isEqualTo _target; private _target = [_target, objNull] select _isSelf; - [QEGVAR(common,doWatch), [[_x, gunner _x], _target], _x] call CBA_fnc_targetEvent; + [_x, _target] call EFUNC(common,forceWatch); if (_isSelf) then {continue}; [[ @@ -166,7 +166,7 @@ { if (!isNull group _x && {!isPlayer _x}) then { - [QEGVAR(common,doWatch), [_x, _position], _x] call CBA_fnc_targetEvent; + [_x, _position] call EFUNC(common,forceWatch); [[ ["ICON", [_position, "\a3\ui_f\data\igui\cfg\simpletasks\types\scout_ca.paa"]], From d6f8e15dac046f884f18b97f0a26d1695a521316 Mon Sep 17 00:00:00 2001 From: mharis001 <34453221+mharis001@users.noreply.github.com> Date: Wed, 22 Mar 2023 01:21:26 -0400 Subject: [PATCH 2/6] Add Toggle Laser keybind (#721) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add Toggle Laser keybind * Update addons/editor/stringtable.xml Co-authored-by: Jouni Järvinen --------- Co-authored-by: Jouni Järvinen --- addons/common/XEH_PREP.hpp | 1 + addons/common/XEH_postInit.sqf | 1 + .../functions/fnc_setVehicleLaserState.sqf | 46 +++++++++++++++++++ addons/editor/initKeybinds.sqf | 12 +++++ addons/editor/stringtable.xml | 6 +++ 5 files changed, 66 insertions(+) create mode 100644 addons/common/functions/fnc_setVehicleLaserState.sqf diff --git a/addons/common/XEH_PREP.hpp b/addons/common/XEH_PREP.hpp index 9489a0a45..339b180ce 100644 --- a/addons/common/XEH_PREP.hpp +++ b/addons/common/XEH_PREP.hpp @@ -68,6 +68,7 @@ PREP(setLampState); PREP(setMagazineAmmo); PREP(setTurretAmmo); PREP(setVehicleAmmo); +PREP(setVehicleLaserState); PREP(showMessage); PREP(spawnLargeObject); PREP(teleportIntoVehicle); diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf index 9467080a5..eaf9c38ab 100644 --- a/addons/common/XEH_postInit.sqf +++ b/addons/common/XEH_postInit.sqf @@ -351,6 +351,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(setVehicleLaserState), LINKFUNC(setVehicleLaserState)] call CBA_fnc_addEventHandler; [QGVAR(showMessage), LINKFUNC(showMessage)] call CBA_fnc_addEventHandler; if (isServer) then { diff --git a/addons/common/functions/fnc_setVehicleLaserState.sqf b/addons/common/functions/fnc_setVehicleLaserState.sqf new file mode 100644 index 000000000..2d1ed3b39 --- /dev/null +++ b/addons/common/functions/fnc_setVehicleLaserState.sqf @@ -0,0 +1,46 @@ +#include "script_component.hpp" +/* + * Author: mharis001 + * Sets the state (on/off) of the given vehicle turret's laser weapon. + * + * Arguments: + * 0: Vehicle + * 1: State (default: nil) + * - Toggles the laser's state when unspecified. + * 2: Turret Path (default: [0]) + * - The primary gunner turret is used by default. + * + * Return Value: + * None + * + * Example: + * [_vehicle, true] call zen_common_fnc_setVehicleLaserState + * + * Public: No + */ + +params [["_vehicle", objNull, [objNull]], ["_state", nil, [true]], ["_turretPath", [0], [[]]]]; + +if (!local _vehicle) exitWith { + [QGVAR(setVehicleLaserState), _this, _vehicle] call CBA_fnc_targetEvent; +}; + +// Exit if the laser is already turned on/off and we are not toggling it +if (!isNil "_state" && {_vehicle isLaserOn _turretPath isEqualTo _state}) exitWith {}; + +// Find the correct magazine id and owner and force the laser weapon to fire +{ + _x params ["_xMagazine", "_xTurretPath", "_xAmmoCount", "_id", "_owner"]; + + if ( + _turretPath isEqualTo _xTurretPath + && {_xAmmoCount > 0} + && { + private _ammo = getText (configFile >> "CfgMagazines" >> _xMagazine >> "ammo"); + private _ammoSimulation = getText (configFile >> "CfgAmmo" >> _ammo >> "simulation"); + _ammoSimulation == "laserDesignate" + } + ) exitWith { + _vehicle action ["UseMagazine", _vehicle, _vehicle turretUnit _turretPath, _owner, _id]; + }; +} forEach magazinesAllTurrets _vehicle; diff --git a/addons/editor/initKeybinds.sqf b/addons/editor/initKeybinds.sqf index 7670968d8..d4c3c908e 100644 --- a/addons/editor/initKeybinds.sqf +++ b/addons/editor/initKeybinds.sqf @@ -190,6 +190,18 @@ [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)); diff --git a/addons/editor/stringtable.xml b/addons/editor/stringtable.xml index db0df926d..d14eb7400 100644 --- a/addons/editor/stringtable.xml +++ b/addons/editor/stringtable.xml @@ -393,6 +393,12 @@ Makes selected AI units fire their current weapon while the key is held down. Vehicles will fire their first available turret with a weapon. + + Toggle Laser + + + Makes selected AI units in vehicles toggle their turret laser weapons on or off. + Move To Cursor From 31c2d4ac5eda269ee0f4ce14f45d51e34521829b Mon Sep 17 00:00:00 2001 From: Ampersand Date: Thu, 23 Mar 2023 21:00:49 -0400 Subject: [PATCH 3/6] Improve conditions for Engine and Lights attributes (#723) --- addons/attributes/initAttributes.sqf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/attributes/initAttributes.sqf b/addons/attributes/initAttributes.sqf index 94613aaf5..af31dffb6 100644 --- a/addons/attributes/initAttributes.sqf +++ b/addons/attributes/initAttributes.sqf @@ -157,7 +157,7 @@ } forEach call EFUNC(common,getSelectedVehicles); }, {isEngineOn _entity}, - {alive _entity && {_entity isKindOf "LandVehicle" || {_entity isKindOf "Air"} || {_entity isKindOf "Ship"}}} + {alive _entity && {getNumber (configOf _entity >> "fuelCapacity") > 0} && {_entity isKindOf "LandVehicle" || {_entity isKindOf "Air"} || {_entity isKindOf "Ship"}}} ] call FUNC(addAttribute); [ @@ -182,7 +182,7 @@ } forEach call EFUNC(common,getSelectedVehicles); }, {isLightOn _entity}, - {alive _entity && {_entity isKindOf "LandVehicle" || {_entity isKindOf "Air"} || {_entity isKindOf "Ship"}}} + {alive _entity && {"true" configClasses (configOf _entity >> "Reflectors") isNotEqualTo []} && {_entity isKindOf "LandVehicle" || {_entity isKindOf "Air"} || {_entity isKindOf "Ship"}}} ] call FUNC(addAttribute); [ From 5f949aba1a9560ddb8e3f2bc6d81384d4c735ee0 Mon Sep 17 00:00:00 2001 From: mharis001 <34453221+mharis001@users.noreply.github.com> Date: Sat, 25 Mar 2023 17:11:52 -0400 Subject: [PATCH 4/6] Add support for waypoint type conditions and priority (#722) --- addons/attributes/CfgWaypointTypes.hpp | 1 + .../functions/fnc_compileWaypoints.sqf | 23 +++++++++++++--- .../attributes/functions/fnc_gui_waypoint.sqf | 27 +++++++++++++++---- addons/attributes/gui.hpp | 15 +---------- docs/frameworks/custom_waypoints.md | 10 ++++--- 5 files changed, 50 insertions(+), 26 deletions(-) diff --git a/addons/attributes/CfgWaypointTypes.hpp b/addons/attributes/CfgWaypointTypes.hpp index 997dc9145..b2bbd667b 100644 --- a/addons/attributes/CfgWaypointTypes.hpp +++ b/addons/attributes/CfgWaypointTypes.hpp @@ -62,6 +62,7 @@ class ZEN_WaypointTypes { displayName = ECSTRING(ai,Fastrope); type = "SCRIPTED"; script = QPATHTOEF(ai,functions\fnc_waypointFastrope.sqf); + condition = QUOTE(isClass (configFile >> 'CfgPatches' >> 'ace_fastroping')); }; class SearchBuilding { displayName = ECSTRING(ai,SearchBuilding); diff --git a/addons/attributes/functions/fnc_compileWaypoints.sqf b/addons/attributes/functions/fnc_compileWaypoints.sqf index 9668ebaac..82705f880 100644 --- a/addons/attributes/functions/fnc_compileWaypoints.sqf +++ b/addons/attributes/functions/fnc_compileWaypoints.sqf @@ -15,6 +15,23 @@ * Public: No */ -uiNamespace setVariable [QGVAR(waypointTypes), configProperties [configFile >> "ZEN_WaypointTypes", "isClass _x"] apply { - [toUpper getText (_x >> "displayName"), getText (_x >> "tooltip"), getText (_x >> "type"), getText (_x >> "script")] -}]; +private _waypointTypes = configProperties [configFile >> "ZEN_WaypointTypes", "isClass _x"] apply { + private _condition = compile getText (_x >> "condition"); + + if (_condition isEqualTo {}) then { + _condition = {true}; + }; + + [ + getText (_x >> "displayName"), + getText (_x >> "tooltip"), + getText (_x >> "type"), + getText (_x >> "script"), + _condition, + getNumber (_x >> "priority") + ] +}; + +[_waypointTypes, 5, false] call CBA_fnc_sortNestedArray; + +uiNamespace setVariable [QGVAR(waypointTypes), _waypointTypes]; diff --git a/addons/attributes/functions/fnc_gui_waypoint.sqf b/addons/attributes/functions/fnc_gui_waypoint.sqf index b46a9ca01..b4eb19955 100644 --- a/addons/attributes/functions/fnc_gui_waypoint.sqf +++ b/addons/attributes/functions/fnc_gui_waypoint.sqf @@ -26,17 +26,35 @@ if (!isNull waypointAttachedVehicle _entity) exitWith { _ctrlBackground ctrlSetText localize "str_a3_rscattributewaypointtype_type"; }; -private _ctrlToolbox = _controlsGroup controlsGroupCtrl IDC_ATTRIBUTE_TOOLBOX; +// Get active waypoint types and create toolbox with appropriate number of rows +private _waypointTypes = uiNamespace getVariable QGVAR(waypointTypes) select { + _entity call (_x select 4) +}; + +private _rows = ceil (count _waypointTypes / 3); +parsingNamespace setVariable [QEGVAR(common,rows), _rows]; +parsingNamespace setVariable [QEGVAR(common,columns), 3]; + +private _ctrlToolbox = _display ctrlCreate [QEGVAR(common,RscToolbox), IDC_ATTRIBUTE_TOOLBOX, _controlsGroup]; +_ctrlToolbox ctrlSetBackgroundColor [0, 0, 0, 0]; +_ctrlToolbox ctrlSetPosition [0, POS_H(1), POS_W(26), POS_H(_rows)]; +_ctrlToolbox ctrlCommit 0; + +private _ctrlBackground = _controlsGroup controlsGroupCtrl IDC_ATTRIBUTE_BACKGROUND; +_ctrlBackground ctrlSetPositionH POS_H(_rows); +_ctrlBackground ctrlCommit 0; + +_controlsGroup ctrlSetPositionH POS_H(_rows + 1); +_controlsGroup ctrlCommit 0; // Determine the waypoint type from the given entity -private _waypointType = waypointType _entity; +private _waypointType = waypointType _entity; private _waypointScript = waypointScript _entity; -private _waypointTypes = uiNamespace getVariable QGVAR(waypointTypes); { _x params ["_name", "_tooltip", "_type", "_script"]; - private _index = _ctrlToolbox lbAdd _name; + private _index = _ctrlToolbox lbAdd toUpper _name; _ctrlToolbox lbSetTooltip [_index, _tooltip]; _ctrlToolbox setVariable [str _index, [_type, _script]]; @@ -49,7 +67,6 @@ _ctrlToolbox ctrlAddEventHandler ["ToolBoxSelChanged", { params ["_ctrlToolbox", "_index"]; private _value = _ctrlToolbox getVariable str _index; - private _controlsGroup = ctrlParentControlsGroup _ctrlToolbox; _controlsGroup setVariable [QGVAR(value), _value]; }]; diff --git a/addons/attributes/gui.hpp b/addons/attributes/gui.hpp index 0e3c23f73..602ba23a9 100644 --- a/addons/attributes/gui.hpp +++ b/addons/attributes/gui.hpp @@ -132,11 +132,8 @@ class GVAR(toolbox): GVAR(base) { }; }; -#define WAYPOINT_ROWS (ceil (count (uiNamespace getVariable QGVAR(waypointTypes)) / 3)) - class GVAR(waypoint): GVAR(base) { function = QFUNC(gui_waypoint); - h = POS_H(WAYPOINT_ROWS + 1); class controls: controls { class Label: Label { w = POS_W(26); @@ -146,18 +143,8 @@ class GVAR(waypoint): GVAR(base) { x = 0; y = POS_H(1); w = POS_W(26); - h = POS_H(WAYPOINT_ROWS); - }; - class Toolbox: ctrlToolbox { - idc = IDC_ATTRIBUTE_TOOLBOX; - x = 0; - y = POS_H(1); - w = POS_W(26); - h = POS_H(WAYPOINT_ROWS); - colorBackground[] = {0, 0, 0, 0}; - rows = WAYPOINT_ROWS; - columns = 3; }; + // Toolbox created through script based on available waypoints }; }; diff --git a/docs/frameworks/custom_waypoints.md b/docs/frameworks/custom_waypoints.md index a380b6cf3..b2bde66d3 100644 --- a/docs/frameworks/custom_waypoints.md +++ b/docs/frameworks/custom_waypoints.md @@ -10,10 +10,12 @@ Waypoints are added as subclasses to the `ZEN_WaypointTypes` root config class. Name | Type | Description ---- | ---- | ----------- -`displayName` | STRING | Displayed name of the waypoint -`tooltip` | STRING | Tooltip displayed when hovered -`type` | STRING | Waypoint type, [reference](https://community.bistudio.com/wiki/Waypoint_types) -`script` | STRING | Path to waypoint script file, used when type is "SCRIPTED" +`displayName` | STRING | Displayed name of the waypoint. +`tooltip` | STRING | Tooltip displayed when hovered. +`type` | STRING | Waypoint type, [reference](https://community.bistudio.com/wiki/Waypoint_types). +`script` | STRING | Path to waypoint script file, used when type is "SCRIPTED". +`condition` | STRING | Condition to show the waypoint type. +`priority` | NUMBER | Waypoint sorting priority. ### Example From 5de15ba02db20fc0a337e4da5da5980a3a3c637a Mon Sep 17 00:00:00 2001 From: Ampersand Date: Fri, 31 Mar 2023 06:03:03 -0400 Subject: [PATCH 5/6] Add icon for Scale Object module (#726) --- addons/modules/CfgVehicles.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/modules/CfgVehicles.hpp b/addons/modules/CfgVehicles.hpp index 960483212..6f6798c30 100644 --- a/addons/modules/CfgVehicles.hpp +++ b/addons/modules/CfgVehicles.hpp @@ -346,6 +346,7 @@ class CfgVehicles { category = QGVAR(Objects); displayName = CSTRING(ScaleObject); function = QFUNC(moduleScaleObject); + icon = "\a3\3den\Data\Cfg3DEN\History\scaleItems_ca.paa"; }; class GVAR(moduleSearchBuilding): GVAR(moduleBase) { curatorCanAttach = 1; From 9def352d8fb9f13d0795a876baad395ec7381f02 Mon Sep 17 00:00:00 2001 From: Ampersand Date: Fri, 31 Mar 2023 06:10:08 -0400 Subject: [PATCH 6/6] Improve Toggle AI Pathing keybind with hint icons (#725) --- addons/editor/initKeybinds.sqf | 25 ++++++++----------------- addons/editor/stringtable.xml | 3 --- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/addons/editor/initKeybinds.sqf b/addons/editor/initKeybinds.sqf index d4c3c908e..f45e95d86 100644 --- a/addons/editor/initKeybinds.sqf +++ b/addons/editor/initKeybinds.sqf @@ -223,32 +223,23 @@ [[ELSTRING(main,DisplayName), LSTRING(AIControl)], QGVAR(toggleAIPATH), [LSTRING(ToggleAIPATH), LSTRING(ToggleAIPATH_Description)], { if (!isNull curatorCamera && {!GETMVAR(RscDisplayCurator_search,false)}) then { - private _enabled = 0; - private _disabled = 0; - { if (!isPlayer _x && {_x == vehicle _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; - if (_isPathEnabled) then { - _disabled = _disabled + 1; - } else { - _enabled = _enabled + 1; - }; + 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; - [ - "%1 - %2: %3 - %4: %5", - LLSTRING(AIPathToggled), - LELSTRING(common,Enabled), - _enabled, - LELSTRING(common,Disabled), - _disabled - ] call EFUNC(common,showMessage); - true // handled }; }, {}, [0, [false, false, false]]] call CBA_fnc_addKeybind; // Default: Unbound diff --git a/addons/editor/stringtable.xml b/addons/editor/stringtable.xml index d14eb7400..9f31792a4 100644 --- a/addons/editor/stringtable.xml +++ b/addons/editor/stringtable.xml @@ -411,8 +411,5 @@ Makes selected AI units start or stop moving. Does not affect aiming or shooting. Similar to "Hold Position" in RTS games. - - AI Pathing Toggled -