HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

How to create a random unit of type A-F, without preplacing them?

11-22-2003, 07:15 PM#1
FerretDruid
I can't figure out how to basically create a random unit of "type", where type is just a range of different units in the editor.

For example I want my trigger to create any ONE RANDOM normal human unit at a point and then do actions. The catch is that I want the creation of each unit to be slightly delayed from the last, very short time - fraction of a second even. But still a delay, I can't have them all popping in at once. So that has screwed up my unit-type array variable that I was using.

I have a trigger set up now that.. KIND OF does what I want, but not really. It's not even worth posting the code, it's so messed up. The actions don't fulfil, the units are all the same unit, etc. They just appear one at a time which I want. But I just can't seem to get any further. Setting a unit-type array at map init doesn't seem to weild any results for this particular situation.

Anyway, I'm clueless. What am I missing here?
11-22-2003, 07:18 PM#2
SpectreReturns
Set every possible unit type into a Unit Type Array. Then create one of type Unit Type Array [Random number between 0 - max amount of units]


[edit] And then just put a wait 0.1 second after it.
11-22-2003, 07:21 PM#3
Ligature
It sounds like you have the right idea - a unit-type array should let you select a random unit type from it... your random unit-type creation code should work like this (if you have an array with N members, starting with 1):

create 1 (UnitTypeArray[random integer between 1 and N]) for player etc...

If that's what you've got, which it sounds like it is, I'm clueless as to what could be the problem...

(EDIT) Agh, Spectre beat me to it!
11-22-2003, 07:26 PM#4
SpectreReturns
Cant beat me in a fast post, :)

Anyway Weasel boy, your problem is probably that you have the creation trigger in a loop, or that you dont have any waits.
11-22-2003, 07:34 PM#5
FerretDruid
Okay, thanks! ;) It's selecting random units now. Apparently there is a problem with my next action though. Ready for the nasty code?

Code:
Unit - Order (Last created unit) to Attack (Random unit from (Units in (Region centered at (Position of (<SpellTarget>)) with size (1200.00, 1200.00)) owned by (Random player from (All enemies of (Owner of <Spellcaster>)))))

They work fine as long as I just say "Unit - Order (Last created unit) to Attack <spelltarget>" but how can I get them to attack a random enemy unit (any enemy of mine, the <spellcaster>'s owner)?