Guest User

XPTable proof

a guest
May 4th, 2010
355
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. This is the actual (obfuscated) code that calculates the level requirements in runescape:
  2. //int i1 = 0;
  3. //for (int i2 = 0; (i2 ^ 0xFFFFFFFF) > -121; ++i2)
  4. //{
  5. // int i3 = 1 + i2;
  6. // int i4 = (int)(i3 + Math.pow(2.0D, i3 / 7.0D) * 300.0D);
  7. // i1 += i4;
  8. // a[i2] = (i1 / 4);
  9. //}
  10. a[] is an array of integers with the size 99 so that contains the field containing the requirements.
  11. If you know how bitwise operators and doubles/integers work you can change it to this method without affecting the result:
  12. //int totalXPIndicator = 0;
  13. //for (int level = 0; level < 120; level++) {
  14. // totalXPIndicator += (int)(1 + level + Math.pow(2D, (1 + level) / 7D) * 300D);
  15. // levelXPArray[i2] = (totalXPIndicator / 4);
  16. //}
  17. Now to change it in an working method:
  18. public int xpTable(final int level) {
  19. int totalXPIndicator = 0;
  20. for (int level2 = 1; level2 < level; level2++) {
  21. totalXPIndicator += (int) (level2 + Math.pow(2D, level2 / 7D) * 300D);
  22. }
  23. return totalXPIndicator / 4;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment