From 3d59c1a283147a2219fa936c59213ebb28e446df Mon Sep 17 00:00:00 2001 From: Florian Kinder Date: Mon, 19 Jul 2021 23:07:46 +0200 Subject: [PATCH 1/7] Replaced Hit with MPHit --- addons/@ocap/addons/ocap/functions/fn_addEventHandlers.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/@ocap/addons/ocap/functions/fn_addEventHandlers.sqf b/addons/@ocap/addons/ocap/functions/fn_addEventHandlers.sqf index efe91d9..90b660d 100644 --- a/addons/@ocap/addons/ocap/functions/fn_addEventHandlers.sqf +++ b/addons/@ocap/addons/ocap/functions/fn_addEventHandlers.sqf @@ -3,7 +3,7 @@ params ["_entity", ["_respawn", false]]; if ((_entity call BIS_fnc_objectType) # 0 == "Soldier") then { _entity addEventHandler ["FiredMan", { _this spawn ocap_fnc_eh_fired; }]; }; -_entity addEventHandler ["Hit", { _this spawn ocap_fnc_eh_hit; }]; +_entity addMPEventHandler ["MPHit", { _this spawn ocap_fnc_eh_hit; }]; if (!_respawn && (_entity call BIS_fnc_objectType) # 0 == "Soldier") then { ocap_fnc_trackAceThrowing remoteExec ["call", _entity]; From a1ab26f56bda5d0984515b31f55f164832776c1d Mon Sep 17 00:00:00 2001 From: Florian Kinder Date: Tue, 20 Jul 2021 19:21:29 +0200 Subject: [PATCH 2/7] Renaming --- .../@ocap/addons/ocap/functions/fn_eh_hit.sqf | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/addons/@ocap/addons/ocap/functions/fn_eh_hit.sqf b/addons/@ocap/addons/ocap/functions/fn_eh_hit.sqf index bb66aa9..30ac53f 100644 --- a/addons/@ocap/addons/ocap/functions/fn_eh_hit.sqf +++ b/addons/@ocap/addons/ocap/functions/fn_eh_hit.sqf @@ -1,23 +1,23 @@ -params ["_victim", "_hitter"]; -_victimId = _victim getVariable "ocap_id"; +params ["_unit", "_causedBy", "_damage", "_instigator"]; +_unitID = _unit getVariable "ocap_id"; -private _eventData = [ocap_captureFrameNo, "hit", _victimId, ["null"], -1]; -if (!isNull _hitter) then { - _hitterInfo = []; - if (_hitter isKindOf "CAManBase") then { - _hitterInfo = [ - _hitter getVariable "ocap_id", - getText (configFile >> "CfgWeapons" >> currentWeapon _hitter >> "displayName") +private _eventData = [ocap_captureFrameNo, "hit", _unitID, ["null"], -1]; +if (!isNull _causedBy) then { + _causedByInfo = []; + if (_causedBy isKindOf "CAManBase") then { + _causedByInfo = [ + _causedBy getVariable "ocap_id", + getText (configFile >> "CfgWeapons" >> currentWeapon _causedBy >> "displayName") ]; } else { - _hitterInfo = [_hitter getVariable "ocap_id"]; + _causedByInfo = [_causedBy getVariable "ocap_id"]; }; _eventData = [ ocap_captureFrameNo, "hit", - _victimId, - _hitterInfo, - round (_victim distance _hitter) + _unitID, + _causedByInfo, + round (_unit distance _causedBy) ]; }; From 6ded1bf3d84f8fda17c181e2052d2c8d60fe2846 Mon Sep 17 00:00:00 2001 From: Florian Kinder Date: Tue, 20 Jul 2021 20:33:45 +0200 Subject: [PATCH 3/7] copied kill to hit event handler --- .../@ocap/addons/ocap/functions/fn_eh_hit.sqf | 32 ++++++++++++++++++- .../addons/ocap/functions/fn_eh_killed.sqf | 3 +- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/addons/@ocap/addons/ocap/functions/fn_eh_hit.sqf b/addons/@ocap/addons/ocap/functions/fn_eh_hit.sqf index 30ac53f..e66e187 100644 --- a/addons/@ocap/addons/ocap/functions/fn_eh_hit.sqf +++ b/addons/@ocap/addons/ocap/functions/fn_eh_hit.sqf @@ -10,7 +10,37 @@ if (!isNull _causedBy) then { getText (configFile >> "CfgWeapons" >> currentWeapon _causedBy >> "displayName") ]; } else { - _causedByInfo = [_causedBy getVariable "ocap_id"]; + 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 + "]"; + }; + }; + + _causedByInfo = [ + _instigator getVariable "ocap_id", + _text + ]; + } else { + _causedByInfo = [_causedBy getVariable "ocap_id"]; + }; }; _eventData = [ ocap_captureFrameNo, diff --git a/addons/@ocap/addons/ocap/functions/fn_eh_killed.sqf b/addons/@ocap/addons/ocap/functions/fn_eh_killed.sqf index 8a93fdc..8f4af51 100644 --- a/addons/@ocap/addons/ocap/functions/fn_eh_killed.sqf +++ b/addons/@ocap/addons/ocap/functions/fn_eh_killed.sqf @@ -55,8 +55,7 @@ if !(_victim getvariable ["ocapIsKilled",false]) then { }; private _curVic = getText(configFile >> "CfgVehicles" >> (typeOf vehicle _instigator) >> "displayName"); - private _curWepInfo = weaponstate [vehicle _instigator, _turPath]; - _curWepInfo params ["_curWep", "_curMuzzle", "_curFiremode", "_curMag"]; + (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 = ""; From cf50c353eb4497dd68ecb6a09defcd7b4d98ba8d Mon Sep 17 00:00:00 2001 From: Florian Kinder Date: Tue, 20 Jul 2021 22:13:59 +0200 Subject: [PATCH 4/7] Fix --- addons/@ocap/addons/ocap/config.cpp | 1 + .../@ocap/addons/ocap/functions/fn_eh_hit.sqf | 96 ++++++++++--------- .../addons/ocap/functions/fn_eh_killed.sqf | 18 +--- .../ocap/functions/fn_getInstigator.sqf | 21 ++++ 4 files changed, 76 insertions(+), 60 deletions(-) create mode 100644 addons/@ocap/addons/ocap/functions/fn_getInstigator.sqf diff --git a/addons/@ocap/addons/ocap/config.cpp b/addons/@ocap/addons/ocap/config.cpp index dd5af17..ae051de 100644 --- a/addons/@ocap/addons/ocap/config.cpp +++ b/addons/@ocap/addons/ocap/config.cpp @@ -40,6 +40,7 @@ class CfgFunctions class exportData{}; class extension{}; class getDelay{}; + class getInstigator{}; 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 e66e187..4fd37f5 100644 --- a/addons/@ocap/addons/ocap/functions/fn_eh_hit.sqf +++ b/addons/@ocap/addons/ocap/functions/fn_eh_hit.sqf @@ -1,54 +1,62 @@ params ["_unit", "_causedBy", "_damage", "_instigator"]; -_unitID = _unit getVariable "ocap_id"; -private _eventData = [ocap_captureFrameNo, "hit", _unitID, ["null"], -1]; -if (!isNull _causedBy) then { - _causedByInfo = []; - if (_causedBy isKindOf "CAManBase") then { - _causedByInfo = [ - _causedBy getVariable "ocap_id", - getText (configFile >> "CfgWeapons" >> currentWeapon _causedBy >> "displayName") - ]; - } 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]; - }; +[_unit, _causedBy, _instigator] spawn { + params ["_unit", "_causedBy", "_instigator"]; + _unitID = _unit getVariable "ocap_id"; - 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) then { + _instigator = [_unit, _causedBy] call ocap_fnc_getInstigator; + }; + private _eventData = [ocap_captureFrameNo, "hit", _unitID, ["null"], -1]; + if (!isNull _causedBy) then { + _causedByInfo = []; + if (_causedBy isKindOf "CAManBase") then { _causedByInfo = [ - _instigator getVariable "ocap_id", - _text + _causedBy getVariable "ocap_id", + getText (configFile >> "CfgWeapons" >> currentWeapon _causedBy >> "displayName") ]; } else { - _causedByInfo = [_causedBy getVariable "ocap_id"]; + 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 + "]"; + }; + }; + + _causedByInfo = [ + _instigator getVariable "ocap_id", + _text + ]; + } else { + _causedByInfo = [_causedBy getVariable "ocap_id"]; + }; }; + _eventData = [ + ocap_captureFrameNo, + "hit", + _unitID, + _causedByInfo, + round (_unit distance _causedBy) + ]; }; - _eventData = [ - ocap_captureFrameNo, - "hit", - _unitID, - _causedByInfo, - round (_unit distance _causedBy) - ]; -}; -[":EVENT:", _eventData] call ocap_fnc_extension; + [":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 8f4af51..92aa797 100644 --- a/addons/@ocap/addons/ocap/functions/fn_eh_killed.sqf +++ b/addons/@ocap/addons/ocap/functions/fn_eh_killed.sqf @@ -15,23 +15,9 @@ if !(_victim getvariable ["ocapIsKilled",false]) then { } else { _killer }; + if (isNull _instigator) then { - _instigator = UAVControl vehicle _killer select 0 - }; - if ((isNull _instigator) || (_instigator == _victim)) then { - _instigator = _killer - }; - if (_instigator isKindOf "AllVehicles") then { - // _instigator = effectiveCommander _instigator - _instigator = call { - if(alive(gunner _instigator))exitWith{gunner _instigator}; - if(alive(commander _instigator))exitWith{commander _instigator}; - if(alive(driver _instigator))exitWith{driver _instigator}; - effectiveCommander _instigator - }; - }; - if (isNull _instigator) then { - _instigator = _killer + _instigator = [_victim, _killer] call ocap_fnc_getInstigator; }; // [ocap_captureFrameNo, "killed", _victimId, ["null"], -1]; diff --git a/addons/@ocap/addons/ocap/functions/fn_getInstigator.sqf b/addons/@ocap/addons/ocap/functions/fn_getInstigator.sqf new file mode 100644 index 0000000..5dae635 --- /dev/null +++ b/addons/@ocap/addons/ocap/functions/fn_getInstigator.sqf @@ -0,0 +1,21 @@ +params ["_victim", ["_killer", objNull], ["_instigator", objNull]]; + +if (isNull _instigator) then { + _instigator = UAVControl vehicle _killer select 0; +}; +if ((isNull _instigator) || (_instigator == _victim)) then { + _instigator = _killer; +}; +if (_instigator isKindOf "AllVehicles") then { + _instigator = call { + if(alive(gunner _instigator))exitWith{gunner _instigator}; + if(alive(commander _instigator))exitWith{commander _instigator}; + if(alive(driver _instigator))exitWith{driver _instigator}; + effectiveCommander _instigator + }; +}; +if (isNull _instigator) then { + _instigator = _killer; +}; + +_instigator; From 1fb3e3686da08bd386ac6ee7ff7bff8415b603d6 Mon Sep 17 00:00:00 2001 From: IndigoFox Date: Tue, 20 Jul 2021 18:34:12 -0400 Subject: [PATCH 5/7] start commit --- .../@ocap/addons/ocap/functions/fn_eh_hit.sqf | 43 ++++------- .../addons/ocap/functions/fn_eh_killed.sqf | 75 +++++++------------ .../ocap/functions/fn_getVicWeaponText.sqf | 37 +++++++++ 3 files changed, 76 insertions(+), 79 deletions(-) create mode 100644 addons/@ocap/addons/ocap/functions/fn_getVicWeaponText.sqf diff --git a/addons/@ocap/addons/ocap/functions/fn_eh_hit.sqf b/addons/@ocap/addons/ocap/functions/fn_eh_hit.sqf index 4fd37f5..b52139b 100644 --- a/addons/@ocap/addons/ocap/functions/fn_eh_hit.sqf +++ b/addons/@ocap/addons/ocap/functions/fn_eh_hit.sqf @@ -2,47 +2,30 @@ 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; }; - private _eventData = [ocap_captureFrameNo, "hit", _unitID, ["null"], -1]; - if (!isNull _causedBy) then { - _causedByInfo = []; - if (_causedBy isKindOf "CAManBase") then { + _unitID = _unit getVariable ["ocap_id", -1]; + if (_unitID == -1) exitWith {}; + private _eventData = []; + // [ocap_captureFrameNo, "hit", _unitID, ["null"], -1]; + + if (!isNull _instigator) then { + _causedById = _causedBy getVariable ["ocap_id", -1]; + + private _causedByInfo = []; + if (_causedBy isKindOf "CAManBase" && !(_causedById == -1)) then { _causedByInfo = [ - _causedBy getVariable "ocap_id", + _causedById, getText (configFile >> "CfgWeapons" >> currentWeapon _causedBy >> "displayName") ]; } 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 + "]"; - }; - }; - + _text = [_instigator] call ocap_fnc_getVicWeaponText; _causedByInfo = [ - _instigator getVariable "ocap_id", + _killerId, _text ]; } else { diff --git a/addons/@ocap/addons/ocap/functions/fn_eh_killed.sqf b/addons/@ocap/addons/ocap/functions/fn_eh_killed.sqf index 92aa797..5cffd59 100644 --- a/addons/@ocap/addons/ocap/functions/fn_eh_killed.sqf +++ b/addons/@ocap/addons/ocap/functions/fn_eh_killed.sqf @@ -4,7 +4,6 @@ if !(_victim getvariable ["ocapIsKilled",false]) then { [_victim, _killer, _instigator] spawn { params ["_victim", "_killer", "_instigator"]; - private _frame = ocap_captureFrameNo; if (_killer == _victim) then { private _time = diag_tickTime; [_victim, { @@ -23,60 +22,38 @@ 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 { - - // 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") - ]; - }; + if (_killerId == -1) exitWith {}; + + private _killerInfo = []; + if (_instigator isKindOf "CAManBase") then { + if (vehicle _instigator != _instigator) then { + _text = [_instigator] call ocap_fnc_getVicWeaponText; + _causedByInfo = [ + _killerId, + _text + ]; } else { - _killerInfo = [_killerId]; + _causedByInfo = [ + _killerId, + getText (configFile >> "CfgWeapons" >> currentWeapon _instigator >> "displayName") + ]; }; - - _eventData = [ - _frame, - "killed", - _victimId, - _killerInfo, - round(_instigator distance _victim) - ]; + } else { + _causedByInfo = [_killerId]; }; + + _eventData = [ + ocap_captureFrameNo, + "killed", + _victimId, + _causedByInfo, + round(_instigator distance _victim) + ]; }; [":EVENT:", _eventData] call ocap_fnc_extension; diff --git a/addons/@ocap/addons/ocap/functions/fn_getVicWeaponText.sqf b/addons/@ocap/addons/ocap/functions/fn_getVicWeaponText.sqf new file mode 100644 index 0000000..fc5d24e --- /dev/null +++ b/addons/@ocap/addons/ocap/functions/fn_getVicWeaponText.sqf @@ -0,0 +1,37 @@ + +params ["_instigator"]; + +// 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 && !(_curMuzzleDisplayName isEqualTo "")) then { + _text = _text + " / " + _curMuzzle + "]"; + } else { + _text = _text + "]"; + }; + }; +}; + +_text; From f3b8a6e52cfeabeaa2d281dafe302c221c3b8031 Mon Sep 17 00:00:00 2001 From: IndigoFox Date: Tue, 20 Jul 2021 18:57:45 -0400 Subject: [PATCH 6/7] ready for testing --- addons/@ocap/addons/ocap/config.cpp | 1 + .../@ocap/addons/ocap/functions/fn_eh_hit.sqf | 20 +++++++++++-------- .../addons/ocap/functions/fn_eh_killed.sqf | 16 ++++----------- ...aponText.sqf => fn_getEventWeaponText.sqf} | 4 ++++ 4 files changed, 21 insertions(+), 20 deletions(-) rename addons/@ocap/addons/ocap/functions/{fn_getVicWeaponText.sqf => fn_getEventWeaponText.sqf} (89%) 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 b52139b..5450dcd 100644 --- a/addons/@ocap/addons/ocap/functions/fn_eh_hit.sqf +++ b/addons/@ocap/addons/ocap/functions/fn_eh_hit.sqf @@ -14,22 +14,26 @@ params ["_unit", "_causedBy", "_damage", "_instigator"]; if (!isNull _instigator) then { _causedById = _causedBy getVariable ["ocap_id", -1]; + _instigatorId = _instigator getVariable ["ocap_id", -1]; private _causedByInfo = []; - if (_causedBy isKindOf "CAManBase" && !(_causedById == -1)) then { + private _distanceInfo = 0; + if (_causedBy isKindOf "CAManBase" && _causedById > -1) then { _causedByInfo = [ _causedById, - getText (configFile >> "CfgWeapons" >> currentWeapon _causedBy >> "displayName") + ([_causedBy] call ocap_fnc_getEventWeaponText) ]; + _distanceInfo = round (_unit distance _causedBy); } else { - if (!isNull _instigator && _causedBy != _instigator && _instigator isKindOf "CAManBase") then { - _text = [_instigator] call ocap_fnc_getVicWeaponText; + if (!isNull _instigator && _causedBy != _instigator && _instigator isKindOf "CAManBase" && _instigatorId > -1) then { _causedByInfo = [ - _killerId, - _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 = [ @@ -37,7 +41,7 @@ params ["_unit", "_causedBy", "_damage", "_instigator"]; "hit", _unitID, _causedByInfo, - round (_unit distance _causedBy) + _distanceInfo ]; }; diff --git a/addons/@ocap/addons/ocap/functions/fn_eh_killed.sqf b/addons/@ocap/addons/ocap/functions/fn_eh_killed.sqf index 5cffd59..3fc488a 100644 --- a/addons/@ocap/addons/ocap/functions/fn_eh_killed.sqf +++ b/addons/@ocap/addons/ocap/functions/fn_eh_killed.sqf @@ -31,18 +31,10 @@ if !(_victim getvariable ["ocapIsKilled",false]) then { private _killerInfo = []; if (_instigator isKindOf "CAManBase") then { - if (vehicle _instigator != _instigator) then { - _text = [_instigator] call ocap_fnc_getVicWeaponText; - _causedByInfo = [ - _killerId, - _text - ]; - } else { - _causedByInfo = [ - _killerId, - getText (configFile >> "CfgWeapons" >> currentWeapon _instigator >> "displayName") - ]; - }; + _causedByInfo = [ + _instigatorId, + ([_instigator] call ocap_fnc_getEventWeaponText) + ]; } else { _causedByInfo = [_killerId]; }; diff --git a/addons/@ocap/addons/ocap/functions/fn_getVicWeaponText.sqf b/addons/@ocap/addons/ocap/functions/fn_getEventWeaponText.sqf similarity index 89% rename from addons/@ocap/addons/ocap/functions/fn_getVicWeaponText.sqf rename to addons/@ocap/addons/ocap/functions/fn_getEventWeaponText.sqf index fc5d24e..509eba8 100644 --- a/addons/@ocap/addons/ocap/functions/fn_getVicWeaponText.sqf +++ b/addons/@ocap/addons/ocap/functions/fn_getEventWeaponText.sqf @@ -1,6 +1,10 @@ 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 { From e07b6e843716dcb8860163e4e6765e441e267908 Mon Sep 17 00:00:00 2001 From: IndigoFox Date: Tue, 20 Jul 2021 20:47:59 -0400 Subject: [PATCH 7/7] fixes --- addons/@ocap/addons/ocap/functions/fn_eh_hit.sqf | 5 +++-- addons/@ocap/addons/ocap/functions/fn_eh_killed.sqf | 13 +++++++------ .../addons/ocap/functions/fn_getEventWeaponText.sqf | 2 +- addons/@ocap/addons/ocap/script_macros.hpp | 1 + 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/addons/@ocap/addons/ocap/functions/fn_eh_hit.sqf b/addons/@ocap/addons/ocap/functions/fn_eh_hit.sqf index 5450dcd..01c6200 100644 --- a/addons/@ocap/addons/ocap/functions/fn_eh_hit.sqf +++ b/addons/@ocap/addons/ocap/functions/fn_eh_hit.sqf @@ -1,3 +1,4 @@ +#include "script_macros.hpp"; params ["_unit", "_causedBy", "_damage", "_instigator"]; [_unit, _causedBy, _instigator] spawn { @@ -9,8 +10,7 @@ params ["_unit", "_causedBy", "_damage", "_instigator"]; _unitID = _unit getVariable ["ocap_id", -1]; if (_unitID == -1) exitWith {}; - private _eventData = []; - // [ocap_captureFrameNo, "hit", _unitID, ["null"], -1]; + private _eventData = [ocap_captureFrameNo, "hit", _unitID, ["null"], -1]; if (!isNull _instigator) then { _causedById = _causedBy getVariable ["ocap_id", -1]; @@ -45,5 +45,6 @@ params ["_unit", "_causedBy", "_damage", "_instigator"]; ]; }; + 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 3fc488a..a162b36 100644 --- a/addons/@ocap/addons/ocap/functions/fn_eh_killed.sqf +++ b/addons/@ocap/addons/ocap/functions/fn_eh_killed.sqf @@ -1,3 +1,4 @@ +#include "script_macros.hpp"; params ["_victim", "_killer", "_instigator"]; if !(_victim getvariable ["ocapIsKilled",false]) then { _victim setvariable ["ocapIsKilled",true]; @@ -22,8 +23,7 @@ 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 = []; - // [ocap_captureFrameNo, "killed", _victimId, ["null"], -1]; + private _eventData = [ocap_captureFrameNo, "killed", _victimId, ["null"], -1]; if (!isNull _instigator) then { _killerId = _instigator getVariable ["ocap_id", -1]; @@ -31,23 +31,24 @@ if !(_victim getvariable ["ocapIsKilled",false]) then { private _killerInfo = []; if (_instigator isKindOf "CAManBase") then { - _causedByInfo = [ - _instigatorId, + _killerInfo = [ + _killerId, ([_instigator] call ocap_fnc_getEventWeaponText) ]; } else { - _causedByInfo = [_killerId]; + _killerInfo = [_killerId]; }; _eventData = [ ocap_captureFrameNo, "killed", _victimId, - _causedByInfo, + _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 index 509eba8..4f7378a 100644 --- a/addons/@ocap/addons/ocap/functions/fn_getEventWeaponText.sqf +++ b/addons/@ocap/addons/ocap/functions/fn_getEventWeaponText.sqf @@ -30,7 +30,7 @@ if (count _curMagDisplayName < 22) then { } else { if !(_curWepDisplayName isEqualTo "") then { _text = _text + " [" + _curWepDisplayName; - if (_curWep != _curMuzzle && !(_curMuzzleDisplayName isEqualTo "")) then { + if (_curWep != _curMuzzle && !(_curMuzzle isEqualTo "")) then { _text = _text + " / " + _curMuzzle + "]"; } else { _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