• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Creep Respawn In Region

Status
Not open for further replies.
Level 6
Joined
Apr 1, 2009
Messages
201
I've created a trigger that spawns a certain number of units between two integers and of a certain unit type. Both are random when the hero enters the region. What I can't figure out how to do is, how to check if all the units spawned in that region are dead and if they are wait 60 seconds then turn the trigger back on. I'm not sure if I should use unit groups and if I do, would I have to make a bunch of unit groups? Or will just one work?

  • Setup Copy
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- Unit Type And Amount Spawned --------
      • Set UnitTypeSpawnF[1] = Wolf
      • Set NumberOfSpawnedUnits[1] = 3
      • Set UnitTypeSpawnF[2] = Bear
      • Set NumberOfSpawnedUnits[2] = 2

  • Forest Region 1
    • Events
      • Unit - A unit enters Enter Forest Spawn 1 <gen>
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Triggering unit)) Not equal to Neutral Passive
          • (Owner of (Triggering unit)) Not equal to Neutral Hostile
          • (All units of CreepRespawnCheck are dead) Equal to True
        • Then - Actions
          • Set UnitTypeSpawnInteger = (Random integer number between 1 and 2)
          • Unit - Create (Random integer number between 1 and NumberOfSpawnedUnits[UnitTypeSpawnInteger]) UnitTypeSpawnF[UnitTypeSpawnInteger] for Neutral Hostile at (Random point in Forest Spawn 1 <gen>) facing (Random angle) degrees
          • Unit Group - Pick every unit in (Units in Enter Forest Spawn 1 <gen>) and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Enter Forest Spawn 1 <gen> contains (Picked unit)) Equal to True
                  • (Owner of (Picked unit)) Equal to Neutral Hostile
                • Then - Actions
                  • Unit Group - Add (Picked unit) to CreepRespawnCheck
                  • Custom script: call DestroyGroup(udg_CreepRespawnCheck)
                  • Trigger - Turn off (This trigger)
                • Else - Actions
        • Else - Actions
 
Level 6
Joined
Apr 1, 2009
Messages
201
Like this?

  • Death Trigger Check
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Triggering unit)) Equal to Neutral Hostile
          • ((Triggering unit) is in CreepRespawnCheck) Equal to True
          • (All units of CreepRespawnCheck are dead) Equal to True
        • Then - Actions
          • Wait 60.00 seconds
          • Trigger - Turn on Forest Region 1 <gen>
        • Else - Actions
 
Level 17
Joined
Jan 21, 2010
Messages
2,111
More like this:
  • Death Trigger Check
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Triggering unit)) Equal to Neutral Hostile
          • ((Triggering unit) is in CreepRespawnCheck) Equal to True
          • (All units of CreepRespawnCheck are dead) Equal to True
        • Then - Actions
          • Timer - Start CreepWait as One-Shot timer that will expires in 60 second
        • Else - Actions
and for the timer:
  • creepwait timer expires
    • Events
      • Timer - CreepWait timer expires
    • Conditions
    • Actions
      • Trigger - Turn on 'your spawn trigger' <gen>
Edit: btw, sorry for the trigger mis-spelling, i don't have we atm
 
Level 6
Joined
Apr 1, 2009
Messages
201
Alright that makes sense but any ideas on how to make it so the death trigger checks what region that unit group came from? The reason I ask because I'm going to have multiple spawning regions and I'm not sure how to set which region is turned on by which unit group dies :/
 
Level 6
Joined
Apr 1, 2009
Messages
201
I thought of that but the only problem with that is if the player pulls the unit out of the region and kills it. Is there anyway to set a variable for each unit created?
 
Level 9
Joined
Nov 19, 2011
Messages
516
Of course. Use tables, or unit gorup with 'pick' acction. Then just while spawning add them to variables or unit group.

var: wolfs[12]: unit

check = true
for i from 0 to 12 do
---if wolfs is alive then check = false

OR

var wolfs: unit_group

check = true
pick every unit in wolfs and do
---if picked unit is alive then check = false
 
Level 6
Joined
Apr 1, 2009
Messages
201
Sorry I shouldn't of added that last part to my response about setting a variable, I already did that. My problem is I have 3 different triggers. The first one is the spawning a random unit and random number in a specific region. Then this trigger is turned off. The next trigger checks if all those units are dead then runs a timer. The last trigger functions when the timer expires and turns my first trigger back on. I'm trying to figure out how to turn the first trigger on through variables because there are going to be about 10-15 regions for each area. I'm not sure how to turn on the right trigger that the units were spawned in.
  • Forest Region 1
    • Events
      • Unit - A unit enters Enter Forest Spawn 1 <gen>
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Triggering unit)) Not equal to Neutral Passive
          • (Owner of (Triggering unit)) Not equal to Neutral Hostile
          • (All units of CreepRespawnCheck are dead) Equal to True
        • Then - Actions
          • Set UnitTypeSpawnInteger = (Random integer number between 1 and 2)
          • Unit - Create (Random integer number between 1 and NumberOfSpawnedUnits[UnitTypeSpawnInteger]) UnitTypeSpawnF[UnitTypeSpawnInteger] for Neutral Hostile at (Random point in Forest Spawn 1 <gen>) facing (Random angle) degrees
          • Unit Group - Pick every unit in (Units in Enter Forest Spawn 1 <gen>) and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Enter Forest Spawn 1 <gen> contains (Picked unit)) Equal to True
                  • (Owner of (Picked unit)) Equal to Neutral Hostile
                  • (Unit-type of (Picked unit)) Equal to UnitTypeSpawnF[UnitTypeSpawnInteger]
                • Then - Actions
                  • Unit Group - Add (Picked unit) to CreepRespawnCheck
                  • Custom script: call DestroyGroup(udg_CreepRespawnCheck)
                  • Trigger - Turn off (This trigger)
                • Else - Actions
        • Else - Actions
  • Death Trigger Check
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Triggering unit)) Equal to Neutral Hostile
          • ((Triggering unit) is in CreepRespawnCheck) Equal to True
          • (All units of CreepRespawnCheck are dead) Equal to True
        • Then - Actions
          • Countdown Timer - Start CreepRespawn as a One-shot timer that will expire in 60.00 seconds
        • Else - Actions
  • Turn Trigger On
    • Events
      • Time - CreepRespawn expires
    • Conditions
    • Actions
      • -------- Need to check if the unit group came from whichever region then turn that regions trigger back on --------
      • Trigger - Turn on Forest Region 1 <gen>
 
Level 9
Joined
Nov 19, 2011
Messages
516
Why not make 10-15 timers? If you got more than one creep spawn region you can't do it well with only one timer, coz when timer will expire you will not know which region turnet it on. Example

1:10 - all units in CSR1 dies so timer starts.
1:15 - all units in CSR2 dies so timer starts again.
Question: when timer should end? At 2:10 or 2:15?

If you will make more timers you will avoid those colisions and all units won't be able to spawn at once, or wait until next spawn 10 minutes. (10 regions x 60 sec coz multi start)
 
Status
Not open for further replies.
Top