HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Spawn trigger help.

03-23-2006, 07:43 AM#1
Hyarion
I need a trigger which runs once every ten seconds, then spawns a number of units equal to 75 minus the no. of units owned by a player, up to a maximum of fifteen.
That's the easy part, I can make that.
Problem is, I have five different types of units that make up the 75 unit army:

20 Swordsmen
20 Rangers
15 Mages
10 Templars (Only with upgrade.)
10 Battlemages (Only with upgrade.)

So I need a trigger which, when run, spawns a random one of those unit types, dependant on how many of that type there are already, so that not all the units in a wave are the same type, and the number of a unit never exceeds the numbers listed above. This is made even MORE complex by the fact that I only want Templars and Battlemages to spawn when their specific upgrade has been researched.

Can anyone help me with this?
03-23-2006, 09:43 AM#2
Anitarf
How about, instead of spawning them randomly, you spawn the one that is more needed. if a player has 2 swordsmen, 5 rangers and 7 manges, then first spawn 3 swordsmen, then alternate between swordsman and ranger until you spawn two of each, then start spawning all 3 of them. Once you hit 15 mages, stop spawning those.
03-23-2006, 10:02 AM#3
Hyarion
Fine idea, but I can't even BEGIN to work out how to make something like that...
And don't forget, I want to be spawning in ten-second waves, not a constant stream.
03-23-2006, 10:09 AM#4
Anitarf
Yes, yes, I mant that. Let me explain a bit more.

When your trigger runs (every 10 seconds), it first counts the number of units the player has in total. Then it loops from 1 to (75-the number of units). Inside the loop, all you have to check is how many units of each type the player has and spawn one of the kind that he has the fewest (unless he already has a maximum number of those units). You could also compare precentages instead of absolute ammount of units, if a player had 2/10 battlemages, that's 20%, while 3/20 rangers is 15%, so in that case, you would spawn a ranger. Anyway, each time the loop runs, you would spawn one unit this way, and in the end, you would end up with 75 units in total (including the units the player had before).
03-23-2006, 11:08 AM#5
Hyarion
Ahhhh!
I think I see.
Yes, that would probably be about right. I'll try that when I get home (In college at the moment).
Thanks dude.
P.S. WORK ON FORTRESS DEFENCE!