Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Function CalcExpNeeded(ByVal startlevel As Long, ByVal exptable As Long) As Currency
- 'FROM: https://www.mudinfo.net/viewtopic.php?p=7703
- On Error GoTo error:
- Dim nModifiers() As Integer, i As Long, j As Currency, k As Currency, exp_multiplier As Long, exp_divisor As Long, Ret() As Currency
- Dim lastexp As Currency, startexp As Currency, running_exp_tabulation As Currency, billions_tabulator As Currency
- Dim potential_new_exp As Currency, ALTERNATE_NEW_EXP As Currency, accurate_exp() As Currency
- Dim MAX_UINT As Double, numlevels As Integer, num_divides As Integer
- MAX_UINT = 4294967295#
- numlevels = 1
- ReDim Ret(startlevel To (startlevel + numlevels - 1))
- For i = 1 To (startlevel + numlevels - 1)
- startexp = lastexp
- If i = 1 Then
- running_exp_tabulation = 0
- ElseIf i = 2 Then
- running_exp_tabulation = exptable * 10
- Else
- If i <= 26 Then 'levels 1-26
- nModifiers() = GetExpModifiers(i)
- exp_multiplier = nModifiers(0)
- exp_divisor = nModifiers(1)
- ElseIf i <= 55 Then 'levels 27-55
- exp_multiplier = 115
- exp_divisor = 100
- ElseIf i <= 58 Then 'levels 56-58
- exp_multiplier = 109
- exp_divisor = 100
- Else 'levels 59+
- exp_multiplier = 108
- exp_divisor = 100
- End If
- If i = 97 Then
- 'Debug.Print i
- End If
- If exp_multiplier = 0 Or exp_divisor = 0 Then
- potential_new_exp = 0
- Else
- potential_new_exp = running_exp_tabulation * exp_multiplier
- End If
- If potential_new_exp > MAX_UINT Then 'UINT ROLLOVER #1
- num_divides = 0
- Do While potential_new_exp > MAX_UINT
- running_exp_tabulation = Fix(running_exp_tabulation / 100)
- potential_new_exp = running_exp_tabulation * exp_multiplier
- num_divides = num_divides + 1
- Loop
- If num_divides > 1 Then
- ALTERNATE_NEW_EXP = Fix((running_exp_tabulation * exp_multiplier * 100) / exp_divisor)
- Else
- ALTERNATE_NEW_EXP = Fix(potential_new_exp / exp_divisor)
- End If
- Do While num_divides > 0
- ALTERNATE_NEW_EXP = ALTERNATE_NEW_EXP * 100
- num_divides = num_divides - 1
- Loop
- Else
- ALTERNATE_NEW_EXP = Fix(potential_new_exp / exp_divisor)
- End If
- j = (1000000 * exp_multiplier * billions_tabulator)
- Do While j > MAX_UINT
- j = j - MAX_UINT - 1 'UINT ROLLOVER #2
- Loop
- Do While j >= 1000000000
- j = j - 1000000000
- billions_tabulator = billions_tabulator + 1
- Loop
- k = (j + ALTERNATE_NEW_EXP)
- Do While k >= 1000000000
- k = k - 1000000000
- billions_tabulator = billions_tabulator + 1
- Loop
- running_exp_tabulation = k
- End If
- lastexp = running_exp_tabulation + (billions_tabulator * 1000000000)
- If i >= startlevel Then
- Ret(i) = lastexp
- End If
- Next i
- CalcExpNeeded = Ret(startlevel)
- out:
- On Error Resume Next
- Exit Function
- error:
- Call HandleError("CalcExpNeeded")
- Resume out:
- End Function
- Private Function GetExpModifiers(ByVal nLevel As Integer) As Integer()
- Dim Ret(1) As Integer
- Ret(0) = 0
- Ret(1) = 0
- Select Case nLevel
- Case 3:
- Ret(0) = 40
- Ret(1) = 20
- 'return [40, 20];
- Case 4, 5:
- Ret(0) = 44
- Ret(1) = 24
- 'return [44, 24];
- Case 6, 7:
- Ret(0) = 48
- Ret(1) = 28
- 'return [48, 28];
- Case 8, 9:
- Ret(0) = 52
- Ret(1) = 32
- 'return [52, 32];
- Case 10, 11:
- Ret(0) = 56
- Ret(1) = 36
- 'return [56, 36];
- Case 12, 13:
- Ret(0) = 60
- Ret(1) = 40
- 'return [60, 40];
- Case 14, 15:
- Ret(0) = 65
- Ret(1) = 45
- 'return [65, 45];
- Case 16, 17:
- Ret(0) = 70
- Ret(1) = 50
- 'return [70, 50];
- Case 18:
- Ret(0) = 75
- Ret(1) = 55
- 'return [75, 55];
- Case Else:
- If nLevel <= 26 Then
- Ret(0) = 50
- Ret(1) = 40
- 'return [50, 40];
- Else
- Ret(0) = 23
- Ret(1) = 20
- 'return [23, 20];
- End If
- End Select
- GetExpModifiers = Ret
- 'function GetExpModifiers($iLevel) {
- ' switch ($iLevel) {
- ' Case 3:
- ' return [40, 20];
- ' Case 4:
- ' Case 5:
- ' return [44, 24];
- ' Case 6:
- ' Case 7:
- ' return [48, 28];
- ' Case 8:
- ' Case 9:
- ' return [52, 32];
- ' Case 10:
- ' Case 11:
- ' return [56, 36];
- ' Case 12:
- ' Case 13:
- ' return [60, 40];
- ' Case 14:
- ' Case 15:
- ' return [65, 45];
- ' Case 16:
- ' Case 17:
- ' return [70, 50];
- ' Case 18:
- ' return [75, 55];
- 'default:
- ' if ($iLevel <= 26) {
- ' return [50, 40];
- ' } else {
- ' return [23, 20];
- ' }
- ' }
- '}
- End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement