enhance / debug combat log detection
This commit is contained in:
5 files changed
+11
-7
No files matched your search
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "dayz-armbands",
|
"name": "dayz-armbands",
|
||||||
"version": "6.3.14",
|
"version": "6.3.15",
|
||||||
"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": {
|
||||||
|
|||||||
@@ -345,6 +345,7 @@ class DayzArmbands extends Client {
|
|||||||
lastTime: null,
|
lastTime: null,
|
||||||
lastConnectionDate: null,
|
lastConnectionDate: null,
|
||||||
lastDamageDate: null,
|
lastDamageDate: null,
|
||||||
|
lastDeathDate: null,
|
||||||
lastHitBy: null,
|
lastHitBy: null,
|
||||||
connected: false,
|
connected: false,
|
||||||
bounties: [],
|
bounties: [],
|
||||||
|
|||||||
@@ -31,10 +31,11 @@ module.exports = {
|
|||||||
|
|
||||||
let newDt = await client.getDateEST(data.time);
|
let newDt = await client.getDateEST(data.time);
|
||||||
|
|
||||||
let diffMs = (newDt - data.lastDamageDate)
|
let diff = Math.round((newDt.getTime() - data.lastDamageDate.getTime()) / 1000 / 60); // diff minutes
|
||||||
let diffMins = Math.round(((diffMs % 86400000) % 3600000) / 60000); // 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);
|
let guild = await client.GetGuild(guildId);
|
||||||
if (!client.exists(guild.connectionLogsChannel)) return;
|
if (!client.exists(guild.connectionLogsChannel)) return;
|
||||||
|
|||||||
@@ -28,6 +28,9 @@ module.exports = {
|
|||||||
distance: data[12]
|
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
|
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;
|
||||||
@@ -49,6 +52,7 @@ module.exports = {
|
|||||||
killerStat.KDR = killerStat.kills / (killerStat.deaths == 0 ? 1 : killerStat.deaths); // prevent division by 0
|
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.KDR = victimStat.kills / (victimStat.deaths == 0 ? 1 : victimStat.deaths); // prevent division by 0
|
||||||
victimStat.killStreak = 0;
|
victimStat.killStreak = 0;
|
||||||
|
victimStat.lastDeathDate = newDt;
|
||||||
killerStat.deathStreak = 0;
|
killerStat.deathStreak = 0;
|
||||||
|
|
||||||
let receivedBounty = null;
|
let receivedBounty = null;
|
||||||
@@ -107,9 +111,6 @@ module.exports = {
|
|||||||
if (victimStatIndex == -1) stats.push(victimStat);
|
if (victimStatIndex == -1) stats.push(victimStat);
|
||||||
else stats[victimStatIndex] = victimStat;
|
else stats[victimStatIndex] = victimStat;
|
||||||
|
|
||||||
let newDt = await client.getDateEST(info.time);
|
|
||||||
let unixTime = Math.floor(newDt.getTime()/1000);
|
|
||||||
|
|
||||||
const killEvent = new EmbedBuilder()
|
const killEvent = new EmbedBuilder()
|
||||||
.setColor(client.config.Colors.Default)
|
.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}**`);
|
.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}**`);
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ module.exports = {
|
|||||||
player: info.player,
|
player: info.player,
|
||||||
lastDamageDate: playerStat.lastDamageDate,
|
lastDamageDate: playerStat.lastDamageDate,
|
||||||
lastHitBy: playerStat.lastHitBy,
|
lastHitBy: playerStat.lastHitBy,
|
||||||
|
lastDeathDate: playerStat.lastDeathDate,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user