update/track deaths+killers per weapon
This commit is contained in:
5 files changed
+15
-3
No files matched your search
@@ -109,6 +109,8 @@ module.exports = {
|
||||
.setDescription(`${tag} stats for the **${weapon}**`)
|
||||
.setThumbnail(weapons[weaponClass][weapon])
|
||||
.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: `Times Shot`, value: `${player.weaponStats[weapon].timesShot}`, inline: true },
|
||||
);
|
||||
|
||||
@@ -61,6 +61,8 @@ module.exports = {
|
||||
shotsLandedPerBodyPart: copy(BodyParts),
|
||||
timesShotPerBodyPart: copy(BodyParts),
|
||||
weaponStats: createWeaponsObject({
|
||||
kills: 0,
|
||||
deaths: 0,
|
||||
shotsLanded: 0,
|
||||
timesShot: 0,
|
||||
shotsLandedPerBodyPart: copy(BodyParts),
|
||||
@@ -101,6 +103,8 @@ module.exports = {
|
||||
player.shotsLandedPerBodyPart = copy(BodyParts);
|
||||
player.timesShotPerBodyPart = copy(BodyParts);
|
||||
player.weaponStats = createWeaponsObject({
|
||||
kills: 0,
|
||||
deaths: 0,
|
||||
shotsLanded: 0,
|
||||
timesShot: 0,
|
||||
shotsLandedPerBodyPart: copy(BodyParts),
|
||||
@@ -112,6 +116,8 @@ module.exports = {
|
||||
// If a new weapon is not in the existing weaponStats, this will add it.
|
||||
createWeaponStats(player, weapon) {
|
||||
player.weaponStats[weapon] = {
|
||||
kills: 0,
|
||||
deaths: 0,
|
||||
shotsLanded: 0,
|
||||
timesShot: 0,
|
||||
shotsLandedPerBodyPart: copy(BodyParts),
|
||||
|
||||
+1
-1
@@ -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
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "dayzr-bot",
|
||||
"version": "12.5.3",
|
||||
"version": "12.5.4",
|
||||
"description": "A General Purpose Discord Bot for DayZ Nitrado Servers.",
|
||||
"main": "index.js",
|
||||
"nodemonConfig": {
|
||||
|
||||
@@ -184,6 +184,8 @@ module.exports = {
|
||||
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.deathStreak = 0;
|
||||
if (!client.exists(killerStat.weaponStats[weapon].kills)) killerStat.weaponStats[weapon].kills = 0;
|
||||
killerStat.weaponStats[weapon].kills++;
|
||||
|
||||
// Update victim stats
|
||||
victimStat.deaths++;
|
||||
@@ -192,6 +194,8 @@ module.exports = {
|
||||
victimStat.KDR = victimStat.kills / (victimStat.deaths == 0 ? 1 : victimStat.deaths); // prevent division by 0
|
||||
victimStat.killStreak = 0;
|
||||
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
|
||||
if (!client.exists(killerStat.combatRating)) killerStat.combatRating = 800;
|
||||
@@ -233,7 +237,7 @@ module.exports = {
|
||||
}
|
||||
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);
|
||||
if (!success) return client.sendInternalError(interaction, 'Failed to add bank');
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user