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

Why respawned units are stacking?

Status
Not open for further replies.
Level 18
Joined
Jun 2, 2009
Messages
1,205
Hello everyone. Here is my issue. My creeps are spawns beyond the limit during the games. Here is the trigger.

  • OrmanSetup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set SpawnRegion[1] = NCGrupDevil1 <gen>
      • Set SpawnRegion[2] = NCGrupDevil2 <gen>
      • Set SpawnRegion[3] = NCGrupDevil3 <gen>
      • Set SpawnRegion[4] = NCGrupDevil3 <gen>
      • Set SpawnRegion[5] = NCGrupDevil4 <gen>
      • Set SpawnRegion[6] = NCGrupDevil5 <gen>
      • Set SpawnRegion[7] = NCGrupDevil6 <gen>
      • Set SpawnRegion[8] = NCGrupReaper1 <gen>
      • Set SpawnRegion[9] = NCGrupReaper2 <gen>
      • Set SpawnRegion[10] = NCGrupReaper3 <gen>
      • Set SpawnRegion[11] = NCGrupReaper3 <gen>
      • Set SpawnRegion[12] = NCGrupReaper4 <gen>
      • Set SpawnRegion[13] = NCGrupReaper5 <gen>
      • Set SpawnRegion[14] = NCGrupReaper6 <gen>
      • Set SpawnUnit[1] = Murloc Flesheater (level 1)
      • Set SpawnUnit[2] = Treant (level 2)
      • Set SpawnUnit[3] = Mud Golem (level 3)
      • Set SpawnUnit[4] = Satyr (level 3)
      • Set SpawnUnit[5] = Ghoul (level 5)
      • Set SpawnUnit[6] = Sasquatch (level 7)
      • Set SpawnUnit[7] = Ogre Lord (level 10)
      • Set SpawnUnit[8] = Murloc Flesheater (level 1 REAPER)
      • Set SpawnUnit[9] = Treant (level 2 REAPER)
      • Set SpawnUnit[10] = Mud Golem (level 3 REAPER)
      • Set SpawnUnit[11] = Satyr (level 3 REAPER)
      • Set SpawnUnit[12] = Ghoul (level 5 REAPER)
      • Set SpawnUnit[13] = Sasquatch (level 7 REAPER)
      • Set SpawnUnit[14] = Ogre Lord (level 10 REAPER)
      • Set SpawnLimit[1] = 3
      • Set SpawnLimit[2] = 3
      • Set SpawnLimit[3] = 1
      • Set SpawnLimit[4] = 2
      • Set SpawnLimit[5] = 3
      • Set SpawnLimit[6] = 1
      • Set SpawnLimit[7] = 1
      • Set SpawnLimit[8] = 3
      • Set SpawnLimit[9] = 3
      • Set SpawnLimit[10] = 1
      • Set SpawnLimit[11] = 2
      • Set SpawnLimit[12] = 3
      • Set SpawnLimit[13] = 1
      • Set SpawnLimit[14] = 1
  • OrmanYaratmaReaper
    • Events
      • Time - Elapsed game time is 132.00 seconds
    • Conditions
    • Actions
      • -------- Reaper 1 --------
      • Set GeciciNokta = (Center of NCGrupReaper1 <gen>)
      • Unit - Create 1 SpawnUnit[8] for Neutral Hostile at GeciciNokta facing Default building facing degrees
      • Unit - Create 1 SpawnUnit[8] for Neutral Hostile at GeciciNokta facing Default building facing degrees
      • Unit - Create 1 SpawnUnit[8] for Neutral Hostile at GeciciNokta facing Default building facing degrees
      • Custom script: call RemoveLocation (udg_GeciciNokta)
      • -------- Reaper 2 --------
      • Set GeciciNokta = (Center of NCGrupReaper2 <gen>)
      • Unit - Create 1 SpawnUnit[9] for Neutral Hostile at GeciciNokta facing Default building facing degrees
      • Unit - Create 1 SpawnUnit[9] for Neutral Hostile at GeciciNokta facing Default building facing degrees
      • Unit - Create 1 SpawnUnit[9] for Neutral Hostile at GeciciNokta facing Default building facing degrees
      • Custom script: call RemoveLocation (udg_GeciciNokta)
      • -------- Reaper 3 --------
      • Set GeciciNokta = (Center of NCGrupReaper3 <gen>)
      • Unit - Create 1 SpawnUnit[10] for Neutral Hostile at GeciciNokta facing Default building facing degrees
      • Unit - Create 1 SpawnUnit[10] for Neutral Hostile at GeciciNokta facing Default building facing degrees
      • Unit - Create 1 SpawnUnit[11] for Neutral Hostile at GeciciNokta facing Default building facing degrees
      • Custom script: call RemoveLocation (udg_GeciciNokta)
      • -------- Reaper 4 --------
      • Set GeciciNokta = (Center of NCGrupReaper4 <gen>)
      • Unit - Create 1 SpawnUnit[12] for Neutral Hostile at GeciciNokta facing Default building facing degrees
      • Unit - Create 1 SpawnUnit[12] for Neutral Hostile at GeciciNokta facing Default building facing degrees
      • Unit - Create 1 SpawnUnit[12] for Neutral Hostile at GeciciNokta facing Default building facing degrees
      • Custom script: call RemoveLocation (udg_GeciciNokta)
      • -------- Reaper 5 --------
      • Set GeciciNokta = (Center of NCGrupReaper5 <gen>)
      • Unit - Create 1 SpawnUnit[13] for Neutral Hostile at GeciciNokta facing Default building facing degrees
      • Custom script: call RemoveLocation (udg_GeciciNokta)
      • -------- Reaper 6 --------
      • Set GeciciNokta = (Center of NCGrupReaper6 <gen>)
      • Unit - Create 1 SpawnUnit[14] for Neutral Hostile at GeciciNokta facing Default building facing degrees
      • Custom script: call RemoveLocation (udg_GeciciNokta)
  • OrmanDiritl
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Dying unit)) Equal to SpawnUnit[1]
        • Then - Actions
          • Wait 120.00 seconds
          • Unit - Create 1 SpawnUnit[1] for Neutral Hostile at (Center of SpawnRegion[1]) facing Default building facing degrees
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Dying unit)) Equal to SpawnUnit[2]
        • Then - Actions
          • Wait 120.00 seconds
          • Unit - Create 1 SpawnUnit[2] for Neutral Hostile at (Center of SpawnRegion[2]) facing Default building facing degrees
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Dying unit)) Equal to SpawnUnit[3]
        • Then - Actions
          • Wait 120.00 seconds
          • Unit - Create 1 SpawnUnit[3] for Neutral Hostile at (Center of SpawnRegion[3]) facing Default building facing degrees
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Dying unit)) Equal to SpawnUnit[4]
        • Then - Actions
          • Wait 120.00 seconds
          • Unit - Create 1 SpawnUnit[4] for Neutral Hostile at (Center of SpawnRegion[4]) facing Default building facing degrees
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Dying unit)) Equal to SpawnUnit[5]
        • Then - Actions
          • Wait 120.00 seconds
          • Unit - Create 1 SpawnUnit[5] for Neutral Hostile at (Center of SpawnRegion[5]) facing Default building facing degrees
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Dying unit)) Equal to SpawnUnit[6]
        • Then - Actions
          • Wait 120.00 seconds
          • Unit - Create 1 SpawnUnit[6] for Neutral Hostile at (Center of SpawnRegion[6]) facing Default building facing degrees
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Dying unit)) Equal to SpawnUnit[7]
        • Then - Actions
          • Wait 120.00 seconds
          • Unit - Create 1 SpawnUnit[7] for Neutral Hostile at (Center of SpawnRegion[7]) facing Default building facing degrees
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Dying unit)) Equal to SpawnUnit[8]
        • Then - Actions
          • Wait 120.00 seconds
          • Unit - Create 1 SpawnUnit[8] for Neutral Hostile at (Center of SpawnRegion[8]) facing Default building facing degrees
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Dying unit)) Equal to SpawnUnit[9]
        • Then - Actions
          • Wait 120.00 seconds
          • Unit - Create 1 SpawnUnit[9] for Neutral Hostile at (Center of SpawnRegion[9]) facing Default building facing degrees
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Dying unit)) Equal to SpawnUnit[10]
        • Then - Actions
          • Wait 120.00 seconds
          • Unit - Create 1 SpawnUnit[10] for Neutral Hostile at (Center of SpawnRegion[10]) facing Default building facing degrees
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Dying unit)) Equal to SpawnUnit[11]
        • Then - Actions
          • Wait 120.00 seconds
          • Unit - Create 1 SpawnUnit[11] for Neutral Hostile at (Center of SpawnRegion[11]) facing Default building facing degrees
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Dying unit)) Equal to SpawnUnit[12]
        • Then - Actions
          • Wait 120.00 seconds
          • Unit - Create 1 SpawnUnit[12] for Neutral Hostile at (Center of SpawnRegion[12]) facing Default building facing degrees
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Dying unit)) Equal to SpawnUnit[13]
        • Then - Actions
          • Wait 120.00 seconds
          • Unit - Create 1 SpawnUnit[13] for Neutral Hostile at (Center of SpawnRegion[13]) facing Default building facing degrees
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Dying unit)) Equal to SpawnUnit[14]
        • Then - Actions
          • Wait 120.00 seconds
          • Unit - Create 1 SpawnUnit[14] for Neutral Hostile at (Center of SpawnRegion[14]) facing Default building facing degrees
        • Else - Actions
