| 01-31-2004, 09:44 AM | #1 |
Hey, remember that trigger that looked fine but didnt fire correctly? The one with the chain lightnings? Well, I shouldve known what the problem was, the GUI "code" was fine but as many of you will know waits inside for/loops dont work correctly, but I NEED waits for it to work, I tried it without waits and it fired correctly but the casters need more time to cast their spells, so could any JASS user convert these three triggers to JASS for me with waits between the give points plz (0.40 sec). Code:
CN1
Events
Conditions
Actions
For each (Integer A) from 1 to 3, do (Actions)
Loop - Actions
Set CNTargets1[(Integer A)] = (Random unit from (Units within 600.00 of (Position of DummyCaster1) matching ((((Matching unit) belongs to an enemy of (Owner of UCNCastingUnit)) Equal to True) and (((((Matching unit) is A structure) Equal to False) and ((Matching unit) Not equal to CNTarge
Game - Display to (All players) the text: (CNTarget1[Integer A] = + ((Name of CNTargets1[(Integer A)]) + (Loop Number: + (String((Integer A))))))
Unit - Order DummyCaster1 to Orc Far Seer - Chain Lightning CNTargets1[(Integer A)]
Wait 0.40 seconds
Unit - Move DummyCaster1 instantly to (Position of CNTargets1[(Integer A)])
CN2
Events
Conditions
Actions
For each (Integer A) from 1 to 3, do (Actions)
Loop - Actions
Set CNTargets2[(Integer A)] = (Random unit from (Units within 600.00 of (Position of DummyCaster2) matching ((((Matching unit) belongs to an enemy of (Owner of UCNCastingUnit)) Equal to True) and (((((Matching unit) is A structure) Equal to False) and ((Matching unit) Not equal to CNTarge
Game - Display to (All players) the text: (CNTarget2[Integer A] = + ((Name of CNTargets2[(Integer A)]) + (Loop Number: + (String((Integer A))))))
Unit - Order DummyCaster2 to Orc Far Seer - Chain Lightning CNTargets2[(Integer A)]
Wait 0.40 seconds
Unit - Move DummyCaster2 instantly to (Position of CNTargets2[(Integer A)])
CN3
Events
Conditions
Actions
For each (Integer A) from 1 to 3, do (Actions)
Loop - Actions
Set CNTargets3[(Integer A)] = (Random unit from (Units within 600.00 of (Position of DummyCaster3) matching ((((Matching unit) belongs to an enemy of (Owner of UCNCastingUnit)) Equal to True) and (((((Matching unit) is A structure) Equal to False) and ((Matching unit) Not equal to CNTarge
Game - Display to (All players) the text: (CNTarget3[Integer A] = + ((Name of CNTargets3[(Integer A)]) + (Loop Number: + (String((Integer A))))))
Unit - Order DummyCaster3 to Orc Far Seer - Chain Lightning CNTargets3[(Integer A)]
Wait 0.40 seconds
Unit - Move DummyCaster3 instantly to (Position of CNTargets3[(Integer A)])/Thx in advance. If you need any more information, just tell me. |
| 01-31-2004, 02:04 PM | #2 |
Are you ordering all three triggers to run at the same time? if you are it can explain why its not working when the each trigger waits the other one is incrementing it and it already hits 3 before you wanted it to because you are using the same integer in your loop. This is the evil of global variables. You can just convert it to custom text your self you realize right? Also that set statement looks far too big for its own good I would set a meditary unit group then set the unit to a ran unit from it. As I myself have had the function with in a function with in a function... cause the thread to die. |
| 01-31-2004, 02:14 PM | #3 |
Ummmm, those are three separate triggers you know, they are ran from another one. Ive use loops like for each integer A from 1 to 20 do: blabla unit[integer A] do ... next action: for each integer A from 1 to 20 do: blabla something[integer A] do... IN the same trigger, but if you really believe youre right then what should I do? (I do not believe I use the same variable in any of the three loops, if there is, I mustve overlooked it so tell me please.) btw: I know I am by far the most unefficient trigger writer ever but I like to make them readable for myself. btw2: Just converting it to custom text will make it work??? If it does, thats amazing. |
| 01-31-2004, 02:28 PM | #4 |
I'm saying all three loops are using IntegerA if they are run at the same time. Are you running them one after another? I don't know thats what I'm asking. I.e. does your code look a little like this? Trigger-Run Trigger CN1 Trigger-Run Trigger CN2 Trigger-Run Trigger CN3 it would be just fine if it was for integer a 1 to 8 do this blah blah then for integer a 1 to 8 do this blah blah Because then worldedit resets the integer a to one after the first loop ends. As far as your wait problem waits do work in loop so it may be the problem with the set statement killing it. and no converting to custom text won't fix anything/ |
| 01-31-2004, 04:29 PM | #5 |
Yes my precedenting trigger has a part that looks like this Code:
Trigger - Run Trigger CN1 Trigger - Run Trigger CN2 Trigger - Run Trigger CN3 So it makes sense what you say, I already have an idea as to solving this problem... I just pick the for loop: Code:
for each integer variable 1 to 3 do: actions: Blablabla And I'll just make three integer variables and use those as "integer A". That should work right? |
| 01-31-2004, 04:32 PM | #6 |
try it it should atleast in theory work better then before. You actually only need one. You use Integer A, Integer B, and your custom integer. |
| 01-31-2004, 05:29 PM | #7 |
Instead of using integer A, B and a custom, make the custom an array CustomLoopVars and then you could use CustomLoopVars[0], CustomLoopVars[1], and CustomLoopVars[2] If you need multiple loops again later, you can just reuse them to get any number of loops you want |
| 01-31-2004, 06:07 PM | #8 |
I was planning on doing that but it doesnt make that much difference now does it? I mean, Weaaddar is really holding on to the fast that each array uses the max of its entries instead of the ones you specify and thus it takes an unnecesary amount of memory. Since I only need to loop once (its for a spell creation thread) I think I'll be better of with jsut 3 diff variables. |
| 01-31-2004, 06:22 PM | #9 |
As far as even more memory conscience idea you can convert your script to all use local variables in place of the globals. and if you really hate globals like I do you can just use game cache vars. |
