enderalse/scripts/source/_00e_fs_fortifysummonssc.psc

63 lines
2.2 KiB
Plaintext

Scriptname _00E_FS_FortifySummonsSC extends activemagiceffect
float fBuffedHealthNewAV
float fBuffedMagickaNewAV
Actor Property PlayerREF Auto
Perk Property _00E_FS_PhasmalistEnchantment Auto
Event OnEffectStart(Actor akTarget, Actor akCaster)
If PlayerREF == NONE
PlayerREF = Game.GetPlayer()
EndIf
float fModifier = PlayerREF.GetActorValue("FavorPointsBonus")/ 100.0
If akTarget.GetActorValue("FavorPointsBonus") == 0
AdjustValues(akTarget, fModifier, 0.0)
EndIf
RegisterForSingleUpdate(3)
EndEvent
Event OnUpdate()
If PlayerREF == NONE ;debug only
PlayerREF = Game.GetPlayer()
EndIf
float fNewModifier = PlayerREF.GetActorValue("FavorPointsBonus")/ 100.0
float fCurrentModifier = GetTargetActor().GetActorValue("FavorPointsBonus")/100.0
If fNewModifier != fCurrentModifier
AdjustValues(GetTargetActor(), fNewModifier, fCurrentModifier)
EndIf
RegisterForSingleUpdate(3)
EndEvent
Function AdjustValues(Actor _Target, float _fNewModifier, float _fCurrentModifier)
float fBuffedHealthOldAV = _Target.GetActorValue("FavorsPerDay")
float fBuffedMagickaOldAV = _Target.GetActorValue("FavorsPerDayTimer")
_Target.ModAV("AttackDamageMult", _fNewModifier-_fCurrentModifier)
fBuffedHealthNewAV = ((GetMaximumActorValue(_Target, "Health")-fBuffedHealthOldAV)*_fNewModifier) as Int
fBuffedMagickaNewAV = ((GetMaximumActorValue(_Target, "Magicka")-fBuffedMagickaOldAV)*_fNewModifier) as Int
_Target.ModAV("Health", (fBuffedHealthNewAV-fBuffedHealthOldAV as Int))
_Target.ModAV("Magicka", (fBuffedMagickaNewAV-fBuffedMagickaOldAV as Int))
_Target.SetActorValue("FavorsPerDay", fBuffedHealthNewAV)
_Target.SetActorValue("FavorsPerDayTimer", fBuffedMagickaNewAV)
If _00E_FS_PhasmalistEnchantment == NONE
_00E_FS_PhasmalistEnchantment = Game.GetFormFromFile(0x102F5A1, "Enderal - Forgotten Stories.esm") as Perk
EndIf
_00E_FS_PhasmalistEnchantment.SetNthEntryValue(0, 0, 1+_fNewModifier)
_Target.SetActorValue("FavorPointsBonus", _fNewModifier*100.0)
EndFunction
Float Function GetMaximumActorValue(Actor _Actor, String _sValueName)
Float CurrentMaxValue = Math.Ceiling(_Actor.GetActorValue(_sValueName) / _Actor.GetActorValuePercentage(_sValueName))
return CurrentMaxValue
EndFunction