Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

having issues calculating EXP per hour

Featured Replies

Currently using this equation with my logic being that 60 minutes / time elapsed * experienced gained will equate to the correct experience per hour and in my script i use this equation to represent that

    public void onStart() {
        startingStrengthEXP = getSkills().getExperience(Skill.STRENGTH);
        startTime = System.currentTimeMillis();
        }

int currentStrengthEXP = getSkills().getExperience(Skill.STRENGTH);
final long runTime = System.currentTimeMillis() - startTime;
(3600000 / runTime) * (currentStrengthEXP-startingStrengthEXP)

and this works up until about the first 15 minutes and i notice the math starts to go under and it becomes very obvious at 20 minutes were i was able to do the math in my head and know that it was 50% what the correct amount of experience per hour should be. Is there an issue with how I'm calculating the run time or is there a better way to calculate experience per hour? thanks :) the calculation code is in my onpaint() if that makes any difference. another thing after about 30 minutes it seems to just equal a 1:1 ratio where exp per hour is = to strength gained

Edited by vladbuff

  • Author

I've realized the error is with how java divides ints normally in that it throws away the quotient and rounds.

after changing my code to do the division without throwing away the quotient and it rounds the final number so the exp per hour doesn't have a decimal seems to be working for now.

    public void onStart() {
        startingStrengthEXP = getSkills().getExperience(Skill.STRENGTH);
        startTime = System.currentTimeMillis();
        }

int currentStrengthEXP = getSkills().getExperience(Skill.STRENGTH);
final long runTime = System.currentTimeMillis() - startTime;
double actualQuotient = (double)3600000 / runTime;
Math.round(actualQuotient) * (currentStrengthEXP-startingStrengthEXP)

 

Edited by vladbuff

2 hours ago, vladbuff said:

I've realized the error is with how java divides ints normally in that it throws away the quotient and rounds.

after changing my code to do the division without throwing away the quotient and it rounds the final number so the exp per hour doesn't have a decimal seems to be working for now.

    public void onStart() {
        startingStrengthEXP = getSkills().getExperience(Skill.STRENGTH);
        startTime = System.currentTimeMillis();
        }

int currentStrengthEXP = getSkills().getExperience(Skill.STRENGTH);
final long runTime = System.currentTimeMillis() - startTime;
double actualQuotient = (double)3600000 / runTime;
Math.round(actualQuotient) * (currentStrengthEXP-startingStrengthEXP)

 

This is the method I have on my Timer class

    public int getPerHour(int value) {
        return (int) (value * 3600000d / (System.currentTimeMillis() - start));
    }

About the same as you have, except for the fact I multiply first instead of diving so there are no rounding errors :)

  • Author
11 hours ago, Khaleesi said:

This is the method I have on my Timer class

    public int getPerHour(int value) {
        return (int) (value * 3600000d / (System.currentTimeMillis() - start));
    }

About the same as you have, except for the fact I multiply first instead of diving so there are no rounding errors :)

Really appreciate this as i was still getting rounding errors at 1hour+ with my new method currently testing yours right now !

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.