diff --git a/addons/@ocap/addons/ocap/config.cpp b/addons/@ocap/addons/ocap/config.cpp index ae051de..d85b490 100644 --- a/addons/@ocap/addons/ocap/config.cpp +++ b/addons/@ocap/addons/ocap/config.cpp @@ -41,6 +41,7 @@ class CfgFunctions class extension{}; class getDelay{}; class getInstigator{}; + class getEventWeaponText{}; class getUnitType{}; class handleMarkers{}; class startCaptureLoop{}; diff --git a/addons/@ocap/addons/ocap/functions/fn_eh_hit.sqf b/addons/@ocap/addons/ocap/functions/fn_eh_hit.sqf index 4fd37f5..01c6200 100644 --- a/addons/@ocap/addons/ocap/functions/fn_eh_hit.sqf +++ b/addons/@ocap/addons/ocap/functions/fn_eh_hit.sqf @@ -1,52 +1,39 @@ +#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 = [ @@ -54,9 +41,10 @@ params ["_unit", "_causedBy", "_damage", "_instigator"]; "hit", _unitID, _causedByInfo, - round (_unit distance _causedBy) + _distanceInfo ]; }; + DEBUG(_eventData); [":EVENT:", _eventData] call ocap_fnc_extension; }; diff --git a/addons/@ocap/addons/ocap/functions/fn_eh_killed.sqf b/addons/@ocap/addons/ocap/functions/fn_eh_killed.sqf index 92aa797..a162b36 100644 --- a/addons/@ocap/addons/ocap/functions/fn_eh_killed.sqf +++ b/addons/@ocap/addons/ocap/functions/fn_eh_killed.sqf @@ -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, { @@ -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; }; }; diff --git a/addons/@ocap/addons/ocap/functions/fn_getEventWeaponText.sqf b/addons/@ocap/addons/ocap/functions/fn_getEventWeaponText.sqf new file mode 100644 index 0000000..4f7378a --- /dev/null +++ b/addons/@ocap/addons/ocap/functions/fn_getEventWeaponText.sqf @@ -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; diff --git a/addons/@ocap/addons/ocap/script_macros.hpp b/addons/@ocap/addons/ocap/script_macros.hpp index ec728d0..b727144 100644 --- a/addons/@ocap/addons/ocap/script_macros.hpp +++ b/addons/@ocap/addons/ocap/script_macros.hpp @@ -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