HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

How do I Replace a Random Unit?

11-27-2004, 07:38 PM#1
Kalvorod
I have a bunch units, and I want a random few of them turn into random units. I'll use easy numbers.

I have 100 footmen over the entire map, and I want 5 of them to change into Generals. How can i do this without triggering everysingle footman into a randomization thing?

If possible, does anyone know how to do this with destructables too?
11-27-2004, 08:25 PM#2
Guest
All i can think of is the array randomization way:

Variable-
-Name: FootmenChange
-Array: Yes - 100
-Starting Value: Blank

Event-
Map Init
Actions-
Set FootmenChange[0] = Footman0
Set FootmenChange[1] = Footman1
etc...

Then:

Events-
Whatever
Actions-
Replace FootmenChange[Random integer number between 1 and 100] with a general using The new unit's default life and mana


The variable takes a while to set up, but it works well.
11-27-2004, 08:43 PM#3
Beta_Tester
Quote:
Originally Posted by Ta_Potski
All i can think of is the array randomization way:

Variable-
-Name: FootmenChange
-Array: Yes - 100
-Starting Value: Blank

Event-
Map Init
Actions-
Set FootmenChange[0] = Footman0
Set FootmenChange[1] = Footman1
etc...

Then:

Events-
Whatever
Actions-
Replace FootmenChange[Random integer number between 1 and 100] with a general using The new unit's default life and mana


The variable takes a while to set up, but it works well.

That is a horrible way to do that, do it like this instead:
Code:
Actions: 
pick a random number of units for unit group

pick 4 units for units of type: footmen
    Replace picked unit with general
11-27-2004, 09:02 PM#4
Guest
I know my way is horrible, but i prefer it. I like my code to be by the bucket so each individual block can be cut up and changed.
To each their own, and i must admit Beta_Tester's way would be better suited for this.