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

many improvements #25

Merged
merged 5 commits into from
Jul 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
25 changes: 19 additions & 6 deletions addons/@ocap/addons/ocap/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,23 @@

class CfgPatches
{
class OCAP
class OCAP2
{
name = "OCAP";
author = "Dell, Zealot, Kurt, IndigoFox";

name = "OCAP2";
author = "Dell, Zealot, Kurt, IndigoFox, Fank";
authors[] = {"Dell", "Zealot", "Kurt", "IndigoFox", "Fank"};
url = "https://github.com/OCAP2/OCAP";
version = 1.1;
versionStr = "1.1.0";
versionAr[] = {1, 1, 0};
requiredAddons[] = {"A3_Functions_F","cba_main"};
requiredVersion = 2.4;
requiredVersion = 2.04;
units[] = {};
weapons[] = {};
};
};

class CfgFunctions
{
class OCAP
Expand All @@ -44,6 +51,7 @@ class CfgFunctions
class getEventWeaponText{};
class getUnitType{};
class handleMarkers{};
class handleCustomEvent{};
class startCaptureLoop{};
class trackAceExplLife{};
class trackAceExplPlace{};
Expand All @@ -58,11 +66,16 @@ class CfgRemoteExec
{
class Functions
{
class ocap_fnc_handleMarkers
class handleMarkers
{
allowedTargets = 2;
};
class trackAceThrowing{
class handleCustomEvent
{
allowedTargets = 2;
};
class trackAceThrowing
{
allowedTargets = 0;
};
};
Expand Down
33 changes: 32 additions & 1 deletion addons/@ocap/addons/ocap/functions/fn_addEventHandlers.sqf
Original file line number Diff line number Diff line change
@@ -1,10 +1,41 @@
/* ----------------------------------------------------------------------------
Script: ocap_fnc_addEventHandlers

Description:
Used for applying unit-specific event handlers to units during initialization. These event handlers will trigger on the server.

Applied during initialization of a unit in <ocap_fnc_startCaptureLoop>.

Parameters:
_entity - Object to apply event handlers to. [Object]
_respawn - Determines if unit is initialized for the first time, or has respawned and does not need certain handlers reapplied. [Boolean, defaults to false]

Returns:
Nothing

Examples:
--- Code
[_unit] spawn ocap_fnc_addEventHandlers;
---

Public:
No

Author:
IndigoFox, Fank
---------------------------------------------------------------------------- */

params ["_entity", ["_respawn", false]];

if ((_entity call BIS_fnc_objectType) # 0 == "Soldier") then {
_entity addEventHandler ["FiredMan", { _this spawn ocap_fnc_eh_fired; }];
};
_entity addMPEventHandler ["MPHit", { _this spawn ocap_fnc_eh_hit; }];

if (!_respawn && (_entity call BIS_fnc_objectType) # 0 == "Soldier") then {
if (
!_respawn &&
(_entity call BIS_fnc_objectType) # 0 == "Soldier" &&
isClass (configFile >> "CfgPatches" >> "ace_advanced_throwing")
) then {
ocap_fnc_trackAceThrowing remoteExec ["call", _entity];
};
38 changes: 30 additions & 8 deletions addons/@ocap/addons/ocap/functions/fn_addEventMission.sqf
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
/* ----------------------------------------------------------------------------
Script: ocap_fnc_addEventMission

Description:
Used for applying mission event handlers.

* Applied during initialization of OCAP2 in <ocap_fnc_init>.

Parameters:
None

Returns:
Nothing

Examples:
--- Code
call ocap_fnc_addEventMission;
---

Public:
No

Author:
IndigoFox, Dell
---------------------------------------------------------------------------- */

addMissionEventHandler["HandleDisconnect", {
_this call ocap_fnc_eh_disconnected;
}];
Expand All @@ -24,7 +50,9 @@ addMissionEventHandler ["EntityRespawned", {
};
}];

call ocap_fnc_trackAceExplPlace;
if (isClass (configFile >> "CfgPatches" >> "ace_explosives")) then {
call ocap_fnc_trackAceExplPlace;
};

if (ocap_saveMissionEnded) then {
addMissionEventHandler ["MPEnded", {
Expand All @@ -34,18 +62,12 @@ if (ocap_saveMissionEnded) then {

// Custom event handler
ocap_customEvent_handle = ["ocap_handleCustomEvent", {
params ["_eventName", "_eventMessage"];
[":EVENT:",
[ocap_captureFrameNo, _eventName, _eventMessage]
] call ocap_fnc_extension;
_this call ocap_fnc_handleCustomEvent;
}] call CBA_fnc_addEventHandler;
// to call, run
// ["ocap_handleCustomEvent", ["eventType", "eventMessage"]] call CBA_fnc_serverEvent;

// Add event saving markers
call ocap_fnc_handleMarkers;


["WMT_fnc_EndMission", {
_this call ocap_fnc_exportData;
}] call CBA_fnc_addEventHandler;
45 changes: 37 additions & 8 deletions addons/@ocap/addons/ocap/functions/fn_eh_fired.sqf
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
/* ----------------------------------------------------------------------------
Script: ocap_fnc_eh_fired

Description:
Tracks bullet and non-bullet projectiles. This is the code triggered when a unit firing is detected by the "FiredMan" Event Handler applied to units during <ocap_fnc_addEventHandlers>.

Parameters:
_firer - Unit the event handler is assigned to (the instigator) [Object]
_weapon - Fired weapon [String]
_muzzle - Muzzle that was used [String]
_mode - Current mode of the fired weapon [String]
_ammo - Ammo used [String]
_magazine - Magazine name which was used [String]
_projectile - Object of the projectile that was shot out [Object]
_vehicle - if weapon is vehicle weapon, otherwise objNull [Object]

Returns:
Nothing

Examples:
--- Code
---

Public:
No

Author:
IndigoFox, Dell
---------------------------------------------------------------------------- */

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

_frame = ocap_captureFrameNo;
Expand All @@ -15,7 +45,7 @@ if (_ammoSimType isEqualTo "shotBullet") then {
};
private _lastPos = [];
waitUntil {
_pos = getPosATL _projectile;
_pos = getPosASL _projectile;
if (((_pos select 0) isEqualTo 0) || isNull _projectile) exitWith {
true
};
Expand All @@ -26,7 +56,8 @@ if (_ammoSimType isEqualTo "shotBullet") then {
if !((count _lastPos) isEqualTo 0) then {
[":FIRED:", [
(_firer getVariable "ocap_id"),
_frame, [_lastPos select 0, _lastPos select 1]
_frame,
_lastPos
]] call ocap_fnc_extension;
};
};
Expand Down Expand Up @@ -100,8 +131,7 @@ if (_ammoSimType isEqualTo "shotBullet") then {
// _mark setMarkerShapeLocal "ICON";
// _mark setMarkerTextLocal format["%1 - %2", _firer, _markTextLocal];

_firerPos = getPosATL _firer;
_firerPos resize 2;
_firerPos = getPosASL _firer;
["ocap_handleMarker", ["CREATED", _markName, _firer, _firerPos, _markerType, "ICON", [1,1], getDirVisual _firer, "Solid", _markColor, 1, _markTextLocal, true]] call CBA_fnc_localEvent;

if (_ammoSimType isEqualTo "shotSubmunitions") then {
Expand All @@ -124,22 +154,21 @@ if (_ammoSimType isEqualTo "shotBullet") then {
private _lastPos = [];
private _lastDir = 0;
waitUntil {
_pos = getPosATL _projectile;
_pos = getPosASL _projectile;
_dir = getDirVisual _projectile;
if (((_pos select 0) isEqualTo 0) || isNull _projectile) exitWith {
true
};
_lastPos = _pos;
_lastDir = _dir;
// params["_eventType", "_mrk_name", "_mrk_owner", "_pos", "_type", "_shape", "_size", "_dir", "_brush", "_color", "_alpha", "_text", "_forceGlobal"];
["ocap_handleMarker", ["UPDATED", _markName, _firer, [_pos # 0, _pos # 1], "", "", "", _dir, "", "", 1]] call CBA_fnc_localEvent;
sleep 0.1;
["ocap_handleMarker", ["UPDATED", _markName, _firer, _pos, "", "", "", _dir, "", "", 1]] call CBA_fnc_localEvent;
sleep 0.3;
false;
};

if !((count _lastPos) isEqualTo 0) then {
// if (count _lastPos == 3) then {
_lastPos resize 2;
// params["_eventType", "_mrk_name", "_mrk_owner", "_pos", "_type", "_shape", "_size", "_dir", "_brush", "_color", "_alpha", "_text", "_forceGlobal"];
["ocap_handleMarker", ["UPDATED", _markName, _firer, _lastPos, "", "", "", _lastDir, "", "", 1]] call CBA_fnc_localEvent;
};
Expand Down
26 changes: 26 additions & 0 deletions addons/@ocap/addons/ocap/functions/fn_eh_hit.sqf
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
/* ----------------------------------------------------------------------------
Script: ocap_fnc_eh_hit

Description:
Tracks when a unit is hit/takes damage. This is the code triggered by the "MPHit" Event Handler applied to units during <ocap_fnc_addEventHandlers>.

Parameters:
_unit - Object the event handler is assigned to. [Object]
_causedBy - Object that caused the damage. Contains the unit itself in case of collisions. [Object]
_damage - Level of damage caused by the hit. [Number]
_instigator - Object - Person who pulled the trigger. [Object]

Returns:
Nothing

Examples:
--- Code
---

Public:
No

Author:
IndigoFox, Fank
---------------------------------------------------------------------------- */

#include "script_macros.hpp";
params ["_unit", "_causedBy", "_damage", "_instigator"];

Expand Down
26 changes: 26 additions & 0 deletions addons/@ocap/addons/ocap/functions/fn_eh_killed.sqf
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
/* ----------------------------------------------------------------------------
Script: ocap_fnc_eh_killed

Description:
Tracks when a unit is killed. This is the code triggered by the "MPKilled" Event Handler applied to units during <ocap_fnc_addEventHandlers>.

Parameters:
_unit - Object the event handler is assigned to. [Object]
_killer - Object that killed the unit. [Object]
_instigator - Person who pulled the trigger. [Object]
_useEffects - same as useEffects in setDamage alt syntax. [Boolean]

Returns:
Nothing

Examples:
--- Code
---

Public:
No

Author:
Dell, IndigoFox, Fank
---------------------------------------------------------------------------- */

#include "script_macros.hpp";
params ["_victim", "_killer", "_instigator"];
if !(_victim getvariable ["ocapIsKilled",false]) then {
Expand Down
39 changes: 39 additions & 0 deletions addons/@ocap/addons/ocap/functions/fn_exportData.sqf
Original file line number Diff line number Diff line change
@@ -1,3 +1,42 @@
/* ----------------------------------------------------------------------------
Script: ocap_fnc_exportData

Description:
This function facilitates the actual endMission and save events in the extension, prompting it to pack the mission and upload it to the web component.

This function MUST be called in order to save a mission recording. A boolean true in the correct option of userconfig.hpp will automatically execute this function when the "MPEnded" Event Handler triggers.

Parameters:
_side - The winning side [optional, Side]
_message - A custom description of how the victory was achieved [optional, String]
_tag - A custom tag to override that which is defined in userconfig.hpp that will make it filterable in web [optional, String]

Returns:
Nothing

Examples:
--- Code
// "Mission ended"
[] call ocap_fnc_exportData;

// "BLUFOR Win."
[west] call ocap_fnc_exportData;

// "OPFOR Win. OPFOR controlled all sectors!
[east, "OPFOR controlled all sectors!"] call ocap_fnc_exportData;

// "Independent Win. INDFOR stole the intel!"
// Mission is saved under filterable "SnatchAndGrab" tag on web
[independent, "INDFOR stole the intel!", "SnatchAndGrab"] call ocap_fnc_exportData;
---

Public:
Yes

Author:
Dell, Zealot, IndigoFox
---------------------------------------------------------------------------- */

#include "script_macros.hpp"
if (!ocap_capture) exitWith {LOG(["fnc_exportData.sqf called, but recording hasn't started."]);};

Expand Down
32 changes: 31 additions & 1 deletion addons/@ocap/addons/ocap/functions/fn_extension.sqf
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
/* ----------------------------------------------------------------------------
Script: ocap_fnc_extension

Description:
Manages raw extension calls and returns values / logs errors where relevant.

Parameters:
_command - The extension command to call [String]
_args - The arguments to send [Array]

Returns:
Depends

Examples:
--- Code
[":VERSION", []] call ocap_fnc_extension;
---

Public:
No

Author:
Dell, Zealot
---------------------------------------------------------------------------- */

params ["_command","_args"];

private _dllName = "OcapReplaySaver2";
Expand All @@ -8,4 +33,9 @@ _res params ["_result","_returnCode","_errorCode"];

if (_errorCode != 0 || _returnCode != 0) then {
diag_log ["fnc_callextension_zlt.sqf: Error: ", _result, _returnCode, _errorCode, _command, _args];
}
};

if (
_command isEqualTo ":VERSION:" &&
_result isEqualType ""
) then {parseSimpleArray _result};
Loading