HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Interrupts in TriggerEvaluate!

01-11-2008, 05:58 PM#1
rain9441
Be forewarned. I tracked a bug today where my TriggerEvaluate was interrupted.

In some cases, if you issue an order to a unit to use an ability or something, certain triggers may fire, halting your function.

In my case, I was ordering a unit to cast a spell. That spell was instant-cast. If the unit was facing the right direction it would INSTANTLY take over the thread right when I called IssueTargetOrder, run all the triggers, then and only then would my script continue running.

So theres a chance when you issue an order that the spell will already be cast before you get to the next line of code.

Similar things occur when giving orders I believe, as well as items?

Heres a little sample of what may occur.

Collapse JASS:
    ...
    set GlobalVariable = 10
    call IssueTargetOrderById(someUnit, someOrder, someTarget)
    if ( GlobalVariable == 10 ) then
        // Maybe this is 10
    else
        // Maybe not.
    endif
    ...

I could see this causing some serious problems. In the time between issuing the target order and checking the global variable, the Starts Channel, Starts Effect, Finish Cast, and Ends Cast triggers got evaluated.
01-11-2008, 07:50 PM#2
Vexorian
IssueTargetOrder/Etc were known to cause other triggers to run before your thread ends, I don't think this is specific to TriggerEvaluate.
01-11-2008, 08:33 PM#3
cohadar
I order spell casting only to dummy units.

But then again it would be good if there was some way to prevent dummies from evaluating spell triggers.
01-11-2008, 11:29 PM#4
Vexorian
Quote:
But then again it would be good if there was some way to prevent dummies from evaluating spell triggers.

If ability level of 'Aloc' is greater than 1 , return false in conditions

..
It is cool sometimes to make a dummy cast an spell that is "triggered" mostly because it saves some extra hassle, and if you had something like spell templates it is quite possible to see it happening.

I think this is only a big issue if your global variables are actually... globals... Should make stuff private and keep some modularity.
01-12-2008, 12:45 AM#5
DioD
damage orders and other event related stuff jump to other trigger.

this is hard to use same globals everywhere soo just use locals.