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

establishes parity between killed and hit in recording/display #23

Merged
merged 8 commits into from
Jul 21, 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
1 change: 1 addition & 0 deletions addons/@ocap/addons/ocap/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class CfgFunctions
class extension{};
class getDelay{};
class getInstigator{};
class getEventWeaponText{};
class getUnitType{};
class handleMarkers{};
class startCaptureLoop{};
Expand Down
56 changes: 22 additions & 34 deletions addons/@ocap/addons/ocap/functions/fn_eh_hit.sqf
Original file line number Diff line number Diff line change
@@ -1,62 +1,50 @@
#include "script_macros.hpp";
params ["_unit", "_causedBy", "_damage", "_instigator"];

[_unit, _causedBy, _instigator] spawn {
params ["_unit", "_causedBy", "_instigator"];
_unitID = _unit getVariable "ocap_id";

if (isNull _instigator) then {
_instigator = [_unit, _causedBy] call ocap_fnc_getInstigator;
};

_unitID = _unit getVariable ["ocap_id", -1];
if (_unitID == -1) exitWith {};
private _eventData = [ocap_captureFrameNo, "hit", _unitID, ["null"], -1];
if (!isNull _causedBy) then {
_causedByInfo = [];
if (_causedBy isKindOf "CAManBase") then {

if (!isNull _instigator) then {
_causedById = _causedBy getVariable ["ocap_id", -1];
_instigatorId = _instigator getVariable ["ocap_id", -1];

private _causedByInfo = [];
private _distanceInfo = 0;
if (_causedBy isKindOf "CAManBase" && _causedById > -1) then {
_causedByInfo = [
_causedBy getVariable "ocap_id",
getText (configFile >> "CfgWeapons" >> currentWeapon _causedBy >> "displayName")
_causedById,
([_causedBy] call ocap_fnc_getEventWeaponText)
];
_distanceInfo = round (_unit distance _causedBy);
} else {
if (!isNull _instigator && _causedBy != _instigator && _instigator isKindOf "CAManBase") then {
// pilot/driver doesn't return a value, so check for this
private _turPath = [];
if (count (assignedVehicleRole _instigator) > 1) then {
_turPath = assignedVehicleRole _instigator select 1;
} else {
_turPath = [-1];
};

private _curVic = getText(configFile >> "CfgVehicles" >> (typeOf vehicle _instigator) >> "displayName");
(weaponstate [vehicle _causedBy, _turPath]) params ["_curWep", "_curMuzzle", "_curFiremode", "_curMag"];
private _curWepDisplayName = getText(configFile >> "CfgWeapons" >> _curWep >> "displayName");
private _curMagDisplayName = getText(configFile >> "CfgMagazines" >> _curMag >> "displayName");
private _text = "";
if (count _curMagDisplayName < 22) then {
_text = _curVic + " [" + _curWepDisplayName + " / " + _curMagDisplayName + "]";
} else {
if (_curWep != _curMuzzle) then {
_text = _curVic + " [" + _curWepDisplayName + " / " + _curMuzzle + "]";
} else {
_text = _curVic + " [" + _curWepDisplayName + "]";
};
};

if (!isNull _instigator && _causedBy != _instigator && _instigator isKindOf "CAManBase" && _instigatorId > -1) then {
_causedByInfo = [
_instigator getVariable "ocap_id",
_text
_instigatorId,
([_instigator] call ocap_fnc_getEventWeaponText)
];
_distanceInfo = round (_unit distance _instigator);
} else {
_causedByInfo = [_causedBy getVariable "ocap_id"];
_causedByInfo = [_causedById];
_distanceInfo = round (_unit distance _causedBy);
};
};
_eventData = [
ocap_captureFrameNo,
"hit",
_unitID,
_causedByInfo,
round (_unit distance _causedBy)
_distanceInfo
];
};

DEBUG(_eventData);
[":EVENT:", _eventData] call ocap_fnc_extension;
};
68 changes: 19 additions & 49 deletions addons/@ocap/addons/ocap/functions/fn_eh_killed.sqf
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#include "script_macros.hpp";
params ["_victim", "_killer", "_instigator"];
if !(_victim getvariable ["ocapIsKilled",false]) then {
_victim setvariable ["ocapIsKilled",true];

[_victim, _killer, _instigator] spawn {
params ["_victim", "_killer", "_instigator"];
private _frame = ocap_captureFrameNo;
if (_killer == _victim) then {
private _time = diag_tickTime;
[_victim, {
Expand All @@ -23,62 +23,32 @@ if !(_victim getvariable ["ocapIsKilled",false]) then {
// [ocap_captureFrameNo, "killed", _victimId, ["null"], -1];
private _victimId = _victim getVariable ["ocap_id", -1];
if (_victimId == -1) exitWith {};
private _eventData = [_frame, "killed", _victimId, ["null"], -1];
private _eventData = [ocap_captureFrameNo, "killed", _victimId, ["null"], -1];

if (!isNull _instigator) then {
_killerId = _instigator getVariable ["ocap_id", -1];
if (_killerId != -1) then {
private _killerInfo = [];
if (_instigator isKindOf "CAManBase") then {
if (vehicle _instigator != _instigator) then {
if (_killerId == -1) exitWith {};

// pilot/driver doesn't return a value, so check for this
private _turPath = [];
if (count (assignedVehicleRole _instigator) > 1) then {
_turPath = assignedVehicleRole _instigator select 1;
} else {
_turPath = [-1];
};

private _curVic = getText(configFile >> "CfgVehicles" >> (typeOf vehicle _instigator) >> "displayName");
(weaponstate [vehicle _instigator, _turPath]) params ["_curWep", "_curMuzzle", "_curFiremode", "_curMag"];
private _curWepDisplayName = getText(configFile >> "CfgWeapons" >> _curWep >> "displayName");
private _curMagDisplayName = getText(configFile >> "CfgMagazines" >> _curMag >> "displayName");
private _text = "";
if (count _curMagDisplayName < 22) then {
_text = _curVic + " [" + _curWepDisplayName + " / " + _curMagDisplayName + "]";
} else {
if (_curWep != _curMuzzle) then {
_text = _curVic + " [" + _curWepDisplayName + " / " + _curMuzzle + "]";
} else {
_text = _curVic + " [" + _curWepDisplayName + "]";
};
};

_killerInfo = [
_killerId,
_text
];
} else {
_killerInfo = [
_killerId,
getText (configFile >> "CfgWeapons" >> currentWeapon _instigator >> "displayName")
];
};
} else {
_killerInfo = [_killerId];
};

_eventData = [
_frame,
"killed",
_victimId,
_killerInfo,
round(_instigator distance _victim)
private _killerInfo = [];
if (_instigator isKindOf "CAManBase") then {
_killerInfo = [
_killerId,
([_instigator] call ocap_fnc_getEventWeaponText)
];
} else {
_killerInfo = [_killerId];
};

_eventData = [
ocap_captureFrameNo,
"killed",
_victimId,
_killerInfo,
round(_instigator distance _victim)
];
};

DEBUG(_eventData);
[":EVENT:", _eventData] call ocap_fnc_extension;
};
};
41 changes: 41 additions & 0 deletions addons/@ocap/addons/ocap/functions/fn_getEventWeaponText.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@

params ["_instigator"];

if (vehicle _instigator isEqualTo _instigator) exitWith {
getText (configFile >> "CfgWeapons" >> currentWeapon _instigator >> "displayName");
};

// pilot/driver doesn't return a value, so check for this
private _turPath = [];
if (count (assignedVehicleRole _instigator) > 1) then {
_turPath = assignedVehicleRole _instigator select 1;
} else {
_turPath = [-1];
};

private _curVic = getText(configFile >> "CfgVehicles" >> (typeOf vehicle _instigator) >> "displayName");
(weaponstate [vehicle _instigator, _turPath]) params ["_curWep", "_curMuzzle", "_curFiremode", "_curMag"];
private _curWepDisplayName = getText(configFile >> "CfgWeapons" >> _curWep >> "displayName");
private _curMagDisplayName = getText(configFile >> "CfgMagazines" >> _curMag >> "displayName");
private _text = _curVic;
if (count _curMagDisplayName < 22) then {
if !(_curWepDisplayName isEqualTo "") then {
_text = _text + " [" + _curWepDisplayName;
if !(_curMagDisplayName isEqualTo "") then {
_text = _text + " / " + _curMagDisplayName + "]";
} else {
_text = _text + "]"
};
};
} else {
if !(_curWepDisplayName isEqualTo "") then {
_text = _text + " [" + _curWepDisplayName;
if (_curWep != _curMuzzle && !(_curMuzzle isEqualTo "")) then {
_text = _text + " / " + _curMuzzle + "]";
} else {
_text = _text + "]";
};
};
};

_text;
1 change: 1 addition & 0 deletions addons/@ocap/addons/ocap/script_macros.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "\userconfig\ocap\config.hpp"
#define REQUIRED_VERSION 2.0
#define LOG(_args) [":LOG:", _args] call ocap_fnc_extension
#if ocap_isDebug
Expand Down