• Check out the results of the Techtree Contest #19!
  • Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

Pick a random stored unit only once

Status
Not open for further replies.
Level 1
Joined
Jun 13, 2008
Messages
132
Hi, I'm creating a custom hero map and I have a problem with the creeps' system, I stored 40 units manually, CreepType[1]: Ghoul, CreepType[2]: Witch..., for example, and I need to create a random unit from that group, I use the TempInteger variable to select one, but then I want that kind of unit to be removed from the group so the same level does not repeat in stage 2 for example. Any idea on how to do it?
 
The easiest thing that came to my mind was this:
  • Spawn
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • CreepType[Counter] Equal to No unit-type
        • Then - Actions
          • Set Counter = (Random integer number between 1 and 80)
          • Unit - Create 5 CreepType[Counter] for Player 1 (Red) at (Center of Region 000 <gen>) facing Default building facing degrees
          • Set CreepType[Counter] = No unit-type
        • Else - Actions
 
The easiest thing that came to my mind was this:
  • Spawn
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • CreepType[Counter] Equal to No unit-type
        • Then - Actions
          • Set Counter = (Random integer number between 1 and 80)
          • Unit - Create 5 CreepType[Counter] for Player 1 (Red) at (Center of Region 000 <gen>) facing Default building facing degrees
          • Set CreepType[Counter] = No unit-type
        • Else - Actions
Conceptually, this work. You need to put the if block in a loop though to make sure a unit type is spawned.

Even better solution is to:
rng = number between 1-80
create CreepType[rng] at...
set CreepType[rng] = CreepType[size (set to 80 at init)]
size = size - 1
 
Conceptually, this work. You need to put the if block in a loop though to make sure a unit type is spawned.

Even better solution is to:
rng = number between 1-80
create CreepType[rng] at...
set CreepType[rng] = CreepType[size (set to 80 at init)]
size = size - 1

I did what you suggested but monsters are repeating as I spawn them. I want a monster to spawn only in stage one for example, then in stage two another kind of monster and in stage three another kind, and so on.
 
Your trigger



Actions:
Set TempInteger = (Random integer number between 1 and IntegerMaxCreepType)
Unit - Create 1 CreepType[IntegerMaxCreepType] for Player 1 (red) at (Center of Región 036 <gen>) facing Vista edificio predeterminada degrees
Unidad - Order (Last created unit) to Move to (Center of Región 037 <gen>)
Set CreepType[TempInteger] = CreepType[IntegerMaxCreepType]
Set IntegerMaxCreepType = (IntegerMaxCreepType - 1)


The store trigger


If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Si: Condiciones
Entonces: Acciones
Set IntegerMaxCreepType = 40
Set CreepType[1] = Monster ( Mob )
Set CreepType[2] = Scorpión ( Mob )
Set CreepType[3] = Spider ( Mob )
Set CreepType[4] = Gnoll ( Mob )
Set CreepType[5] = Siren ( Mob )
Set CreepType[6] = Wisp ( Mob )
Set CreepType[7] = Murloc ( Mob )
Set CreepType[8] = Sátir ( Mob )
Set CreepType[9] = Giant Wing Beast ( Mob )
Set CreepType[10] = Wolf ( Mob )
Set CreepType[11] = Dark Troll ( Mob )
Set CreepType[12] = Treant ( Mob )
Set CreepType[13] = Necromancer ( Mob )
Set CreepType[14] = Centaur ( Mob )
Set CreepType[15] = Warrior Treant ( Mob )
Set CreepType[16] = Elemental ( Mob )
Set CreepType[17] = Marine Tortoise ( Mob )
Set CreepType[18] = Salamander ( Mob )
Set CreepType[19] = Steel Golem ( Mob )
Set CreepType[20] = Orc Ghost ( Mob )
Set CreepType[21] = Shadow ( Mob )
Set CreepType[22] = Banshee ( Mob )
Set CreepType[23] = Faceless ( Mob )
Set CreepType[24] = Necro Ant ( Mob )
Set CreepType[25] = Crustacean ( Mob )
Set CreepType[26] = Zombi ( Mob )
Set CreepType[27] = Ghoul ( Mob )
Set CreepType[28] = Goblin Machine ( Mob )
Set CreepType[29] = Ground Dragon ( Mob )
Set CreepType[30] = Harpy ( Mob )
Set CreepType[31] = Stone Golem ( Mob )
Set CreepType[32] = Small Demon ( Mob )
Set CreepType[33] = Catapult ( Mob )
Set CreepType[34] = Ogre ( Mob )
Set CreepType[35] = Alien ( Mob )
Set CreepType[36] = Wendigo ( Mob )
Set CreepType[37] = Quill Beast ( Mob )
Set CreepType[38] = Lava Demon ( Mob )
Set CreepType[39] = Spectral Banshee ( Mob )
Set CreepType[40] = Witch ( Mob )
Otros: Acciones
 
The trigger you recently posted should work. Are you maybe using the variables IntegerMaxCreepType or TempInteger anywhere else?

Also, do note that if you care about the order in which you registered the units, then the method you're using is not ideal.
Order is not important, only important thing is to spawn the mobs only once, the 40 levels must have different enemies, and each time I restart the game, as the enemies get a different number, the stages will also be different.
 
If order doesn't matter, than dynamic indexing should work. Would you be able to post all the triggers for your spawn system?

Since I'm experimenting, event is a periodic timer (2seconds):

Time - Every 2.00 seconds of game time


Actions
Set TempInteger = (Random integer number between 1 and IntegerMaxCreepType)
Unidad - Create 1 CreepType[TempInteger] for Player 1 (red) at (Center of Región 036 <gen>) facing Vista edificio predeterminada degrees
Unidad - Order (Last created unit) to Mover a (Center of Región 037 <gen>)
Set CreepType[TempInteger] = CreepType[IntegerMaxCreepType]
Set IntegerMaxCreepType = (IntegerMaxCreepType - 1)
 
Actions:
Set IntegerCreepType = (Random integer number between 1 and IntegerMaxCreepType)
Unidad - Create 1 CreepType[IntegerCreepType] for Jugador 1 (rojo) at (Center of Región 036 <gen>) facing Vista edificio predeterminada degrees
Unidad - Order (Last created unit) to Mover a (Center of Región 037 <gen>)
Set CreepType[IntegerCreepType] = CreepType[IntegerMaxCreepType]
Set IntegerMaxCreepType = (IntegerMaxCreepType - 1)


I've changed the variable name so I only use it on this trigger but the problem remains.

Creeps repeat and at the end it starts to repeat a lot.
 
Status
Not open for further replies.
Back
Top