Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[BUG]Carry Over Exp
#1
Hi there, didn't see it mentioned so here I go. In version 3.59 Roll over exp was added, but I beileve its nots working correctly as it does its calculation after player has a new (and higher) NextLevelExp. This gave me atleast, a negative exp number when leveling up.

Here is the Code:
Code:
Sub CheckPlayerLevelUp(ByVal Index As Long)
Dim i As Long

    ' Check if attacker got a level up
    If GetPlayerExp(Index) >= GetPlayerNextLevel(Index) Then
        Call SetPlayerLevel(Index, GetPlayerLevel(Index) + 1)
                    
        ' Get the ammount of skill points to add
        i = Int(GetPlayerStat(Index, Stats.Speed) / 10)
        If i < 1 Then i = 1
        If i > 3 Then i = 3
            
        Call SetPlayerPOINTS(Index, GetPlayerPOINTS(Index) + i)
        Call SetPlayerExp(Index, CLng(GetPlayerExp(Index) - GetPlayerNextLevel(Index)))
        Call GlobalMsg(GetPlayerName(Index) & " has gained a level!", Brown)
        Call PlayerMsg(Index, "You have gained a level!  You now have " & GetPlayerPOINTS(Index) & " stat points to distribute.", BrightBlue)
    End If
    
End Sub

To fix it, simply add a variable "expRollover" and have the calculation give this variable the value right after the Exp >= NextLevel check. Then obviously use this new variable as the setExp parameter.

Example:
Code:
Sub CheckPlayerLevelUp(ByVal Index As Long)
Dim i As Long
Dim expRollover As Long

    ' Check if attacker got a level up
    If GetPlayerExp(Index) >= GetPlayerNextLevel(Index) Then
        expRollover = CLng(GetPlayerExp(Index) - GetPlayerNextLevel(Index))
        Call SetPlayerLevel(Index, GetPlayerLevel(Index) + 1)
                    
        ' Get the ammount of skill points to add
        i = Int(GetPlayerStat(Index, Stats.Speed) / 10)
        If i < 1 Then i = 1
        If i > 3 Then i = 3
            
        Call SetPlayerPOINTS(Index, GetPlayerPOINTS(Index) + i)
        Call SetPlayerExp(Index, expRollover)
        Call GlobalMsg(GetPlayerName(Index) & " has gained a level!", Brown)
        Call PlayerMsg(Index, "You have gained a level!  You now have " & GetPlayerPOINTS(Index) & " stat points to distribute.", BrightBlue)
    End If
    
End Sub

and there you go, I'm very much a VB6 noob so sorry if I missed something.
Reply
#2
has anyone else noticed this?
Reply
#3
yep i think he is right looks like it would negative out ^^.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)