Jump to content

Photo

OnUpdateGameTime Not being called

script skyrim papyrus magic effect active magic effect

  • Please log in to reply
3 replies to this topic

#1
Flopmind

Flopmind

    Stranger

  • Members
  • Pip
  • 2 posts

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)


#2
foamyesque

foamyesque

    Old hand

  • Members
  • PipPipPip
  • 852 posts

GameTime updates are in game hours, not seconds, so you might just not be waiting long enough. If you want an update every half second of actual time, you probably want to use just normal updates instead.

 

Also, be aware that it is considerably better practice to register for a single update (of either sort), and then in the OnUpdate block, register for the next one. It avoids orphaning the registration if something unexpected happens.


Edited by foamyesque, 04 April 2019 - 07:45 PM.


#3
ReDragon2013

ReDragon2013

    Old hand

  • Members
  • PipPipPip
  • 740 posts

I believe foamyesque gave you the right answer already.

 

flightSpeedEnchantScript

Spoiler


#4
Flopmind

Flopmind

    Stranger

  • Members
  • Pip
  • 2 posts

Thank you both! The enchantment works now thanks to your help!







Also tagged with one or more of these keywords: script, skyrim, papyrus, magic effect, active magic effect

IPB skins by Skinbox
Page loaded in: 1.262 seconds