HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Trigger lags up wc3

07-13-2004, 05:35 PM#1
johnfn
For my map I have a trigger that determines if 55 or 75 of a unit have entered a region, and if so it creates a barracks. It would be simple if there wasnt 18 different regions to enter and a variable amount of units that have to enter for you to get a barracks.

The trigger was working fine with no lag at all up until now. Suddenly when you hit 100 food (~50 units) wc3 lags up and its almost impossible to move your mouse.

It has never done this before and I havent made any major adjustments to the code. Can someone correct my error?

Here's the trigger:

Code:
Control New Zone
	Events
		Unit - A unit enters Dark Green 1 <gen>
		Unit - A unit enters Dark Green 2 <gen>
		Unit - A unit enters Dark Green 3 <gen>
		Unit - A unit enters Dark Green 4 <gen>
		Unit - A unit enters Green 1 <gen>
		Unit - A unit enters Green 2 <gen>
		Unit - A unit enters Light Green 1 <gen>
		Unit - A unit enters Light Green 2 <gen>
		Unit - A unit enters Light Green 3 <gen>
		Unit - A unit enters Light Green 4 <gen>
		Unit - A unit enters Light Green 5 <gen>
		Unit - A unit enters Light Green 6 <gen>
		Unit - A unit enters Light Yellow 1 <gen>
		Unit - A unit enters Light Yellow 2 <gen>
		Unit - A unit enters Light Yellow 3 <gen>
		Unit - A unit enters Light Yellow 4 <gen>
		Unit - A unit enters Light Yellow 5 <gen>
		Unit - A unit enters Light Yellow 6 <gen>
		Unit - A unit enters Light Yellow 6 <gen>
	Conditions
	Actions
		For each (Integer A) from 1 to 18, do (Actions)
			Loop - Actions
				If (All Conditions are True) then do (Then Actions) else do (Else Actions)
					If - Conditions
						(ZoneControlledrgn[(Integer A)] contains (Position of (Entering unit))) Equal to True
					Then - Actions
						If (All Conditions are True) then do (Then Actions) else do (Else Actions)
							If - Conditions
								(Number of units in (Units in ZoneControlledrgn[(Integer A)])) Greater than or equal to zonemenamount[(Integer A)]
								zoneControlled[(Integer A)] Equal to False
							Then - Actions
								Unit Group - Pick every unit in (Units in ZoneControlledrgn[(Integer A)] matching ((Unit-type of (Triggering unit)) Equal to Footman)) and do (Actions)
									Loop - Actions
										If (All Conditions are True) then do (Then Actions) else do (Else Actions)
											If - Conditions
												(Owner of (Picked unit)) Equal to (Owner of (Entering unit))
											Then - Actions
												Unit - Remove (Picked unit) from the game
												Set zoneControlled[(Integer A)] = True
												Unit - Create 1 Barracks for (Owner of (Entering unit)) at (Center of ZoneControlledrgn[(Integer A)]) facing Default building facing degrees
											Else - Actions
							Else - Actions
					Else - Actions
07-13-2004, 06:42 PM#2
Anitarf
So, the trigger works for some time and then it lags up? Here's a possible cause:

(ZoneControlledrgn[(Integer A)] contains (Position of (Entering unit))) Equal to True

You are leaking a point object. Perhaps it lagged up when this leak clogged up all the memory?

And there is other wierd stuff in your trigger... It checks for the number of units in the zone; but it checks for all units, not just those belonging to the owner of entering unit. So, if two players are fighting in a zone, their total unit ammount can be enough for one of them to claim the zone.

When you remove units, you at the same time create one barracks for each of them, altrough I suppose there were meant to be one barracks for all of them.
07-13-2004, 07:08 PM#3
johnfn
Quote:
Originally Posted by Anitar
So, the trigger works for some time and then it lags up? Here's a possible cause:

(ZoneControlledrgn[(Integer A)] contains (Position of (Entering unit))) Equal to True

You are leaking a point object. Perhaps it lagged up when this leak clogged up all the memory?
I saw this earlier, darn it, why didnt I fix it then?

Quote:
Originally Posted by Anitar
And there is other wierd stuff in your trigger... It checks for the number of units in the zone; but it checks for all units, not just those belonging to the owner of entering unit. So, if two players are fighting in a zone, their total unit ammount can be enough for one of them to claim the zone.
Oops. It looks like I didnt completely finish my trigger. What on Earth was I thinking? See I have it all set up to set a few different variables at the end to then create a barracks later but for some reason I create a barracks every time like you mention below.

For example I have

(Owner of (Picked unit)) Equal to (Owner of (Entering unit))

Which is useless because it is in the if statement to create a barracks.

I must have been really tired when I wrote this or something. Thanks again.
07-13-2004, 08:37 PM#4
Vexorian
It has tons of point + group leaks, surelly when there are 100 units going everywhere and entering all those regions, it would kind of leak 100 things by second, and end up destroying wc3 memory, read Cubasis' tuturial, it is your only way of solving this