NOTE: There will be a lot of formulas and mathematics in this post. All computer code examples will be written in Java, as complete functions that can be used in any program. All formulas have been compiled and tested with the latest version of Java.

Let's start with...

~~ The Combat Formula ~~

Source: http://forum.runesca...23,466,33330028

| History of the Formula |

````````````````````````````````````

- In RuneScape Classic

Back in the RSC days, the game used a different combat formula than the one RS2 uses. A couple of smart people started working on finding out the secret. Jagex didn't release the formula, so they had to guess and make spreadsheets to get an idea of the accuracy. The accuracy would allow them to see how close they were and if changes would be actual improvements. They managed to find the exact formula and in the end (just before RS2 came), nearly every fansite used it.

- In RuneScape 2

When RS2 was released, Jagex told everyone there had been a change in the combat formula. Again, the original combat formula people set out on a quest to find the new formula. Unfortunately, this was a lot harder, firstly, because there was a lot more competition. Well established fansites all wanted to find out the formula on their own. Secondly, the formula itself was complex, as RuneScape 2 introduced a new combat class (Mage).

Shortly after, many people who were involved in finding the new formula gave up due to lack of interest by the community. This included the original group of people who found the RSC formula. This was the time when MaxWaterman stood up and decided to finish that quest of finding the combat formula. He gathered the available investigation data that others had left behind, and he started improving the existing version. He created a thread here on the RuneScape forum to gather data from players. Some intelligent players wanted to help the project, and so, The Combat Formula Crew was born. We kept improving the formula until it reached near-perfect accuracy ratings.

- Today

Today, our formula is used on most well known fansites. It is now displayed in this sticky thread, and recognised as an integral part of RuneScape's community. We continue to gather data and help players with calculating. The project is as old as RuneScape 2 is.

RuneScape classic's original combat formula was the following:

public static double combatFormulaRSC(int attack, int strength, int defence, int hitpoints, int prayer, int ranged, int magic) { double combatLevel = ((defence + hitpoints) * 0.25) + ((magic + prayer) * 0.125); double warrior = (attack + strength) * 0.25; double ranger = ranged * 0.375; return combatLevel + (((ranged * 1.5) > (attack + strength)) ? ranger : warrior); }

After RS2 it was changed to the following; this is the current,

**100% accurate**formula with summoning included, used today for calculating combat levels. Entering 0 or 1 in the summoning parameter will cause the formula to calculate your F2P combat level.

public static double combatFormula(int attack, int strength, int defence, int hitpoints, int prayer, int ranged, int magic, int summoning) { double combatLevel = (defence + hitpoints + Math.floor(prayer / 2) + Math.floor(summoning / 2)) * 0.25; double warrior = (attack + strength) * 0.325; double ranger = ranged * 0.4875; double mage = magic * 0.4875; return combatLevel + Math.max(warrior, Math.max(ranger, mage)); }

Even before the release of summoning, when Tip.It claimed to have a 100% accurate formula, it still failed at times during ranged and magic combat level calculations. Until recently after the release of summoning, no one had entertained the notion that odd prayer/summoning levels were not counted. I'd like to thank Maxwaterman for his incredible efforts on providing the RuneScape community with the real, 100% accurate combat level formula. This formula is used by our very own Tip.It (you'll see Maxwaterman in the credits), and RuneHQ, another major fansite. It is also used on my fansite, the RuneScape Wikia, and possibly and probably others.

The next formula I will introduce is for calculating how many levels in a particular skill you need for the next combat level:

