• 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.

Randomization

Status
Not open for further replies.
Level 8
Joined
Jan 17, 2019
Messages
163
Hello, I'm making a 4v4 dungeon and I would like the player controlled units, items, and doors/keys in certain regions to be random. What's the best way to make sure all the items are randomly placed?

Idea is to make it so even I won't have an unfair advantage playing the map and it will have a ton of replay value.

Thanks in advance!
 
Level 8
Joined
Jan 17, 2019
Messages
163
To elaborate:

One example in my dungeon will be a forbidden library. I'll have "locust units" with the bookshelf art and multiple regions where they could be placed or not placed so to randomize the layout of the library. I'll also have random places for switches which will reveal either enemies or the way out by turning the angle of a bookcase like a secret passageway. Also with that will be the patrolling/stationary enemies and treasures. I'd like to place my finite resources randomly but with purpose, ie only 1 treasure can be found in the first room but 2 will be placed in the second (and I'll make worthless trash items to mix into the batch for randomness). Same goes with my enemy placement: how can I make it so my 5 banshees are placed randomly in my designated regions but without crowding any them with more than 1 banshee?

Figuring this out will open many possibilities for my maps so I'd love to learn more!
 
Level 8
Joined
Oct 3, 2008
Messages
189
I think using Arrays would probably work for what you need.

For the banshees for example; make a region array of the possible spawn locations, then iterate over them using the "For every integer A between 1 and 5" action and spawn a banshee at a random point in each.

If you have less items to place than regions you'd generate random numbers between 1 and the number of regions and only pick those regions. I can type out some proper code when I'm at my home computer later.
 
Level 30
Joined
Aug 29, 2012
Messages
1,386
For the banshees, I'd try something like this:

  • Temp
    • Evénements
    • (Your event)
      • Conditions
      • Actions
        • For each (Integer A) from 1 to 5, do (Actions)
          • Boucle - Actions
            • Set TempPoint = (Random point in (Playable map area))
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • Si - Conditions
                • (Number of units in (Units within 150.00 of TempPoint matching ((Unit-type of (Matching unit)) Egal à Banshee))) Egal à 0
              • Alors - Actions
                • Unité - Create 1 Banshee for Joueur 1 (Rouge) at TempPoint facing Orientation bâtiment par défaut degrees
              • Sinon - Actions
Sorry there's a bit of French in there, but I think it's pretty straightforward. What I did is using a loop to create 5 units in a random point in playable map area (of course you can put your region here), but I did a check so that my actions will only fire if there's no banshee in a 150 radius around my point (you can adjust the size as well). I didn't clear the memory leak because that's just an example :p

Problem: this trigger might create less than 5 banshees if the random points are too close from each other. But I guess you can try to tinker with that to see if that fits your idea.
 
Status
Not open for further replies.
Top