track explosive deaths, minor debug
This commit is contained in:
4 files changed
+43
-21
No files matched your search
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "dayz-armbands",
|
"name": "dayz-armbands",
|
||||||
"version": "6.6.7",
|
"version": "6.7.1",
|
||||||
"description": "A General Purpose Discord Bot for DayZ Servers.",
|
"description": "A General Purpose Discord Bot for DayZ Servers.",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"nodemonConfig": {
|
"nodemonConfig": {
|
||||||
|
|||||||
@@ -140,7 +140,8 @@ class DayzArmbands extends Client {
|
|||||||
|
|
||||||
for (let i = logIndex + 1; i < lines.length; i++) {
|
for (let i = logIndex + 1; i < lines.length; i++) {
|
||||||
if (lines[i].includes("Unknown")) continue;
|
if (lines[i].includes("Unknown")) continue;
|
||||||
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('hit by explosion') && lines[i].includes('(DEAD)')) s = await HandleKillfeed(this, guildId, s, lines[i]);
|
||||||
if (!(i + 1 >= lines.length) && lines[i + 1].includes('killed by Player')) s = await HandleKillfeed(this, guildId, s, lines[i]);
|
if (!(i + 1 >= lines.length) && lines[i + 1].includes('killed by Player')) s = await HandleKillfeed(this, guildId, s, lines[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+31
-13
@@ -9,28 +9,46 @@ module.exports = {
|
|||||||
let guild = await client.GetGuild(guildId);
|
let guild = await client.GetGuild(guildId);
|
||||||
const channel = client.channels.cache.get(guild.killfeedChannel);
|
const channel = client.channels.cache.get(guild.killfeedChannel);
|
||||||
|
|
||||||
let template = /(.*) \| Player \"(.*)\" \(DEAD\) \(id=(.*) pos=<(.*)>\)\[HP\: 0\] hit by Player \"(.*)\" \(id=(.*) pos=<(.*)>\) into (.*) for (.*) damage \((.*)\) with (.*) from (.*) meters /g;
|
let template = /(.*) \| Player \"(.*)\" \(DEAD\) \(id=(.*) pos=<(.*)>\)\[HP\: 0\] hit by Player \"(.*)\" \(id=(.*) pos=<(.*)>\) into (.*) for (.*) damage \((.*)\) with (.*) from (.*) meters /g;
|
||||||
let data = [...line.matchAll(template)][0];
|
let explosionTemplate = /(.*) \| Player \"(.*)\" \(DEAD\) \(id=(.*) pos=<(.*)>\)\[HP\: 0] hit by explosion \((.*)\)/g;
|
||||||
|
|
||||||
|
let killedByPlayer = line.includes('hit by Player') ? true : false;
|
||||||
|
|
||||||
|
let data = killedByPlayer ? [...line.matchAll(template)][0] : [...line.matchAll(explosionTemplate)];
|
||||||
if (!data) return stats;
|
if (!data) return stats;
|
||||||
|
|
||||||
|
// Create base data
|
||||||
let info = {
|
let info = {
|
||||||
time: data[1],
|
time: data[1],
|
||||||
victim: data[2],
|
victim: data[2],
|
||||||
victimID: data[3],
|
victimID: data[3],
|
||||||
victimPOS: data[4],
|
victimPOS: data[4],
|
||||||
killer: data[5],
|
|
||||||
killerID: data[6],
|
|
||||||
killerPOS: data[7],
|
|
||||||
bodyPart: data[8],
|
|
||||||
damage: data[9],
|
|
||||||
bullet: data[10],
|
|
||||||
weapon: data[11],
|
|
||||||
distance: data[12]
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Add additional data
|
||||||
|
if (killedByPlayer) {
|
||||||
|
info.killer = data[5];
|
||||||
|
info.killerID = data[6];
|
||||||
|
info.killerPOS = data[7];
|
||||||
|
info.bodyPart = data[8];
|
||||||
|
info.damage = data[9];
|
||||||
|
info.bullet = data[10];
|
||||||
|
info.weapon = data[11];
|
||||||
|
info.distance = data[12];
|
||||||
|
} else info.explosive = data[5];
|
||||||
|
|
||||||
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 (!killedByPlayer) {
|
||||||
|
const killEvent = new EmbedBuilder()
|
||||||
|
.setColor(client.config.Colors.Default)
|
||||||
|
.setDescription(`**Death Event** - <t:${unixTime}>\n**${info.victim}** blew up from a **${info.explosive}.**>`);
|
||||||
|
|
||||||
|
if (client.exists(channel)) await channel.send({ embeds: [killEvent] });
|
||||||
|
return stats;
|
||||||
|
}
|
||||||
|
|
||||||
KillInAlarm(client, guildId, info); // check if kill happened in a no kill zone
|
KillInAlarm(client, guildId, info); // check if kill happened in a no kill zone
|
||||||
|
|
||||||
if (!client.exists(info.victim) || !client.exists(info.victimID) || !client.exists(info.killer) || !client.exists(info.killerID)) return stats;
|
if (!client.exists(info.victim) || !client.exists(info.victimID) || !client.exists(info.killer) || !client.exists(info.killerID)) return stats;
|
||||||
|
|||||||
+9
-6
@@ -6,11 +6,11 @@ module.exports = {
|
|||||||
|
|
||||||
HandlePlayerLogs: async (client, guildId, stats, line) => {
|
HandlePlayerLogs: async (client, guildId, stats, line) => {
|
||||||
|
|
||||||
const connectTemplate = /(.*) \| Player \"(.*)\" is connected \(id=(.*)\)/g;
|
const connectTemplate = /(.*) \| Player \"(.*)\" is connected \(id=(.*)\)/g;
|
||||||
const disconnectTemplate = /(.*) \| Player \"(.*)\"\(id=(.*)\) has been disconnected/g;
|
const disconnectTemplate = /(.*) \| Player \"(.*)\"\(id=(.*)\) has been disconnected/g;
|
||||||
const positionTemplate = /(.*) \| Player \"(.*)\" \(id=(.*) pos=<(.*)>\)/g;
|
const positionTemplate = /(.*) \| Player \"(.*)\" \(id=(.*) pos=<(.*)>\)/g;
|
||||||
const damageTemplate = /(.*) \| Player \"(.*)\" \(id=(.*) pos=<(.*)>\)\[HP\: (.*)\] hit by Player \"(.*)\" \(id=(.*) pos=<(.*)>\) into (.*) for (.*) damage \((.*)\) with (.*) from (.*) meters /g;
|
const damageTemplate = /(.*) \| Player \"(.*)\" \(id=(.*) pos=<(.*)>\)\[HP\: (.*)\] hit by Player \"(.*)\" \(id=(.*) pos=<(.*)>\) into (.*) for (.*) damage \((.*)\) with (.*) from (.*) meters /g;
|
||||||
const deadTemplate = /(.*) \| Player \"(.*)\" \(DEAD\) \(id=(.*) pos=<(.*)>\)\[HP\: (.*)\] hit by Player \"(.*)\" \(id=(.*) pos=<(.*)>\) into (.*) for (.*) damage \((.*)\) with (.*) from (.*) meters /g;
|
const deadTemplate = /(.*) \| Player \"(.*)\" \(DEAD\) \(id=(.*) pos=<(.*)>\)\[HP\: 0] hit by Player \"(.*)\" \(id=(.*) pos=<(.*)>\) into (.*) for (.*) damage \((.*)\) with (.*) from (.*) meters /g;
|
||||||
|
|
||||||
if (line.includes(' connected')) {
|
if (line.includes(' connected')) {
|
||||||
let data = [...line.matchAll(connectTemplate)][0];
|
let data = [...line.matchAll(connectTemplate)][0];
|
||||||
@@ -98,6 +98,11 @@ module.exports = {
|
|||||||
playerStat.lastTime = playerStat.time;
|
playerStat.lastTime = playerStat.time;
|
||||||
playerStat.time = `${info.time} EST`;
|
playerStat.time = `${info.time} EST`;
|
||||||
|
|
||||||
|
if (playerStatIndex == -1) stats.push(playerStat);
|
||||||
|
else stats[playerStatIndex] = playerStat;
|
||||||
|
|
||||||
|
if (line.includes('hit by') || line.includes('killed by')) return; // prevent additional information from being fed to Alarms & UAVs
|
||||||
|
|
||||||
HandleAlarmsAndUAVs(client, guildId, {
|
HandleAlarmsAndUAVs(client, guildId, {
|
||||||
time: info.time,
|
time: info.time,
|
||||||
player: info.player,
|
player: info.player,
|
||||||
@@ -105,8 +110,6 @@ module.exports = {
|
|||||||
pos: info.pos,
|
pos: info.pos,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (playerStatIndex == -1) stats.push(playerStat);
|
|
||||||
else stats[playerStatIndex] = playerStat;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (line.includes('hit by Player')) {
|
if (line.includes('hit by Player')) {
|
||||||
|
|||||||
Reference in new issue
Block a user