enderalse/source/scripts/_00E_Func_ComputeNeededExp.psc

56 lines
2.1 KiB
Plaintext

Scriptname _00E_Func_ComputeNeededExp Hidden
import Math
float Function Run(int CurrentLevel, float Slope, float Mult, float fExpAcc = 1.0, float fExpAcc_Level20 = 1.2, float fExpAcc_Level30 = 1.5, float fExpAcc_Level40 = 2.0) Global
{Computes the total Experience (EP) needed by the player to reach the level CurrentLevel + 1. This includes the experience needed for the previous level.}
if SKSE.GetVersion()
return EnderalFunctions.ComputeNeededExp(CurrentLevel, Slope, Mult, fExpAcc, fExpAcc_Level20, fExpAcc_Level30, fExpAcc_Level40);
endif
; This can be used as a quick way to scale the leveling process
; for all levels:
;float fExpAcc = 1.0
;float fExpAcc_Level20 = 1.2
;float fExpAcc_Level30 = 1.5
;float fExpAcc_Level40 = 2.0
Mult *= fExpAcc
If CurrentLevel <= 20
; no changes to the old formula until level 20.
return pow(CurrentLevel, Slope) * Mult
Else
; no changes to the old formula for the first 20 levels.
float result = pow(20, Slope) * Mult
; Progressive taxation:
if CurrentLevel <= 30
result += (pow(CurrentLevel, Slope) - pow(20, Slope)) * Mult * fExpAcc_Level20
return result
elseif CurrentLevel <= 40
result += (pow(30, Slope) - pow(20, Slope)) * Mult * fExpAcc_Level20
result += (pow(CurrentLevel, Slope) - pow(30, Slope)) * Mult * fExpAcc_Level30
return result
else
result += (pow(30, Slope) - pow(20, Slope)) * Mult * fExpAcc_Level20
result += (pow(40, Slope) - pow(30, Slope)) * Mult * fExpAcc_Level30
result += (pow(CurrentLevel, Slope) - pow(40, Slope)) * Mult * fExpAcc_Level40
return result
endif
EndIf
EndFunction
; A debugging function:
;function DumpLevelCurve()
;{Dump a table of required EP for each level from 0 to 100 to the Papyrus log}
; string aua = ""
; int iIndex = 0
; while iIndex < 100
; aua += "To get to level " + (iIndex + 1) + ", you need " + ComputeNeededExp(iIndex, EXPMultSlope.GetValue(), EXPMult.GetValue()) + "EP. \n "
; iIndex += 1
; endwhile
; Debug.Trace(aua)
;Endfunction