Cobal Posted June 12, 2023 Share Posted June 12, 2023 (edited) As the title says, I need to something like a timer that does not slow down while VATS or Jet is active. problem is, I use papyrus like 3 times every bethesda game so I don't really know it's proper tricks. What I actually need is something that triggers an event every 0.5 seconds while the effect I am working on is active, It's not a constant thing, it will just be ticking for 2 minutes. What I am making is intended to run Only while slow time is active. Options I'm thinking of now: -A while loop that checks real time passed since while loop started and then cuts out at 0.5 seconds passed is an option, but it's a while loop and a mild waste of script time. -Add a dummy sound that lasts 0.5 seconds and then use playandwait in some function to get my desired delay. I think that is easier on the script engine but I do not know for sure. What would you advise me to do? Is the dummy sound a good idea, should I stick with the whileLoop, or do you perhaps know of something I can register for that reliably goes bump every half second? Cheers for any help Edited June 12, 2023 by Cobal Link to comment Share on other sites More sharing options...
niston Posted June 12, 2023 Share Posted June 12, 2023 Utility.Wait(0.5) Link to comment Share on other sites More sharing options...
Cobal Posted June 12, 2023 Author Share Posted June 12, 2023 (edited) Utility.Wait(0.5)That slows down together with VATS and other slow time effects so I cant use it. The other timers mentioned in the CK wiki are all useless when slow time is running. The thing I am making will run only during VATS or while Jet is active, maybe the time as a variable and then something likefloat waittime = 0.5 * GetCurrentTimeSPeedMultiplier (if a function to get whatever the current slow time multiplier is exists)Utility.Wait(waittime) Not sure if the timer excepts more then 2 digits, VATS runs at a 0.004 time multiplier. Also, 0.002 waiting, while slow time is not running that is less then a single frame. My gut feeling says that's bad. Edited June 12, 2023 by Cobal Link to comment Share on other sites More sharing options...
dylbill Posted June 13, 2023 Share Posted June 13, 2023 Do you know if Utility.GetCurrentRealTime() is affected by VATS? That gets the number of seconds since the game has been launched. If it's not affected by VATS you could do something like this: Function WaitLoop(float afSeconds) Float CurrentTime = Utility.GetCurrentRealTime() While (Utility.GetCurrentRealTime() - CurrentTime) < afSeconds ;wait until difference is greater than or equal to afSeconds EndWhile EndFunctionIt's not the most performance friendly function, but for short durations shouldn't be much of a problem. Also it's accuracy would depend on how well the script engine is performing at that moment. Link to comment Share on other sites More sharing options...
Cobal Posted June 13, 2023 Author Share Posted June 13, 2023 (edited) Yep. That works. Yours is cleaner though, I dont know why I added a time difference calculation and range the time should fall between. Don't know why I didn't think of just using bloody less then. :wallbash: But since that is a bit of a waste of script time, and might have to repeat for a a minute or two, I'm looking for a better method. The other option I was thinking about was to add a dummy sound that lasts 0.5 seconds and then use playandwait in some function to get my desired delay.Something like CustomEvent SendTick function EventTicker() EmptyWav.PlayAndWait(actor) TickSender() endfunction function TickSender() SendCustomEvent("SendTick") EventTicker() endfunction {and something to stop it all} But I have no idea if that is better or worse then a whileloop. Edited June 14, 2023 by Cobal Link to comment Share on other sites More sharing options...
dylbill Posted June 14, 2023 Share Posted June 14, 2023 I think PlayAndWait would be better performance wise. I would just have different sounds of different durations for whatever wait time you need. So if you need to wait 2 minutes, just use a silent wav file that's 2 minutes long. Link to comment Share on other sites More sharing options...
niston Posted June 14, 2023 Share Posted June 14, 2023 EventTicker() calls TickSender() which calls EventTicker() which calls TickSender() which.....nets you a stack overflow sooner than later. Even more so, as Papyrus is very bad at recursion due to it's shallow stack depth. But this outcome can be completely avoided by raising an event or using a timer (that raises an event), to invoke one of the calls.Because doing so will let the current thread end, while running the call on a new thread. The upside is, you already have an event you can use: SendTick. Link to comment Share on other sites More sharing options...
DieFeM Posted June 14, 2023 Share Posted June 14, 2023 I think the duration of a magic effect is not affected by slow time. So you could use OnEffectStart and OnEffectFinish. Link to comment Share on other sites More sharing options...
Cobal Posted June 14, 2023 Author Share Posted June 14, 2023 (edited) EventTicker() calls TickSender() which calls EventTicker() which calls TickSender() which.....nets you a stack overflow sooner than later. Even more so, as Papyrus is very bad at recursion due to it's shallow stack depth. But this outcome can be completely avoided by raising an event or using a timer (that raises an event), to invoke one of the calls.I really can NOT use a timer. what I am making ONLY runs when time is slowed and that makes timers useless and unreliable. States and callfunnctioNoWait should be fine to prevent stack overflow I think. The ticker will be a separate script, a manager script turns it on and off. Only way that a timer would be usefull to me is if I set it to 10 seconds. Then it is garanteed to fire 2 seconds AFTER (because slow time) I the effect has finished and I can let that event check if a cleanup is needed. I think the duration of a magic effect is not affected by slow time. So you could use OnEffectStart and OnEffectFinish.Oh good idea, I'll go test what slow time does to effects. Cheers Edited June 14, 2023 by Cobal Link to comment Share on other sites More sharing options...
niston Posted June 14, 2023 Share Posted June 14, 2023 Forget I said anything about timers.CallFunctionNoWait() will work as well. Link to comment Share on other sites More sharing options...
Recommended Posts