Adblock breaks this site

[Function] GetCombatLevel & GetCombatClass

Discussion in 'Programming General' started by Darthatron, Nov 3, 2007.

  1. Darthatron

    Darthatron Massive Troll
    Retired Sectional Moderator Visual Basic Programmers

    Joined:
    May 22, 2006
    Posts:
    1,612
    Referrals:
    3
    Sythe Gold:
    0
    [Function] GetCombatLevel & GetCombatClass

    This is the formula the the people on the Official RuneScape Forums have made.

    Put this in a module:

    Code:
    Dim MeleeC, RangeC, MagicC As Integer
    Dim BaseCombat As Integer
    Dim CombatClass As String
    
    Public Function GetCombatLevel(Attack As Integer, Defence As Integer, Strength As Integer, Hitpoints As Integer, Prayer As Integer, Range As Integer, Magic As Integer)
        CombatClass = GetCombatClass(Attack, Defence, Strength, Hitpoints, Prayer, Range, Magic)
        
        If CombatClass = "Melee" Then GetCombatLevel = MeleeC + BaseCombat
        If CombatClass = "Range" Then GetCombatLevel = RangeC + BaseCombat
        If CombatClass = "Magic" Then GetCombatLevel = MagicC + BaseCombat
    End Function
    
    Public Function GetCombatClass(Attack As Integer, Defence As Integer, Strength As Integer, Hitpoints As Integer, Prayer As Integer, Range As Integer, Magic As Integer)
        Defence = Defence * 100
        Hitpoints = Hitpoints * 100
        If Prayer = Int(Prayer) Then Prayer = Prayer * 50 Else Prayer = Prayer - 1 * 50
        BaseCombat = (Defence + Hitpoints + Prayer) / 400
        
        Attack = Attack * 130
        Strength = Strength * 130
        
        If Range = Int(Range) Then Range = Range * 195 Else Range = (Range - 1) + (Range * 2) * 65
        
        If Magic = Int(Magic) Then Magic = Magic * 195 Else Magic = (Magic - 1) + (Magic * 2) * 65
        
        MeleeC = (Attack + Strength) / 400
        RangeC = Range / 400
        MagicC = Magic / 400
        
        If MeleeC > MagicC And MeleeC > RangeC Then CombatClass = "Melee"
        If RangeC > MeleeC And RangeC > MagicC Then CombatClass = "Range"
        If MagicC > RangeC And MagicC > MeleeC Then CombatClass = "Magic"
        GetCombatClass = CombatClass
    End Function
    Example usage:
    Code:
    lblCombat.Caption = Int(GetCombatLevel(txtAttack.Text, txtDefence.Text, txtStrength.Text, txtHitpoints.Text, txtPrayer.Text, txtRange.Text, txtMagic))
    lblClass.Caption = "You have " & GetCombatClass(txtAttack.Text, txtDefence.Text, txtStrength.Text, txtHitpoints.Text, txtPrayer.Text, txtRange.Text, txtMagic) & " based Combat."
    Please remember I did not make this formula. It was created by Maxwaterman on the Official RuneScape Forums.

    Credits:
    Code:
    ____________________
    | Combat Formula Crew |
    ````````````````````````````````````
    Maxwaterman
    Fern1970
    Helcaterian
    Oblivion590
    Hans980
    Benmarchant
    
    
    Converted to VB6 by Darthatron
    Also, I'd like to add. I know it's coded poorly, because it didn't take very long and I am lazy. :cool:
     
  2. garaa447

    garaa447 Guest

    Referrals:
    0
    [Function] GetCombatLevel & GetCombatClass

    how do i use this???
     
  3. jdsfighter

    jdsfighter Forum Addict
    Visual Basic Programmers

    Joined:
    Jan 21, 2007
    Posts:
    603
    Referrals:
    0
    Sythe Gold:
    0
    [Function] GetCombatLevel & GetCombatClass

    AHHHHHHHH bloated code, hide your eyes children. It is so much easier if you it the way I posted below. This is just a modded version of their PHP code.


    Code:
    Public strClass As String
    
    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
     
  4. Darthatron

    Darthatron Massive Troll
    Retired Sectional Moderator Visual Basic Programmers

    Joined:
    May 22, 2006
    Posts:
    1,612
    Referrals:
    3
    Sythe Gold:
    0
    [Function] GetCombatLevel & GetCombatClass

    LOL! I knew it was badly coded... But not THAT bad... Thanks.
     
< Need help! | [Source]Sorting a ListView >


 
 
Adblock breaks this site