Hello fellow modders. I'm trying to get a custom enchantment working for a skyrim mod, but the papyrus script on the magic effect does not want to cooperate. I registered for UpdateGameTime(), made sure it was being called by using Debug.Trace in the same place that RegisterForUpdateGameTime(0.5) (for every half second, right?) is being called, and have not called wait() anywhere, so I don't know why OnUpdateGameTime is being called. The boots that the enchantment is attached to have the enchantment and magic effect applied properly, so I'm confident that's not the issue. The papyrus logs also write "yo" and TRUE, amidst other chaos, but nothing that appears in OnUpdateGameTime. If you can offer any insight as to what the issue may be, I would greatly appreciate it! Here's the full script:
Scriptname flightSpeedEnchant extends activemagiceffect
{This will make a magic effect increase speed based on missing health.}
import debug
Float Property maxSpeed = 1000.0 Auto
Actor target
Event OnEffectStart(Actor akTarget, Actor akCaster)
; Target Actor
target = GetTargetActor()
self.RegisterForUpdateGameTime(0.5)
Debug.Trace("yo")
Debug.Trace(target == Game.GetPlayer())
endEvent
Event OnUpdateGameTime()
Debug.Trace("HI THERE FUTURE ME!")
Float percentage = 1 - (target.GetActorValuePercentage("Health"))
Float baseSpeed = target.GetActorValue("SpeedMult")
; adjustedSpeed = interpolate with percentage and magnitude
Float adjustedSpeed = baseSpeed + (percentage * (maxSpeed - baseSpeed))
target.SetActorValue("SpeedMult", adjustedSpeed)
Debug.Trace("percentage is: " + percentage )
Debug.Trace("baseSpeed is: " + baseSpeed)
Debug.Trace("adjustedSpeed is: " + adjustedSpeed )
Debug.Trace("target is: " + target)
Debug.Trace("maxSpeed is: " + maxSpeed )
endEvent
; Player's current health value
; Float currentHP = target.GetActorValue("Health")
; Player's max health
; Float maxHP = target.GetAVMax("Health")
; Float percentage = 1 - (currentHP / maxHP)