Talk:GetPlayerLevel - Game
Jump to navigation
Jump to search
SetPlayerLevel[edit source]
Function SetPlayerLevel(Int aiLevel)
Actor Player = Game.GetPlayer()
; First get the total xp gained since level 1.
Int TotalXP = Player.GetValue(Experience) as int
; Calculate total xp for the passed in level.
Float TotalXPForLvl = 37.5 * aiLevel * aiLevel + 87.5 * aiLevel - 124
Float TotalXPRemaining = TotalXPForLvl - TotalXP
Player.SetValue(Experience, TotalXP + TotalXPRemaining)
EndFunction
This takes the difference between the total experience gained and the total experience for a particular level and adds the result to the total experience gained. You just need the Actor Value experience. Don't get too excited.. while it works as intended and will set the player's level to the level chosen, unfortunately, the UI will still display the XP counter, which will keep on counting til it reaches the result. This can take a really long time if say you want to level up 50 times. All the XP based functions do this, as well as the console command version of this function, and I have not found a way around it. --Lisselli (talk) 2017-05-15T06:14:43 (EDT)