HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

How is this possible!!!?

12-17-2006, 05:15 PM#1
Moss
I am getting impossible behavior from an if statement. Observe:

Trigger:
ManablastStops
Collapse Actions
Game - Display to (All players) the text: blasterstop
Unit Group - Remove u from blastingnodes[i]
Unit - Remove u from the game
Game - Display to (All players) the text: (String((Number of units in blastingnodes[i])))
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Number of units in blastingnodes[i]) Equal to 0
Collapse Then - Actions
Game - Display to (All players) the text: herostopping
Else - Actions

That is just the critical parts, the full trigger is here if you want.
Hidden information:
Trigger:
ManablastStops
Collapse Events
Unit - A unit Stops casting an ability
Unit - A unit Finishes casting an ability
Collapse Conditions
(Ability being cast) Equal to Mana Blast
Collapse Actions
Custom script: local integer udg_i
Set u = (Triggering unit)
Custom script: set udg_i = GetAttachedInt(udg_u, "owner")
-------- REMOVE THE CASTER UNIT --------
Game - Display to (All players) the text: blasterstop
Unit Group - Remove u from blastingnodes[i]
Custom script: call CleanAttachedVars(udg_u)
Unit - Remove u from the game
Game - Display to (All players) the text: (String((Number of units in blastingnodes[i])))
-------- NO MORE NODES MANA BLASTING, STOP HERO --------
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Number of units in blastingnodes[i]) Equal to 0
Collapse Then - Actions
Game - Display to (All players) the text: herostopping
Unit - Pause u
Unit - Order Hero[i] to Stop
Unit - Unpause u
Else - Actions


What this prints out is

blasterstop
1
herostopping

So it is saying that the number of units in the unit group == 1 and then it is doing stuff inside the if statement that requires the number of units to be == 0!
12-17-2006, 05:59 PM#2
Captain Griffen
Learn JASS. GUI merely removes you from actual code.

The if statement is in a different function. Use a global, or use JASS. Don't use locals in GUI unless you know what you are doing.
12-17-2006, 06:10 PM#3
blu_da_noob
Why the hell are you even using a local there? It has no purpose.
12-17-2006, 09:02 PM#4
Moss
Doh. That is not the first time that one has got me. I know JASS, GUI is just easier most of the time. But then it does silly stuff like that. What business does it have making a seperate function for the if statement?

I added the local variable because of all the triggers flying around triggering each other and screwing up the globals. This trigger was firing off from some actions in another trigger using the global i variable and I didn't what it to get changed. But now that I look at the triggering trigger it seems I don't use udg_i after this one gets called. Maybe I needed it at some point but I guess I don't now.
12-17-2006, 10:50 PM#5
Pheonix-IV
you only need locals where there is some kind of wait or delay involved.
12-18-2006, 12:00 AM#6
Moss
Quote:
Originally Posted by Pheonix-IV
you only need locals where there is some kind of wait or delay involved.

That's not true. And apparently I do need that variable to be local, it is changing around as the trigger runs for who knows what reason.

Phoenix, consider this example that can screw up globals with no waits (too lazy to make some real triggers):
Code:
Trigger 1
Event: 
-Unit does something
Action:
-Set udg_u = triggering unit
-Stop unit from doing aforementioned thing.
-move udg_u someplace

Trigger 2
Event:
-Unit stops doing something
Action:
-Set udg_u = some crazy unit

When trigger 1 stops the unit trigger 2 will immediately fire and change udg_u to "some crazy unit" and then trigger 1 will end up moving "some crazy unit" instead of the original unit.