diff --git a/package.json b/package.json index 711a272..f4bbe39 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dayzr-bot", - "version": "9.3.0", + "version": "9.4.0", "description": "A General Purpose Discord Bot for DayZ Nitrado Servers.", "main": "index.js", "nodemonConfig": { diff --git a/structures/DayzRBot.js b/structures/DayzRBot.js index e7bdf13..7b393fb 100644 --- a/structures/DayzRBot.js +++ b/structures/DayzRBot.js @@ -142,8 +142,9 @@ class DayzRBot extends Client { if ((i - 1) >= 0 && lines[i] == lines[i-1]) continue; // continue if this line is a duplicate of the last line if (lines[i].includes('connected') || lines[i].includes('pos=<') || lines[1].includes('hit by Player')) s = await HandlePlayerLogs(this, guildId, s, lines[i]); if (lines[i].includes('killed by with') || lines[i].includes('killed by LandMineTrap')) s = await HandleKillfeed(this, guildId, s, lines[i]); // Handles explosive 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]); - if (lines[i].includes('killed by Player') && !lines[i - 1].includes('hit by Player')) s = await HandleKillfeed(this, guildId, s, lines[i]); + 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 } const playerTemplate = /(.*) \| Player \"(.*)\" \(id=(.*) pos=<(.*)>\)/g; diff --git a/util/KillfeedHandler.js b/util/KillfeedHandler.js index e3b128a..d3b209b 100644 --- a/util/KillfeedHandler.js +++ b/util/KillfeedHandler.js @@ -9,7 +9,8 @@ const Templates = { Explosion: 4, LandMine: 5, Melee: 6, -} + Vehicle: 7, +}; module.exports = { @@ -24,11 +25,13 @@ module.exports = { let explosionTemplate = /(.*) \| Player \"(.*)\" \(DEAD\) \(id=(.*) pos=<(.*)>\) killed by with (.*)/g; let landMineTemplate = /(.*) \| Player \"(.*)\" \(DEAD\) \(id=(.*) pos=<(.*)>\) killed by LandMineTrap/g; let meleeTemplate = /(.*) \| Player \"(.*)\" \(DEAD\) \(id=(.*) pos=<(.*)>\)\[HP\: (.*)\] hit by Player \"(.*)\" \(id=(.*) pos=<(.*)>\) into (.*) for (.*) damage \((.*)\) with (.*)/g; + let vehicleTemplate = /(.*) \| Player \"(.*)\" \(DEAD\) \(id=(.*) pos=<(.*)>\)\[HP\: (.*)\] hit by (.*) with TransportHit/g; let killedBy = line.includes('hit by Player') && line.includes('(DEAD)') ? Templates.HitByAndDead : line.includes('hit by Player') && !line.includes('meters') ? Templates.Melee : // Missing meters indicates it was a melee attack. line.includes('hit by Player') ? Templates.HitBy : line.includes('killed by Player') ? Templates.Killed : + line.includes('TransportHit') ? Templates.Vehicle : line.includes('killed by LandMineTrap') ? Templates.LandMine : Templates.Explosion; let data = killedBy == Templates.HitByAndDead ? [...line.matchAll(templateDEAD)][0] : @@ -36,6 +39,7 @@ module.exports = { killedBy == Templates.Killed ? [...line.matchAll(templateKilled)][0] : killedBy == Templates.LandMine ? [...line.matchAll(landMineTemplate)][0] : killedBy == Templates.Melee ? [...line.matchAll(meleeTemplate)][0] : + killedBy == Templates.Vehicle ? [...line.matchAll(vehicleTemplate)][0] : [...line.matchAll(explosionTemplate)][0]; if (!data) return stats; @@ -63,12 +67,15 @@ module.exports = { info.killerPOS = data[7].split(', ').map(v => parseFloat(v)); info.weapon = data[8]; info.distance = data[9]; - } else if (killedBy == Templates.Explosion) info.causeOfDeath = data[5]; // use 'else if' because it will cause error if killedBy == 4 (LandMineTrap) + } + else if (killedBy == Templates.Vehicle) info.causeOfDeath = data[6]; + else if (killedBy == Templates.Explosion) info.causeOfDeath = data[5]; + else return stats; // Unknown template; let newDt = await client.getDateEST(info.time); let unixTime = Math.floor(newDt.getTime()/1000); - if (killedBy == Templates.LandMine || killedBy == Templates.Explosion) { + if (killedBy == Templates.LandMine || killedBy == Templates.Explosion || killedBy == Templates.Vehicle) { let cod = killedBy == Templates.LandMine ? `Land Mine Trap` : info.causeOfDeath; const killEvent = new EmbedBuilder()