Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Equip Bonus System
#1
So I have been working on this equipment bonus thing for a couple hours and have it all figured out so it's working nicely however I think it is sort of messy. I am not sure. I was hoping to get somebodys advice on if there would be a faster way to do any of the things I am or not.

As it is I have 6 Functions that are each like this:
Code:
Function GetPlayerWeaponBonus(ByVal Index As Long)
Dim WeaponSlot As Long
    
    StrengthBonus = 0
    EnduranceBonus = 0
    DexterityBonus = 0
    WisdomBonus = 0
    AgilityBonus = 0
    
    If GetPlayerWeaponSlot(Index) > 0 Then
    
    WeaponSlot = GetPlayerWeaponSlot(Index)
    
        If Item(GetPlayerInvItemNum(Index, WeaponSlot)).BonusType = 0 Then
            StrengthBonus = Item(GetPlayerInvItemNum(Index, WeaponSlot)).Bonus
        End If
        If Item(GetPlayerInvItemNum(Index, WeaponSlot)).BonusType = 1 Then
            EnduranceBonus = Item(GetPlayerInvItemNum(Index, WeaponSlot)).Bonus
        End If
        If Item(GetPlayerInvItemNum(Index, WeaponSlot)).BonusType = 2 Then
            DexterityBonus = Item(GetPlayerInvItemNum(Index, WeaponSlot)).Bonus
        End If
        If Item(GetPlayerInvItemNum(Index, WeaponSlot)).BonusType = 3 Then
            WisdomBonus = Item(GetPlayerInvItemNum(Index, WeaponSlot)).Bonus
        End If
        If Item(GetPlayerInvItemNum(Index, WeaponSlot)).BonusType = 4 Then
            AgilityBonus = Item(GetPlayerInvItemNum(Index, WeaponSlot)).Bonus
        End If
    End If
End Function
6 of those, one for each item type.

Then I have this:
Code:
Function GetPlayerBonus(Index)
    Call GetPlayerWeaponBonus(Index)
    Call GetPlayerArmorBonus(Index)
    Call GetPlayerSheildBonus(Index)
    Call GetPlayerHelmBonus(Index)
    Call GetPlayerNecklaceBonus(Index)
    Call GetPlayerRingBonus(Index)
    Call SendStats(Index)
End Function

So thats called whenever an item is equipped or unequipped and when you first join the game.

Then obviously I have 5 declares like StrengthBonus, EnduranceBonus, etc. Those are sent in the SendStats sub so I can have my visual stats update like 8 + (1).

So this seems slow, any faster ways? xD thanks!
Reply
#2
Why are they functions if they aren't returning their own value?

=/



GetPlayerWeaponBonus doesn't return a variable named GetPlayerWeaponBonus, so why isn't it just a sub?
Reply
#3
Because I didn't know the difference... :oops: haha. I guess I should have looked into that a bit.
Reply
#4
Why would negatives not work?
Reply
#5
That's pretty close to what I did for my bonus system. Mines a bit sloppier though I think.

This is what it looks like :p

Code:
Function GetPlayerBonusSTR(ByVal Index As Long) As Byte ' get players extra strength from items
Dim ArmorSlot As Byte, HelmSlot As Byte, WeaponSlot As Byte, ShieldSlot As Byte
    
    GetPlayerBonusSTR = 0
    
    ' Check for subscript out of range
    If IsPlaying(Index) = False Or Index  MAX_PLAYERS Then
        Exit Function
    End If
    
    ArmorSlot = GetPlayerArmorSlot(Index)
    HelmSlot = GetPlayerHelmetSlot(Index)
    WeaponSlot = GetPlayerWeaponSlot(Index)
    ShieldSlot = GetPlayerShieldSlot(Index)
    
    If ArmorSlot > 0 Then GetPlayerBonusSTR = GetPlayerBonusSTR + (Item(ArmorSlot).StrBon)
    If HelmSlot > 0 Then GetPlayerBonusSTR = GetPlayerBonusSTR + (Item(HelmSlot).StrBon)
    If WeaponSlot > 0 Then GetPlayerBonusSTR = GetPlayerBonusSTR + (Item(WeaponSlot).StrBon)
    If ShieldSlot > 0 Then GetPlayerBonusSTR = GetPlayerBonusSTR + (Item(ShieldSlot).StrBon)
    
    If GetPlayerBonusSTR < 0 Then GetPlayerBonusSTR = 0 ' Gotta check, never know :p
End Function

My item/inventory code was changed so the code isn't what it would be for a vanilla mse but you get the point.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)