Jump to content

Runaway Timer dangerous?


The6thMessenger

Recommended Posts

Scriptname MinigunSpinupDispel extends ActiveMagicEffect
ActorValue Property HasChaingun Auto
Event OnEffectStart(Actor akTarget, Actor akCaster)
- StartTimer(0.1,1)
EndEvent
Event OnTimer(int aiTimerId)
- if aiTimerId == 1
- - Float Chaingun = Game.GetPlayer().GetValue(HasChaingun)
- - If Chaingun <= 0
- - - self.dispel()
- - elseif Chaingun > 0
- - - StartTimer(0.1,1)
- - endif
- endif
EndEvent
Event OnEffectFinish(Actor akTarget, Actor akCaster)
- CancelTimer(1)
Endevent

 

That's a custom script for a persistent-checking MGEF, it checks if actor has x every 0.1s, and would dispel if not true.

 

Now supposed that like 90 of these are running at the same time, is it safe or unsafe?

Link to comment
Share on other sites

A bit strange thing to script, but having too many active timers is not good, since almost any register based event is locket into frame rate and each event will require 1 frame, so if you have i lot you can end up with 1 fps.... You are violating important performance rule here: do not use timers to check your stuff, use events!

Edited by Engager
Link to comment
Share on other sites

A bit strange thing to script, but having too many active timers is not good, since almost any register based event is locket into frame rate and each event will require 1 frame, so if you have i lot you can end up with 1 fps.... You are violating important performance rule here: do not use timers to check your stuff, use events!

This is not quite right. Scripts will not impact FPS performance - they will impact the performance of other scripts.

 

That being said, it would be a good idea, The6thMessenger, to look over this Creation Kit Wiki article (written by the guy who designed and implemented Papyrus in Skyrim). What Engager is saying about events versus timers is definitely true from a performance standpoint, though.

Edited by Reneer
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...