Skip to content

Commit

Permalink
finalize 2.0.0-RC2
Browse files Browse the repository at this point in the history
- change MPHit to HitPart
- fire tracking, setShotParents
- fix debug entityDraw
- exclude objects w empty models
- fix duplicate fnc_init calls
- fix remoteExec diary entries
- init at PostInit
  • Loading branch information
indig0fox committed Apr 12, 2022
1 parent 62affe4 commit 64c1aed
Show file tree
Hide file tree
Showing 18 changed files with 113 additions and 155 deletions.
17 changes: 0 additions & 17 deletions x/ocap2/addons/licence.txt

This file was deleted.

Binary file removed x/ocap2/addons/logo_ocap.paa
Binary file not shown.
Empty file.
2 changes: 1 addition & 1 deletion x/ocap2/addons/main/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// During postInit, we'll remoteExec these settings onto clients so vars are synchronized and modifiable during a mission.
{
_x remoteExec ["CBA_fnc_addSetting", [0, -2] select isDedicated, true];
_x remoteExec ["CBA_fnc_addSetting", [0, -2] select isServer, true];
} forEach GVAR(allSettings);


Expand Down
6 changes: 1 addition & 5 deletions x/ocap2/addons/main/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ GVAR(allSettings) = [
[COMPONENT_NAME, "Core"], // 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
{
params ["_value"];
if (!isServer) exitWith {};
if (_value) then {call EFUNC(recorder,init)};
}, // function that will be executed once on mission start and every time the setting is changed.
{}, // function that will be executed once on mission start and every time the setting is changed.
false // requires restart to apply
],

Expand Down
22 changes: 0 additions & 22 deletions x/ocap2/addons/mod.cpp

This file was deleted.

7 changes: 5 additions & 2 deletions x/ocap2/addons/recorder/XEH_postInit.sqf
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#include "script_component.hpp"
#include "XEH_prep.sqf"

{
_x remoteExec ["CBA_fnc_addSetting", [0, -2] select isDedicated, true];
_x remoteExec ["CBA_fnc_addSetting", [0, -2] select isServer, true];
} forEach GVAR(allSettings);

if (!is3DEN) then {
call FUNC(init);
};

ADDON = true;
4 changes: 0 additions & 4 deletions x/ocap2/addons/recorder/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,4 @@ GVAR(allSettings) = [
_x call CBA_fnc_addSetting;
} forEach GVAR(allSettings);

if (!is3DEN) then {
call FUNC(init);
};

ADDON = true;
118 changes: 69 additions & 49 deletions x/ocap2/addons/recorder/fnc_addUnitEventHandlers.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -40,56 +40,76 @@ if ((_entity call BIS_fnc_objectType) # 0 == "Soldier") then {
};

// MPHIT
if (isNil {_entity getVariable QGVARMAIN(MPHitEH)}) then {
_entity setVariable [
QGVARMAIN(MPHitEH),
_entity addMPEventHandler ["MPHit", { _this call FUNC(eh_hit); }]
];
};
// if (isNil {_entity getVariable QGVARMAIN(MPHitEH)}) then {
// _entity setVariable [
// QGVARMAIN(MPHitEH),
// _entity addMPEventHandler ["MPHit", { _this call FUNC(eh_hit); }]
// ];
// };



// HITPART
// [_entity, [
// "HitPart",
// {
// // https://community.bistudio.com/wiki/HitPart_Sample
// (_this select 0) params ["_target", "_shooter", "_projectile", "_position", "_velocity", "_selection", "_ammo", "_vector", "_radius", "_surfaceType", "_isDirect"];

// if (isNull _shooter) then {
// // _shooter = [_target, _projectile] call FUNC(getInstigator);
// _shooter = (getShotParents _projectile) select 1;
// };

// private _hitFrame = GVAR(captureFrameNo);

