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: 404
General chit-chat
Help Users
  • No one is chatting at the moment.
  • WildTurkey WildTurkey:
    is there a stephen green in the house?
    +1
  • The Helper The Helper:
    What is up WildTurkey?
  • The Helper The Helper:
    Looks like Google fixed whatever mistake that made the recipes on the site go crazy and we are no longer trending towards a recipe site lol - I don't care though because it motivated me to spend alot of time on the site improving it and at least now the content people are looking at is not stupid and embarrassing like it was when I first got back into this like 5 years ago.
  • The Helper The Helper:
    Plus - I have a pretty bad ass recipe collection now! That section of the site is 10 thousand times better than it was before
  • The Helper The Helper:
    We now have a web designer at my job. A legit talented professional! I am going to get him to redesign the site theme. It is time.
  • Varine Varine:
    I got one more day of community service and then I'm free from this nonsense! I polished a cop car today for a funeral or something I guess
  • Varine Varine:
    They also were digging threw old shit at the sheriff's office and I tried to get them to give me the old electronic stuff, but they said no. They can't give it to people because they might use it to impersonate a cop or break into their network or some shit? idk but it was a shame to see them take a whole bunch of radios and shit to get shredded and landfilled
  • The Helper The Helper:
    whatever at least you are free
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • 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 Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top