enhance / debug combat log detection

This commit is contained in:
SowinskiBraeden committed 2023-04-15 21:42:42 -07:00
1 parent f9a4726825
commit 9d0e468142
5 files changed
+12 -8

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "dayz-armbands",
"version": "6.3.14",
"version": "6.3.15",
"description": "A General Purpose Discord Bot for DayZ Servers.",
"main": "index.js",
"nodemonConfig": {
+1
View File
@@ -345,6 +345,7 @@ class DayzArmbands extends Client {
lastTime: null,
lastConnectionDate: null,
lastDamageDate: null,
lastDeathDate: null,
lastHitBy: null,
connected: false,
bounties: [],
+4 -3
View File
@@ -31,10 +31,11 @@ module.exports = {
let newDt = await client.getDateEST(data.time);
let diffMs = (newDt - data.lastDamageDate)
let diffMins = Math.round(((diffMs % 86400000) % 3600000) / 60000); // minutes
let diff = Math.round((newDt.getTime() - data.lastDamageDate.getTime()) / 1000 / 60); // diff minutes
if (diffMins > 5) return;
// If diff is greater than 5 minutes, not a combat log
// or if death after last combat and death was before logout event
if (diffMins > 5 || (data.lastDamageDate < data.lastDeathDate && data.lastDeathDate < newDt)) return;
let guild = await client.GetGuild(guildId);
if (!client.exists(guild.connectionLogsChannel)) return;
+5 -4
View File
@@ -28,6 +28,9 @@ module.exports = {
distance: data[12]
};
let newDt = await client.getDateEST(info.time);
let unixTime = Math.floor(newDt.getTime()/1000);
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;
@@ -49,8 +52,9 @@ module.exports = {
killerStat.KDR = killerStat.kills / (killerStat.deaths == 0 ? 1 : killerStat.deaths); // prevent division by 0
victimStat.KDR = victimStat.kills / (victimStat.deaths == 0 ? 1 : victimStat.deaths); // prevent division by 0
victimStat.killStreak = 0;
victimStat.lastDeathDate = newDt;
killerStat.deathStreak = 0;
let receivedBounty = null;
if (victimStat.bounties.length > 0 && killerStat.discordID != "") {
let totalBounty = 0;
@@ -107,9 +111,6 @@ module.exports = {
if (victimStatIndex == -1) stats.push(victimStat);
else stats[victimStatIndex] = victimStat;
let newDt = await client.getDateEST(info.time);
let unixTime = Math.floor(newDt.getTime()/1000);
const killEvent = new EmbedBuilder()
.setColor(client.config.Colors.Default)
.setDescription(`**Kill Event** - <t:${unixTime}>\n**${info.killer}** killed **${info.victim}**\n> **__Kill Data__**\n> **Weapon:** \` ${info.weapon} \`\n> **Distance:** \` ${info.distance} \`\n> **Body Part:** \` ${info.bodyPart.split('(')[0]} \`\n> **Damage:** \` ${info.damage} \`\n **Killer\n${killerStat.KDR.toFixed(2)} K/D - ${killerStat.kills} Kills - Killstreak: ${killerStat.killStreak}\nVictim\n${victimStat.KDR.toFixed(2)} K/D - ${victimStat.deaths} Deaths - Deathstreak: ${victimStat.deathStreak}**`);
+1
View File
@@ -79,6 +79,7 @@ module.exports = {
player: info.player,
lastDamageDate: playerStat.lastDamageDate,
lastHitBy: playerStat.lastHitBy,
lastDeathDate: playerStat.lastDeathDate,
});
}