update/track vehicle deaths
This commit is contained in:
3 files changed
+14
-6
No files matched your search
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "dayzr-bot",
|
"name": "dayzr-bot",
|
||||||
"version": "9.3.0",
|
"version": "9.4.0",
|
||||||
"description": "A General Purpose Discord Bot for DayZ Nitrado Servers.",
|
"description": "A General Purpose Discord Bot for DayZ Nitrado Servers.",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"nodemonConfig": {
|
"nodemonConfig": {
|
||||||
|
|||||||
@@ -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 ((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('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 (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 (!(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 (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 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;
|
const playerTemplate = /(.*) \| Player \"(.*)\" \(id=(.*) pos=<(.*)>\)/g;
|
||||||
|
|||||||
+10
-3
@@ -9,7 +9,8 @@ const Templates = {
|
|||||||
Explosion: 4,
|
Explosion: 4,
|
||||||
LandMine: 5,
|
LandMine: 5,
|
||||||
Melee: 6,
|
Melee: 6,
|
||||||
}
|
Vehicle: 7,
|
||||||
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
||||||
@@ -24,11 +25,13 @@ module.exports = {
|
|||||||
let explosionTemplate = /(.*) \| Player \"(.*)\" \(DEAD\) \(id=(.*) pos=<(.*)>\) killed by with (.*)/g;
|
let explosionTemplate = /(.*) \| Player \"(.*)\" \(DEAD\) \(id=(.*) pos=<(.*)>\) killed by with (.*)/g;
|
||||||
let landMineTemplate = /(.*) \| Player \"(.*)\" \(DEAD\) \(id=(.*) pos=<(.*)>\) killed by LandMineTrap/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 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 :
|
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') && !line.includes('meters') ? Templates.Melee : // Missing meters indicates it was a melee attack.
|
||||||
line.includes('hit by Player') ? Templates.HitBy :
|
line.includes('hit by Player') ? Templates.HitBy :
|
||||||
line.includes('killed by Player') ? Templates.Killed :
|
line.includes('killed by Player') ? Templates.Killed :
|
||||||
|
line.includes('TransportHit') ? Templates.Vehicle :
|
||||||
line.includes('killed by LandMineTrap') ? Templates.LandMine : Templates.Explosion;
|
line.includes('killed by LandMineTrap') ? Templates.LandMine : Templates.Explosion;
|
||||||
|
|
||||||
let data = killedBy == Templates.HitByAndDead ? [...line.matchAll(templateDEAD)][0] :
|
let data = killedBy == Templates.HitByAndDead ? [...line.matchAll(templateDEAD)][0] :
|
||||||
@@ -36,6 +39,7 @@ module.exports = {
|
|||||||
killedBy == Templates.Killed ? [...line.matchAll(templateKilled)][0] :
|
killedBy == Templates.Killed ? [...line.matchAll(templateKilled)][0] :
|
||||||
killedBy == Templates.LandMine ? [...line.matchAll(landMineTemplate)][0] :
|
killedBy == Templates.LandMine ? [...line.matchAll(landMineTemplate)][0] :
|
||||||
killedBy == Templates.Melee ? [...line.matchAll(meleeTemplate)][0] :
|
killedBy == Templates.Melee ? [...line.matchAll(meleeTemplate)][0] :
|
||||||
|
killedBy == Templates.Vehicle ? [...line.matchAll(vehicleTemplate)][0] :
|
||||||
[...line.matchAll(explosionTemplate)][0];
|
[...line.matchAll(explosionTemplate)][0];
|
||||||
|
|
||||||
if (!data) return stats;
|
if (!data) return stats;
|
||||||
@@ -63,12 +67,15 @@ module.exports = {
|
|||||||
info.killerPOS = data[7].split(', ').map(v => parseFloat(v));
|
info.killerPOS = data[7].split(', ').map(v => parseFloat(v));
|
||||||
info.weapon = data[8];
|
info.weapon = data[8];
|
||||||
info.distance = data[9];
|
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 newDt = await client.getDateEST(info.time);
|
||||||
let unixTime = Math.floor(newDt.getTime()/1000);
|
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;
|
let cod = killedBy == Templates.LandMine ? `Land Mine Trap` : info.causeOfDeath;
|
||||||
|
|
||||||
const killEvent = new EmbedBuilder()
|
const killEvent = new EmbedBuilder()
|
||||||
|
|||||||
Reference in new issue
Block a user