update/track deaths+killers per weapon

This commit is contained in:
SowinskiBraeden committed 2024-01-04 09:43:37 -08:00
1 parent 970abfac9f
commit 747cf04769
5 files changed
+15 -3

No files matched your search

+2
View File
@@ -109,6 +109,8 @@ module.exports = {
.setDescription(`${tag} stats for the **${weapon}**`) .setDescription(`${tag} stats for the **${weapon}**`)
.setThumbnail(weapons[weaponClass][weapon]) .setThumbnail(weapons[weaponClass][weapon])
.addFields( .addFields(
{ name: `Kills`, value: `${player.weaponStats[weapon].kills}`, inline: true },
{ name: `Deaths`, value: `${player.weaponStats[weapon].deaths}`, inline: true },
{ name: `Shots Landed`, value: `${player.weaponStats[weapon].shotsLanded}`, inline: true }, { name: `Shots Landed`, value: `${player.weaponStats[weapon].shotsLanded}`, inline: true },
{ name: `Times Shot`, value: `${player.weaponStats[weapon].timesShot}`, inline: true }, { name: `Times Shot`, value: `${player.weaponStats[weapon].timesShot}`, inline: true },
); );
+6
View File
@@ -61,6 +61,8 @@ module.exports = {
shotsLandedPerBodyPart: copy(BodyParts), shotsLandedPerBodyPart: copy(BodyParts),
timesShotPerBodyPart: copy(BodyParts), timesShotPerBodyPart: copy(BodyParts),
weaponStats: createWeaponsObject({ weaponStats: createWeaponsObject({
kills: 0,
deaths: 0,
shotsLanded: 0, shotsLanded: 0,
timesShot: 0, timesShot: 0,
shotsLandedPerBodyPart: copy(BodyParts), shotsLandedPerBodyPart: copy(BodyParts),
@@ -101,6 +103,8 @@ module.exports = {
player.shotsLandedPerBodyPart = copy(BodyParts); player.shotsLandedPerBodyPart = copy(BodyParts);
player.timesShotPerBodyPart = copy(BodyParts); player.timesShotPerBodyPart = copy(BodyParts);
player.weaponStats = createWeaponsObject({ player.weaponStats = createWeaponsObject({
kills: 0,
deaths: 0,
shotsLanded: 0, shotsLanded: 0,
timesShot: 0, timesShot: 0,
shotsLandedPerBodyPart: copy(BodyParts), shotsLandedPerBodyPart: copy(BodyParts),
@@ -112,6 +116,8 @@ module.exports = {
// If a new weapon is not in the existing weaponStats, this will add it. // If a new weapon is not in the existing weaponStats, this will add it.
createWeaponStats(player, weapon) { createWeaponStats(player, weapon) {
player.weaponStats[weapon] = { player.weaponStats[weapon] = {
kills: 0,
deaths: 0,
shotsLanded: 0, shotsLanded: 0,
timesShot: 0, timesShot: 0,
shotsLandedPerBodyPart: copy(BodyParts), shotsLandedPerBodyPart: copy(BodyParts),
+1 -1
View File
@@ -70,5 +70,5 @@ module.exports = {
}, },
}, },
weaponClassOf: (weapon) => Object.keys(module.exports.weapons).filter(v => module.exports.weapons[v].hasOwnProperty(weapon))[0], weaponClassOf: (weapon) => Object.keys(module.exports.weapons).filter(c => weapon in module.exports.weapons[c])[0],
} }
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "dayzr-bot", "name": "dayzr-bot",
"version": "12.5.3", "version": "12.5.4",
"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": {
+5 -1
View File
@@ -184,6 +184,8 @@ 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
killerStat.longestKill = info.distance > killerStat.longestKill ? info.distance : killerStat.longestKill; killerStat.longestKill = info.distance > killerStat.longestKill ? info.distance : killerStat.longestKill;
killerStat.deathStreak = 0; killerStat.deathStreak = 0;
if (!client.exists(killerStat.weaponStats[weapon].kills)) killerStat.weaponStats[weapon].kills = 0;
killerStat.weaponStats[weapon].kills++;
// Update victim stats // Update victim stats
victimStat.deaths++; victimStat.deaths++;
@@ -192,6 +194,8 @@ module.exports = {
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; victimStat.lastDeathDate = newDt;
if (!client.exists(victimStat.weaponStats[weapon].deaths)) victimStat.weaponStats[weapon].death = 0;
victimStat.weaponStats[weapon].deaths++;
// Create defaults for non-existing ratings // Create defaults for non-existing ratings
if (!client.exists(killerStat.combatRating)) killerStat.combatRating = 800; if (!client.exists(killerStat.combatRating)) killerStat.combatRating = 800;
@@ -233,7 +237,7 @@ module.exports = {
} }
banking = banking.user; banking = banking.user;
if (!client.exists(banking.guilds[ guild.serverID])) { if (!client.exists(banking.guilds[guild.serverID])) {
const success = addUser(banking.guilds, guild.serverID, interaction.member.user.id, client, guild.startingBalance); const success = addUser(banking.guilds, guild.serverID, interaction.member.user.id, client, guild.startingBalance);
if (!success) return client.sendInternalError(interaction, 'Failed to add bank'); if (!success) return client.sendInternalError(interaction, 'Failed to add bank');
} }