HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

My Trigger is slowing/crashing warcraft

07-26-2008, 07:37 PM#1
Bulletbutter
Ok, so the idea is this. Four groups of 5 creeps are spawned in 4 second increments. When the first group spawns a countdown timer with 10 seconds appears. The plan is that at the end of the timer I need to kill all units that are still alive in the specified region and subtract the number of units that are killed from the total amount of lives that are left.


Here is the trigger that either crash's the game or slows it down to where it's unplayable.

Trigger:
Kill creeps and Lives
Collapse Events
Unit - A unit comes within 1250.00 of Military Ward 0000 <gen>
Collapse Conditions
(Owner of (Triggering unit)) Equal to Player 2 (Blue)
isLevel Equal to False
Collapse Actions
For each (Integer creepNum) from 0 to creepNum, do (Unit Group - Pick every unit in (Units in Player1Zone <gen> owned by Player 2 (Blue)) and do (Set Lives = (Lives - 1)))
For each (Integer creepNum) from 0 to creepNum, do (Unit Group - Pick every unit in (Units in Player1Zone <gen> owned by Player 2 (Blue)) and do (Unit - Kill (Random unit from CreepsUnitGroup)))
I originally had it killing the creeps one at a time but it wasn't fast enough and all the creeps didn't die before the next level started.

Here is the trigger that keeps count of the creeps (used for creepNum in above trigger).
Trigger:
P1Zone Creep Count
Collapse Events
Unit - A unit enters Player1Zone <gen>
Collapse Conditions
(Owner of (Triggering unit)) Equal to Player 2 (Blue)
(Player1Zone <gen> contains (Triggering unit)) Equal to True
(Player 1 (Red) controller) Equal to User
isLevel Equal to True
Collapse Actions
If ((Mobs[CurrentLevel] is alive) Equal to True) then do (Set creepNum = (creepNum + 1)) else do (Do nothing)

And lastly the trigger that places each unit into a unit group...
Trigger:
Spawn Levels
Collapse Events
Game - TrickVar becomes Equal to 1.00
Collapse Conditions
CurrentLevel Greater than 0
isLevel Equal to True
Collapse Actions
Unit - Create 5 (Unit-type of Mobs[CurrentLevel]) for Player 2 (Blue) at (Center of P1spawn <gen>) facing Default building facing degrees
Wait 4.00 seconds
Unit - Create 5 (Unit-type of Mobs[CurrentLevel]) for Player 2 (Blue) at (Center of P1spawn <gen>) facing Default building facing degrees
Wait 4.00 seconds
Unit - Create 5 (Unit-type of Mobs[CurrentLevel]) for Player 2 (Blue) at (Center of P1spawn <gen>) facing Default building facing degrees
Wait 4.00 seconds
Unit - Create 5 (Unit-type of Mobs[CurrentLevel]) for Player 2 (Blue) at (Center of P1spawn <gen>) facing Default building facing degrees
Set CreepsUnitGroup = (Units in Player1Zone <gen> owned by Player 2 (Blue))
Set TrickVar = 0.00

So the question is, how can make the trigger work more effectively and without crashing the game?
07-26-2008, 08:39 PM#2
Silvenon
I don't know if I'm stupid or something, but this:

Trigger:
For each (Integer creepNum) from 0 to creepNum, do (Unit Group - Pick every unit in (Units in Player1Zone <gen> owned by Player 2 (Blue)) and do (Set Lives = (Lives - 1)))
For each (Integer creepNum) from 0 to creepNum, do (Unit Group - Pick every unit in (Units in Player1Zone <gen> owned by Player 2 (Blue)) and do (Unit - Kill (Random unit from CreepsUnitGroup)))

are REALLY confusing, wtf is Integer creepNum?? I thought there were only Integer A and Integer B, how did you do that?

Another thing, what you're doing is for each creep you're picking the whole group and killing them and whatnot. If you, for example, had 50 creeps, you would pick that group and kill each of them 50 times (maybe that was causing the crash).

So instead of those integer loops, use "Pick every unit in unit group" action, I hope you understand why.

Btw, I don't see why you needed that condition (in the second trigger) that checks if the triggering unit is in that region, if the trigger fires when the unit enters the region, I think it's logical that the unit is in it.

Also, in the last trigger you will probably have major lags, because you have a pretty serious leak here:

Trigger:
Set CreepsUnitGroup = (Units in Player1Zone <gen> owned by Player 2 (Blue))

No good, man, destroy the bastard:

Trigger:
Custom script: call DestroyGroup(udg_CreepUnitGroup)
Set CreepsUnitGroup = (Units in Player1Zone <gen> owned by Player 2 (Blue))

I think that's the right way to do it.
07-26-2008, 09:05 PM#3
Bulletbutter
Quote:
Originally Posted by Silvenon
Trigger:
For each (Integer creepNum) from 0 to creepNum, do (Unit Group - Pick every unit in (Units in Player1Zone <gen> owned by Player 2 (Blue)) and do (Set Lives = (Lives - 1)))
For each (Integer creepNum) from 0 to creepNum, do (Unit Group - Pick every unit in (Units in Player1Zone <gen> owned by Player 2 (Blue)) and do (Unit - Kill (Random unit from CreepsUnitGroup)))

are REALLY confusing, wtf is Integer creepNum?? I thought there were only Integer A and Integer B, how did you do that?

Another thing, what you're doing is for each creep you're picking the whole group and killing them and whatnot. If you, for example, had 50 creeps, you would pick that group and kill each of them 50 times (maybe that was causing the crash).

So instead of those integer loops, use "Pick every unit in unit group" action, I hope you understand why.
creepNum is an integer variable. It is used so I can keep track of many creeps are in a region. The trigger is "For each Integer Variable, Do Actions". That's the one I used. Looking closely at it I see what was happening now.

However, when I use "Pick every unit in unit group" the action I use is "Unit - Kill (triggering unit)" BUT like I stated before, it doesn't do it fast enough. I need to be able to kill ALL the creeps when isLevel = false (which is about 10 seconds).

Quote:
Originally Posted by Silvenon
Btw, I don't see why you needed that condition (in the second trigger) that checks if the triggering unit is in that region, if the trigger fires when the unit enters the region, I think it's logical that the unit is in it.
I didn't, thanks for catching that :)

Quote:
Originally Posted by Silvenon
Also, in the last trigger you will probably have major lags, because you have a pretty serious leak here:

Trigger:
Set CreepsUnitGroup = (Units in Player1Zone <gen> owned by Player 2 (Blue))

No good, man, destroy the bastard:

Trigger:
Custom script: call DestroyGroup(udg_CreepUnitGroup)
Set CreepsUnitGroup = (Units in Player1Zone <gen> owned by Player 2 (Blue))

I think that's the right way to do it.
Each level will spawn different creeps, so CreepsUnitGroup will contain different creeps for each level. So again, thank you.

The question still remains...how do I kill all the remaining creeps (creepNum, the number of creeps, can only be a max of 20.) in the 10 seconds that isLevel = False?
07-26-2008, 11:54 PM#4
Ammorth
Trigger:
For each (Integer creepNum) from 0 to creepNum...

converts to:

Collapse JASS:
set udg_creepNum = 0
loop
    exitwhen udg_creepNum > udg_creepNum
    call Do stuff()
    set udg_creepNum = udg_creepNum + 1
endloop

The problem is creepNum will never be greater than itself, so you will hit an infinite loop. To fix this, use another variable for your loop variable (like tempint) or use Integer A/ Integer B

If you are using The Frozen Throne World Editor, I would use the "and do multiple actions" as it's more efficient than using 2 loops.