diff --git a/x/ocap2/addons/recorder/XEH_preInit.sqf b/x/ocap2/addons/recorder/XEH_preInit.sqf index 6c459c6..85c10e7 100644 --- a/x/ocap2/addons/recorder/XEH_preInit.sqf +++ b/x/ocap2/addons/recorder/XEH_preInit.sqf @@ -115,6 +115,20 @@ GVAR(allSettings) = [ false // requires restart to apply ], + [ + QEGVAR(settings,trackTickets), + "CHECKBOX", // setting type + [ + "Enable Ticket Tracking", // Pretty name shown inside the ingame settings menu. Can be stringtable entry. + "Will track respawn ticket counts for missionNamespace and each playable faction every 30th frame. Default: true" + ], + [COMPONENT_NAME, "Recording Settings"], // Pretty name of the category where the setting can be found. Can be stringtable entry. + true, // default enabled + true, // "_isGlobal" flag. Set this to true to always have this setting synchronized between all clients in multiplayer + {}, // function that will be executed once on mission start and every time the setting is changed. + true // requires restart to apply + ], + [ QEGVAR(settings,trackTimes), "CHECKBOX", // setting type diff --git a/x/ocap2/addons/recorder/XEH_prep.sqf b/x/ocap2/addons/recorder/XEH_prep.sqf index 35fc9fc..656d587 100644 --- a/x/ocap2/addons/recorder/XEH_prep.sqf +++ b/x/ocap2/addons/recorder/XEH_prep.sqf @@ -28,6 +28,8 @@ PREP(getAmmoMarkerData); PREP(getWeaponDisplayData); PREP(projectileMonitors); +PREP(entityMonitors); + PREP(aceThrowing); PREP(aceExplosives); diff --git a/x/ocap2/addons/recorder/fnc_addEventMission.sqf b/x/ocap2/addons/recorder/fnc_addEventMission.sqf index ebb390c..101dcf1 100644 --- a/x/ocap2/addons/recorder/fnc_addEventMission.sqf +++ b/x/ocap2/addons/recorder/fnc_addEventMission.sqf @@ -111,6 +111,34 @@ if (isNil QEGVAR(listener,customEvent)) then { OCAPEXTLOG(["Initialized customEvent listener"]); }; +// Custom event handler with key "ocap2_counterInit" +// Used for tracking scores or counts per side +if (isNil QEGVAR(listener,counterInit)) then { + EGVAR(listener,counterInit) = [QGVARMAIN(counterInit), { + EGVAR(counter,sides) = _this apply {_x#0}; + [QGVARMAIN(customEvent), ["counterInit", EGVAR(counter,sides)]] call CBA_fnc_localEvent; + { + [QGVARMAIN(counterEvent), _x] call CBA_fnc_serverEvent; + } forEach _this; + [_thisType, _thisId] call CBA_fnc_removeEventHandler; + }] call CBA_fnc_addEventHandlerArgs; + OCAPEXTLOG(["Initialized counterInit listener"]); +}; +if (isNil QEGVAR(listener,counterEvent)) then { + EGVAR(listener,counterEvent) = [QGVARMAIN(counterEvent), { + if (isNil QEGVAR(counter,sides)) exitWith {}; + if (typeName (_this#0) != "SIDE") exitWith {}; + if !((_this#0) in EGVAR(counter,sides)) exitWith {}; + + private _scores = []; + { + if ((_this#0) isEqualTo _x) then {_scores pushBack (_this#1)} else {_scores pushBack -1}; + } forEach EGVAR(counter,sides); + [QGVARMAIN(customEvent), ["counterSet", _scores]] call CBA_fnc_localEvent; + }] call CBA_fnc_addEventHandler; + OCAPEXTLOG(["Initialized counterEvent listener"]); +}; + // Custom event handler with key "ocap2_record" // This will START OR RESUME recording if not already. if (isNil QEGVAR(listener,record)) then { diff --git a/x/ocap2/addons/recorder/fnc_captureLoop.sqf b/x/ocap2/addons/recorder/fnc_captureLoop.sqf index 5010f06..cfa174a 100644 --- a/x/ocap2/addons/recorder/fnc_captureLoop.sqf +++ b/x/ocap2/addons/recorder/fnc_captureLoop.sqf @@ -46,6 +46,15 @@ GVAR(PFHObject) = [ [] call FUNC(updateTime); }; + // every 15 frames of recording check respawn ticket state of each of three sides + if (GVAR(captureFrameNo) % (30 / GVAR(frameCaptureDelay)) == 0 && EGVAR(settings,trackTickets)) then { + private _scores = []; + { + _scores pushBack ([_x] call BIS_fnc_respawnTickets); + } forEach [missionNamespace, east, west, independent]; + ["ocap2_customEvent", ["respawnTickets", _scores]] call CBA_fnc_localEvent; + }; + // update diary record every 320 frames if (GVAR(captureFrameNo) % (320 / GVAR(frameCaptureDelay)) == 0) then { publicVariable QGVAR(captureFrameNo); @@ -63,8 +72,8 @@ GVAR(PFHObject) = [ { if !(_x getVariable [QGVARMAIN(isInitialized), false]) then { if (_x isKindOf "Logic") exitWith { - _x setVariable [QGVARMAIN(exclude), true]; - _x setVariable [QGVARMAIN(isInitialized), true]; + _x setVariable [QGVARMAIN(exclude), true, true]; + _x setVariable [QGVARMAIN(isInitialized), true, true]; }; _x setVariable [QGVARMAIN(id), GVAR(nextId)]; [":NEW:UNIT:", [ @@ -78,7 +87,7 @@ GVAR(PFHObject) = [ ]] call EFUNC(extension,sendData); [_x] spawn FUNC(addUnitEventHandlers); GVAR(nextId) = GVAR(nextId) + 1; - _x setVariable [QGVARMAIN(isInitialized), true]; + _x setVariable [QGVARMAIN(isInitialized), true, true]; }; if !(_x getVariable [QGVARMAIN(exclude), false]) then { private _unitRole = _x getVariable [QGVARMAIN(unitType), ""]; @@ -126,8 +135,8 @@ GVAR(PFHObject) = [ }; if ((_class isEqualTo "unknown") || (_vehType in (parseSimpleArray EGVAR(settings,excludeClassFromRecord))) || _toExcludeKind) exitWith { LOG(ARR2("WARNING: vehicle is defined as 'unknown' or exclude:", _vehType)); - _x setVariable [QGVARMAIN(isInitialized), true]; - _x setVariable [QGVARMAIN(exclude), true]; + _x setVariable [QGVARMAIN(isInitialized), true, true]; + _x setVariable [QGVARMAIN(exclude), true, true]; }; _x setVariable [QGVARMAIN(id), GVAR(nextId)]; @@ -139,7 +148,7 @@ GVAR(PFHObject) = [ ]] call EFUNC(extension,sendData); [_x] spawn FUNC(addUnitEventHandlers); GVAR(nextId) = GVAR(nextId) + 1; - _x setVariable [QGVARMAIN(isInitialized), true]; + _x setVariable [QGVARMAIN(isInitialized), true, true]; }; if !(_x getVariable [QGVARMAIN(exclude), false]) then { private _crew = []; diff --git a/x/ocap2/addons/recorder/fnc_eh_firedMan.sqf b/x/ocap2/addons/recorder/fnc_eh_firedMan.sqf index 7c7f02b..7794c81 100644 --- a/x/ocap2/addons/recorder/fnc_eh_firedMan.sqf +++ b/x/ocap2/addons/recorder/fnc_eh_firedMan.sqf @@ -33,13 +33,15 @@ if (!SHOULDSAVEEVENTS) exitWith {}; params ["_firer", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_vehicle"]; -private "_who"; -{ - if (_firer == _x getVariable ["BIS_fnc_moduleRemoteControl_owner", objNull]) then { - _who = _x; - }; -} forEach (allUnits select {!isNull (_firer getVariable ["BIS_fnc_moduleRemoteControl_owner", objNull])}); -if (!isNil "_who") then {_firer = _who}; +private _initialProjPos = getPos _projectile; +if (getPos _firer distance _initialProjPos > 50) then { + // if projectile in unscheduled environment is > 50m from FiredMan then likely remote controlled + // we should find the actual firing entity + _nearest = [_initialProjPos, allUnits select {!isPlayer _x}, 5] call CBA_fnc_getNearest; + _firer = _nearest#0; +}; +// missionNamespace getVariable ["bis_fnc_moduleRemoteControl_unit", _firer]; +// _unit getVariable ["BIS_fnc_moduleRemoteControl_owner", objNull]; // not sent in ACE Throwing events if (isNil "_vehicle") then {_vehicle = objNull}; diff --git a/x/ocap2/addons/recorder/fnc_entityMonitors.sqf b/x/ocap2/addons/recorder/fnc_entityMonitors.sqf new file mode 100644 index 0000000..6d124e7 --- /dev/null +++ b/x/ocap2/addons/recorder/fnc_entityMonitors.sqf @@ -0,0 +1,36 @@ +#include "script_component.hpp" + +// DEBUG draws on clients +{ + if (!hasInterface) exitWith {}; + [] spawn { + waitUntil {!isNull (findDisplay 12)}; + GVAR(liveDebugBullets) = []; + disableSerialization; + (findDisplay 12 displayCtrl 51) ctrlAddEventHandler ["Draw", { + if (GVARMAIN(isDebug)) then { + { + // _x params ["_startPos", "_endPos", "_color", "_timeHit"]; + (_this#0) drawIcon [ + ["iconMan"] call BIS_fnc_textureVehicleIcon, // Custom images can also be used: getMissionPath "\myFolder\myIcon.paa" + [side group _x] call BIS_fnc_sideColor, + getPos _x, + 1, + 1, + getDir _x, + name _x, + 0, + 0.03, + "PuristaLight", + "center" + ]; + } forEach (allUnits + vehicles) select { + _x getVariable [QGVARMAIN(isInitialized), false] && + _x getVariable [QGVARMAIN(exclude), true] + }; + }; + }]; + }; +} remoteExec ["call", [0, -2] select isDedicated, true]; + +GVAR(entityMonitorsInitialized) = true; diff --git a/x/ocap2/addons/recorder/fnc_init.sqf b/x/ocap2/addons/recorder/fnc_init.sqf index 3b4c1b5..e59c155 100644 --- a/x/ocap2/addons/recorder/fnc_init.sqf +++ b/x/ocap2/addons/recorder/fnc_init.sqf @@ -153,3 +153,7 @@ if (GVAR(missionName) == "") then { if (isNil QGVAR(projectileMonitorsInitialized)) then { call FUNC(projectileMonitors); }; + +if (isNil QGVAR(entityMonitorsInitialized)) then { + call FUNC(entityMonitors); +};