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

Region Spawning

Level 3
Joined
Oct 3, 2025
Messages
15
Hello, im trying to get back into the WC3 editor and not very big on coding and all the language that comes with it XD, but im trying to figure a way to have Units Spawn in a Region while Player(s) are within a region, and the more players in the region the more/different units will start to spawn and then when all players have left said region it despawns all units within the region. I am pretty sure this might be complicated and if some one is willing to help a newbie out with trying to understand how the coding of this would be possible, i would much appreciate it
 
Here's one way with 3 triggers, you'll need to create an Integer variable

First detect when players get in the region and increase the count

  • Player Enters
    • Events
      • Unit - A unit enters Player Region <gen>
    • Conditions
    • Actions
      • Set VariableSet Integer_PlayersInRegion = (Integer_PlayersInRegion + 1)

Then the spawn trigger, I don't know how exactly how they are supposed to spawn but I decided that they show up every 10 seconds

  • Spawn Trigger
    • Events
      • Time - Every 10.00 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Integer_PlayersInRegion Equal to 1
        • Then - Actions
          • Unit - Create 1 Footman for Player 1 (Red) at (Center of Spawn Region <gen>) facing Default building facing degrees
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Integer_PlayersInRegion Equal to 2
        • Then - Actions
          • Unit - Create 2 Footman for Player 1 (Red) at (Center of Spawn Region <gen>) facing Default building facing degrees
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Integer_PlayersInRegion Equal to 3
        • Then - Actions
          • Unit - Create 2 Footman for Player 1 (Red) at (Center of Spawn Region <gen>) facing Default building facing degrees
          • Unit - Create 1 Rifleman for Player 1 (Red) at (Center of Spawn Region <gen>) facing Default building facing degrees
        • Else - Actions
      • -------- etc. etc. --------

And then when players leave the region

  • Player Exits
    • Events
      • Unit - A unit leaves Player Region <gen>
    • Conditions
    • Actions
      • Set VariableSet Integer_PlayersInRegion = (Integer_PlayersInRegion - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Integer_PlayersInRegion Less than or equal to 0
        • Then - Actions
          • Unit Group - Pick every unit in (Units in Spawn Region <gen>) and do (Actions)
            • Loop - Actions
              • Unit - Remove (Picked unit) from the game
        • Else - Actions

But things aren't very clear, what are "players" exactly? 1 hero only? Up to 100 units? if the latter then you'll need a lot of if/then/elses in this example. Also if the units leave Spawn Region then they wouldn't be removed if all players are gone, so again not sure how things work in your map

Also I didn't handle memory leaks in this example but that's something you'll need to worry about later on
 
Here's one way with 3 triggers, you'll need to create an Integer variable

First detect when players get in the region and increase the count

  • Player Enters
    • Events
      • Unit - A unit enters Player Region <gen>
    • Conditions
    • Actions
      • Set VariableSet Integer_PlayersInRegion = (Integer_PlayersInRegion + 1)

Then the spawn trigger, I don't know how exactly how they are supposed to spawn but I decided that they show up every 10 seconds

  • Spawn Trigger
    • Events
      • Time - Every 10.00 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Integer_PlayersInRegion Equal to 1
        • Then - Actions
          • Unit - Create 1 Footman for Player 1 (Red) at (Center of Spawn Region <gen>) facing Default building facing degrees
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Integer_PlayersInRegion Equal to 2
        • Then - Actions
          • Unit - Create 2 Footman for Player 1 (Red) at (Center of Spawn Region <gen>) facing Default building facing degrees
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Integer_PlayersInRegion Equal to 3
        • Then - Actions
          • Unit - Create 2 Footman for Player 1 (Red) at (Center of Spawn Region <gen>) facing Default building facing degrees
          • Unit - Create 1 Rifleman for Player 1 (Red) at (Center of Spawn Region <gen>) facing Default building facing degrees
        • Else - Actions
      • -------- etc. etc. --------

And then when players leave the region

  • Player Exits
    • Events
      • Unit - A unit leaves Player Region <gen>
    • Conditions
    • Actions
      • Set VariableSet Integer_PlayersInRegion = (Integer_PlayersInRegion - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Integer_PlayersInRegion Less than or equal to 0
        • Then - Actions
          • Unit Group - Pick every unit in (Units in Spawn Region <gen>) and do (Actions)
            • Loop - Actions
              • Unit - Remove (Picked unit) from the game
        • Else - Actions

But things aren't very clear, what are "players" exactly? 1 hero only? Up to 100 units? if the latter then you'll need a lot of if/then/elses in this example. Also if the units leave Spawn Region then they wouldn't be removed if all players are gone, so again not sure how things work in your map

Also I didn't handle memory leaks in this example but that's something you'll need to worry about later on
Sorry on phone at moment, players will be player count/ amount of heros they have, my goal is up to 10 players and each player can choose up to 2 heros so anywhere from 1-20 heros in a region I will have to look at this more when I return to pc sorry for the inconvenience.

i am now home, so What i have planned is that my RPG im making will have both Active and Idle play to it, and right now im stuck on the region spawning, im new to trying to code it what throws me off is the Coding language of thing, ur triggers u have provided look like what i have come across, but i still dont know what i have done wrong, the variables and stuff are confusing for me and im willing to learn, i will provide what i have as well an maybe can explain what im doing wrong?

1779920805190.webp

this is what i have sorry i cant figure how to add the trigger itself like u did, everything here is what i was able to find to place, and the only thing i did personally are the bits Crazy Chicken,MSP1 the rest is what i came across and couldnt figure out what goes what and what means what XD
im very newbie to the coding stuff Sorry in advance
 
Last edited:
Back
Top