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",
|
||||
"version": "6.3.14",
|
||||
"version": "6.3.15",
|
||||
"description": "A General Purpose Discord Bot for DayZ Servers.",
|
||||
"main": "index.js",
|
||||
"nodemonConfig": {
|
||||
|
||||
@@ -345,6 +345,7 @@ class DayzArmbands extends Client {
|
||||
lastTime: null,
|
||||
lastConnectionDate: null,
|
||||
lastDamageDate: null,
|
||||
lastDeathDate: null,
|
||||
lastHitBy: null,
|
||||
connected: false,
|
||||
bounties: [],
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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,6 +52,7 @@ 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;
|
||||
@@ -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}**`);
|
||||
|
||||
@@ -79,6 +79,7 @@ module.exports = {
|
||||
player: info.player,
|
||||
lastDamageDate: playerStat.lastDamageDate,
|
||||
lastHitBy: playerStat.lastHitBy,
|
||||
lastDeathDate: playerStat.lastDeathDate,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user