Jump to content

Welcome to Rune Tips, the first ever RuneScape help site. We aim to offer skill guides, quest guides, maps, calculators, informative databases, tips, and much more to help you get the most from the Massive Online Adventure Game, RuneScape, by Jagex Ltd © 2009.

Report Ad

Welcome to Forum.Tip.It
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. If you already have an account, login here - otherwise create an account for free today!

Python OSRS Combat Level Function


  • Please log in to reply
1 reply to this topic

[ Display Name History ]


    Chicken Feather

  • Members
  • 6 posts
  • Joined:1 July 2008

I have a nice spaghetti code program I did as a project for my Linux class.

The main code is a bash script.

I'm using perl to check if the player name is valid (not really important).

I'm using bash to get the osrs hiscores.

I'm using awk to put the combat stats into a file.

I'm using python to read the combat stats file and calculate the combat level.
Then this information gets passed to other python functions to calculate what rank I should assign my clanmates.

import math

def combat_level(stats):
    #1.	Take your Prayer level and divide it by two and round down 
    base = math.trunc(stats[5]/2)
    #2.	Add this to your Hitpoints and Defence levels and divide the result by 4.
    base = (base+stats[3]+stats[1])/4
    #3. Add your Strength and Attack levels together and multiply by 0.325.
    melee = (stats[2]+stats[0])*0.325
    #Add this to your base combat level and you should have your melee combat level.
    #4.	If your Magic or Ranged level is exceptionally higher than your Attack and Strength,
    #carry on - in the calculation noted below Magic is used, 
    #but if your Ranged is exceptionally higher, use that instead in all cases
    higher = stats[6]
    if (higher < stats[4]):
        higher = stats[4]
    if (higher > stats[0]+14 and higher > stats[2]+14):
    #5. Divide your Magic level by 2 and round down, and then add your Magic level again to this 
        magic = math.trunc(higher/2)+higher
    #6. Multiply this by 0.325 and add the result to your base combat level calculated above, 
    #and you should have your magic combat level
        magic = magic*0.325
        return math.trunc(base+magic)
         return math.trunc(base+melee)


stats = []
    f = open("osrs/temp")
    for line in f:
        line = line.rstrip("\n")


Anyway, I just wanted to ask if anyone knows what the wiki means by

"If your Magic or Ranged level is exceptionally higher than your Attack and Strength"?

I just did +14, but I'm not sure if this is correct.


[ Display Name History ]


    Dragon Slayer

  • Members
  • 9,236 posts
It's not as simple as +14 I think it's closer to if magic or range is higher than str+atk combined

Not 100% sure if HP is calculated along with Def either. Remember the splash mage pures that had 99 magic and 10hp? They were only like mid 20s if memory serves


Anyone who likes tacos is incapable of logic.

Anyone who likes logic is incapable of tacos.


PSA: SaqPrets is an Estonian Dude
Steam: NippleBeardTM
Origin: Brand_New_iPwn

Also tagged with one or more of these keywords: OSRS

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users