HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Help: how to create randomly 1 unit among 10 other

12-03-2003, 10:04 AM#1
ABM
i have for example a group where there is a footman, a knight, a priest, a sorcerer and i would like to create one of them but randomly so that could be any of them.

how to do this?

thanks for help
12-03-2003, 11:07 AM#2
HEZZA
variables my good friends, variables. You gota set them as a unit-type i think and then make a trigger saying randomingly select internger 1-10 or what ever u want.

if thats wrong the answer defintly is vairables :ggani:
12-03-2003, 12:07 PM#3
AllPainful
Further in-depth answer, HEZZA is correct, variables.

Make this variable:
ranspawn = Unit-type ARRAY

Set the variable in the map init:
Set ranspawn[1] = Footman
Set ranspawn[2] = Knight
Set ranspawn[3] = Preist
Set ranspawn[4] = Sorceror

Trigger:
Code:
Events:
  What ever you want here
Conditions:
  What ever you want here
Actions:
  Create 1 unit of type ranspawn[math-random number between 1 and 4] at location [color=red](your location here)[/color] facing default building degrees.


If you need to random pick units in region and make 1 of them, then you don't need any variables.

Trigger:

Code:
Events:
  What ever you want here
Conditions:
  What ever you want here
Actions:
  Pick random unit in region [color=red]Your region here[/color] and create new unit of type (unit type of picked unit) at [color=red](your location here)[/color] facing default building degrees.
If you need any further/detailed assistance with this, let me know. I would be glad to help.
12-03-2003, 04:25 PM#4
ABM
thanks to both hezza and allpainful.

painfull your answer is very clear and detailed thanks a lot i think i will stick to variable, your first example look pretty easy to do and match perfectly what i wana do.

By the way allpainful as you are here could i ask you one more difficult question?

how can build ask a peon to die after finishing a building? as you are not allowed to do the ancient classification and night elf peon trick. only with variable and trigger.
and anyone who answer please try to do the trigger work before you say:
event a unit finish construction
condition unit type = peon
action kill peon
because it doesn't work at all...
using triggering unit don't work and there is no way in the response event to determine the builder only the building....
pretty annoying as there is nothing more simple than to kill an units once you can detect it in trigger.
12-03-2003, 04:33 PM#5
AllPainful
As far as I know there is only 1 way to do the "Kill after build" with triggers, and thats 2 triggers. The first one is a "Unit is issued an order targeting a point" with a condition "order is build" and the actions is to store the unit in a Unit variable. And then do a second trigger "Unit is finished construction" and the action would be "Kill unit (your variable here)".

There main problem with that is if each player has more than one of the "worker" units that builds. If they each only have 1 then its easy, just make the variable a unit-array, and then when the units is issued the order to build you would store the unit in the array index of the player.

unit[player number(owner of(ordered unit))]

would be what you would use if your variable was called "unit".
12-03-2003, 04:43 PM#6
Newhydra
All you need to do for the second one is:
Event - Unit finishes construction
Conditions - Unit-type of unit that was constructed equal to something that eats a peon
Actions - kill 1 random unit in unit group ( units within XXX of constructed unit matching condition ( matching unit is a peon ) )
12-03-2003, 07:31 PM#7
Shimfs
Well you could also say

Event: unit finish construction
Condition:
then make a region that is a little biggere then the building you want to build

then find out how long time it takes for the peon to build building then

Action: wait: (the amount of Sec it takes to build your building)

Kill all units in region (the region that is a little bigger then the building
12-04-2003, 02:24 AM#8
RicFaith
Quote:
Originally posted by Shimfs
Well you could also say

Event: unit finish construction
Condition:
then make a region that is a little biggere then the building you want to build

then find out how long time it takes for the peon to build building then

Action: wait: (the amount of Sec it takes to build your building)

Kill all units in region (the region that is a little bigger then the building


wouldn't that kill the building too?
You could kill/remove (constructing unit)

E: Unit finishes construction
C: (constructing unit) == peon
A: Unit - Kill/Remove (constructing unit)

Well I'm not sure if there's a constructing unit option, but there should be :P
12-04-2003, 06:26 AM#9
AllPainful
Quote:
Originally posted by RicFaith
wouldn't that kill the building too?
You could kill/remove (constructing unit)

E: Unit finishes construction
C: (constructing unit) == peon
A: Unit - Kill/Remove (constructing unit)

Well I'm not sure if there's a constructing unit option, but there should be :P


Constructing Unit DOES exist, but it refers to the building that just finished constructing, so that would remove the building, not the peon that built it.

NewHydra has the right Idea.
12-04-2003, 07:58 AM#10
ABM
thanks to Allpainful and newhydra and everyone...:ggani:

i think i will stick to newhydra trigger look nice, can be use easily in any case and still not too hard to understand.

Thanks everyone for your help :D