• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

How to use random gruops

Status
Not open for further replies.
Level 2
Joined
Apr 26, 2014
Messages
10
How Random Groups Work?

The function of Random Groups is however complex. You'll need a lot of brains to finish the job. Here is an explanation of how random groups work:

- In order to use a random group, place a Random Unit located in the Neutral Hostile palette and place the unit in the map. Double click the unit and set the Random Unit Type to From Random Group and set which position could be implemented to the random unit itself.

- Each set has a chance of being implemented to the random unit. The more sets are there in a group, the lesser chance is there in a specific set. The chances are spread evenly.

- If a set with multiple positions has been picked by chance, the positions will now undergo a randomization process. An explanation below
* For example, I have a random group named Two Trolls. It has 2 sets, having both chances of 50%. And each set has 4 positions. Each position has a unit. Then the other set is selected by chance. Once the set has been selected, it gives a chance for the positions of the set. If a single position has been chosen by chance, then that will be the unit appearing as the previously random unit. Well that's it hope you like it:ogre_hurrhurr:
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,191
Sounds like the functionality you want is that of the unitpool object. Baiscally you create said object (probably not available in GUI, will have to use JASS directly) and then you add the appropriate unit types to it at the appropriate unit weight. You then place however many units from the pool on your map wherever. Finally you need to destroy the unitpool object or keep it cached in a global for use later.

JASS:
native CreateUnitPool takes nothing returns unitpool
native DestroyUnitPool takes unitpool whichPool returns nothing
native UnitPoolAddUnitType takes unitpool whichPool,integer unitId,real weight returns nothing
native UnitPoolRemoveUnitType takes unitpool whichPool,integer unitId returns nothing
native PlaceRandomUnit takes unitpool whichPool,player forWhichPlayer,real x,real y,real facing returns unit

I hope this solves your problem.
 
Status
Not open for further replies.
Top