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,462
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,462
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,462
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: 396
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Varine Varine:
    How can you tell the difference between real traffic and indexing or AI generation bots?
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such
  • Varine Varine:
    That's mostly what I've been looking at
  • Varine Varine:
    I don't think I'm dealing with quite the same pressures though, at the very least its a significantly smaller system. For the time being I'm just going to put together a quick scrubby box though and hope it works good enough to not make my house toxic
  • Varine Varine:
    I mean I don't use this enough to pose any significant danger I don't think, but I would still rather not be throwing styrene all over the air
  • The Helper The Helper:
    New dessert added to recipes Southern Pecan Praline Cake https://www.thehelper.net/threads/recipe-southern-pecan-praline-cake.193555/
  • The Helper The Helper:
    Another bot invasion 493 members online most of them bots that do not show up on stats
  • Varine Varine:
    I'm looking at a solid 378 guests, but 3 members. Of which two are me and VSNES. The third is unlisted, which makes me think its a ghost.
    +1
  • The Helper The Helper:
    Some members choose invisibility mode
    +1
  • The Helper The Helper:
    I bitch about Xenforo sometimes but it really is full featured you just have to really know what you are doing to get the most out of it.
  • The Helper The Helper:
    It is just not easy to fix styles and customize but it definitely can be done
  • The Helper The Helper:
    I do know this - xenforo dropped the ball by not keeping the vbulletin reputation comments as a feature. The loss of the Reputation comments data when we switched to Xenforo really was the death knell for the site when it came to all the users that left. I know I missed it so much and I got way less interested in the site when that feature was gone and I run the site.
  • Blackveiled Blackveiled:
    People love rep, lol
    +1
  • The Helper The Helper:
    The recipe today is Sloppy Joe Casserole - one of my faves LOL https://www.thehelper.net/threads/sloppy-joe-casserole-with-manwich.193585/
  • The Helper The Helper:
    Decided to put up a healthier type recipe to mix it up - Honey Garlic Shrimp Stir-Fry https://www.thehelper.net/threads/recipe-honey-garlic-shrimp-stir-fry.193595/

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top