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

Kill Tracker - Add setting to show kills from vehicle to crew #10069

Merged
merged 2 commits into from
Jun 17, 2024
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
43 changes: 26 additions & 17 deletions addons/killtracker/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ GVAR(killCount) = 0;
};
};
private _unitIsPlayer = hasInterface && {_unit in [player, ace_player]}; // isPlayer check will fail at this point
private _killerIsPlayer = (!isNull _instigator) && {_unit != _instigator} && {[_instigator] call EFUNC(common,isPlayer)};
TRACE_2("",_unitIsPlayer,_killerIsPlayer);
private _instigatorIsPlayer = (!isNull _instigator) && {_unit != _instigator} && {[_instigator] call EFUNC(common,isPlayer)};
TRACE_2("",_unitIsPlayer,_instigatorIsPlayer);

// Don't do anything if neither are players
if (!(_unitIsPlayer || _killerIsPlayer)) exitWith {};
if (!(_unitIsPlayer || _instigatorIsPlayer)) exitWith {};

// Log firendly fire
private _fnc_getSideFromConfig = {
Expand Down Expand Up @@ -110,23 +110,23 @@ GVAR(killCount) = 0;

// If unit was player then send event to self
if (_unitIsPlayer) then {
private _killerName = "Self?";
if ((!isNull _killer) && {_unit != _killer}) then {
if (_killerIsPlayer) then {
_killerName = [_killer, true, false] call EFUNC(common,getName);
private _instigatorName = "Self?";
if ((!isNull _instigator) && {_unit != _instigator}) then {
if (_instigatorIsPlayer) then {
_instigatorName = [_instigator, true, false] call EFUNC(common,getName);
} else {
_killerName = _killer getVariable [QGVAR(aiName), ""]; // allow setting a custom AI name (e.g. VIP Target)
if (_killerName == "") then {
_killerName = format ["*AI* - %1", getText ((configOf _killer) >> "displayName")];
_instigatorName = _instigator getVariable [QGVAR(aiName), ""]; // allow setting a custom AI name (e.g. VIP Target)
if (_instigatorName == "") then {
_instigatorName = format ["*AI* - %1", getText ((configOf _instigator) >> "displayName")];
};
};
};
TRACE_3("send death event",_unit,_killerName,_killInfo);
[QGVAR(death), [_killerName, _killInfo]] call CBA_fnc_localEvent;
TRACE_3("send death event",_unit,_instigatorName,_killInfo);
[QGVAR(death), [_instigatorName, _killInfo]] call CBA_fnc_localEvent;
};

// If killer was player then send event to killer
if (_killerIsPlayer) then {
// If shooter was player then send event to them (and optionally the whole crew)
if (_instigatorIsPlayer && {_unitIsPlayer || GVAR(trackAI)}) then {
private _unitName = "";
if (_unitIsPlayer) then {
_unitName = [_unit, true, false] call EFUNC(common,getName); // should be same as profileName
Expand All @@ -136,9 +136,18 @@ GVAR(killCount) = 0;
_unitName = format ["*AI* - %1", getText ((configOf _unit) >> "displayName")];
};
};
if (_unitIsPlayer || GVAR(trackAI)) then {
TRACE_3("send kill event",_killer,_unitName,_killInfo);
[QGVAR(kill), [_unitName, _killInfo], _killer] call CBA_fnc_targetEvent;
TRACE_3("send kill event",_instigator,_unitName,_killInfo);
[QGVAR(kill), [_unitName, _killInfo], _instigator] call CBA_fnc_targetEvent;

if (GVAR(showCrewKills) && {!(_killer isKindOf "CAManBase")}) then {
private _crew = [driver _killer, gunner _killer, commander _killer] - [_instigator];
johnb432 marked this conversation as resolved.
Show resolved Hide resolved
_crew = _crew select {[_x] call EFUNC(common,isPlayer)};
_crew = _crew arrayIntersect _crew;
TRACE_1("showCrewKills",_crew);
_killInfo = format [" - [<t color='#99ff99'>%1</t>, %2", localize "str_a3_rscdisplaygarage_tab_crew", _killInfo select [4]];
johnb432 marked this conversation as resolved.
Show resolved Hide resolved
{
[QGVAR(kill), [_unitName, _killInfo], _x] call CBA_fnc_targetEvent;
} forEach _crew;
};
};
}] call CBA_fnc_addEventHandler;
9 changes: 9 additions & 0 deletions addons/killtracker/initSettings.inc.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,12 @@
true,
1
] call CBA_fnc_addSetting;

[
QGVAR(showCrewKills),
"CHECKBOX",
[LSTRING(showCrewKills_DisplayName), LSTRING(showCrewKills_Description)],
LSTRING(Category),
false,
1
] call CBA_fnc_addSetting;
6 changes: 6 additions & 0 deletions addons/killtracker/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,11 @@
<German>Legt fest, ob getötete KIs während des Endbildschirms der Mission in den Abschüssen angezeigt werden.</German>
<Spanish>Define si las IAs matadas se mostrarán en el contador de muertes en el debiefring de la misión.</Spanish>
</Key>
<Key ID="STR_ACE_KillTracker_showCrewKills_DisplayName">
<English>Show vehicle kills to other crew members</English>
</Key>
<Key ID="STR_ACE_KillTracker_showCrewKills_Description">
<English>Show kills from a vehicle to driver, gunner and commander</English>
</Key>
</Package>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ if (isNull _unit || {!isNil {_unit getVariable QEGVAR(medical,causeOfDeath)}}) e
TRACE_4("enteredStateDeath",_this,_thisOrigin,_thisTransition,CBA_missionTime);

private _causeOfDeath = format ["%1:%2", _thisOrigin, _thisTransition];
private _source = _unit getVariable [QEGVAR(medical,lastDamageSource), objNull];
private _instigator = _unit getVariable [QEGVAR(medical,lastInstigator), objNull];

[_unit, _causeOfDeath, _instigator] call EFUNC(medical_status,setDead);
[_unit, _causeOfDeath, _source, _instigator] call EFUNC(medical_status,setDead);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change effects more than killtracker,
vanilla killed EH will also have correct killer/instigator now as well

I don't expect it to cause any problems, but it's something to remember

Loading