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

Random towers for builder?

Level 1
Joined
Apr 14, 2025
Messages
1
I was wondering if it was possible that a builder does't just have the same towers, but if it could be coded that the builder would receive a couple of towers randomly.
So if there were basic, normal and advanced towers:

A B C D E (Basic)
F G H I J (Normal)
K L M N O (Advanced)

He could get something like this as his "structures built":

B D E
F I J
K M O
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,914
So you can't edit Hotkeys at runtime so unless you rely on a completely alternate mechanic (custom UI) or an insane amount of Object Editor data (copies of each unit) then that's not going to happen.

But if that's a compromise you're willing to make then you can simply add every single tower to your builder's "Structures Built" field, disable their availability using triggers, and then randomly enable some of them using triggers. You can hold shift while opening the "Structures Built" field to bypass the build cap.

Here's a working system you could use. This trigger is where you set everything up and get the system up and running:
  • RT Setup
    • Events
      • Time - Elapsed game time is 0.01 seconds
    • Conditions
    • Actions
      • -------- =============================================================== --------
      • -------- DEFINE how many different types of towers you have - remember to update this: --------
      • Set VariableSet Random_Tower_Count = 6
      • -------- --------
      • -------- DEFINE your different types of towers: --------
      • Set VariableSet Random_Tower_Type[1] = Guard Tower
      • Set VariableSet Random_Tower_Type[2] = Cannon Tower
      • Set VariableSet Random_Tower_Type[3] = Arcane Tower
      • Set VariableSet Random_Tower_Type[4] = Sky-Fury Tower
      • Set VariableSet Random_Tower_Type[5] = Dalaran Guard Tower
      • Set VariableSet Random_Tower_Type[6] = Death Tower
      • -------- * Copy and paste the above variable and add more tower types as needed... --------
      • -------- =============================================================== --------
      • -------- --------
      • -------- Note: You don't have to edit anything else from this point on. Only do so if you know what you're doing! --------
      • -------- --------
      • -------- Create, hide, and track the towers. This acts like your "hat" that you can use to "draw a random name from the hat" later on: --------
      • For each (Integer Random_Tower_Loop) from 1 to Random_Tower_Count, do (Actions)
        • Loop - Actions
          • Unit - Create 1 Random_Tower_Type[Random_Tower_Loop] for Neutral Passive at (Center of OutOfSight <gen>) facing Default building facing degrees
          • Unit - Hide (Last created unit)
          • Unit Group - Add (Last created unit) to Random_Tower_Base_Group
      • -------- --------
      • -------- Disable construction of ALL random towers for each player: --------
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • For each (Integer Random_Tower_Loop) from 1 to Random_Tower_Count, do (Actions)
            • Loop - Actions
              • Player - Make Random_Tower_Type[Random_Tower_Loop] Unavailable for training/construction by (Picked player)
^ You need to define the variables between the ===== comments I've made and you need to edit the "Unit - Create" action to use your own Region:
  • (Center of OutOfSight <gen>)
I created this Region in the corner of my map, away from anything important. I recommend doing the same thing.

Then here's how you can enable some random towers for a player:
  • RT Enable Random Towers
    • Events
      • Player - Player 1 (Red) types a chat message containing go as An exact match
      • Player - Player 2 (Blue) types a chat message containing go as An exact match
      • Player - Player 3 (Teal) types a chat message containing go as An exact match
    • Conditions
    • Actions
      • -------- Fill up your "hat" with random "tower names" that you can then pull from: --------
      • Unit Group - Remove all units from Random_Tower_RNG_Group.
      • Unit Group - Add all units of Random_Tower_Base_Group to Random_Tower_RNG_Group
      • -------- --------
      • -------- [OPTIONAL] Disable all of the player's current towers before getting new ones: --------
      • For each (Integer Random_Tower_Loop) from 1 to Random_Tower_Count, do (Actions)
        • Loop - Actions
          • Player - Make Random_Tower_Type[Random_Tower_Loop] Unavailable for training/construction by (Triggering player)
      • -------- --------
      • -------- Enable construction of 'X' random towers for the desired player. X is 3 in this example: --------
      • For each (Integer Random_Tower_Loop) from 1 to 3, do (Actions)
        • Loop - Actions
          • Set VariableSet Random_Tower = (Random unit from Random_Tower_RNG_Group)
          • Unit Group - Remove Random_Tower from Random_Tower_RNG_Group.
          • Player - Make (Unit-type of Random_Tower) Available for training/construction by (Triggering player)
^ This trigger shows you HOW to enable the towers randomly, but you'll obviously want to customize the logic to suit the needs of your map. For example, you may want to pick every player at the 60.00 second mark and enable the random towers for them then. To do this, the Actions would remain mostly the same, aside from some Event Responses changing like (Triggering player) becoming (Picked player).

Your builder MUST be able to build every single one of these towers for the system to work:
1747830618862.png


To test the map:
Once in-game, type "go" and you'll be given 3 random towers from the 6 different types that I've defined in the RT Setup trigger.
 

Attachments

  • Random Towers 1.w3m
    19.6 KB · Views: 1
Last edited:
Top