Skip to content

Instantly share code, notes, and snippets.

@LaughingLeader
Created September 9, 2020 18:15
Show Gist options
  • Save LaughingLeader/e5904c5c83735c29fe2915a97044d5dd to your computer and use it in GitHub Desktop.
Save LaughingLeader/e5904c5c83735c29fe2915a97044d5dd to your computer and use it in GitHub Desktop.
Vitality scaling functions transcribed from decompiled code. For Divinity: Original Sin 2 - Definitive Edition.
import numpy as np
class ExtraDataClass():
def Reset(self):
setattr(self, "VitalityStartingAmount", 21)
setattr(self, "VitalityExponentialGrowth", 1.25)
setattr(self, "VitalityLinearGrowth", 9.091)
setattr(self, "VitalityToDamageRatio", 5)
setattr(self, "VitalityToDamageRatioGrowth", 0.2)
setattr(self, "FirstVitalityLeapLevel", 9)
setattr(self, "FirstVitalityLeapGrowth", 1.25)
setattr(self, "SecondVitalityLeapLevel", 13)
setattr(self, "SecondVitalityLeapGrowth", 1.25)
setattr(self, "ThirdVitalityLeapLevel", 16)
setattr(self, "ThirdVitalityLeapGrowth", 1.25)
setattr(self, "FourthVitalityLeapLevel", 18)
setattr(self, "FourthVitalityLeapGrowth", 1.35)
setattr(self, "VitalityBoostFromAttribute", 0.07)
def __init__(self):
self.Reset()
ExtraData = ExtraDataClass()
def GetVitalityGrowth(level):
expGrowth = ExtraData.VitalityExponentialGrowth
growth = expGrowth ** (level - 1)
if level >= ExtraData.FirstVitalityLeapLevel:
growth = growth * ExtraData.FirstVitalityLeapGrowth / expGrowth
if level >= ExtraData.SecondVitalityLeapLevel:
growth = growth * ExtraData.SecondVitalityLeapGrowth / expGrowth
if level >= ExtraData.ThirdVitalityLeapLevel:
growth = growth * ExtraData.ThirdVitalityLeapGrowth / expGrowth
if level >= ExtraData.FourthVitalityLeapLevel:
growth = growth * ExtraData.FourthVitalityLeapGrowth / expGrowth
return growth
def CalculateVitalityBoostByLevel(level):
growth = GetVitalityGrowth(level)
vit = level * ExtraData.VitalityLinearGrowth + ExtraData.VitalityStartingAmount * growth
return np.round(vit / 5.0) * 5.0
def GetVitalityScalar(level, baseVitality):
vitalityBoost = np.round((level * ExtraData.VitalityLinearGrowth) + (ExtraData.VitalityStartingAmount * GetVitalityGrowth(level))) / 5 * 5.0
return vitalityBoost * baseVitality / 100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment