Staredit Network > Forums > SC1 UMS Mapmaking Assistance > Topic: Random Powerup Spawning
Random Powerup Spawning
Jul 28 2011, 11:43 pm
By: Excalibur  

Jul 28 2011, 11:43 pm Excalibur Post #1

The sword and the faith

Sup Assist forum. :)

Alright, I'm making a map in which powerups and enemies need to be randomly distributed around a certain area of the map.

Power Up Requirements:
A certain number of them need to exist at any given time, IE if there are 4 of powerup A, and 3 are picked up, another one will spawn somewhere.
Their position will be random, and their frequency will be determined by how rare of an item they are. So although powerup A will exist in up to 4 places at any time, powerup B is more rare and will only exist in 2.
There are 6 powerups total.

Enemy Requirements:
After a certain amount of game-time has passed, enemies will spawn. The length of game time determines which of them and how many of them will be spawned. So in the first five minutes one or two minor enemies are spawned with there being multiple big baddys by thirty minutes in.
There are lets say five types of enemies, in three tiers.

Problem: I have no idea how to make all these things happen correctly and I cannot for the life of me understand DCs or grids. :(

SEN Global Moderator and Resident Zealot
The sword and the faith.

Sector 12
My stream, live PC building and tech discussion.

Jul 29 2011, 12:53 am Roy Post #2

An artist's depiction of an Extended Unit Death

You'll probably have to learn death counters and grids; the wikis describe them pretty well in layman's terms, and they shouldn't be concepts that are unattainable by someone such as yourself. I wrote a tutorial on basic grids myself a long time ago, which you may find helpful. Here's an excerpt for static grids:

WARNING: This is ancient (December 2008)

If you have the units to spare, static grids are not too complicated to implement and give a pseudo-random placement effect. Of course, if you want something with more outcomes or you cannot afford placing all those units, there are more complex solutions for creating a unit at a random location on a map. The conversation in the shoutbox about using junkyard observers could be combined with a static grid system to increase the randomness of the spawns. You can create an observer at a random static grid point and let it wander a little before placing the power-up.

As far as enemies spawning, the best method would be to use death counters. You could combine this with Elapsed Time to determine which units should spawn. Think of using a death counter like you would use the countdown timer: when it hits 0, you spawn units and set it to a particular number to count down from again. To set this up, always have a trigger subtracting 1 from the death counter (this makes it count down like the countdown timer does automatically). Then, after spawning units, set it to a number. Setting to 12 deaths is close to one second, so if you wanted the enemies to spawn every 20 seconds, the number would be 20*12 = 240.

Hope this helps.

Jul 29 2011, 6:25 am rockz Post #3

ᴄʜᴇᴇsᴇ ɪᴛ!

I think you should have units to spare, so I'll go into a bit more detail.

Preplace 32, 64, or 128 burrowed zerg units. This is going to be the static "random" grid. it's not really a grid, but 32-128 locations at which units can spawn.

Randomize a switch. If it's on, add 1 to a DC "cantina". Re-randomize it. This time, add 2 if it's on. Repeat the process, doubling the amount each time until you have added 16, 32, or 64, depending on the amount you chose. This will create a random number from 0-31, 63, or 127, depending on the number you chose. I would suggest you use as the conditions of all these triggers to be Deaths of "cave". That way, if you ever want to run the trigger, set deaths of "cave" to 1, and it will run.

Next up is binary countoffs. You've already started with the randomized DC "cantina" value. Subtract out 64 from the DC "cantina", then give 64 of the burrowed zerg units to a different player, like from player 9 to player 10. Repeat for 32, 16, 8, etc...
Now, center location on the burrowed zerg unit owned by player 9. This is the random location which you will create stuff at. Make sure you subtract 1 deaths of "cave" now that the randomization is done, and give all burrowed units back to player 9. The DC "cantina" is actually a useless step. If you're not using it for anything else, you can safely give away the units in the trigger after you randomize the switches if you want.

To decide which powerups will be created requires a few things. First, I assume you want a cooldown on the items so that they can only spawn every so often, up to a maximum. That's not hard actually. All you have to do is set a DC for each powerup. Roy has elaborated on this. Whenever the DC reaches 0, add 1 to the "cave" DC so the randomized location occurs again, then create a powerup at the location whenever the DC is 0 as well. In the create trigger, reset the DC timer. To add a "maximum" all you need to do is add a "bring/command at most X" condition. Make a separate trigger for the condition "bring/command exactly 0" so that whenever there are no powerups of a type left, spawn another one somewhere else.

Enemies would spawn in the same way. You just need the "elapsed time" condition, or use the countdown timer. Someone can make the triggers in a trigger format if you're hopelessly lost.

Post has been edited 1 time(s), last time on Jul 29 2011, 6:30 am by rockz.

"Parliamentary inquiry, Mr. Chairman - do we have to call the Gentleman a gentleman if he's not one?"

Jul 29 2011, 12:50 pm Excalibur Post #4

The sword and the faith

Yeah, rockz, I don't understand that system at all. :(

I think I may just have pre-placed spawn spots and use semi-randomization since I can actually understand it. :(

Current system:
15 spawn points. 6 power ups. Cycle deaths of cantina from 1-6. 3 powerups will only spawn at even numbered locations, half at odd.

Post has been edited 1 time(s), last time on Jul 29 2011, 1:08 pm by Excalibur.

SEN Global Moderator and Resident Zealot
The sword and the faith.

Sector 12
My stream, live PC building and tech discussion.

Jul 29 2011, 3:03 pm ubermctastic Post #5

You want them randomly distributed right?
I just made this yesterday out of complete boredom.
This system randomly distributes units to 64 locations.

#1 randomize necesarry ammount of switches.

#2 spawn unit based on switches at outside location (only if it does not exceed limit of that unit)

#3 randomize switches again

#4 send unit to location based on switch (only if there isn't anything at that location already.

#5 kill unit at the outside location ( encase the spot was already taken.

If you are doing this with burrowed units, just cut out #3 - #5 and make #2 check if theres something there already before it spawns.
Have the location constantly cycling through the burrowed units.

Hits: 1 Size: 50.8kb


Jul 29 2011, 5:19 pm rockz Post #6

ᴄʜᴇᴇsᴇ ɪᴛ!

Well I can't see K_A's on this computer so I may as well explain.

This trigger set randomizes the location

These triggers set up the timers to spawn the powerups and set up new powerups to be created when there are none.

Does this help, or is it still confusing? There's actually a ton of ways to do this, so do whatever works for you.

"Parliamentary inquiry, Mr. Chairman - do we have to call the Gentleman a gentleman if he's not one?"

Jul 29 2011, 5:48 pm jjf28 Post #7

Cartography Artisan

for the life of me understand DCs

don't think of them as deaths at all, think of them as variables that can be positive integers

you can modify them via subtraction, addition, and set deaths, so they are incredibly useful

apparently they can be negative when you add negative values rather than subtract anything

or grids

when you create 9 muta's at a location they'll show up in this formation


If you were to center a location on a muta, it would always center on the same muta

then if you remove that muta you can center again, and it will center on the next one

since the pattern of which muta the location gets centered on is always the same, you can use this to move locations to precise places in the grid

always remove units, never kill them

some very nice illistrations here...

earlier rockz mentioned static grids, these are simliar; except you don't create or remove the units, insted you change which player owns pre-placed units, these are also useful b/c you can spawn units precisly where you mean too based on a variable (death counter) making them much more useful than placing mass locations for randomization.

Rs_yes-im4real - Clan Aura -

Reached the top of StarCraft theory crafting 2:12 AM CST, August 2nd, 2014.

  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[09:10 pm]
Ultraviolet -- This guy: got banned :P
[08:54 pm]
Vrael -- there aren't enough of us left for a ban to be worthwhile
[08:54 pm]
Vrael -- yeah just go for it I don't think they ban people anymore
[06:37 pm]
Zoan -- MTiger156
MTiger156 shouted: I'd try to spell "WOB" with wobs, but that would require 5 uninterrupted lines and probably a ban >_<
do it
[05:11 pm]
MTiger156 -- I'd try to spell "WOB" with wobs, but that would require 5 uninterrupted lines and probably a ban >_<
[02:30 pm]
MTiger156 -- I used that joke already :P
[01:08 am]
Oh_Man -- They see me wobbing... they hating...
[10:45 pm]
RIVE -- Using the Search box is enough to crash the site. Do your worst.
[2019-11-14. : 8:15 pm]
MTiger156 -- I calculate that it is possible to fill a shoutbox page with 1125 wobs. Is that enough GIF power to crash the server?
[2019-11-14. : 8:09 pm]
MTiger156 -- :wob: :wob: :wob: :wob: :wob: :wob: :wob: :wob: :wob: :wob: :wob: :wob: :wob: :wob: :wob:
Please log in to shout.

Members Online: Roy