HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Random Spawns

05-09-2006, 03:42 PM#1
StRoNgFoE_2000
Hi everyone. I am creating a map where random spawns happen constantly in a huge arena where they will fight each other. I will try to explain my goal in the simplest way possible.

I am trying to create multiple units of the same type in random locations in a rect keeping the triggers as small as possible. Each player (1-12 and Neutral) is going to recieve these spawns, 3 units at a time of 3 different types.

Each "round" has 3 types of units- melee, range, and strong. So for example, round 1 units will spawn 3 melee (soldier), 3 range (rifleman), and 3 strong (knight) for each player in a totally random spot in the arena. After each unit is created, it is given the order to patrol a random spot in the arena, so it attacks other spawns.

The problem I face is that my current triggers are huge because I can't figure out a way to make units spawn in completely random locations unless I create only 1 of the units at a time. If I create more than 1 unit, than they all form at the same random location.

This monster trigger below is the only trigger I could think of so far to get what I'm trying to do work, and this is just for the melee units, so there is 2 more of these for the range and strong for just the first round.

Soldier is the melee unit for players and bandits are for neutral.

Trigger:
Round1Melee
Collapse Events
Time - Every 14.00 seconds of game time
Conditions
Collapse Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Player 1 (Red) slot status) Equal to Is playing
Collapse Then - Actions
Unit - Create 1 Soldier (Level 1-HMelee) for Player 1 (Red) at (Random point in Bowl <gen>) facing Default building facing (270.0) degrees
Unit - Order (Last created unit) to Patrol To (Random point in Bowl <gen>)
Special Effect - Create a special effect attached to the origin of (Last created unit) using Abilities\Spells\Undead\RaiseSkeletonWarrior\RaiseSkeleton.mdl
Unit - Create 1 Soldier (Level 1-HMelee) for Player 1 (Red) at (Random point in Bowl <gen>) facing Default building facing (270.0) degrees
Unit - Order (Last created unit) to Patrol To (Random point in Bowl <gen>)
Special Effect - Create a special effect attached to the origin of (Last created unit) using Abilities\Spells\Undead\RaiseSkeletonWarrior\RaiseSkeleton.mdl
Unit - Create 1 Soldier (Level 1-HMelee) for Player 1 (Red) at (Random point in Bowl <gen>) facing Default building facing (270.0) degrees
Unit - Order (Last created unit) to Patrol To (Random point in Bowl <gen>)
Special Effect - Create a special effect attached to the origin of (Last created unit) using Abilities\Spells\Undead\RaiseSkeletonWarrior\RaiseSkeleton.mdl
Collapse Else - Actions
Do nothing
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Player 2 (Blue) slot status) Equal to Is playing
Collapse Then - Actions
Unit - Create 1 Soldier (Level 1-HMelee) for Player 2 (Blue) at (Random point in Bowl <gen>) facing Default building facing (270.0) degrees
Unit - Order (Last created unit) to Patrol To (Random point in Bowl <gen>)
Special Effect - Create a special effect attached to the origin of (Last created unit) using Abilities\Spells\Undead\RaiseSkeletonWarrior\RaiseSkeleton.mdl
Unit - Create 1 Soldier (Level 1-HMelee) for Player 2 (Blue) at (Random point in Bowl <gen>) facing Default building facing (270.0) degrees
Unit - Order (Last created unit) to Patrol To (Random point in Bowl <gen>)
Special Effect - Create a special effect attached to the origin of (Last created unit) using Abilities\Spells\Undead\RaiseSkeletonWarrior\RaiseSkeleton.mdl
Unit - Create 1 Soldier (Level 1-HMelee) for Player 2 (Blue) at (Random point in Bowl <gen>) facing Default building facing (270.0) degrees
Unit - Order (Last created unit) to Patrol To (Random point in Bowl <gen>)
Special Effect - Create a special effect attached to the origin of (Last created unit) using Abilities\Spells\Undead\RaiseSkeletonWarrior\RaiseSkeleton.mdl
Collapse Else - Actions
Do nothing
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Player 3 (Teal) slot status) Equal to Is playing
Collapse Then - Actions
Unit - Create 1 Soldier (Level 1-HMelee) for Player 3 (Teal) at (Random point in Bowl <gen>) facing Default building facing (270.0) degrees
Unit - Order (Last created unit) to Patrol To (Random point in Bowl <gen>)
Special Effect - Create a special effect attached to the origin of (Last created unit) using Abilities\Spells\Undead\RaiseSkeletonWarrior\RaiseSkeleton.mdl
Unit - Create 1 Soldier (Level 1-HMelee) for Player 3 (Teal) at (Random point in Bowl <gen>) facing Default building facing (270.0) degrees
Unit - Order (Last created unit) to Patrol To (Random point in Bowl <gen>)
Special Effect - Create a special effect attached to the origin of (Last created unit) using Abilities\Spells\Undead\RaiseSkeletonWarrior\RaiseSkeleton.mdl
Unit - Create 1 Soldier (Level 1-HMelee) for Player 3 (Teal) at (Random point in Bowl <gen>) facing Default building facing (270.0) degrees
Unit - Order (Last created unit) to Patrol To (Random point in Bowl <gen>)
Special Effect - Create a special effect attached to the origin of (Last created unit) using Abilities\Spells\Undead\RaiseSkeletonWarrior\RaiseSkeleton.mdl
Collapse Else - Actions
Do nothing
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Player 4 (Purple) slot status) Equal to Is playing
Collapse Then - Actions
Unit - Create 1 Soldier (Level 1-HMelee) for Player 4 (Purple) at (Random point in Bowl <gen>) facing Default building facing (270.0) degrees
Unit - Order (Last created unit) to Patrol To (Random point in Bowl <gen>)
Special Effect - Create a special effect attached to the origin of (Last created unit) using Abilities\Spells\Undead\RaiseSkeletonWarrior\RaiseSkeleton.mdl
Unit - Create 1 Soldier (Level 1-HMelee) for Player 4 (Purple) at (Random point in Bowl <gen>) facing Default building facing (270.0) degrees
Unit - Order (Last created unit) to Patrol To (Random point in Bowl <gen>)
Special Effect - Create a special effect attached to the origin of (Last created unit) using Abilities\Spells\Undead\RaiseSkeletonWarrior\RaiseSkeleton.mdl
Unit - Create 1 Soldier (Level 1-HMelee) for Player 4 (Purple) at (Random point in Bowl <gen>) facing Default building facing (270.0) degrees
Unit - Order (Last created unit) to Patrol To (Random point in Bowl <gen>)
Special Effect - Create a special effect attached to the origin of (Last created unit) using Abilities\Spells\Undead\RaiseSkeletonWarrior\RaiseSkeleton.mdl
Collapse Else - Actions
Do nothing
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Player 5 (Yellow) slot status) Equal to Is playing
Collapse Then - Actions
Unit - Create 1 Soldier (Level 1-HMelee) for Player 5 (Yellow) at (Random point in Bowl <gen>) facing Default building facing (270.0) degrees
Unit - Order (Last created unit) to Patrol To (Random point in Bowl <gen>)
Special Effect - Create a special effect attached to the origin of (Last created unit) using Abilities\Spells\Undead\RaiseSkeletonWarrior\RaiseSkeleton.mdl
Unit - Create 1 Soldier (Level 1-HMelee) for Player 5 (Yellow) at (Random point in Bowl <gen>) facing Default building facing (270.0) degrees
Unit - Order (Last created unit) to Patrol To (Random point in Bowl <gen>)
Special Effect - Create a special effect attached to the origin of (Last created unit) using Abilities\Spells\Undead\RaiseSkeletonWarrior\RaiseSkeleton.mdl
Unit - Create 1 Soldier (Level 1-HMelee) for Player 5 (Yellow) at (Random point in Bowl <gen>) facing Default building facing (270.0) degrees
Unit - Order (Last created unit) to Patrol To (Random point in Bowl <gen>)
Special Effect - Create a special effect attached to the origin of (Last created unit) using Abilities\Spells\Undead\RaiseSkeletonWarrior\RaiseSkeleton.mdl
Collapse Else - Actions
Do nothing
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Player 6 (Orange) slot status) Equal to Is playing
Collapse Then - Actions
Unit - Create 1 Soldier (Level 1-HMelee) for Player 6 (Orange) at (Random point in Bowl <gen>) facing Default building facing (270.0) degrees
Unit - Order (Last created unit) to Patrol To (Random point in Bowl <gen>)
Special Effect - Create a special effect attached to the origin of (Last created unit) using Abilities\Spells\Undead\RaiseSkeletonWarrior\RaiseSkeleton.mdl
Unit - Create 1 Soldier (Level 1-HMelee) for Player 6 (Orange) at (Random point in Bowl <gen>) facing Default building facing (270.0) degrees
Unit - Order (Last created unit) to Patrol To (Random point in Bowl <gen>)
Special Effect - Create a special effect attached to the origin of (Last created unit) using Abilities\Spells\Undead\RaiseSkeletonWarrior\RaiseSkeleton.mdl
Unit - Create 1 Soldier (Level 1-HMelee) for Player 6 (Orange) at (Random point in Bowl <gen>) facing Default building facing (270.0) degrees
Unit - Order (Last created unit) to Patrol To (Random point in Bowl <gen>)
Special Effect - Create a special effect attached to the origin of (Last created unit) using Abilities\Spells\Undead\RaiseSkeletonWarrior\RaiseSkeleton.mdl
Collapse Else - Actions
Do nothing
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Player 7 (Green) slot status) Equal to Is playing
Collapse Then - Actions
Unit - Create 1 Soldier (Level 1-HMelee) for Player 7 (Green) at (Random point in Bowl <gen>) facing Default building facing (270.0) degrees
Unit - Order (Last created unit) to Patrol To (Random point in Bowl <gen>)
Special Effect - Create a special effect attached to the origin of (Last created unit) using Abilities\Spells\Undead\RaiseSkeletonWarrior\RaiseSkeleton.mdl
Unit - Create 1 Soldier (Level 1-HMelee) for Player 7 (Green) at (Random point in Bowl <gen>) facing Default building facing (270.0) degrees
Unit - Order (Last created unit) to Patrol To (Random point in Bowl <gen>)
Special Effect - Create a special effect attached to the origin of (Last created unit) using Abilities\Spells\Undead\RaiseSkeletonWarrior\RaiseSkeleton.mdl
Unit - Create 1 Soldier (Level 1-HMelee) for Player 7 (Green) at (Random point in Bowl <gen>) facing Default building facing (270.0) degrees
Unit - Order (Last created unit) to Patrol To (Random point in Bowl <gen>)
Special Effect - Create a special effect attached to the origin of (Last created unit) using Abilities\Spells\Undead\RaiseSkeletonWarrior\RaiseSkeleton.mdl
Collapse Else - Actions
Do nothing
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Player 8 (Pink) slot status) Equal to Is playing
Collapse Then - Actions
Unit - Create 1 Soldier (Level 1-HMelee) for Player 8 (Pink) at (Random point in Bowl <gen>) facing Default building facing (270.0) degrees
Unit - Order (Last created unit) to Patrol To (Random point in Bowl <gen>)
Special Effect - Create a special effect attached to the origin of (Last created unit) using Abilities\Spells\Undead\RaiseSkeletonWarrior\RaiseSkeleton.mdl
Unit - Create 1 Soldier (Level 1-HMelee) for Player 8 (Pink) at (Random point in Bowl <gen>) facing Default building facing (270.0) degrees
Unit - Order (Last created unit) to Patrol To (Random point in Bowl <gen>)
Special Effect - Create a special effect attached to the origin of (Last created unit) using Abilities\Spells\Undead\RaiseSkeletonWarrior\RaiseSkeleton.mdl
Unit - Create 1 Soldier (Level 1-HMelee) for Player 8 (Pink) at (Random point in Bowl <gen>) facing Default building facing (270.0) degrees
Unit - Order (Last created unit) to Patrol To (Random point in Bowl <gen>)
Special Effect - Create a special effect attached to the origin of (Last created unit) using Abilities\Spells\Undead\RaiseSkeletonWarrior\RaiseSkeleton.mdl
Collapse Else - Actions
Do nothing
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Player 9 (Gray) slot status) Equal to Is playing
Collapse Then - Actions
Unit - Create 1 Soldier (Level 1-HMelee) for Player 9 (Gray) at (Random point in Bowl <gen>) facing Default building facing (270.0) degrees
Unit - Order (Last created unit) to Patrol To (Random point in Bowl <gen>)
Special Effect - Create a special effect attached to the origin of (Last created unit) using Abilities\Spells\Undead\RaiseSkeletonWarrior\RaiseSkeleton.mdl
Unit - Create 1 Soldier (Level 1-HMelee) for Player 9 (Gray) at (Random point in Bowl <gen>) facing Default building facing (270.0) degrees
Unit - Order (Last created unit) to Patrol To (Random point in Bowl <gen>)
Special Effect - Create a special effect attached to the origin of (Last created unit) using Abilities\Spells\Undead\RaiseSkeletonWarrior\RaiseSkeleton.mdl
Unit - Create 1 Soldier (Level 1-HMelee) for Player 9 (Gray) at (Random point in Bowl <gen>) facing Default building facing (270.0) degrees
Unit - Order (Last created unit) to Patrol To (Random point in Bowl <gen>)
Special Effect - Create a special effect attached to the origin of (Last created unit) using Abilities\Spells\Undead\RaiseSkeletonWarrior\RaiseSkeleton.mdl
Collapse Else - Actions
Do nothing
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Player 10 (Light Blue) slot status) Equal to Is playing
Collapse Then - Actions
Unit - Create 1 Soldier (Level 1-HMelee) for Player 10 (Light Blue) at (Random point in Bowl <gen>) facing Default building facing (270.0) degrees
Unit - Order (Last created unit) to Patrol To (Random point in Bowl <gen>)
Special Effect - Create a special effect attached to the origin of (Last created unit) using Abilities\Spells\Undead\RaiseSkeletonWarrior\RaiseSkeleton.mdl
Unit - Create 1 Soldier (Level 1-HMelee) for Player 10 (Light Blue) at (Random point in Bowl <gen>) facing Default building facing (270.0) degrees
Unit - Order (Last created unit) to Patrol To (Random point in Bowl <gen>)
Special Effect - Create a special effect attached to the origin of (Last created unit) using Abilities\Spells\Undead\RaiseSkeletonWarrior\RaiseSkeleton.mdl
Unit - Create 1 Soldier (Level 1-HMelee) for Player 10 (Light Blue) at (Random point in Bowl <gen>) facing Default building facing (270.0) degrees
Unit - Order (Last created unit) to Patrol To (Random point in Bowl <gen>)
Special Effect - Create a special effect attached to the origin of (Last created unit) using Abilities\Spells\Undead\RaiseSkeletonWarrior\RaiseSkeleton.mdl
Collapse Else - Actions
Do nothing
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Player 11 (Dark Green) slot status) Equal to Is playing
Collapse Then - Actions
Unit - Create 1 Soldier (Level 1-HMelee) for Player 11 (Dark Green) at (Random point in Bowl <gen>) facing Default building facing (270.0) degrees
Unit - Order (Last created unit) to Patrol To (Random point in Bowl <gen>)
Special Effect - Create a special effect attached to the origin of (Last created unit) using Abilities\Spells\Undead\RaiseSkeletonWarrior\RaiseSkeleton.mdl
Unit - Create 1 Soldier (Level 1-HMelee) for Player 11 (Dark Green) at (Random point in Bowl <gen>) facing Default building facing (270.0) degrees
Unit - Order (Last created unit) to Patrol To (Random point in Bowl <gen>)
Special Effect - Create a special effect attached to the origin of (Last created unit) using Abilities\Spells\Undead\RaiseSkeletonWarrior\RaiseSkeleton.mdl
Unit - Create 1 Soldier (Level 1-HMelee) for Player 11 (Dark Green) at (Random point in Bowl <gen>) facing Default building facing (270.0) degrees
Unit - Order (Last created unit) to Patrol To (Random point in Bowl <gen>)
Special Effect - Create a special effect attached to the origin of (Last created unit) using Abilities\Spells\Undead\RaiseSkeletonWarrior\RaiseSkeleton.mdl
Collapse Else - Actions
Do nothing
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Player 12 (Brown) slot status) Equal to Is playing
Collapse Then - Actions
Unit - Create 1 Soldier (Level 1-HMelee) for Player 12 (Brown) at (Random point in Bowl <gen>) facing Default building facing (270.0) degrees
Unit - Order (Last created unit) to Patrol To (Random point in Bowl <gen>)
Special Effect - Create a special effect attached to the origin of (Last created unit) using Abilities\Spells\Undead\RaiseSkeletonWarrior\RaiseSkeleton.mdl
Unit - Create 1 Soldier (Level 1-HMelee) for Player 12 (Brown) at (Random point in Bowl <gen>) facing Default building facing (270.0) degrees
Unit - Order (Last created unit) to Patrol To (Random point in Bowl <gen>)
Special Effect - Create a special effect attached to the origin of (Last created unit) using Abilities\Spells\Undead\RaiseSkeletonWarrior\RaiseSkeleton.mdl
Unit - Create 1 Soldier (Level 1-HMelee) for Player 12 (Brown) at (Random point in Bowl <gen>) facing Default building facing (270.0) degrees
Unit - Order (Last created unit) to Patrol To (Random point in Bowl <gen>)
Special Effect - Create a special effect attached to the origin of (Last created unit) using Abilities\Spells\Undead\RaiseSkeletonWarrior\RaiseSkeleton.mdl
Collapse Else - Actions
Do nothing
Unit - Create 1 Bandit (Level 1-CMelee) for Neutral Hostile at (Random point in Bowl <gen>) facing Default building facing (270.0) degrees
Unit - Order (Last created unit) to Patrol To (Random point in Bowl <gen>)
Special Effect - Create a special effect attached to the origin of (Last created unit) using Abilities\Spells\Undead\RaiseSkeletonWarrior\RaiseSkeleton.mdl
Unit - Create 1 Bandit (Level 1-CMelee) for Neutral Hostile at (Random point in Bowl <gen>) facing Default building facing (270.0) degrees
Unit - Order (Last created unit) to Patrol To (Random point in Bowl <gen>)
Special Effect - Create a special effect attached to the origin of (Last created unit) using Abilities\Spells\Undead\RaiseSkeletonWarrior\RaiseSkeleton.mdl
Unit - Create 1 Bandit (Level 1-CMelee) for Neutral Hostile at (Random point in Bowl <gen>) facing Default building facing (270.0) degrees
Unit - Order (Last created unit) to Patrol To (Random point in Bowl <gen>)
Special Effect - Create a special effect attached to the origin of (Last created unit) using Abilities\Spells\Undead\RaiseSkeletonWarrior\RaiseSkeleton.mdl
Wait 12.00 seconds
Trigger - Run Cleanup1Melee <gen> (ignoring conditions)

