Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Events - Add "turretOpticsMode" Player EH #1665

Merged
merged 3 commits into from
Jul 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 22 additions & 14 deletions addons/events/fnc_addPlayerEventHandler.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,21 @@ Description:
Adds a player event handler.

Possible events:
"unit" - player controlled unit changed
"weapon" - currently selected weapon change
"turretweapon" - currently selected turret weapon change
"muzzle" - currently selected muzzle change
"weaponMode" - currently selected weapon mode change
"loadout" - players loadout changed
"vehicle" - players current vehicle changed
"turret" - position in vehicle changed
"visionMode" - player changed to normal/night/thermal view
"cameraView" - camera mode changed ("Internal", "External", "Gunner" etc.)
"featureCamera" - camera changed (Curator, Arsenal, Spectator etc.)
"visibleMap" - opened or closed map
"group" - player group changes
"leader" - leader of player changes
"unit" - player controlled unit changed
"weapon" - currently selected weapon change
"turretweapon" - currently selected turret weapon change
"muzzle" - currently selected muzzle change
"weaponMode" - currently selected weapon mode change
"loadout" - players loadout changed
"vehicle" - players current vehicle changed
"turret" - position in vehicle changed
"turretOpticsMode" - turret zoom (FOV) changed
"visionMode" - player changed to normal/night/thermal view
"cameraView" - camera mode changed ("Internal", "External", "Gunner" etc.)
"featureCamera" - camera changed (Curator, Arsenal, Spectator etc.)
"visibleMap" - opened or closed map
"group" - player group changes
"leader" - leader of player changes

Parameters:
_type - Event handler type. <STRING>
Expand Down Expand Up @@ -103,6 +104,12 @@ private _id = switch (_type) do {
};
[QGVAR(turretEvent), _function] call CBA_fnc_addEventHandler // return id
};
case "turretopticsmode": {
if (_applyRetroactively) then {
[GVAR(oldUnit), getTurretOpticsMode GVAR(oldUnit)] call _function;
hypoxia125 marked this conversation as resolved.
Show resolved Hide resolved
};
[QGVAR(turretOpticsModeEvent), _function] call CBA_fnc_addEventHandler;
};
case "visionmode": {
if (_applyRetroactively) then {
[GVAR(oldUnit), currentVisionMode GVAR(oldUnit), -1] call _function;
Expand Down Expand Up @@ -158,6 +165,7 @@ if (_id != -1) then {
GVAR(oldLoadoutNoAmmo) = [];
GVAR(oldVehicle) = objNull;
GVAR(oldTurret) = [];
GVAR(oldTurretOpticsMode) = -1;
GVAR(oldVisionMode) = -1;
GVAR(oldCameraView) = "";
GVAR(oldFeatureCamera) = "";
Expand Down
9 changes: 7 additions & 2 deletions addons/events/fnc_playerEvent.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private _state = [
_unit, group _unit, leader _unit,
currentWeapon _unit, currentMuzzle _unit, currentWeaponMode _unit,
getUnitLoadout _unit, _vehicle, _turret, _vehicle currentWeaponTurret _turret,
currentVisionMode _controlledEntity, cameraView
currentVisionMode _controlledEntity, cameraView, getTurretOpticsMode _unit
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this should be _unit or focusOn for UAVs
will test

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't seem to matter
getTurretOpticsMode focuson = getTurretOpticsMode player

];

if (_state isNotEqualTo GVAR(oldState)) then {
Expand All @@ -54,7 +54,7 @@ if (_state isNotEqualTo GVAR(oldState)) then {
"", "_newGroup", "_newLeader",
"_newWeapon", "_newMuzzle", "_newWeaponMode",
"_newLoadout", "", "", "_newTurretWeapon",
"_newVisionMode", "_newCameraView"
"_newVisionMode", "_newCameraView", "_newTurretOpticsMode"
];

// These events should fire if the context of the state has changed.
Expand Down Expand Up @@ -137,4 +137,9 @@ if (_state isNotEqualTo GVAR(oldState)) then {
[QGVAR(cameraViewEvent), [_unit, _newCameraView, GVAR(oldCameraView)]] call CBA_fnc_localEvent;
GVAR(oldCameraView) = _newCameraView; // This assignment may be returned.
};

if (_newTurretOpticsMode isNotEqualTo GVAR(oldTurretOpticsMode)) then {
[QGVAR(turretOpticsModeEvent), [_unit, _newTurretOpticsMode, GVAR(oldTurretOpticsMode)]] call CBA_fnc_localEvent;
GVAR(oldTurretOpticsMode) = _newTurretOpticsMode;
};
};
Loading