Skip to content

Commit 723ab0f

Browse files
committed
fix: attribute Zeus remote-controlled shots to the controlled unit
When a Zeus curator remote-controls an AI manning a static weapon, FiredMan fires on the controller's body — not the controlled unit. This caused all rounds to be recorded as originating from the Zeus unit instead of the .50cal gunner. Replace the old distance-based heuristic in eh_firedMan with a proper check using bis_fnc_moduleRemoteControl_unit (missionNamespace, local to the controller's machine) and BIS_fnc_moduleRemoteControl_owner (broadcast on the controlled unit). Both fired handlers now swap _firer and recalculate _vehicle from the controlled unit's state.
1 parent 13774b7 commit 723ab0f

2 files changed

Lines changed: 19 additions & 13 deletions

File tree

addons/recorder/fnc_eh_firedMan.sqf

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,15 @@ if (!SHOULDSAVEEVENTS) exitWith {};
4141

4242
params ["_firer", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_vehicle"];
4343

44-
private _initialProjPos = getPosASL _projectile;
45-
if (getPos _firer distance _initialProjPos > 50 || vehicle _firer isKindOf "Air") then {
46-
// if projectile in unscheduled environment is > 50m from FiredMan then likely remote controlled
47-
// we should find the actual firing entity
48-
private _nearest = [_initialProjPos, allUnits select {
49-
!isPlayer _x
50-
}, 75] call CBA_fnc_getNearest;
51-
if (count _nearest > 0) then {
52-
_firer = _nearest#0;
53-
};
44+
// Zeus remote control fix: FiredMan fires on the controller's body, not the
45+
// controlled unit. Swap to the actual controlled unit for correct attribution.
46+
private _controlledUnit = missionNamespace getVariable ["bis_fnc_moduleRemoteControl_unit", objNull];
47+
if (!isNull _controlledUnit && {_controlledUnit getVariable ["BIS_fnc_moduleRemoteControl_owner", objNull] isEqualTo _firer}) then {
48+
_firer = _controlledUnit;
49+
_vehicle = vehicle _controlledUnit;
50+
if (_vehicle isEqualTo _controlledUnit) then { _vehicle = objNull; };
5451
};
5552

56-
// missionNamespace getVariable ["bis_fnc_moduleRemoteControl_unit", _firer];
57-
// _unit getVariable ["BIS_fnc_moduleRemoteControl_owner", objNull];
58-
5953
// not sent in ACE Throwing events
6054
if (isNil "_vehicle") then {
6155
_vehicle = objNull

addons/recorder/fnc_eh_fired_client.sqf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@ if (isNil "_projectile") exitWith {
1515
false;
1616
};
1717

18+
// Zeus remote control fix: FiredMan fires on the controller's body, not the
19+
// controlled unit. bis_fnc_moduleRemoteControl_unit (local to the controller's
20+
// machine) gives us the actual unit doing the firing.
21+
private _controlledUnit = missionNamespace getVariable ["bis_fnc_moduleRemoteControl_unit", objNull];
22+
if (!isNull _controlledUnit && {_controlledUnit getVariable ["BIS_fnc_moduleRemoteControl_owner", objNull] isEqualTo _firer}) then {
23+
TRACE_2("Swapping firer from Zeus body to remote-controlled unit",name _firer,name _controlledUnit);
24+
_firer = _controlledUnit;
25+
// Fix _vehicle — Zeus body isn't in the static weapon, but the controlled unit is
26+
private _controlledVehicle = vehicle _controlledUnit;
27+
_vehicle = if (_controlledVehicle isEqualTo _controlledUnit) then {objNull} else {_controlledVehicle};
28+
};
29+
1830
// get ocap id of firer
1931
private _firerOcapId = _firer getVariable [QGVARMAIN(id), -1];
2032
if (_firerOcapId isEqualTo -1) exitWith {

0 commit comments

Comments
 (0)