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

View file

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