update/handle-land-mine-death

This commit is contained in:
SowinskiBraeden committed 2023-09-02 15:51:31 -07:00
1 parent a36d68d292
commit b5f5218016
3 files changed
+11 -6

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "dayzr-bot", "name": "dayzr-bot",
"version": "9.0.1", "version": "9.1.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": {
+1 -1
View File
@@ -142,7 +142,7 @@ class DayzRBot extends Client {
if (lines[i].includes("(id=Unknown") || lines[i].includes("Player \"Unknown Entity\"")) continue; if (lines[i].includes("(id=Unknown") || lines[i].includes("Player \"Unknown Entity\"")) continue;
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')) 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 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 (lines[i].includes('killed by Player') && !lines[i - 1].includes('hit by Player')) s = await HandleKillfeed(this, guildId, s, lines[i]);
} }
+9 -4
View File
@@ -13,14 +13,17 @@ module.exports = {
let template = /(.*) \| Player \"(.*)\" \(id=(.*) pos=<(.*)>\)\[HP\: (.*)\] hit by Player \"(.*)\" \(id=(.*) pos=<(.*)>\) into (.*) for (.*) damage \((.*)\) with (.*) from (.*) meters /g; let template = /(.*) \| Player \"(.*)\" \(id=(.*) pos=<(.*)>\)\[HP\: (.*)\] hit by Player \"(.*)\" \(id=(.*) pos=<(.*)>\) into (.*) for (.*) damage \((.*)\) with (.*) from (.*) meters /g;
let templateDEAD = /(.*) \| Player \"(.*)\" \(DEAD\) \(id=(.*) pos=<(.*)>\)\[HP\: (.*)\] hit by Player \"(.*)\" \(id=(.*) pos=<(.*)>\) into (.*) for (.*) damage \((.*)\) with (.*) from (.*) meters /g; let templateDEAD = /(.*) \| Player \"(.*)\" \(DEAD\) \(id=(.*) pos=<(.*)>\)\[HP\: (.*)\] hit by Player \"(.*)\" \(id=(.*) pos=<(.*)>\) into (.*) for (.*) damage \((.*)\) with (.*) from (.*) meters /g;
let explosionTemplate = /(.*) \| Player \"(.*)\" \(DEAD\) \(id=(.*) pos=<(.*)>\) killed by with (.*)/g; let explosionTemplate = /(.*) \| Player \"(.*)\" \(DEAD\) \(id=(.*) pos=<(.*)>\) killed by with (.*)/g;
let landMineTemplate = /(.8) \| Player \"(.*)\" \(DEAD\) \(id=(.*) pos=<(.*)>\) killed by LandMineTrap/g;
let killedBy = line.includes('hit by Player') && line.includes('(DEAD)') ? 1 : let killedBy = line.includes('hit by Player') && line.includes('(DEAD)') ? 1 :
line.includes('hit by Player') ? 2 : line.includes('hit by Player') ? 2 :
line.includes('killed by Player') ? 3 : 4; line.includes('killed by Player') ? 3 :
line.includes('killed by LandMineTrap') ? 4 : 5;
let data = killedBy == 1 ? [...line.matchAll(templateDEAD)][0] : let data = killedBy == 1 ? [...line.matchAll(templateDEAD)][0] :
killedBy == 2 ? [...line.matchAll(template)][0] : killedBy == 2 ? [...line.matchAll(template)][0] :
killedBy == 3 ? [...line.matchAll(templateKilled)][0] : killedBy == 3 ? [...line.matchAll(templateKilled)][0] :
killedBy == 4 ? [...line.matchAll(landMineTemplate)][0] :
[...line.matchAll(explosionTemplate)][0] [...line.matchAll(explosionTemplate)][0]
if (!data) return stats; if (!data) return stats;
@@ -49,15 +52,17 @@ 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 info.causeOfDeath = data[5]; } else if (killedBy == 5) info.causeOfDeath = data[5]; // use 'else if' because it will cause error if killedBy == 4 (LandMineTrap)
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 == 4) { if (killedBy == 4 || killedBy == 5) {
let cod = killedBy == 4 ? `Land Mine Trap` : info.causeOfDeath;
const killEvent = new EmbedBuilder() const killEvent = new EmbedBuilder()
.setColor(client.config.Colors.Default) .setColor(client.config.Colors.Default)
.setDescription(`**Death Event** - <t:${unixTime}>\n**${info.victim}** killed by a **${info.causeOfDeath}.\nLocation [${info.victimPOS[0]}, ${info.victimPOS[1]}](https://www.izurvive.com/chernarusplussatmap/#location=${info.victimPOS[0]};${info.victimPOS[1]})**`); .setDescription(`**Death Event** - <t:${unixTime}>\n**${info.victim}** killed by a **${cod}.\nLocation [${info.victimPOS[0]}, ${info.victimPOS[1]}](https://www.izurvive.com/chernarusplussatmap/#location=${info.victimPOS[0]};${info.victimPOS[1]})**`);
if (client.exists(channel)) await channel.send({ embeds: [killEvent] }); if (client.exists(channel)) await channel.send({ embeds: [killEvent] });
return stats; return stats;