• 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 faction for Warcraft 3 and enter Hive's 19th Techtree Contest: Co-Op Commanders! Click here to enter!
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 21st Texturing Contest: Upgrade is now concluded, time to vote for your favourite set of icons! Click here to vote!

Spawn Units in an area.

Status
Not open for further replies.
Level 14
Joined
Jul 12, 2011
Messages
1,371
Hello everyone!
I need a trigger script in which a unit is spawned in a specific region every 10 seconds of the game.
But I don't want the spawned units to overcome the maximum number of 7.
I don't know if this is the right forum but I've tried it 3 times but it leaks.

Anyway,
Thanks!
 
Level 37
Joined
Mar 6, 2006
Messages
9,243

  • Untitled Trigger 002
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
      • creeps Less than 7
    • Actions
      • Set point = (Random point in (Playable map area))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Terrain type at point) Not equal to Lordaeron Summer - Dirt
          • (Terrain pathing at point of type Walkability is off) Equal to False
        • Then - Actions
          • Set creeps = (creeps + 1)
          • Trigger - Run Untitled Trigger 001 <gen> (ignoring conditions)
          • Custom script: call RemoveLocation(udg_point)
        • Else - Actions
          • Custom script: call RemoveLocation(udg_point)
          • Trigger - Run (This trigger) (ignoring conditions)
  • Untitled Trigger 001
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Random integer number between 1 and 4) Equal to 4
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Random integer number between 1 and 2) Equal to 1
            • Then - Actions
              • Unit - Create 1 Archmage for Neutral Hostile at point facing Default building facing degrees
            • Else - Actions
              • Unit - Create 1 Paladin for Neutral Hostile at point facing Default building facing degrees
        • Else - Actions
          • Unit - Create 1 Footman for Neutral Hostile at point facing Default building facing degrees
  • Untitled Trigger 003
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Owner of (Triggering unit)) Equal to Neutral Hostile
    • Actions
      • Set creeps = (creeps - 1)
 
Level 14
Joined
Jul 12, 2011
Messages
1,371
Will this also work??
  • Prepare Region 015
    • Events
      • Time - Every 7.00 seconds of game time
    • Conditions
    • Actions
      • Set Point0008 = (Random point in Region 015 <gen>)
      • Unit Group - Pick every unit in (Units in Region 015 <gen>) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Picked unit)) Equal to Skeletal Minnion (1)
            • Then - Actions
              • Unit Group - Add (Picked unit) to SkeletalSmallMinionsReg15
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Number of units in SkeletalSmallMinionsReg15) Less than 7
                • Then - Actions
                  • Unit - Create 1 Skeletal Minnion (1) for Neutral Hostile at Point0008 facing Default building facing degrees
                  • Custom script: call RemoveLocation(udg_Point0008)
                • Else - Actions
            • Else - Actions
 
Level 14
Joined
Jul 12, 2011
Messages
1,371
Will that do it??
  • Prepare Region 015
    • Events
      • Time - Every 5.00 seconds of game time
    • Conditions
    • Actions
      • Unit - Create 1 Skeletal Minnion (1) for Neutral Hostile at (Random point in Region 015 <gen>) facing Default building facing degrees
      • Unit Group - Add (Last created unit) to SkeletalSmallMinionsReg15
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in SkeletalSmallMinionsReg15) Greater than 7
        • Then - Actions
          • Do nothing
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in SkeletalSmallMinionsReg15) Less than 7
            • Then - Actions
              • Unit - Create 1 Skeletal Minnion (1) for Neutral Hostile at (Random point in Region 015 <gen>) facing Default building facing degrees
              • Unit Group - Add (Last created unit) to SkeletalSmallMinionsReg15
            • Else - Actions
I know it leaks point but I'll fix that.
 
Level 12
Joined
Mar 24, 2011
Messages
1,082
No. The do nothing is absolutely unnecesary. The Greater than 7 too it should be equal and the overal trigger is much smaller like:

  • Untitled Trigger 002
    • 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
          • (Number of units in CREEP_GROUP) Equal to 7
        • Then - Actions
        • Else - Actions
          • Set TempPoint = (Random point in SPAWN_REGION <gen>)
          • Unit - Create 1 CREEP for Neutral Hostile at TempPoint facing Default building facing degrees
          • Unit Group - Add (Last created unit) to CREEP_GROUP
          • Custom script: call RemoveLocaton(udg_TempPoint))
There would be a second trigger to remove dead units:

  • Untitled Trigger 003
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is in CREEP_GROUP) Equal to True
    • Actions
      • Unit Group - Remove (Triggering unit) from CREEP_GROUP
Wait a sec... doesn't a dead unit auto removed from unit group or it needs to decay...
 
Status
Not open for further replies.
Top