But i want to tell you something about it. It is not guarantee but it happens when someone buys Staff of Reanimation and Reanimates these creeps. I haven't verified yet.
Is there any problem with my triggers?

This triggers simply doing that.
You have a region and for example there are 3 Murlocs spawns within region. If someone kills these creatures, they are reviving after 120 seconds.
But they we're stacking in our last match.
 
Level 28
Joined
Sep 26, 2009
Messages
2,520
well, what makes you think that the reanimated units are of different unit-type than what you have in your trigger?
Anyway, reanimated units have 'summoned' classification, so adding the below condition to your trigger should fix the issue:
  • Untitled Trigger 001
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is Summoned) Equal to False
 

Uncle

Warcraft Moderator
Level 70
Joined
Aug 10, 2018
Messages
7,397
It looks like the Creeps are all owned by Neutral Hostile so you can easily check for that when the Creep dies. Also, you should use a Point array so you can easily reference the center of the Spawn Regions and avoid memory leaks.

Here's how I would change your triggers to make things a lot easier to work with. Delete OrmanDiritl and then create these two new triggers.

This trigger runs whenever a creep dies. Since you're using Arrays you can take advantage of the For Loop function in order to easily check all of your different SpawnUnits:
  • Creep Dies
    • Events
      • Unit - A unit owned by Neutral Hostile Dies
    • Conditions
    • Actions
      • Set Death_UnitType = (Unit-type of (Dying unit))
      • -------- --------
      • For each (Integer Death_Loop) from 1 to SpawnTotal, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Death_UnitType Equal to SpawnUnit[Death_Loop]
            • Then - Actions
              • Trigger - Run Creep Respawn <gen> (ignoring conditions)
              • Custom script: exitwhen true
            • Else - Actions
