• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Waits with anything other than spells

Status
Not open for further replies.

hdm

hdm

Level 9
Joined
Nov 19, 2011
Messages
384
Waits are only useless in spells ? They make it not MUI, are inaccurate, I know. But about anything else ? Like I have a trigger "Pick every player in all player and do actions: action, WAIT x Seconds, other action..."Will it work ?
 
Level 13
Joined
Mar 24, 2013
Messages
1,105
It's best to post your trigger so we can look at it and give more guided replies but...

Something simple like

Turn off trigger
Wait x
Turn on trigger

will work just fine yes
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
Waits do remove the certainty of the (standard) global values, all event responses "could" be overridden by the time that the wait ends.
That is why wait timers do remove the MUI aspect of the triggers... unless you use local variables
"Custom script - local unit udg_MyGlobalVariableIsSavedAfterWaits" will keep track of your nice global variable :)

Having waits is inaccurate yes, but do you need your effect to be perfectly accurate?
Using timers (replacement of waits) efficiently, forces you to use JASS instead of GUI, which could be a pain in the ass.
But back to the point. If you have something like a buff, or use it in a loop, the effect could make a big difference.
Waits add a random value between 0s and 0,2s to the wait (because of how they are made) and they would be a pain in the ass if you would have that value added to a loop that runs the whole game (ex. unit spawn, special effects, clocks, etc.)
They would be very inaccurate.

But if you use them in stuff like "The hero quickly dashes between 2 points dealing damage to everyone between it." has no need for perfect timing. You just use a 0.01 wait (0.15 ~ 0.16) and it would work fine.

So it all depends on what you want and how you have your data stored.
Next to that... what would you want to use waits for?
 
  • Like
Reactions: hdm
Level 29
Joined
Oct 24, 2012
Messages
6,543
Waits do remove the certainty of the (standard) global values, all event responses "could" be overridden by the time that the wait ends.
That is why wait timers do remove the MUI aspect of the triggers... unless you use local variables

Waits do not remove the MUI aspect of triggers. If the above is your basis for why they do then timers also remove MUI.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,225
How can you be sure that naives are leakless?
I cannot... However I can be sure that it does not do this...
waits leak a timer handle.. if used too much it can couse performance issues
I think that Sleep Action works the same as polledwait but only negating gamespeed.
Nope, you see here are their declarations.
JASS:
native TriggerSleepAction takes real timeout returns nothing
function PolledWait takes real duration returns nothing
    local timer t
    local real  timeRemaining
    if (duration > 0) then
        set t = CreateTimer()
        call TimerStart(t, duration, false, null)
        loop
            set timeRemaining = TimerGetRemaining(t)
            exitwhen timeRemaining <= 0
            if (timeRemaining > bj_POLLED_WAIT_SKIP_THRESHOLD) then
                call TriggerSleepAction(0.1 * timeRemaining)
            else
                call TriggerSleepAction(bj_POLLED_WAIT_INTERVAL)
            endif
        endloop
        call DestroyTimer(t)
    endif
endfunction
So you see, one is a native while the other is a leaky BJ. The leak is due to the local handle reference counter bug. The handle used for the timer is never recycled.
 
Waits have a use, usually with longer periods of waiting. Especially in GUI. There is no rule that they can't be used within a spell's loop. It all depends on how accurate you want (waits are not that accurate as they depend on latencies).There are several exceptions to this of course; They open up the issue of having global variables change in value, or the event responses changing what they return. Local variables and global variable indexing can be used to solve this.In JASS timers can be used much more effectively than in GUI. They are precise, and can repeat. They also can have a callback function. The only time a wait can't be used is within a conditional function. That is, a function that is registered as a trigger's condition or as the filter function provided to various enumerating functions. You can't get at these functions from within GUI however.
 
Status
Not open for further replies.
Top