public static int levelsToNextCombat(int attack, int strength, int defence, int hitpoints, int prayer, int ranged, int magic, int summoning, CombatSkills skill) { double currentCombat = Math.floor(combatFormula(attack, strength, defence, hitpoints, prayer, ranged, magic, summoning)); // Array of number of skills to next level int[] next_level = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; // 1 to 8, since there's 8 combat skills for (int j = 1; j <= 8; j++) { // Efficiency <img src='http://forum.tip.it/ipbnew/public/style_emoticons/<#EMO_DIR#>/smile.gif' class='bbc_emoticon' alt=':)' /> if (j != (skill.ordinal() + 1)) { continue; } // Which skill are we working with? int[] add = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; // There's 8 prayer or summoning levels to a combat level, BUT note that magic or range can get very high so we'll check all the way to 99 for (int i = 1; i <= MAX_LEVEL; i++) { // Increment the current skill we're adding to, by 1 add[j - 1] = i; double cb = combatFormula(attack + add[0], strength + add[1], defence + add[2], hitpoints + add[3], prayer + add[4], ranged + add[5], magic + add[6], summoning + add[7]); if (Math.floor(cb) > Math.floor(currentCombat)) { next_level[j - 1] = i; break; } } } // Make sure this won't say you need levels over 99... int[] skills = new int[] { attack, strength, defence, hitpoints, prayer, ranged, magic, summoning }; for (int i = 0; i < next_level.length; i++) { if (skills[i] + next_level[i] > MAX_LEVEL) { next_level[i] = 0; } } return next_level[skill.ordinal()]; }

I would highly recommend Tip.It use this in their calculator as their current method can be off sometimes; this will never be. It also counts attack/strength and defence/hitpoints separately as sometimes you can require 1 attack level until the next combat, or 2 strength... the word "OR" would not apply here.

I hope everyone's enjoyed this little thing about the combat formula and that it helps them. Now, it's time for the...

~~ Melee Max Hit Formula ~~

This formula is a tricky one. No website has yet gotten it correct. Some are more accurate on some things, others are better at others. The method I've written for calculating the melee max hit formula has a parameter allowing the programmer to specify which website's formula he wishes to use. Here is the code:

public static int meleeMaxHit(int strengthBase, int strengthCurrent, int strengthBonus, StrengthPrayers prayer, FightingStyles fightStyle, SpecialAttacks special, Effects effect, ItemSets itemSet, int hpBase, int hpCurrent, Websites website) throws Exception { // Check for invalid input if (itemSet == ItemSets.Dharok && special != SpecialAttacks.None) { throw new Exception("Dharok's set effect cannot be used in conjuction with a special attack as all special attacks require a weapon other than Dharok's greataxe to be wielded."); } if (itemSet != ItemSets.None && (effect == Effects.BlackMask || effect == Effects.SlayerHelmet)) { throw new Exception("No item set can be used in conjuction with the black mask or slayer helmet as only one helmet can be worn at once and helmets cannot be worn in Castle Wars."); } if (itemSet == ItemSets.Dharok && hpCurrent == 0) { throw new Exception("Dharok's set effect cannot be used with a current hitpoints level of zero as you would be dead and could not attack."); } if (itemSet == ItemSets.Dharok && hpBase > MAX_LEVEL) { throw new Exception("You cannot have a base hitpoints level greater than " + MAX_LEVEL + "."); } if (special == SpecialAttacks.Keris && !(effect == Effects.None || effect == Effects.BlackMask || effect == Effects.SlayerHelmet)) { throw new Exception("Keris can only be used with the black mask / slayer helmet effect. Keris can only be used on Kalphites, so the other effects are nonexistant."); } // Calculate according to each website's current formula... // Criticisms: Follows an unusual formula with no real background; very accurate in certain areas but far off in others. if (website == Websites.RuneUniverse) { double dharokMultiplier = ((1 - ((float)hpCurrent / (float)hpBase)) * 0.95) + 1; double baseStrength = ((strengthCurrent + fightStyle.getStrengthBoost()) * (1 + prayer.getBoost() + effect.getBoost())); double bonusMultiplier = (strengthBonus * 0.00175) + 0.1; double maxHit = (baseStrength * bonusMultiplier) + 1.3; if (itemSet == ItemSets.Dharok) { maxHit *= dharokMultiplier; } else if (itemSet == ItemSets.None) { maxHit *= special.getMultiplier(); } else { maxHit *= itemSet.getMultiplier(); } return (int)Math.floor(maxHit); } // Criticisms: // Assumes special attacks increase strength bonus, whereas Jagex states they increase damage (e.g. max hit). // Assumes that the Saradomin and Zamorak godsword special attacks increase max hit by 5% when there is NO evidence for this, plus the KB specifically says that the SGS "inflicts normal damage". No mention at all, of extra damage is made in the KB for the ZGS either. // Uses potions as a multiplier (e.g. Super strength potion makes a multiplier of 1.2 whereas ALL potions do is increase your strength LEVEL by a set amount derived by a formula. // I've modified the formula so that potions are used correctly; sections changed are commented out. else if (website == Websites.TipIt) { /* Not needed because this is incorrect double potion = 0; 1 = None 1.125 = Strength 1.2 = Super Strength 1.15 = Zamorak */ double multiplier = 1; double maxHit = 0; double strengthBonus2 = strengthBonus; if (special == SpecialAttacks.DragonDagger) { strengthBonus += 20; } else if (special == SpecialAttacks.DragonLongsword) { strengthBonus += 30; } else if (special == SpecialAttacks.DragonMace) { strengthBonus += 60; } else if (special == SpecialAttacks.BandosGodsword) { multiplier += 0.1; } else if (special == SpecialAttacks.ArmadylGodsword) { multiplier += 0.25; } else if (special == SpecialAttacks.SaradominGodsword || special == SpecialAttacks.ZamorakGodsword) { multiplier += 0.05; } else if (itemSet == ItemSets.Dharok) { strengthBonus2 = (strengthBonus * (((float)(hpBase - hpCurrent) / 99) + 1)); } else if (itemSet == ItemSets.VoidKnight) { multiplier += 0.1; } else if (special == SpecialAttacks.BerserkerNecklace) { multiplier += 0.2; } else { throw new Exception("Tip.It's formula does not support this special attack or item set."); } strengthCurrent += (int)Math.floor(strengthCurrent * effect.getBoost()); /* Not needed because this is incorrect if (special == SpecialAttacks.Rampage) { potion = 1.2; } */ // strengthCurrent was previously: Math.floor(strengthBase * potion) maxHit = (((strengthCurrent + Math.floor(strengthCurrent * prayer.getBoost()) + fightStyle.getStrengthBoost()) * ((strengthBonus2 * 0.00175) + 0.1) + 1.05) * multiplier); if (maxHit < 1.5) { maxHit = 1; } else { maxHit = Math.ceil(maxHit); } return (int)maxHit; } // Criticisms: Like most of the others, is horrible at calculating Dharok max hits. On a positive note, it almost handles potions correctly (it factors in the fight style strength addition before the potion, where the potion should be first). else if (website == Websites.RuneHQ) { // NOTE: Due to the way RuneHQ's formula uses potions, the following two lines MAY cause an inaccuracy of 1 strength level due to the way it had to be converted to be used in this system double postMultiplier = ((float)(strengthCurrent - strengthBase) / strengthBase) + 1; strengthCurrent = (int)Math.ceil((strengthBase + fightStyle.getStrengthBoost()) * postMultiplier); double dharokMultiplier = ((1 - ((float)hpCurrent / (float)hpBase)) * ((float)2 / (float)3)) + 1; double baseStrength = strengthCurrent * (1 + prayer.getBoost() + effect.getBoost()); double maxHit = 1 + ((float)strengthBonus / 100) + (((float)strengthBonus / 925) * Math.log(baseStrength)); double maxHit2 = ((baseStrength + 13) * maxHit) / 10; if (special == SpecialAttacks.DragonHalberd) { maxHit2 *= 1.1; } else if (itemSet == ItemSets.Dharok) { maxHit2 *= dharokMultiplier; } else if (special == SpecialAttacks.Keris) { maxHit2 = Math.floor(maxHit2) * special.getMultiplier(); } else { maxHit2 *= special.getMultiplier(); } return (int)Math.floor(maxHit2); } // Criticisms: Same as Tip.It's formula in terms of potions. // I've also modified this one to use potions properly. else if (website == Websites.RuneScapeWikia) { if (itemSet != ItemSets.None) { throw new Exception("RuneScape Wikia formula does not support item sets."); } if (special != SpecialAttacks.None) { throw new Exception("RuneScape Wikia formula does not support item sets."); } if (effect != Effects.None) { throw new Exception("RuneScape Wikia does not support special effects."); } // Was previously: (strengthBase * (1 + potion + prayer.getBoost()... double baseStrength = (strengthCurrent * (1 + prayer.getBoost())) + fightStyle.getStrengthBoost(); double strengthMultiplier = (strengthBonus * 0.00175) + 0.1; double maxHit = (baseStrength * strengthMultiplier) + 1.05; return (int)Math.floor(maxHit); } // Criticisms: Outdated and same potion problem as Tip.It and RS Wikia, but seems very accurate and simple and is the most logical to use as a base for new formulas. // Corrected potion error here also. else if (website == Websites.OldRSCWebsites) { if (itemSet != ItemSets.None) { throw new Exception("Old RSC formula does not support item sets."); } if (special != SpecialAttacks.None) { throw new Exception("Old RSC formula does not support item sets."); } if (effect != Effects.None) { throw new Exception("Old RSC formula does not support special effects."); } // strengthCurrent was previously (strength * potion) return (int)Math.floor(((strengthCurrent + (strengthBase * (1 * prayer.getBoost())) + fightStyle.getStrengthBoost()) * ((strengthBonus * 0.00175) + 0.1)) + 1.05); } // This is our research formula, the one that is hoped to become 100% accurate else if (website == Websites.Experimental) { if (itemSet == ItemSets.Dharok) { strengthCurrent += (hpBase - hpCurrent); } double finalStrength = strengthCurrent + fightStyle.getStrengthBoost() + (strengthBase * prayer.getBoost()) + (strengthBase * effect.getBoost()) + (itemSet == ItemSets.Dharok ? (hpBase - hpCurrent) : 0); double strengthMultiplier = (strengthBonus * 0.00175) + 0.1; double maxHit = (int)Math.floor((finalStrength * strengthMultiplier) + 1.05); return (int)Math.floor(Math.floor(Math.floor(maxHit) * itemSet.getMultiplier()) * special.getMultiplier()); } else { throw new Exception("Parameter 'website' must be a valid constant in the 'Websites' enumeration."); } }

Yes, that took a while to write.

Now, for the programmers of Tip.It, or those who can understand Java easily enough to see it in mathematical terms, I'd like to point out a few things that most sites do incorrectly in their formulas.

[*:33nsra4c]Potions are calculated incorrectly by every formula I've ever come across. RuneHQ's is the only one that even comes close at all. A lot of sites calculate potions as strengthLevel * 1.2 for a Super strength potion, etc. This is NOT correct. ALL a potion does it raise your strength level. Potions don't belong in the max hit formula AT ALL; they are to be pre-calculated and passed in AS the strength level itself, not added to it. For example, I'm 99 strength. Drinking a super strength potion gives me 19 strength levels putting me at level 118. I don't tell the formula to calculate 99 strength + a super strength potion - I tell it to calculate with 118 strength.

[*:33nsra4c]Jagex differentiates between things that raise your

**strength**and those that raise your

**max hit**. For example, the description of Dharok's special attack is "The lower your Hitpoints, the higher your Strength". The higher your STRENGTH, not max hit. Therefore, in the formula, Dharok's effect should be calculated and added to strength level BEFORE other calculations. Same idea for things like Keris, which triples your MAX HIT, not your strength. That should be calculated near the END of the formula, after other calculations have already been made.

[*:33nsra4c]Pay attention to the knowledge base. Tip.It's max hit calculator actually factors in the Saradomin and Zamorak godswords as having a 5% max hit bonus! This is wrong. ONLY the Armadyl (+25%) and Bandos (+10%) godsword special attacks affect max hit. RuneHQ also claims the name of Keris' special attack / effect is "Scabaras Slayer" and that the Berserker Necklace's effect is "Obsidian Synergy". Neither of these are found anywhere else, and especially not on the KB.

[*:33nsra4c]All the special attacks raise MAX HIT, according to the KB - not strength. Let's remember to factor it in correctly. Also, don't take the special attack multipliers used in my class as correct. I used the same ones as Tip.It and RuneHQ - they are experimental only, just like the formula itself!

And the questions we have to answer...

[*:33nsra4c]Are prayers and other bonuses cumulative? E.G., do you calculate that 99 strength * 1.23 for piety is 121.77, then 121.77 * 1.15 for Black mask? Or are they based on your BASE level, e.g. 99 * (1 + 0.23 + 0.15)? I am considering removing the base strength and current strength parameters from the formula and just using one strength variable. It'd make more sense, because I think Jagex considers "level" in their code to be your actual level, and your

**XP**to be your base level.

[*:33nsra4c]Where did the numbers 0.00175, 0.1 and 1.05, from the RSC formula, originate? And should we use them?

[*:33nsra4c]The max hit rounded down before Keris is calculated? Is it rounded down before the Void Knight set is counted and what order are these calculations done in? In our experimental formula I have: floor(floor(floor(maxHit) * itemSet.getMultiplier()) * special.getMultiplier()) at the moment. It makes sense to round down before raising your "max hit" by X percent.

[*:33nsra4c]Does the Void Knight set stack with special attacks? Pretty sure it does...

Please take a look at the full source code of this in the Downloads and Links section. Hopefully we can work together to come up with an extremely accurate formula! Posting screenshots and/or videos of max hits detailing all conditions at the time would be helpful to our project.

If you have any thoughts or ideas about the math in these formulas, please post them! I'd love to hear it.

I'm also thinking of adding a function to grab player stats from the highscores to my class but as I currently have other work, I probably won't have the time for a while. I actually had this post ready as a draft for a while now so I figured I'd post it. I hope you enjoy this topic and hopefully we'll come up with something good!

~~ Downloads and Links ~~

This is an open source project, as such, the source code is available for you to view and edit!

Click here to download the source code of RuneScapeFormulas.java

I also made a little max hit calculator with a GUI (I wrote it in about an hour last night and didn't really bother to follow good coding guidelines so excuse me if the code's a bit messy). It uses my RuneScapeFormulas class, so be sure to download RuneScapeFormulas.java above if you want to compile it!

Click here to download the source code of MaxHitCalculator.java

Click here to download a JAR file of my Max Hit Calculator

Click here to download an EXE file of my Max Hit Calculator

Jard Y Dooku's members combat: 136.1

Jard Y Dooku's free combat level: 126.1

Jard Y Dooku's RSC combat level: 123.125

Jard Y Dooku's remaining summoning levels to advance a combat level: 8

Jard Y Dooku's melee max hit with Dharok and best setup and conditions (Experimental): 118

Jard Y Dooku's melee max hit with Dharok and best setup and conditions (Rune HQ): 93

Jard Y Dooku's melee max hit with Dharok and best setup and conditions (Rune Universe): 111

Jard Y Dooku's melee max hit with Dharok and best setup and conditions (Tip.It): 98

Jard Y Dooku's melee max hit with Keris and best setup and conditions (Experimental): 114

Jard Y Dooku's melee max hit with Keris and best setup and conditions (Rune HQ): 117

Jard Y Dooku's melee max hit with Keris and best setup and conditions (Rune Universe): 121

Jard Y Dooku's Pest Control points reward for ranged skill: 448

Jard Y Dooku's amount of levels boosted in the hitpoints skill, using a Saradomin Brew: 16