The exitwhen true custom script tells the For Loop to stop once it's found the unit-type of the dying unit. This makes it more efficient since it doesn't have to keep going even after it's found the unit-type.

This trigger uses a trick to store the [index] of your Dying creep in a shadowed local variable. Once the Wait is over we reference this local variable (Death_Index) in order to Create the correct Unit-Type at the correct Spawn Point:
  • Creep Respawn
    • Events
    • Conditions
    • Actions
      • Custom script: local integer udg_Death_Index = udg_Death_Loop
      • Wait 120.00 game-time seconds
      • Unit - Create 1 SpawnUnit[Death_Index] for Neutral Hostile at SpawnPoint[Death_Index] facing Default building facing degrees
Local variables are special because they always keep their value even after a Wait. This is because they exist only in the trigger that created them and are generated each time the trigger runs. However, local variables can only be used in Custom Script, so we use this trick to convert our global variable (Death_Index) into a local variable, which allows it to behave like both a local and global variable at the same time.


Setting up the variables:

Death_Loop is an Integer variable.
Death_Index is an Integer variable.
Death_UnitType is a Unit-Type variable.
SpawnTotal is an Integer variable. You should set it in your OrmanSetup trigger to the total number of SpawnUnits you have (It looks like you have 14).
SpawnPoint is a Point array variable. You should set it in your OrmanSetup trigger so you have a reference to the center of the SpawnRegions like this:
  • Set SpawnTotal = 14
  • Set SpawnPoint[1] = (Center of SpawnRegion[1])
  • Set SpawnPoint[2] = (Center of SpawnRegion[2])
  • Set SpawnPoint[3] = (Center of SpawnRegion[3])
I recommend learning how to use For Loops, especially with Arrays, it will make your life a lot easier.
 
Last edited:
Level 18
Joined
Jun 2, 2009
Messages
1,205
@Nichilus Thank you so much my friend. I will try this and test it.
@Uncle Thank you so much but it seems complicated and beyond my knowledge. Probably you will remember me. I am the stupid guy with low intelligence and if i try to use your system, probably it causes many bugs because i even don't know where should i put these triggers in my trigger. Being stupid was not my choice i am sorry..
Update: Yes. Dying unit not equal to summoned solved the issue. Thank you my friends.
 
Last edited:

Uncle

Warcraft Moderator
Level 70
Joined
Aug 10, 2018
Messages
7,397
@Nichilus Thank you so much my friend. I will try this and test it.
@Uncle Thank you so much but it seems complicated and beyond my knowledge. Probably you will remember me. I am the stupid guy with low intelligence and if i try to use your system, probably it causes many bugs because i even don't know where should i put these triggers in my trigger.
You would delete your OrmanDiritl trigger and then create those two triggers I posted.

The first trigger (Creep Dies) runs when a unit owned by Neutral Hostile dies. It then tells the second trigger (Creep Respawn) to run which will respawn the dying unit after 120.00 seconds. They look advanced but they're actually really simple and easy to create.

