HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

quick loop q

03-26-2005, 12:27 AM#1
TheNyne
Okay, I'm using a loop, and I was wondering if I could have multiple exitwhen functions. Like exitwhen blah == blah or exitwhen blah == blah. But everytime I try that(that's how I was told to do it) after I save, WE crashes.

What I want, is for the loop to end when the specific unit is dead, or after a certain amount of time. Could someone show me how to do that?
Code:
exitwhen ( not ( IsUnitAliveBJ(udg_u) == false ) ) or exitwhen udg_t == 10

Could someone show me how to properly do this?
03-26-2005, 12:56 AM#2
curi
show us the whole loop

PS change
not ( IsUnitAliveBJ(udg_u) == false )
to
IsUnitAliveBJ(udg_u) == true
your way is silly
03-26-2005, 01:00 AM#3
TheNyne
I want it to end when the unit is dead, but I don't know JASS to well, but going by your way, wouldn't I just change 'true' to 'false' for it to equal being dead? Anyway, here is the full trigger. Not that some of things are in there just for testing(the Arrow Tower being the attacking unit). It will change to a tower called 'Blazed Tower' after I make it, just wanted to make the trigger before I forgot how to do it.
Code:
Blazed Tower
    Events
        Unit - A unit Is issued an order targeting an object
    Conditions
        Or - Any (Conditions) are true
            Conditions
                (Unit-type of (Attacking unit)) Equal to Arrow Tower (Level 1)
    Actions
        Custom script:   local unit udg_u
        Custom script:   local unit udg_au
        Custom script:   local effect udg_sfx
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Unit-type of (Attacking unit)) Equal to Arrow Tower (Level 1)
            Then - Actions
                Custom script:   loop
                Custom script:   exitwhen ( not ( IsUnitAliveBJ(udg_u) == false ) )
                Set u = (Attacked unit)
                Set au = (Attacked unit)
                Unit - Order au to damage u for 50.00 using attack type Normal and damage type Normal.
                Special Effect - Create a special effect attached to the chest of u using Environment\LargeBuildingFire\LargeBuildingFire2.mdl
                Set sfx = (Last created special effect)
                Wait 0.90 seconds
                Special Effect - Destroy sfx
                Custom script:   endloop
            Else - Actions

Edit:Didn't put the or in there, just because that is what I want to know how to do.
03-26-2005, 07:34 AM#4
PitzerMike
Custom script: exitwhen IsUnitAliveBJ(udg_u) or (udg_t == 10)
03-26-2005, 11:48 AM#5
Vexorian
As for the first question, the answer is yes, you can have multiple exitwhen inside the loop
03-26-2005, 11:41 PM#6
TheNyne
Yea, I figured out how it all works. And using the exitwhen blah = blah or blah = blah, I was told that it works just the same, and better if I do it as:
exitwhen blah = blah
exitwhen blah = blah

As 2 lines of code as opposed to 1. Thanks anyways.