enderalse/scripts/source/_00e_fs_fortifysummonssc.psc

70 lines
2.2 KiB
Plaintext
Raw Normal View History

Scriptname _00E_FS_FortifySummonsSC extends activemagiceffect
Actor Property PlayerREF Auto
Perk Property _00E_FS_PhasmalistEnchantment Auto
2021-10-05 22:59:59 +00:00
Actor Target
Event OnEffectStart(Actor akTarget, Actor akCaster)
2021-10-05 22:59:59 +00:00
Target = akTarget
2021-10-05 22:59:59 +00:00
If Target
If PlayerREF == None
PlayerREF = Game.GetPlayer()
EndIf
If _00E_FS_PhasmalistEnchantment == None
_00E_FS_PhasmalistEnchantment = Game.GetFormFromFile(0x102F5A1, "Enderal - Forgotten Stories.esm") as Perk
EndIf
AdjustValues(True)
RegisterForSingleUpdate(3)
EndIf
EndEvent
Event OnUpdate()
2021-10-05 22:59:59 +00:00
AdjustValues(False)
RegisterForSingleUpdate(3)
EndEvent
2021-10-05 22:59:59 +00:00
Function AdjustValues(Bool bForceEnchantmentStrength)
Float fNewModifier = PlayerREF.GetAV("FavorPointsBonus") / 100.0
Float fOldModifier = Target.GetAV("FavorPointsBonus") / 100.0
If (fNewModifier != fOldModifier) || bForceEnchantmentStrength
_00E_FS_PhasmalistEnchantment.SetNthEntryValue(0, 0, 1.0 + fNewModifier)
EndIf
2021-10-05 22:59:59 +00:00
If fNewModifier == fOldModifier
Return ; Nothing changed
EndIf
2021-10-05 22:59:59 +00:00
Float fMaxHealth = GetTargetMaxValue("Health")
Float fMaxMagicka = GetTargetMaxValue("Magicka")
If fMaxHealth < 0.0 || fMaxMagicka < 0.0
Return ; Bad current health or magicka to deal with, wait for better ones
EndIf
2021-10-05 22:59:59 +00:00
Target.SetAV("FavorPointsBonus", fNewModifier * 100.0)
Target.ModAV("AttackDamageMult", fNewModifier - fOldModifier)
AdjustTargetMainValue("Health", "FavorsPerDay", fMaxHealth, fNewModifier)
AdjustTargetMainValue("Magicka", "FavorsPerDayTimer", fMaxMagicka, fNewModifier)
EndFunction
2021-10-05 22:59:59 +00:00
Float Function GetTargetMaxValue(String sValueName)
Float fValue = Target.GetAV(sValueName)
Float fPercentage = Target.GetActorValuePercentage(sValueName)
If fValue > 0.0 && fPercentage > 0.0
Return Math.Ceiling(fValue / fPercentage)
Else
Return -1.0 ; We are dealing with bad numbers, nothing good would come out of (fValue / fPercentage)
EndIf
EndFunction
2021-10-05 22:59:59 +00:00
Float Function AdjustTargetMainValue(String sValueName, String sStoreValueName, Float fMaxValue, Float fNewModifier)
Float fNewBuff = Math.Floor(fMaxValue * fNewModifier)
Float fOldBuff = Target.GetAV(sStoreValueName)
If fNewBuff != fOldBuff
Target.ModAV(sValueName, fNewBuff - fOldBuff)
Target.SetAV(sStoreValueName, fNewBuff)
EndIf
EndFunction