aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--features/dungeonSolvers/index.js41
-rw-r--r--features/hud/HudTextElement.js13
-rw-r--r--features/settings/settingThings/location.js10
3 files changed, 57 insertions, 7 deletions
diff --git a/features/dungeonSolvers/index.js b/features/dungeonSolvers/index.js
index 781a324..4dc4a9b 100644
--- a/features/dungeonSolvers/index.js
+++ b/features/dungeonSolvers/index.js
@@ -2,6 +2,7 @@
/// <reference lib="es2015" />
import { f, m } from "../../../mappings/mappings";
import Feature from "../../featureClass/class";
+import { numberWithCommas } from "../../utils/numberUtils";
import * as renderUtils from "../../utils/renderUtils";
import HudTextElement from "../hud/HudTextElement";
import LocationSetting from "../settings/settingThings/location";
@@ -51,7 +52,28 @@ class DungeonSolvers extends Feature {
this.hudElements.push(this.spiritBowDestroyElement)
this.bloodCampAssist = new ToggleSetting("Assist blood camp", "Helps guess where and when blood mobs will spawn", true, "blood_camp_assist", this)
-
+
+ this.runSpeedRates = new ToggleSetting("Show run speed and exp rates", "(Run speed includes downtime inbetween runs, only shows while doing dungeon runs)", true, "run_speed_rates", this)
+ this.runSpeedRatesElement = new HudTextElement().setText("&eRun Speed: &floading...\n&eExp/hour: &floading...")
+ .setToggleSetting(this.runSpeedRates)
+ .setLocationSetting(new LocationSetting("Run speed and exp rates location", "Allows you to edit the location of the information", "run_speed_rates_location", this, [10, 100, 1, 1])
+ .requires(this.runSpeedRates)
+ .editTempText("&6Run speed&7> &f4:30\n&6Exp/hour&7> &f1,234,567\n&6Runs/hour&7> &f17"))
+
+ this.lastDungFinishes = []
+ this.lastDungExps = []
+ this.registerChat("&r&r&r &r&8+&r&3${exp} Catacombs Experience&r", (exp)=>{
+ this.lastDungExps.push(parseFloat(exp.replace(/,/gi, "")))
+ if(this.lastDungExps.length > 5){
+ this.lastDungExps.shift()
+ }
+
+ this.lastDungFinishes.push(Date.now())
+ if(this.lastDungFinishes.length > 5){
+ this.lastDungFinishes.shift()
+ }
+ })
+
this.spiritBowPickUps = []
this.registerChat("&r&aYou picked up the &r&5Spirit Bow&r&a! Use it to attack &r&cThorn&r&a!&r", ()=>{
this.spiritBowPickUps.push(Date.now())
@@ -201,6 +223,8 @@ class DungeonSolvers extends Feature {
for(let element of this.hudElements){
element.render()
}
+
+ this.runSpeedRatesElement.render()
}
onWorldLoad(){
@@ -336,6 +360,21 @@ class DungeonSolvers extends Feature {
this.checkingPing = true
}
}
+
+ let averageExp = this.lastDungExps.reduce((a, b) => a + b, 0) / this.lastDungExps.length
+ let averageLength = (this.lastDungFinishes[this.lastDungFinishes.length-1] - this.lastDungFinishes[0])/(this.lastDungFinishes.length-1)
+ let runsperHour = 60000*60/averageLength
+ let expPerHour = averageExp*runsperHour
+
+ if(Date.now()-this.lastDungFinishes[this.lastDungFinishes.length-1] < 60000*5 || (this.FeatureManager.features["dataLoader"].class.dungeonFloor)){
+ if(this.lastDungFinishes.length > 1){
+ this.runSpeedRatesElement.setText("&6Run speed&7> &f" + Math.floor(averageLength/60000) + ":" + ((Math.floor(averageLength/1000)%60<10?"0":"") + Math.floor(averageLength/1000)%60) + "\n&6Exp/hour&7> &f" + numberWithCommas(Math.round(expPerHour)) + "\n&6Runs/hour&7> &f" + Math.floor(runsperHour))
+ }else{
+ this.runSpeedRatesElement.setText("&6Run speed&7> &floading...\n&6Exp/hour&7> &floading...\n&6Runs/hour&7> &floading...")
+ }
+ }else{
+ this.runSpeedRatesElement.setText("")
+ }
}
initVariables(){
diff --git a/features/hud/HudTextElement.js b/features/hud/HudTextElement.js
index b56b350..5599b5c 100644
--- a/features/hud/HudTextElement.js
+++ b/features/hud/HudTextElement.js
@@ -16,7 +16,7 @@ class HudTextElement{
setText(text){
this.text = text
- if(this.locationSetting.shadowType === 2){
+ if(this.locationSetting && this.locationSetting.shadowType === 2){
this.blackText = "&0" + ChatLib.removeFormatting(text)
}
return this
@@ -28,6 +28,10 @@ class HudTextElement{
setLocationSetting(setting){
this.locationSetting = setting
setting.setParent(this)
+
+ if(this.locationSetting.shadowType === 2){
+ this.blackText = "&0" + ChatLib.removeFormatting(text)
+ }
return this
}
@@ -38,6 +42,13 @@ class HudTextElement{
this.renderRaw()
}
+ getWidth(){
+ return Math.max(...(this.getText()[0].map(a=>Renderer.getStringWidth(ChatLib.removeFormatting(a)))))
+ }
+ getHeight(){
+ return 9*this.getText()[0].length
+ }
+
getText(){
let text = this.text
let blackText = this.blackText
diff --git a/features/settings/settingThings/location.js b/features/settings/settingThings/location.js
index 69d1a43..9655764 100644
--- a/features/settings/settingThings/location.js
+++ b/features/settings/settingThings/location.js
@@ -166,7 +166,7 @@ class LocationSetting extends ButtonSetting {
clicked(mouseX, mouseY){
let width = this.getWidth()
- let height = 9*this.parent.getText()[0].length
+ let height = this.parent.getHeight()
let locations = [[this.x, this.y], [this.x+width*this.scale, this.y], [this.x, this.y+height*this.scale], [this.x+width*this.scale, this.y+height*this.scale]]
@@ -195,12 +195,12 @@ class LocationSetting extends ButtonSetting {
}
getWidth(){
- return Math.max(...(this.parent.getText()[0].map(a=>Renderer.getStringWidth(ChatLib.removeFormatting(a)))))
+ return this.parent.getWidth()
}
updateLocation(mouseX, mouseY, drawCollidingBox){
let width = this.getWidth()
- let height = 9*this.parent.getText()[0].length
+ let height = this.parent.getHeight()
if(this.dragging){
this.x = mouseX+this.dragOffset[0]
@@ -283,7 +283,7 @@ class LocationSetting extends ButtonSetting {
}
let width = this.getWidth()
- let height = 9*this.parent.getText()[0].length
+ let height = this.parent.getHeight()
this.updateLocation(mouseX, mouseY, true)
@@ -313,7 +313,7 @@ class LocationSetting extends ButtonSetting {
renderBox(drawHandles){
let width = this.getWidth()
- let height = 9*this.parent.getText()[0].length
+ let height = this.parent.getHeight()
Renderer.drawRect(Renderer.color(255, 255, 255), this.x, this.y, width*this.scale, 1)
Renderer.drawRect(Renderer.color(255, 255, 255), this.x, this.y, 1, height*this.scale)