This commit is contained in:
night0721 2022-03-14 03:07:05 +08:00
parent cc672c163b
commit d5efd6a7cf
2 changed files with 58 additions and 71 deletions

View file

@ -11,7 +11,6 @@ let currGun,
recoilAvailable,
chart,
hasError;
const errMsg = "*Generic placeholder error message*";
module.exports = {
name: "stats",
description: "Check gun stats",
@ -59,7 +58,9 @@ module.exports = {
repEmb = statsHandler(args.join(" ").replace("\n", " "));
else repEmb = statsHandler(args.join(" + ").replace("\n", " "));
if (hasError) {
interaction.followUp({ content: `**${repEmb}**` });
interaction.followUp({
content: `**${repEmb || "An error has occured"}**`,
});
} else {
if (recoilAvailable) {
repEmb.fields.push({
@ -81,38 +82,38 @@ function inpHandler(inpmsg) {
function statsHandler(inpmsg) {
let statsNames = [
"Pellets",
"Detonation Range",
"Explosion Radius",
"Explosion Damage",
"Firing Mode",
"Rate of Fire",
"Bullet in Burst",
"Time Between Burst",
"Bullet Speed",
"Penetration Level",
"Bullet Spread",
"Idle Sway",
"Hipfire Pellet Spread",
"ADS Pellet Spread",
"ADS Time",
"Sprint-to-Fire Time",
"ADS Zoom",
"Magazine",
"Reserve",
"Reload Type",
"Cancel Reload Time",
"Reload Time",
"Full Reload Time",
"Drop Time",
"Raise Time",
"Sprinting Speed",
"Walking Speed",
"Straifing Speed",
"Damage per Tick",
"Number of Ticks",
"Time Between Ticks",
"Breath Hold Time",
"Pellets", //0
"Detonation Range", //1
"Explosion Radius", //2
"Explosion Damage", //3
"Firing Mode", //4
"Rate of Fire", //5
"Bullet in Burst", //6
"Time Between Burst", //7
"Bullet Speed", //8
"Penetration Level", //9
"Bullet Spread", //10
"Idle Sway", //11
"Hipfire Pellet Spread", //12
"ADS Pellet Spread", //13
"ADS Time", //14
"Sprint-to-Fire Time", //15
"ADS Zoom", //16
"Magazine", //17
"Reserve", //18
"Reload Type", //19
"Cancel Reload Time", //20
"Reload Time", //21
"Full Reload Time", //22
"Drop Time", //23
"Raise Time", //24
"Sprinting Speed", //25
"Walking Speed", //26
"Straifing Speed", //27
"Damage per Tick", //28
"Number of Ticks", //29
"Time Between Ticks", //30
"Breath Hold Time", //31
"shouldNeverHappen0",
"shouldNeverHappen1",
"shouldNeverHappen2",
@ -187,8 +188,8 @@ function statsHandler(inpmsg) {
inpIndx = inpIndx.filter(x => outReady[x]);
return inpIndx.length
? {
name: "**" + inpName + "**",
value: "```\n" + inpIndx.map(x => outReady[x]).join("\n") + "```",
name: `**${inpName}**`,
value: `\`\`\`\n${inpIndx.map(x => outReady[x]).join("\n")}\`\`\``,
}
: "";
}
@ -219,17 +220,17 @@ function statsHandler(inpmsg) {
function addUnit(j) {
switch (j) {
case 07:
case 7:
case 14:
case 15:
case 23:
case 24:
case 31:
return " ms";
case 27:
case 28:
case 25:
case 26:
case 27:
case 28:
return " m/s";
case 20:
case 21:
@ -237,9 +238,9 @@ function statsHandler(inpmsg) {
return " s";
case 16:
return "%";
case 06:
case 6:
return " Rounds";
case 05:
case 5:
return " RPM";
default:
return "";
@ -256,16 +257,11 @@ function statsHandler(inpmsg) {
currRecoilArr[2]
);
recoilAvailable = true;
} else {
recoilAvailable = false;
}
if (chart == "none") {
recoilAvailable = false;
}
if (chart == "err" || currAttachments == "err") {
hasError = true;
return "Cocaineeee";
}
} else recoilAvailable = false;
if (chart == "none") recoilAvailable = false;
if (chart == "err") hasError = true;
const dmg =
common.damageHandler(
currDRM.damage,
@ -281,7 +277,7 @@ function statsHandler(inpmsg) {
currGun.description
? {
name: "**Description:**",
value: "```\n" + currGun.description + "```",
value: `\`\`\`\n${currGun.description}\`\`\``,
}
: {},
{ name: "**Damage Profile:**", value: dmg },

View file

@ -458,22 +458,15 @@ function damageHandler(
}
function stk(dmg) {
let out;
if (!pellets) {
out = Math.ceil(hp / dmg);
} else {
out = Math.ceil(hp / (dmg * pellets));
}
out = out == Infinity ? "∞" : out;
return out;
if (!pellets) out = Math.ceil(hp / dmg);
else out = Math.ceil(hp / (dmg * pellets));
return out == Infinity ? "∞" : out;
}
function ttk(dmg) {
const stkVal = stk(dmg);
if (stkVal == "∞") {
return stkVal;
}
if (!bib) {
return Math.round((stkVal - 1) * tbs);
}
if (stkVal == "∞") return stkVal;
if (!bib) return Math.round((stkVal - 1) * tbs);
let out = 0;
if (dmg > 0) {
if (stkVal % bib == 0) {
@ -526,13 +519,11 @@ function recoilHandler(
yMultiplier,
bulletCount
) {
if (xRecoil.length != yRecoil.length) {
return "err";
}
if (xRecoil.length != yRecoil.length) return "err";
const recoilLength = xRecoil.length;
if (recoilLength == 0) {
return "none";
}
if (recoilLength == 0) return "none";
const recoilPattern = [
{
x: 0,