Skip to content

Commit f1653f1

Browse files
authored
Improve Watch Cursor and Watch Curator Camera keybinds (#720)
1 parent 13b0b82 commit f1653f1

File tree

4 files changed

+76
-2
lines changed

4 files changed

+76
-2
lines changed

addons/common/XEH_PREP.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ PREP(fireArtillery);
1717
PREP(fireVLS);
1818
PREP(fireWeapon);
1919
PREP(forceFire);
20+
PREP(forceWatch);
2021
PREP(formatDegrees);
2122
PREP(getActiveTree);
2223
PREP(getAllTurrets);

addons/common/XEH_postInit.sqf

+21
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,27 @@
143143
_unit doWatch _target;
144144
}] call CBA_fnc_addEventHandler;
145145

146+
[QGVAR(doTarget), {
147+
params ["_unit", "_target", ["_reveal", true]];
148+
149+
if (_reveal) then {
150+
if (_unit isEqualType objNull) then {
151+
_unit = [_unit];
152+
};
153+
154+
{
155+
_x reveal [_target, 4];
156+
} forEach _unit;
157+
};
158+
159+
_unit doTarget _target;
160+
}] call CBA_fnc_addEventHandler;
161+
162+
[QGVAR(lockCameraTo), {
163+
params ["_vehicle", "_target", "_turretPath", "_temporary"];
164+
_vehicle lockCameraTo [_target, _turretPath, _temporary];
165+
}] call CBA_fnc_addEventHandler;
166+
146167
[QGVAR(enableGunLights), {
147168
params ["_unit", "_mode"];
148169
_unit enableGunLights _mode;
+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#include "script_component.hpp"
2+
/*
3+
* Author: mharis001
4+
* Makes the given unit watch the specified target.
5+
*
6+
* Arguments:
7+
* 0: Unit <OBJECT>
8+
* 1: Target <OBJECT|ARRAY> (default: objNull)
9+
* - When given objNull, the unit stops watching its current target.
10+
* - Positions must be in AGL format.
11+
*
12+
* Return Value:
13+
* None
14+
*
15+
* Example:
16+
* [_unit, _target] call zen_common_fnc_forceWatch
17+
*
18+
* Public: No
19+
*/
20+
21+
params [["_unit", objNull, [objNull]], ["_target", objNull, [objNull, []], 3]];
22+
23+
[QGVAR(doWatch), [[_unit, gunner _unit], _target], _unit] call CBA_fnc_targetEvent;
24+
25+
// If an object is given, make the unit target the object in addition to watching it
26+
if (_target isEqualType objNull && {!isNull _target}) then {
27+
[QGVAR(doTarget), [[_unit, gunner _unit], _target], _unit] call CBA_fnc_targetEvent;
28+
};
29+
30+
// Make vehicles or units in vehicles watch target by locking their turret cameras onto it
31+
private _vehicle = vehicle _unit;
32+
33+
if (
34+
_unit isNotEqualTo _vehicle
35+
|| {_unit isKindOf "LandVehicle"}
36+
|| {_unit isKindOf "Air"}
37+
|| {_unit isKindOf "Ship"}
38+
) then {
39+
private _turretPaths = if (_unit isEqualTo _vehicle) then {
40+
_vehicle call FUNC(getAllTurrets)
41+
} else {
42+
[_vehicle unitTurret _unit]
43+
};
44+
45+
if (_target isEqualType []) then {
46+
_target = AGLToASL _target;
47+
};
48+
49+
{
50+
[QGVAR(lockCameraTo), [_vehicle, _target, _x, false], _vehicle, _x] call CBA_fnc_turretEvent;
51+
} forEach _turretPaths;
52+
};

addons/editor/initKeybinds.sqf

+2-2
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@
146146
// Cancel if target is self
147147
private _isSelf = _x isEqualTo _target;
148148
private _target = [_target, objNull] select _isSelf;
149-
[QEGVAR(common,doWatch), [[_x, gunner _x], _target], _x] call CBA_fnc_targetEvent;
149+
[_x, _target] call EFUNC(common,forceWatch);
150150
if (_isSelf) then {continue};
151151

152152
[[
@@ -166,7 +166,7 @@
166166

167167
{
168168
if (!isNull group _x && {!isPlayer _x}) then {
169-
[QEGVAR(common,doWatch), [_x, _position], _x] call CBA_fnc_targetEvent;
169+
[_x, _position] call EFUNC(common,forceWatch);
170170

171171
[[
172172
["ICON", [_position, "\a3\ui_f\data\igui\cfg\simpletasks\types\scout_ca.paa"]],

0 commit comments

Comments
 (0)