Another trigger tells it to turn on to spawn, and turn it off to stop the spawning. The cleanup at the end kills off all units after a certain period.

Trigger:
Cleanup1Melee
Events
Conditions
Collapse Actions
Collapse Player Group - Pick every player in (All players) and do (Actions)
Collapse Loop - Actions
Collapse Unit Group - Pick every unit in (Units owned by (Picked player) of type Soldier (Level 1-HMelee)) and do (Actions)
Collapse Loop - Actions
Unit - Explode (Picked unit)
Unit Group - Destroy unit group (Last created unit group)
Collapse Unit Group - Pick every unit in (Units owned by Neutral Hostile of type Bandit (Level 1-CMelee)) and do (Actions)
Collapse Loop - Actions
Unit - Explode (Picked unit)
Unit Group - Destroy unit group (Last created unit group)

To accomplish all the rounds, im going to need approximately 60-80 of these triggers, and that would add significant size to the map and possibly lag. Is there any possible way of doing this in an easier fashion? Any help would be appreciated!
05-09-2006, 03:59 PM#2
Captain Griffen
First, I very much recommend you go to the tutorial section and read a tutorial on memory leaks. If you are going to do something like this, you need to know about them, and how to avoid them.

Second, don't put in 'do nothing'. It is a pointless thing with no purpose.