Have you tried using Search For Text? It will help you find the Actions I posted. Search for the word "custom" and you'll find the Custom Script action, type "For each" and you'll find the For Each Integer action, type "run" and you'll find the Run Trigger action.

The variables needed are all explained in my last post. It looks like you were smart enough to make variables for SpawnUnits/SpawnRegions so I don't see why you wouldn't be able to make the other variables I mentioned.

For the Custom Script you can copy and paste the text from the triggers in my last post. Just make sure that your variables have the same exact names as mine and that you don't copy the words "Custom script:" as well.

I took pictures of all of the Actions and the Event I used in my triggers and combined them into one big picture. You can see how I'm using Search For Text to find the Actions.
 

Attachments

  • example.png
    example.png
    41.7 KB · Views: 9
Last edited:
Level 18
Joined
Jun 2, 2009
Messages
1,205
You would delete your OrmanDiritl trigger and then create those two triggers I posted.

The first trigger (Creep Dies) runs when a unit owned by Neutral Hostile dies. It then tells the second trigger (Creep Respawn) to run which will respawn the dying unit after 120.00 seconds.

Have you tried using Search For Text? It will help you find the Actions I posted. Search for the word "custom" and you'll find the Custom Script action, type "For each" and you'll find the For Each Integer action, type "run" and you'll find the Run Trigger action.

The variables needed are all explained in my last post. It looks like you were smart enough to make variables for SpawnUnits/SpawnRegions so I don't see why you wouldn't be able to make the other variables I mentioned.
No please. If i try to do that and if i will fail again, i will be upset and start to hate myself. No more i want to say "i have failed again, i don't understand again, i sucked again, everyone can do that but i cannot" bla bla. It is not about creating variables. When i look at the picture it looks extremely complicated and difficult to me.

You mean just delete OrmanDirilt trigger and simply put this "creep dies" and "creep respawn" (2 triggers) in your map? Is that all?
Any extra triggers? variables? systems? If yes, i will create this and put into my map.
 

Uncle

Warcraft Moderator
Level 70
Joined
Aug 10, 2018
Messages
7,397
No please. If i try to do that and if i will fail again, i will be upset and start to hate myself. No more i want to say "i have failed again, i don't understand again, i sucked again, everyone can do that but i cannot" bla bla. It is not about creating variables. When i look at the picture it looks extremely complicated and difficult to me.

You mean just delete OrmanDirilt trigger and simply put this "creep dies" and "creep respawn" (2 triggers) in your map? Is that all?
Any extra triggers? variables? systems? If yes, i will create this and put into my map.
Yes, pretty much.

Those two triggers I made will replace your OrmanDirilt trigger. They use a lot of the same or similar Events/Conditions/Actions as OrmanDirilt so it shouldn't be too hard to create them. Also, I'm sure you can figure out how to use the Search For Text feature, you simply type anything you want like "hello" and any Actions that have the word "hello" in them will show up.

Then I explained the variables you need to create. Make sure you create these first so that you can use them in your new triggers:

Death_Loop is an Integer variable.
Death_Index is an Integer variable.
Death_UnitType is a Unit-Type variable.
SpawnTotal is an Integer variable.
SpawnPoint is a Point array variable.

You would then go into your OrmanSetup trigger and Set SpawnTotal to 14 and then Set SpawnPoint the same way you Set SpawnRegion.

So add these to the end of the OrmanSetup trigger:
  • Set SpawnTotal = 14
  • Set SpawnPoint[1] = (Center of SpawnRegion[1])
  • Set SpawnPoint[2] = (Center of SpawnRegion[2])
  • Set SpawnPoint[3] = (Center of SpawnRegion[3])
  • Set SpawnPoint[4] = (Center of SpawnRegion[4])
  • Set SpawnPoint[5] = (Center of SpawnRegion[5])
  • Set SpawnPoint[6] = (Center of SpawnRegion[6])
  • Set SpawnPoint[7] = (Center of SpawnRegion[7])
  • Set SpawnPoint[8] = (Center of SpawnRegion[8])
  • Set SpawnPoint[9] = (Center of SpawnRegion[9])
  • Set SpawnPoint[10] = (Center of SpawnRegion[10])
  • Set SpawnPoint[11] = (Center of SpawnRegion[11])
  • Set SpawnPoint[12] = (Center of SpawnRegion[12])
  • Set SpawnPoint[13] = (Center of SpawnRegion[13])
  • Set SpawnPoint[14] = (Center of SpawnRegion[14])
Then you're finished.

With this setup you shouldn't need to mess with the Creep Dies or Creep Respawn triggers ever again.
 
Last edited:
Status
Not open for further replies.
Top