update/filter out false positives in combat log detection

This commit is contained in:
SowinskiBraeden committed 2023-10-08 09:48:57 -07:00
1 parent ece6c267ea
commit 58487a1505
4 files changed
+39 -4

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "dayzr-bot",
"version": "10.3.5",
"version": "10.3.6",
"description": "A General Purpose Discord Bot for DayZ Nitrado Servers.",
"main": "index.js",
"nodemonConfig": {
+2 -1
View File
@@ -8,7 +8,7 @@ const mongoose = require('mongoose');
// custom util imports
const { DownloadNitradoFile, CheckServerStatus } = require('../util/NitradoAPI');
const { HandlePlayerLogs, HandleActivePlayersList } = require('../util/LogsHandler');
const { HandleKillfeed } = require('../util/KillfeedHandler');
const { HandleKillfeed, UpdateLastDeathDate } = require('../util/KillfeedHandler');
const { HandleExpiredUAVs, HandleEvents } = require('../util/AlarmsHandler');
const path = require("path");
@@ -155,6 +155,7 @@ class DayzRBot extends Client {
if (!(i + 1 >= lines.length) && lines[i + 1].includes('killed by') && lines[i].includes('TransportHit')) s = await HandleKillfeed(this, guildId, s, lines[i]) // Handles vehicle deaths
if (!(i + 1 >= lines.length) && lines[i + 1].includes('killed by Player') && lines[i].includes('hit by Player')) s = await HandleKillfeed(this, guildId, s, lines[i]); // Handles regular deaths
if (lines[i].includes('killed by Player') && !lines[i - 1].includes('hit by Player')) s = await HandleKillfeed(this, guildId, s, lines[i]); // Handles deaths missing hit by log
if (lines[i].includes('killed by Zmb') || lines[i].includes('>) died.')) s = await UpdateLastDeathDate(this, s, lines[i]); // Updates users last death date for non PVP deaths.
}
for (const [channel_id, data] of Object.entries(this.alarmPingQueue)) {
+2 -2
View File
@@ -41,8 +41,8 @@ module.exports = {
if (diffSeconds > (data.combatLogTimer * 60)) return;
if (data.lastDamageDate <= data.lastDeathDate) return;
// If lastHitBy (attacker) died to this player or another,
// then it does not count as combat logging, (the combat ended)
// If lastHitBy (attacker) died after shooting this player
// then it does not count as combat logging, (the combat ended due to death)
let attacker = guild.playerstats.find(stat => stat.gamertag = data.lastHitBy);
if (attacker.lastDeathDate > data.lastDamageDate) return;
+34
View File
@@ -40,6 +40,33 @@ const Vehicles = {
module.exports = {
// Update last death date for non PVP deaths
UpdateLastDeathDate: async (client, stats, line) => {
let killedByZmb = /(.*) \| Player \"(.*)\" \(DEAD\) \(id=(.*) pos=<(.*)>) killed by (.*)/g;
let diedTemplate = /(.*) \| Player \"(.*)\" \(DEAD\) \(id=(.*) pos=<(.*)>) died. Stats> Water: (.*) Energy: (.*) Bleed sources: (.*)/g;
let data = line.includes('>) died.') ? [...line.matchAll(diedTemplate)][0] : [...line.matchAll(killedByZmb)][0];
if (!data) return stats;
let info = {
time: data[1],
victim: data[2],
victimID: data[3],
victimPOS: data[4].split(', ').map(v => parseFloat(v)),
};
const newDt = await client.getDateEST(info.time);
let victimStat = stats.find(stat => stat.playerID == info.victimID);
let victimStatIndex = stats.indexOf(victimStat);
if (victimStat == undefined) victimStat = client.getDefaultPlayerStats(info.victim, info.victimID);
victimStat.lastDeathDate = newDt;
if (victimStatIndex == -1) stats.push(victimStat);
else stats[victimStatIndex] = victimStat;
return stats;
},
HandleKillfeed: async (client, guildId, stats, line) => {
let guild = await client.GetGuild(guildId);
@@ -117,6 +144,13 @@ module.exports = {
const destination = lastDist > 500 ? `${destination_dir} of ${tempDest}` : `Near ${tempDest}`;
if (killedBy == Templates.LandMine || killedBy == Templates.Explosion || killedBy == Templates.Vehicle) {
let victimStat = stats.find(stat => stat.playerID == info.victimID)
let victimStatIndex = stats.indexOf(victimStat);
if (victimStat == undefined) victimStat = client.getDefaultPlayerStats(info.victim, info.victimID);
victimStat.lastDeathDate = newDt;
if (victimStatIndex == -1) stats.push(victimStat);
else stats[victimStatIndex] = victimStat;
const cod = killedBy == Templates.LandMine ? `Land Mine Trap` :
killedBy == Templates.Vehicle ? Vehicles[info.causeOfDeath] : info.causeOfDeath;
const coord = showCoords ? `\n***Location [${info.victimPOS[0]}, ${info.victimPOS[1]}](https://www.izurvive.com/chernarusplussatmap/#location=${info.victimPOS[0]};${info.victimPOS[1]})***\n${destination}` : '';