Thidly, http://www.wc3campaigns.net/showthread.php?t=73104 is what you are looking for, I believe.
05-09-2006, 04:26 PM#3
StRoNgFoE_2000
-Thank you for the heads up on memory leaks. I read about them some time back because someone pointed them out in one of my older maps, but I never really understood them 100%. I'll take the time to read up more after I post this.

-I'll remove the "Do Nothings" just because "it is a pointless thing with no purpose". :)

-And no this is close, it might help out a bit, but looking at it.. it will still probably not do what i want it to do.

Here is a crude example:
This would be the arena below. Each unit spawned is random. So the first time you play, the units might be in this spot, next time, another spot.
___________
|--------x---|
|--x---------|
|------x-----|
|---x--------|
|x--------x--|

If i just create a mass of units using Units - Create XX units for player at XX facing blah blah, then it creates them all at one point instead if I create them individually like so.
____________
|------------|
|------------|
|--xxx-------|
|--xxx-------|
|------------|

I doubt it's possible, but the main goal I guess I am trying to reach would be to use the standard create units action but make them all appear in a random spot in a single rect, as opposed to using multiple rects. It's probably just not possible.
05-09-2006, 04:56 PM#4
Captain Griffen
Set SpawnType = Level 1-HMelee
For each Integer A from 1 to 12:
--Loop
----If Player(Integer A) is Equal to Playing
------Then
--------For each Integer B from 1 to 3:
----------Loop
------------Set TempPoint = (Random point in Bowl <gen>)
------------Unit - Create 1 Soldier SpawnType for Player(Integer A) at TempPoint facing Default building facing (270.0) degrees
------------Custom Script: RemoveLocation(udg_TempPoint)
------------Set TempPoint = (Random point in Bowl <gen>)
------------Unit - Order (Last created unit) to Patrol To TempPoint
------------Custom Script: RemoveLocation(udg_TempPoint)
------------Special Effect - Create a special effect attached to the origin of (Last created unit) using Abilities\Spells\Undead\RaiseSkeletonWarrior\RaiseSkeleton.mdl
------------Special Effect - Destroy last created special effect
------------Unit - Add 14 second generic expiration timer to (last created unit) // more efficient

You can forget about the other trigger if you use expiration timers, and you can just use the same trigger but set the spawn type to something else.
05-09-2006, 05:15 PM#5
StRoNgFoE_2000
I put a few hours of thought into this trying to figure it out and you whip it up in a few minutes! I'm very greatful, works like a charm! Thanks a bunch, super greatful!