math = fun ...sometimes [Archive] - ForumsHQ
Posted: Wed Jan 01, 2003 3:27 pm
my monster exp dividing formula:
If DatFileVersion = v111j Then
If Monsterrec.ExpMulti = 1 Or Monsterrec.ExpMulti = 0 Then
nBase = SLong2ULong(Monsterrec.Experience)
nBase = Round(nBase / divisor)
If nBase 2147483646 Then nBase = 2147483646
Monsterrec.Experience = ULong2SLong(nBase)
Else
nBase = SLong2ULong(Monsterrec.Experience) * SLong2ULong(Monsterrec.ExpMulti)
nBase = Round(nBase / divisor)
If nBase > 2147483646 Then nBase = 2147483646
tryagain:
nMultiMax = 20
For x = 20 To 65538
If x * 32767 >= nBase Then
nMultiMax = x
Exit For
End If
Next x
nMulti = 1
For x = 3 To nMultiMax
temp = nBase Mod x
If temp = 0 Then nMulti = x
Next x
If nMulti = 1 Then
nBase = nBase - 1
GoTo tryagain:
End If
nBase = nBase / nMulti
If nBase <= 0 Then nBase = 1
Monsterrec.Experience = ULong2SLong(nBase)
Monsterrec.ExpMulti = ULong2SLong(nMulti)
End If
Else
nBase = SLong2ULong(Monsterrec.Experience)
nBase = Round(nBase / divisor)
If nBase <= 0 Then nBase = 1
Monsterrec.Experience = ULong2SLong(nBase)
End If
If DatFileVersion = v111j Then
If Monsterrec.ExpMulti = 1 Or Monsterrec.ExpMulti = 0 Then
nBase = SLong2ULong(Monsterrec.Experience)
nBase = Round(nBase / divisor)
If nBase 2147483646 Then nBase = 2147483646
Monsterrec.Experience = ULong2SLong(nBase)
Else
nBase = SLong2ULong(Monsterrec.Experience) * SLong2ULong(Monsterrec.ExpMulti)
nBase = Round(nBase / divisor)
If nBase > 2147483646 Then nBase = 2147483646
tryagain:
nMultiMax = 20
For x = 20 To 65538
If x * 32767 >= nBase Then
nMultiMax = x
Exit For
End If
Next x
nMulti = 1
For x = 3 To nMultiMax
temp = nBase Mod x
If temp = 0 Then nMulti = x
Next x
If nMulti = 1 Then
nBase = nBase - 1
GoTo tryagain:
End If
nBase = nBase / nMulti
If nBase <= 0 Then nBase = 1
Monsterrec.Experience = ULong2SLong(nBase)
Monsterrec.ExpMulti = ULong2SLong(nMulti)
End If
Else
nBase = SLong2ULong(Monsterrec.Experience)
nBase = Round(nBase / divisor)
If nBase <= 0 Then nBase = 1
Monsterrec.Experience = ULong2SLong(nBase)
End If