Skip to content

Commit

Permalink
HuntIR - Add Events & Animation Disable Flag (acemod#10214)
Browse files Browse the repository at this point in the history
  • Loading branch information
BrettMayson authored and blake8090 committed Aug 18, 2024
1 parent 6c62325 commit c3fe78e
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
2 changes: 2 additions & 0 deletions addons/huntir/functions/fnc_cam.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ GVAR(no_cams) sort true;
//Close monitor if we no longer have the item:
if ((!([ACE_player, "ACE_HuntIR_monitor"] call EFUNC(common,hasItem))) && {!isNull (uiNameSpace getVariable [QGVAR(monitor), displayNull])}) then {
closeDialog 0;
[QGVAR(monitorClosed), [ACE_player]] call CBA_fnc_localEvent;
};

GVAR(nearHuntIRs) = ACE_player nearEntities ["ACE_HuntIR", HUNTIR_MAX_TRANSMISSION_RANGE];
Expand Down Expand Up @@ -113,6 +114,7 @@ GVAR(no_cams) sort true;
if (player != ACE_player) then {
player remoteControl ACE_player;
};
[QGVAR(monitorClosed), [ACE_player]] call CBA_fnc_localEvent;
};

switch (GVAR(ZOOM)) do {
Expand Down
13 changes: 12 additions & 1 deletion addons/huntir/functions/fnc_huntir.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,19 @@

#define __TYPE_WRITER_DELAY 0.05

if ((ACE_player call CBA_fnc_getUnitAnim) select 0 == "stand") then {
if (missionNamespace getVariable [QGVAR(animatePlayer), true] && {(ACE_player call CBA_fnc_getUnitAnim) select 0 == "stand"}) then {
ACE_player playMove "AmovPercMstpSrasWrflDnon_diary";
};

HUNTIR_BACKGROUND_LAYER_ID cutText ["", "BLACK", 0];
createDialog QGVAR(cam_dialog_off);

[QGVAR(monitorOpened), [ACE_player]] call CBA_fnc_localEvent;

[{
if (!dialog) exitWith {
HUNTIR_BACKGROUND_LAYER_ID cutText ["", "PLAIN", 0];
[QGVAR(monitorClosed), [ACE_player]] call CBA_fnc_localEvent;
};
closeDialog 0;
createDialog QGVAR(cam_dialog_inactive);
Expand All @@ -40,10 +43,12 @@ createDialog QGVAR(cam_dialog_off);
GVAR(message) = [];
GVAR(messageSearching) = toArray "Searching.....";
GVAR(messageConnecting) = toArray "Connecting.....";
[QGVAR(monitorStarted), [ACE_player]] call CBA_fnc_localEvent;
[{
//Close monitor if we no longer have item:
if ((!([ACE_player, "ACE_HuntIR_monitor"] call EFUNC(common,hasItem))) && {!isNull (uiNameSpace getVariable [QGVAR(monitor), displayNull])}) then {
closeDialog 0;
[QGVAR(monitorClosed), [ACE_player]] call CBA_fnc_localEvent;
};

private _elapsedTime = CBA_missionTime - GVAR(startTime);
Expand All @@ -55,6 +60,7 @@ createDialog QGVAR(cam_dialog_off);
GVAR(done) = false;
GVAR(message) = [];
GVAR(connectionDelay) = 5;
[QGVAR(monitorDisconnected), [ACE_player]] call CBA_fnc_localEvent;
};

if ((!dialog) || GVAR(done)) exitWith {
Expand All @@ -64,6 +70,7 @@ createDialog QGVAR(cam_dialog_off);
[_nearestHuntIRs select 0] call FUNC(cam);
} else {
HUNTIR_BACKGROUND_LAYER_ID cutText ["", "PLAIN"];
[QGVAR(monitorClosed), [ACE_player]] call CBA_fnc_localEvent;
};
};
switch (GVAR(state)) do {
Expand All @@ -75,9 +82,11 @@ createDialog QGVAR(cam_dialog_off);
GVAR(message) = [];
if (_elapsedTime > 10) then {
GVAR(state) = "noGDS";
[QGVAR(monitorNoGDS), [ACE_player]] call CBA_fnc_localEvent;
};
if (_elapsedTime > 5 && {{_x getHitPointDamage "HitCamera" < 0.25} count _nearestHuntIRs > 0}) then {
GVAR(state) = "connecting";
[QGVAR(monitorConnecting), [ACE_player]] call CBA_fnc_localEvent;
};
};
};
Expand All @@ -91,6 +100,7 @@ createDialog QGVAR(cam_dialog_off);
if (GVAR(connectionDelay) <= 0) then {
GVAR(done) = true;
GVAR(state) = "connected";
[QGVAR(monitorConnected), [ACE_player, _nearestHuntIRs select 0]] call CBA_fnc_localEvent;
};
};
};
Expand All @@ -100,6 +110,7 @@ createDialog QGVAR(cam_dialog_off);
GVAR(done) = true;
closedialog 0;
HUNTIR_BACKGROUND_LAYER_ID cutText ["", "PLAIN"];
[QGVAR(monitorClosed), [ACE_player]] call CBA_fnc_localEvent;
}, [], 3, 0] call CBA_fnc_waitAndExecute;
};
};
Expand Down
12 changes: 12 additions & 0 deletions docs/wiki/framework/events-framework.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,18 @@ MenuType: 0 = Interaction, 1 = Self Interaction
| `ace_headless_groupTransferPre` | [_group, _HC (OBJECT), _previousOwner, _idHC] | Target | Listen | Called just before a group is transferred from any machine to a HC. Called where group currently is local and on the HC, where group is going to be local.
| `ace_headless_groupTransferPost` | [_group, _HC (OBJECT), _previousOwner, _idHC, _transferredSuccessfully] | Target | Listen | Called just after a group is transferred from a machine to a HC. Called where group was local and on the HC, where group is now local. `_transferredSuccessfully` is passed so mods can actually check if the locality was properly transferred, as ownership transfer is not guaranteed.

### 2.18 HuntIR (`ace_huntir`)

| Event Key | Parameters | Locality | Type | Description |
|---------- |------------|----------|------|-------------|
| `ace_huntir_monitorOpened` | [_unit] | Local | Listen | Called when the monitor is opened
| `ace_huntir_monitorClosed` | [_unit] | Local | Listen | Called when the monitor is closed (may be fired multiple times when the monitor is closed by ACE and not the user)
| `ace_huntir_monitorStarted` | [_unit] | Local | Listen | Called when the monitor is started
| `ace_huntir_monitorSearching` | [_unit] | Local | Listen | Called when the monitor is searching
| `ace_huntir_monitorConnecting` | [_unit] | Local | Listen | Called when the monitor is connecting
| `ace_huntir_monitorConnected` | [_unit, _huntir] | Local | Listen | Called when the monitor is connected
| `ace_huntir_monitorNoGDS` | [_unit] | Local | Listen | Called when the monitor found no GDS

## 3. Usage
Also Reference [CBA Events System](https://github.com/CBATeam/CBA_A3/wiki/Custom-Events-System){:target="_blank"} documentation.

Expand Down
12 changes: 12 additions & 0 deletions docs/wiki/framework/huntIR-framework.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,15 @@ class CfgWeapons {
};
};
```
## 2. Player Animation
Player animation when entering the HuntIR Monitor can be disabled by setting `ace_huntir_animatePlayer` to `false`.
```sqf
// Disable player animation locally
missionNamespace setVariable ["ace_huntir_animatePlayer", false];
// Disable player animation for everyone
missionNamespace setVariable ["ace_huntir_animatePlayer", false, true];
```

0 comments on commit c3fe78e

Please sign in to comment.