Kill Summoned units after Summoner Dies

eric922

Active Member
Reaction score
0
How would you make it so when a unit dies, all of it's summoned units die also? Would I do this with triggers?

I tried to make a trigger that adds the summoned units to a "Unit Group Array" and then when the summoning unit dies, have a trigger that kills all of the units that were added to the Unit Group, but didn't work.
 

O.A

Quantum physics rules
Reaction score
29
You should always post your trigger as well so folks can see what's not working. You can copy the trigger as text in between the tags [.wc3][./wc3] (without the punctuation marks)

That being said, using a Unit Group array is a good way to do this if you don't need MUI, something like this;
Trigger:
  • AddAllThings
    • Events
    • Unit - A unit Spawns a summoned unit
    • Conditions
    • Actions
    • Unit Group - Add (Triggering unit) to Aug_SummonedUnits[(Player number of (Owner of (Triggering unit)))]


Trigger:
  • KillAllThings
    • Events
    • Unit - A unit Dies
    • Conditions
    • Actions
    • Unit Group - Pick every unit in Aug_SummonedUnits[(Player number of (Owner of (Triggering unit)))] and do (Actions)
    • Loop - Actions
    • Unit - Kill (Picked unit)
    • Unit Group - Remove all units from Aug_SummonedUnits[(Player number of (Owner of (Triggering unit)))]


Fill in the conditions and other things based on your map.
 

eric922

Active Member
Reaction score
0
I tried this and it did not work, maybe I did something wrong? I am making a Necromancer in my game and he summons skeletons when attacked. When I kill the Necromancer I would like all of his summons to die as well.

For the "Unit Group" variable, I called mine "Skeleton_Array" and variable type is Unit Group, size is 10. I didn't know what to put for the size so I tested it with different numbers and each test failed to kill the summoned units after the Necromancer dies. Here is my code:

Trigger:
  • Necro Skeletons
    • Events
      • Unit - A unit Spawns a summoned unit
    • Conditions
    • Actions
      • Unit Group - Add (Summoned unit) to Skeleton_Array[(<i>Player number of (Owner of (Triggering unit</i>)))]


Trigger:
  • Kill Necro Skeletons
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Skeleton_Array[(Player number of (Owner of (Triggering unit)))] and do (Actions)
        • Loop - Actions
          • Unit - Kill (Picked unit)
          • Unit Group - Remove all units from Skeleton_Array[(Player number of (Owner of (Triggering unit)))]


I tried with conditions to, but then took them out to simplify the trigger once I saw that it was not working.
The part that I really don't understand is this part: Skeleton_Array[(Player number of (Owner of (Triggering unit)))]
I do not know what this part means or does.
Trigger:
  • Unit Group - Add (Summoned unit) to Skeleton_Array[(Player number of (Owner of (Triggering unit)))]



UPDATE:
I found a way to kill all summoned units for the entire player after a Necromancer dies. This is better that what I had before, but I would like to make a trigger that only kills the summoned units of the unit that specifically summoned them. Example; you are fighting two necromancers at once and you kill one, all summoned units from both necromancers would die. I would like to make it so only the summoned units of the specific necromancer who died, would die at the same time.

Here is the code anyway, it might help:
Trigger:
  • Kill Necro Skeletons
    • Events
      • Unit - A unit Dies
    • Conditions
      • (((Dying unit) is Summoned) Equal to False) and ((Owner of (Dying unit)) Equal to Player 12 (Brown))
    • Actions
      • Unit Group - Pick every unit in (Units owned by (Owner of (Dying unit)) matching (((Matching unit) is Summoned) Equal to True)) and do (Actions)
        • Loop - Actions
          • Unit - Kill (Picked unit)
 
Last edited:

Accname

2D-Graphics enthusiast
Reaction score
1,463
I found a way to kill all summoned units for the entire player after a Necromancer dies. This is better that what I had before, but I would like to make a trigger that only kills the summoned units of the unit that specifically summoned them. Example; you are fighting two necromancers at once and you kill one, all summoned units from both necromancers would die. I would like to make it so only the summoned units of the specific necromancer who died, would die at the same time.
The correct terminology is MPI vs MUI. What you have right now is MPI (Multi-Player-Instanceable), you kill all summoned units that belong to a certain player. What you want is MUI (Multi-Unit-Instanceable), killing all units summoned by a certain unit.

To make the triggers MUI you are going to need a way to reference the summoner by the summons. There 3 ways to do this that I know of:
1) Get a unit indexing library. This could be heavy weight and overkill if you use it only for this single purpose.
2) Use Hashtables, a very reliable option but for beginners its often hard to understand at first how they work.
3) Use a little glitch and abuse the Rally ability. Give the summoned units the Rally ability and, when summoned, make them set their rally-point to their summoner. Later, you can use the rally-point to reference the summone of the unit.
 

O.A

Quantum physics rules
Reaction score
29
You don't need to set up the size of most arrays at all. It looks like the trigger you have made is for player 12, and if your array size is set to 10 the trigger probably won't work because of that, not sure.
'Player number of (Owner of (Triggering unit))' takes the number of the player (1-12) and places the units into that slot in the array. (E.g Player 4 = Skeleton Array [4]).

But like I said if you need MUI these triggers are useless. This only works if you have, for example, one hero per player whose summoned units you wish to kill off.
Sounds like you want MUI, which will not be as simple. Accname has listed options for that already I see.
 

eric922

Active Member
Reaction score
0
Does anyone know of a good Hash Table tutorial for WC3? I have taken a few programming classes including Python and Perl, so I am familiar with how hash tables work. Basically it's an array where each value has a corresponding key value.
 

Accname

2D-Graphics enthusiast
Reaction score
1,463
Basically it's an array where each value has a corresponding key value.
Not really, no.

A hashtable is, first and foremost, a table. Its a 2-dimensional data structure.
Every cell of the table contains one piece of data. The data can be of any type, and every cell of the table can hold a different type of data.

Now comes the "hash" part. The cells are not indexed with normal integers like in a standard table (like a 2 dimensional array for example) instead they are indexed by 2 keys.
One key for the column, and one key for the row. The keys can also be any kind of data. You can use 2 Strings, one String and an Integer, a String and a Unit, two Units, a Unit and a Player, anything.
In the background the keys will be hashed to generate integer values out of them, but I am not goin to explain the technical stuff.

What is important is that its a 2-dimensional table that can use any kinds of keys, of any type, to store any number of data, of any type.
Its powerful, its complex and its really damn useful.
 

Slapshot136

Divide et impera
Reaction score
471
3) Use a little glitch and abuse the Rally ability. Give the summoned units the Rally ability and, when summoned, make them set their rally-point to their summoner. Later, you can use the rally-point to reference the summone of the unit.

wouldn't the Rally disappear when the summoner dies?
 

Accname

2D-Graphics enthusiast
Reaction score
1,463
wouldn't the Rally disappear when the summoner dies?
Nope. Works like a charm.

Of course, the downside of this is, that the summons must NOT be controllable by the owner! If the owner changes the rally point then this will obviously not work anymore...

I attached a demo map showing how this would be done.
 

Attachments

  • KillDemSummonerz.w3x
    17.6 KB · Views: 404
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top