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

Fix missing teamkill event on instakill #217

Closed
Closed
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
5 changes: 5 additions & 0 deletions squad-server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ export default class SquadServer extends EventEmitter {

this.logParser.on('PLAYER_DIED', async (data) => {
data.victim = await this.getPlayerByName(data.victimName);
data.attacker = await this.getPlayerByName(data.attackerName);

if (data.victim && data.attacker)
data.teamkill =
Expand All @@ -254,6 +255,10 @@ export default class SquadServer extends EventEmitter {
delete data.attackerName;

this.emit('PLAYER_DIED', data);

if (data.teamkill) {
this.emit('TEAMKILL', data);
Copy link
Collaborator

@Thomas-Smyth Thomas-Smyth Oct 31, 2021

Choose a reason for hiding this comment

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

Using the "TEAMKILL" event name is problematic because it also occurs when someone is wounded (iirc), thus this change could trigger somewhat duplicate events - not great considering people use this event within plugins that automatically ban players after x teamkill events.

Need to make changes to prevent that somehow.

Copy link
Author

@MatthiasKunnen MatthiasKunnen Oct 31, 2021

Choose a reason for hiding this comment

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

According to my testing, the following events exist:

  • PLAYER_DAMAGED: the player is hurt but not down
  • PLAYER_WOUNDED: the player is downed but revivable
  • PLAYER_DIED: the player cannot be revived and must respawn

PLAYER_WOUNDED and PLAYER_DIED are mutually exclusive and preceded by the PLAYER_DAMAGED event.

Currently, only PLAYER_WOUNDED causes a TEAMKILL event and PLAYER_DIED does not.

Examples

Multiple damage events leading to a TK, player is revivable

[2021.10.31-01.13.44:364][426]LogSquad: Player:Watson ActualDamage=26.040001 from Charlz caused by BP_M4_Classic_M68_C_2147477285
[2021.10.31-01.13.45:125][464]LogSquad: Player:Watson ActualDamage=62.000004 from Charlz caused by BP_M4_Classic_M68_C_2147477285
[2021.10.31-01.13.45:125][464]LogSquadTrace: [DedicatedServer]ASQSoldier::Wound(): Player:Watson KillingDamage=62.000004 from BP_PlayerController_C_2147478566 caused by BP_M4_Classic_M68_C_2147477285

TK victim dies

Caused by instakills such as large caliber and greyed-out kills

[2021.10.31-00.38.35:319][ 83]LogSquad: Player:Victim ActualDamage=900.000000 from Attacker caused by BP_BTR82A_RUS_2A72_AP_C_2147479210
[2021.10.31-00.38.35:319][ 83]LogSquadTrace: [DedicatedServer]ASQSoldier::Die(): Player:Victim KillingDamage=900.000000 from BP_PlayerController_C_2147481608 caused by BP_BTR82A_RUS_2A72_AP_C_2147479210

Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you mean PLAYER_WOUNDED and PLAYER_DIED are mutually exclusive? Looks like a typo?

Copy link
Author

Choose a reason for hiding this comment

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

Do you mean PLAYER_WOUNDED and PLAYER_DIED are mutually exclusive? Looks like a typo?

oops, yes, exactly

Copy link
Collaborator

@Thomas-Smyth Thomas-Smyth Oct 31, 2021

Choose a reason for hiding this comment

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

They're not mutually exclusive, both can be trigger of a player is wounded and then gives us (or bleeds out afaik).

Copy link
Author

@MatthiasKunnen MatthiasKunnen Oct 31, 2021

Choose a reason for hiding this comment

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

Just tested it and giving up/bleeding out triggers PLAYER_DIED indeed.

I believe we can fix this by checking whether the damage event has the same chainID as the PLAYER_DIED event. what do you think? If it is not the same, it's not an instakill.

Copy link
Collaborator

Choose a reason for hiding this comment

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

That's a possible solution, but not sure how much of a fan I am of the TEAMKILL event possibly being triggered at two different times when a player is wounded or killed. I think there need to be two separate events, e.g. WOUNDED_TEAMKILL and DIED_TEAMKILL, or just not use the events entirely and listen to the PLAYER_WOUNDED and PLAYER_DIED events and look at the teamkill flag in that.

}
});

this.logParser.on('PLAYER_REVIVED', async (data) => {
Expand Down