Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into move-camera-to-se…
Browse files Browse the repository at this point in the history
…lection-cqb
  • Loading branch information
ampersand38 committed Mar 31, 2023
2 parents cba9564 + 9def352 commit 7313e56
Show file tree
Hide file tree
Showing 13 changed files with 203 additions and 50 deletions.
1 change: 1 addition & 0 deletions addons/attributes/CfgWaypointTypes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
23 changes: 20 additions & 3 deletions addons/attributes/functions/fnc_compileWaypoints.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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];
27 changes: 22 additions & 5 deletions addons/attributes/functions/fnc_gui_waypoint.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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]];

Expand All @@ -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];
}];
15 changes: 1 addition & 14 deletions addons/attributes/gui.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
};
};

Expand Down
4 changes: 2 additions & 2 deletions addons/attributes/initAttributes.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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);

[
Expand All @@ -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);

[
Expand Down
2 changes: 2 additions & 0 deletions addons/common/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ PREP(fireArtillery);
PREP(fireVLS);
PREP(fireWeapon);
PREP(forceFire);
PREP(forceWatch);
PREP(formatDegrees);
PREP(getActiveTree);
PREP(getAllTurrets);
Expand Down Expand Up @@ -67,6 +68,7 @@ PREP(setLampState);
PREP(setMagazineAmmo);
PREP(setTurretAmmo);
PREP(setVehicleAmmo);
PREP(setVehicleLaserState);
PREP(showMessage);
PREP(spawnLargeObject);
PREP(teleportIntoVehicle);
Expand Down
22 changes: 22 additions & 0 deletions addons/common/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -330,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 {
Expand Down
52 changes: 52 additions & 0 deletions addons/common/functions/fnc_forceWatch.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#include "script_component.hpp"
/*
* Author: mharis001
* Makes the given unit watch the specified target.
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Target <OBJECT|ARRAY> (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;
};
46 changes: 46 additions & 0 deletions addons/common/functions/fnc_setVehicleLaserState.sqf
Original file line number Diff line number Diff line change
@@ -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 <OBJECT>
* 1: State <BOOL> (default: nil)
* - Toggles the laser's state when unspecified.
* 2: Turret Path <ARRAY> (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;
41 changes: 22 additions & 19 deletions addons/editor/initKeybinds.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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};

[[
Expand All @@ -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"]],
Expand All @@ -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));
Expand All @@ -211,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
9 changes: 6 additions & 3 deletions addons/editor/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,12 @@
<Key ID="STR_ZEN_Editor_ForceFire_Description">
<English>Makes selected AI units fire their current weapon while the key is held down. Vehicles will fire their first available turret with a weapon.</English>
</Key>
<Key ID="STR_ZEN_Editor_ToggleLaser">
<English>Toggle Laser</English>
</Key>
<Key ID="STR_ZEN_Editor_ToggleLaser_Description">
<English>Makes selected AI units in vehicles toggle their turret laser weapons on or off.</English>
</Key>
<Key ID="STR_ZEN_Editor_MoveToCursor">
<English>Move To Cursor</English>
</Key>
Expand All @@ -405,9 +411,6 @@
<Key ID="STR_ZEN_Editor_ToggleAIPath_Description">
<English>Makes selected AI units start or stop moving. Does not affect aiming or shooting. Similar to "Hold Position" in RTS games.</English>
</Key>
<Key ID="STR_ZEN_Editor_AIPathToggled">
<English>AI Pathing Toggled</English>
</Key>
<Key ID="STR_ZEN_Editor_MoveCamToSelection">
<English>Focus Object Mode</English>
</Key>
Expand Down
1 change: 1 addition & 0 deletions addons/modules/CfgVehicles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading

0 comments on commit 7313e56

Please sign in to comment.