• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] 3 questions, just for clarification

Status
Not open for further replies.
Level 5
Joined
Sep 19, 2006
Messages
152
1) Is it better to use something like RACE_UNDEAD or its converted version ConvertRace (3)? And, if RACE_OTHER is ConvertRace (7), then what is ConvertRace (6?)

2) Is there any efficiency difference between a trigger event-triggering every 30 seconds, or triggering only once and then running itself after a 30-second wait, like:

call TriggerSleepAction (30.00)
call TriggerExecute (GetTriggeringTrigger ())

3) In a trigger's condition part, is it necessary to assign and null a variable if it is referenced only once, like:

function Trigger_Condition01
return GetTriggerUnit () = udg_unit
endfunction
 
Level 5
Joined
Dec 17, 2007
Messages
145
1) Either will work ok, I suppose, since RACE_UNDEAD just fills in with the value "ConvertRace (3). I don't know what ConvertRace(6) is.

2) I'd do the former, as the latter can cause problems with timing.

3) That's impossible. You cannot return something like that, as it is not returning a boolean... or anything, for that matter.
To answer your question correctly, this:
return IsUnitAlly(Player(0), GetFilterUnit())
Would be just fine. It wouldn't leak or anything, and assigning a variable would be just plain stupid (since it couldn't be nulled).
 
Level 20
Joined
Apr 22, 2007
Messages
1,960
1) It's always better to use the globals. Meaning, better to use RACE_UNDEAD than ConvertRace(3), since ConvertRace() is a function, and calling it takes time. Referring to the global takes alot less time.

2) Yes. TriggerSleepAction() is extremely inaccurate, so I wouldn't do that if I were you. Something you could do is a timer, and in the timer callback you'd do call TriggerExecute(yourtrigger), but in that case you'd have to attach the trigger to the timer and.... bah... wayyy too complex just for this. Much better to make a periodic event'd trigger.

3) I don't understand... only local handles have to be nulled, and in that situation, you're using 1:a value returned from a function and 2:a global variable. You only need to null local handles.

And also, please learn to use the
JASS:
 tags. It makes things easier to read for all of us :P

EDIT: Geez I'm slow...
 
Level 5
Joined
Dec 17, 2007
Messages
145
Actually, you're thinking of PolledWait() that's innacurate. TriggerSleepAction is very accurate (unless you need like .00000000002 second waits, in which you're fucked anyways). 30 second waits would be right on the mark unless something SERIOUSLY wrong happened.

You wouldn't have to attach the trigger... >.>

JASS:
function B takes nothing returns nothing
call DestroyTimer(GetExpiredTimer())
  call ExecuteTrigger(InsertArgumentValueHere)
endfunction

function A takes nothing returns nothing
  local timer t = CreateTimer()
//other locals and then any actions you want done
  call TimerStart(t, 30., false, function B)
endfunction


This may leak a timer, so don't shoot me if it does.
 
Level 5
Joined
Dec 17, 2007
Messages
145
THAT'S A POLLEDWAIT().

Oy vey people! And the minimum time of a PolledWait() is 2.1 I believe, not 2.7

AGH!!!! TRIGGERSLEEPACTION() does not have a minimum time! It runs regardless of pause or lag! POLLEDWAIT() IS THE ONE THAT DOES THAT! IT RUNS ACCORDING TO GAME-TIME! TRANSLATE A GUI TRIGGER WITH WAIT AND WAIT (GAME-TIME) AND SEE WHAT YOU GET!!!

God. Sorry about that, bad day, and this just set me off. Hard.
 
Level 5
Joined
Dec 17, 2007
Messages
145
I never said TriggerSleepAction is better than timers. Ever. And if you needed a wait of something tiny like .005 seconds, a timer would obviously be your choice. But for something like 30 seconds, either works. It depends on your prefence and which is more convenient.


HINDYhat said:
I'm very mixed up now. What you're telling me is completely the opposite of what everyone has told me for ever... including moderators on this site and on other sites and very respectable people.
Yes. From what I've learned, if you take a GUI trigger with the two actions "Wait" and Wait-Game time" and make them JASS, you get TriggerSleepAction and PolledWait, respectively. Now, reading the GUI action for Wait-Game Time, it mentions that it will factor in lag and pauses.

Also, if you look at PolledWait()'s composition, the timer it runs ends early, whereas TriggerSleepAction does not... since it's a Native and PolledWait() actually USES TSA in it.
 
Level 5
Joined
Dec 17, 2007
Messages
145
Hey, I'm going with what I remember.

If you prove me wrong then by all means I'll believe you. If I do remember correctly:

TSA has no 'minimum', will run despite pause or lag, and is used in PolledWait()

PW has a 'minimum' of about .21 seconds (it will always be that short unless the given value is higher), will stop for pausing and lagging, and uses timers.

I do believe they run at the same 'speed' though.
 
Level 11
Joined
Feb 22, 2006
Messages
752
TSA has no 'minimum'

Um.....try scripting a knockback with a loop and triggersleepaction set to 0.04. If TSA actually waited only 0.04 seconds (meaning it has no min. time), that knockback would run smooth. But that's not what happens, instead you basically get a slide show in your game. If TSA had no min time, there would be no point in using timers to script knockback and other periodic events that require really small timeouts. Think about it, with timers you have to create and destroy timers, and use either structs or attached handles to transfer locals from the function starting the timer to the timer callback function. You wouldn't have to do any of that if TSA worked like you say it works.

If you don't believe me listen to Daelin:

You probably all know that the minimum value for TriggerSleepAction is 0.27

http://www.hiveworkshop.com/forums/showthread.php?t=22710

Just wanted to clear that one thing up; don't want people to be gettin wrong info.
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
Also, I highly doubt PolledWait is less accurate than TriggerSleepAction. Have you ever read the function?

JASS:
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 we have a bit of time left, skip past 10% of the remaining
            // duration instead of checking every interval, to minimize the
            // polling on long waits.
            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

It can get bad at small intervals... but so does TSA can. By the way, the minimum value is .1. Judging by the ~.27 minimum of a TSA, that won't make much of a difference.

Anyhow, I find that TSA gets less accurate from delay and leaks, and PW minimizes the effect due to its synching with a timer.
 
Level 5
Joined
Sep 19, 2006
Messages
152
Well, I didn't think everyone would get so excited about some questions like these. For my Question 3, though, here is an example:

JASS:
function HeroesDeath_Condition01 takes nothing returns boolean
    local unit u          = GetDyingUnit ()
    local boolean b
//
    if IsUnitIllusion (u) then
        set b = false
    else
        set b = IsUnitType (u, UNIT_TYPE_HERO)
    endif
    set u = null
    return b
endfunction

And HINDYhat, I didn't use the JASS tags because I figured it was only a couple of short lines, so no one would have a seizure over it.

Thanks for the feedback!
 
Level 3
Joined
Sep 4, 2007
Messages
49
TriggerSleepAction()= ultimate evil
The wait goes through pauses and is very innacurate in short periods. It seems to bypass certain things and in some situations can even cause desyncs especially when dealing with local code
 
Status
Not open for further replies.
Top