Results 1 to 3 of 3

Thread: Need help with a formula I am working on

  1. #1

    Thread Starter
    Fanatic Member Mxjerrett's Avatar
    Join Date
    Apr 2006
    Location
    Oklahoma
    Posts
    939

    Need help with a formula I am working on

    Well I've been sitting down at my desk for the past 2 hours and I bet the answer is probably easy, but I am trying to work on a formula to tell exactly how many levels are needed to get to the next level on a game I play, Runescape, this is within the rules of the game so I know it shouldn't be a problem. Below is the formula to get the characters combat level. So now I am trying to figure out a formula to see how many levels are needed to get to the next level. I was trying as hard as I could, but I couldn't even get past Melee levels.


    Code:
    Public Function CalcCombat(Attack As Integer, Defence As Integer, Strength As Integer, HP As Integer, Prayer As Integer, Ranged As Integer, Magic As Integer) As Double
    On Error Resume Next
    Dim Base As Double, Melee As Double, Mage As Double, Range As Double
    
    Base = ((Defence + HP + Int(Prayer / 2)) * 0.25)
    Melee = (Attack + Strength) * 0.325
    Range = Int(Ranged * 1.5) * 0.325
    Mage = Int(Magic * 1.5) * 0.325
    
    If Melee > Range And Melee > Mage Then
        CalcCombat = Int(Melee + Base)
        strClass = "Knight"
    ElseIf Range > Melee And Range > Mage Then
        CalcCombat = Int(Range + Base)
        strClass = "Archer"
    Else
        CalcCombat = Int(Mage + Base)
        strClass = "Mage"
    End If
    End Function

    If a post has been helpful please rate it.
    If your question has been answered, pull down the tread tools and mark it as resolved.

  2. #2
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    Re: Need help with a formula I am working on

    You want to know "how many levels are needed to get to the next level". Besides the fact that one gets confused by the double-use of level, how do you collect levels. What does the storyoard of the game tell you. Not knowing the game we can't even guess.
    Looking at your function, you seem to have an idea what to calculate. You use as String-variable(strclass) which isn't declared in or handed over to the function. Why are you declaring the function return as a double although it is calculated like and probably used as an integer.
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  3. #3

    Thread Starter
    Fanatic Member Mxjerrett's Avatar
    Join Date
    Apr 2006
    Location
    Oklahoma
    Posts
    939

    Re: Need help with a formula I am working on

    It is a double because when I first wrote the function, I did not convert the variables to integers. Now what I mean is you 7 separate skills that calculate your combat level. Now based on the levels of your skills, your combat level increases. There is no set number by which your combat increases, because your base can change your level as well. Do you understand?

    If a post has been helpful please rate it.
    If your question has been answered, pull down the tread tools and mark it as resolved.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width