// _targetID = _target getVariable [QGVARMAIN(id), -1];
// if (_targetID == -1) exitWith {};
// private _eventData = [_hitFrame, "hit", _targetID, ["null", getText(configOf _projectile >> "displayName")], -1];

// if (!isNull _shooter) then {
// // _projectileId = _projectile getVariable [QGVARMAIN(id), -1];
// _shooterId = _shooter getVariable [QGVARMAIN(id), -1];

// _projectileInfo = [
// _shooterId,
// ([_shooter] call FUNC(getEventWeaponText))
// ];
// _distanceInfo = round (_target distance _shooter);

// if (GVARMAIN(isDebug)) then {
// OCAPEXTLOG(ARR4("HIT EVENT", _hitFrame, _targetID, _shooterId));
// };
// _eventData = [
// _hitFrame,
// "hit",
// _targetID,
// _projectileInfo,
// _distanceInfo
// ];
// };

// [":EVENT:", _eventData] remoteExecCall [QEFUNC(extension,sendData), 2];

// }
// ]] remoteExec ["addEventHandler", [0, -2] select isDedicated, true];
[_entity, [
"HitPart",
{
// https://community.bistudio.com/wiki/HitPart_Sample
(_this select 0) params ["_target", "_shooter", "_projectile", "_position", "_velocity", "_selection", "_ammo", "_vector", "_radius", "_surfaceType", "_isDirect"];

if (isNull _shooter) then {
// _shooter = [_target, _projectile] call FUNC(getInstigator);
private _shotParents = getShotParents _projectile;
if (count _shotParents == 1) then {
_shooter = [_target, _shotParents#0, objNull] call FUNC(getInstigator);
};
if (count _shotParents == 2) then {
_shooter = [_target, _shotParents#0, _shotParents#1] call FUNC(getInstigator);
};
};
if (isNull _shooter) exitWith {};

private _hitFrame = GVAR(captureFrameNo);

_targetID = _target getVariable [QGVARMAIN(id), -1];
if (_targetID == -1) exitWith {};
_shooterId = _shooter getVariable [QGVARMAIN(id), -1];
if (_shooterId == -1) exitWith {};

private _eventData = [_hitFrame, "hit", _targetID, [_shooterId, getText(configOf _projectile >> "displayName")], -1];



_wepText = format["%1x", count _this];

private _allSelections = flatten(_this apply {_x#5});
if (count _allSelections > 0) then {
private _uniqueSelections = _allSelections arrayIntersect _allSelections;
_wepText = format["%1 - %2", _wepText, _uniqueSelections joinString ","];
};

_wepText = format["%1 - %2", _wepText, ([_shooter] call FUNC(getEventWeaponText))];




_projectileInfo = [
_shooterId,
_wepText
];
_distanceInfo = round (_target distance _shooter);

if (GVARMAIN(isDebug)) then {
OCAPEXTLOG(ARR4("HIT EVENT", _hitFrame, _targetID, _shooterId));
};
_eventData = [
_hitFrame,
"hit",
_targetID,
_projectileInfo,
_distanceInfo
];

[":EVENT:", _eventData] remoteExecCall [QEFUNC(extension,sendData), 2];

}
]] remoteExec ["addEventHandler", [0, -2] select isDedicated, true];
7 changes: 7 additions & 0 deletions x/ocap2/addons/recorder/fnc_eh_firedMan.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,17 @@ if (getPos _firer distance _initialProjPos > 50 || vehicle _firer isKindOf "Air"
_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};
if (!isNull _vehicle) then {
_projectile setShotParents [_vehicle, _firer];
} else {
_projectile setShotParents [_firer, _firer];
};

private _frame = GVAR(captureFrameNo);

Expand All @@ -66,6 +72,7 @@ if (!isNull _vehicle) then {
_wepString = format["%1 [%2]", (configOf _vehicle) call BIS_fnc_displayName, _wepString];
};
_firer setVariable [QGVARMAIN(lastFired), _wepString];
(vehicle _firer) setVariable [QGVARMAIN(lastFired), _wepString];

_ammoSimType = getText(configFile >> "CfgAmmo" >> _ammo >> "simulation");
// _ammoSimType
Expand Down
16 changes: 9 additions & 7 deletions x/ocap2/addons/recorder/fnc_entityMonitors.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,25 @@
if (!hasInterface) exitWith {};
[] spawn {
waitUntil {!isNull (findDisplay 12)};
GVAR(liveDebugBullets) = [];
disableSerialization;
(findDisplay 12 displayCtrl 51) ctrlAddEventHandler ["Draw", {
if (GVARMAIN(isDebug)) then {
_sizeInMeters = 2.5;
_iconSize = (_sizeInMeters * 0.15) * 10^(abs log (ctrlMapScale (_this#0)));
{
// _x params ["_startPos", "_endPos", "_color", "_timeHit"];
if (!alive _x || isNull _x) then {continue};
(_this#0) drawIcon [
[getText((configOf _x) >> "icon")] call BIS_fnc_textureVehicleIcon, // Custom images can also be used: getMissionPath "\myFolder\myIcon.paa"
getText(configFile >> "CfgVehicleIcons" >> (getText((configOf _x) >> "icon"))), // Custom images can also be used: getMissionPath "\myFolder\myIcon.paa"
[side group _x] call BIS_fnc_sideColor,
getPos _x,
1,
1,
_iconSize,
_iconSize,
getDir _x,
name _x,
0,
0.03,
"PuristaLight",
1,
0.02,
"TahomaB",
"center"
];
} forEach (allUnits + vehicles) select {
Expand Down
2 changes: 2 additions & 0 deletions x/ocap2/addons/recorder/fnc_getClass.sqf
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "script_component.hpp"

if (getText(configFile >> "CfgVehicles" >> _this >> "model") isEqualTo "\A3\Weapons_f\empty") exitWith {"unknown"};

if (_this isKindOf "Truck_F") exitWith {"truck"}; // Should be higher than Car
if (_this call FUNC(isKindOfApc)) exitWith {"apc"};
if (_this isKindOf "Car") exitWith {"car"};
Expand Down
19 changes: 13 additions & 6 deletions x/ocap2/addons/recorder/fnc_init.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ if (is3DEN) exitWith {};
// if OCAP is disabled do nothing
if (!GVARMAIN(enabled)) exitWith {};
// if recording has already initialized this session then just start recording, don't re-init
if (!isNil QGVAR(startTime)) exitWith {call FUNC(startRecording)};
if (!isNil QGVAR(startTime)) exitWith {
if (!SHOULDSAVEEVENTS) exitWith {};
call FUNC(startRecording)
};

// "debug_console" callExtension format["clientState: %1 (%2) | %3", getClientState, getClientStateNumber, __FILE__];

// bool: GVAR(recording)
GVAR(recording) = false;
Expand Down Expand Up @@ -61,7 +66,7 @@ call FUNC(addEventMission);
[{!isNil QGVARMAIN(version) && !isNil QEGVAR(extension,version)}, {
player createDiarySubject ["OCAP2Info", "OCAP2 AAR", "\A3\ui_f\data\igui\cfg\simpleTasks\types\whiteboard_ca.paa"];

ocap_fnc_copyGitHubToClipboard = {copyToClipboard "https://github.com/OCAP2/OCAP"; systemChat "OCAP2 GitHub link copied to clipboard";};
ocap2_fnc_copyGitHubToClipboard = {copyToClipboard "https://github.com/OCAP2/OCAP"; systemChat "OCAP2 GitHub link copied to clipboard";};
EGVAR(diary,about) = player createDiaryRecord [
"OCAP2Info",
[
Expand All @@ -72,7 +77,7 @@ call FUNC(addEventMission);
"<br/>" +
"Extension version: " + (EGVAR(extension,version) # 0) + " (built " + (EGVAR(extension,version) # 1) + ")" +
"<br/>" +
"<execute expression='call ocap_fnc_copyGitHubToClipboard;'>https://github.com/OCAP2/OCAP</execute>" +
"<execute expression='call ocap2_fnc_copyGitHubToClipboard;'>https://github.com/OCAP2/OCAP</execute>" +
"<br/><br/>" +
"OCAP2 is a server-side Arma 3 recording suite that provides web-based playback of all units, vehicles, markers, and projectiles present, placed, and fired during a mission." +
"<br/><br/>" +
Expand Down Expand Up @@ -132,8 +137,10 @@ if (GVAR(missionName) == "") then {
The startRecording function checks internally if recording has already started by other means via whether GVAR(startTime) has been declared or not.
*/
[
{((count allPlayers) >= EGVAR(settings,minPlayerCount) && GVAR(autoStart)) || !isNil QGVAR(startTime)},
{call FUNC(startRecording)}
{(getClientStateNumber > 8 && (count allPlayers) >= EGVAR(settings,minPlayerCount) && GVAR(autoStart)) || !isNil QGVAR(startTime)},
{
call FUNC(startRecording)
}
] call CBA_fnc_waitUntilAndExecute;

// When the server progresses past briefing and enters the mission, save an event to the timeline if recording
Expand All @@ -146,7 +153,7 @@ if (GVAR(missionName) == "") then {
// If a recording has been started, exceeds min mission time, and no players are on the server, auto-save
[{
if (!isNil QGVAR(startTime) && (GVAR(frameCaptureDelay) * GVAR(captureFrameNo)) / 60 >= GVAR(minMissionTime) && count allPlayers == 0) then {
[nil, "Mission ended due to server being empty"] call FUNC(exportData);
[nil, "Recording ended due to server being empty"] call FUNC(exportData);
};
}, 30] call CBA_fnc_addPerFrameHandler;

Expand Down
7 changes: 5 additions & 2 deletions x/ocap2/addons/recorder/fnc_startRecording.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ if (!GVARMAIN(enabled)) exitWith {};
// if recording started earlier and startTime has been noted, only restart the capture loop with any updated settings.
if (GVAR(recording)) exitWith {
OCAPEXTLOG(["OCAP2 was asked to record and is already recording!"]);
["OCAP2 was asked to record and is already recording", 1, [1, 1, 1, 1]] remoteExecCall ["CBA_fnc_notify", [0, -2] select isDedicated];
[
["OCAP2 was asked to record", 1, [1, 1, 1, 1]],
["and is already recording", 1, [1, 1, 1, 1]]
] remoteExecCall ["CBA_fnc_notify", [0, -2] select isDedicated];
};

GVAR(recording) = true;
Expand Down Expand Up @@ -39,7 +42,7 @@ _missionDateFormat append (date apply {if (_x < 10) then {"0" + str _x} else {st
"\A3\ui_f\data\igui\cfg\simpleTasks\types\use_ca.paa"
];
}, _this] call CBA_fnc_waitUntilAndExecute;
}] remoteExecCall ["call", 0, true];
}] remoteExecCall ["call", [0, -2] select isDedicated, true];

if (GVAR(captureFrameNo) == 0) then {
// Notify the extension
Expand Down
2 changes: 1 addition & 1 deletion x/ocap2/addons/recorder/fnc_stopRecording.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ publicVariable QGVAR(recording);
"\A3\ui_f\data\igui\cfg\simpleTasks\types\use_ca.paa"
];
}, _this] call CBA_fnc_waitUntilAndExecute;
}] remoteExecCall ["call", 0, true];
}] remoteExecCall ["call", [0, -2] select isDedicated, true];

// Log times
[] call FUNC(updateTime);
17 changes: 0 additions & 17 deletions x/ocap2/licence.txt

This file was deleted.

Binary file removed x/ocap2/logo_ocap.paa
Binary file not shown.
Loading

0 comments on commit 64c1aed

Please sign in to comment.