The "Kill All Summoned Units When Hero Dies" Trick

Status
Not open for further replies.
Level 4
Joined
Aug 27, 2007
Messages
127
Hey guys, good to be back here and into Warcraft again. Anyway, I'm trying add a trigger that kills all units summoned by the hero when he dies. This is what I have so far.

  • Everybody Dies
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Dying unit) is A Hero) Equal to True
    • Actions
      • Unit Group - Pick every unit in (Units owned by (Owner of (Dying unit))) and do (Actions)
        • Loop - Actions
          • Unit - Kill (Picked unit)
Oh and before you asked, the map that I'm going to put it in will take a leaf out of DotA's book and make it so you can only control 1 hero and any units summoned by that 1 hero. It works fine under normal circumstances, but when my hero gets affected by Reincarnation, the summoned units are still alive. Any ideas on how to fix it?
 
Level 9
Joined
Dec 26, 2010
Messages
475
I think its impossible :ogre_haosis:
PS: your trigger leaks. use this instead :D i think its leakless

  • Kill All Summoned Units
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • Set SummonedGroup = (Units owned by (Owner of (Triggering unit)) matching (((Matching unit) is Summoned) Equal to True))
      • Unit Group - Pick every unit in SummonedGroup and do (Actions)
        • Loop - Actions
          • Unit - Kill (Picked unit)
      • Custom script: call DestroyGroup(udg_SummonedGroup)
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
I've got this box package for you, sign here please: _______________

Instructions:
1. Download the test map attached.
2. Test the map.
3. Summon as many snakes as you want.
4. When you're ready to test the trigger, press ESC and it will kill the caster on press.
5. When the caster dies = Snakes die.
6. If you're not happy, you can ask for more questions, just visit us over at the www.hiveworkshop.com.

This package is created by a member from our forum, defskull.
Thank you.
 

Attachments

  • Summoning Dies.w3x
    12.6 KB · Views: 55
Level 26
Joined
Aug 18, 2009
Messages
4,097
It works fine under normal circumstances, but when my hero gets affected by Reincarnation, the summoned units are still alive.

Then maybe ask how to detect death including reincarnation.

  • Death Destroy Summons
    • Events
    • Conditions
    • Actions
      • Custom script: if (IsUnitType(GetTriggerUnit(), UNIT_TYPE_DEAD) == false) then
        • //Destroy summons, giving Triggering unit as the died hero
      • Custom script: endif
  • Events
    • Map initialization
  • Conditions
  • Actions
    • Custom script: set bj_wantDestroyGroup = true
    • Unit Group - Pick every unit in (Units in (Entire map) matching (((Matching unit) is A Hero) Equal To True)) and do (Actions)
      • Loop - Actions
        • Trigger - Add to Death Destroy Summons <gen> the event (Unit - (Picked unit)'s life becomes Equal To 0.00)
  • Events
    • Unit - A unit enters (Entire map)
  • Conditions
    • ((Triggering unit) is A Hero) Equal To True
  • Actions
    • Trigger - Add to Death Destroy Summons <gen> the event (Unit - (Triggering unit)'s life becomes Equal To 0.00)
 
Last edited:
Level 26
Joined
Aug 18, 2009
Messages
4,097
It's 0.405 but GUI only allows 2 decimals by fixed value :wink:, so I thought I would just require it to be Equal To 0 that should also work as a unit's life is set to 0 when dying.

But another thing: This seems to work only once with or without reincarnation. After that, the hero is considered dead before the life event runs (also tested it with < 0.405).

Hmkay, then take less than 0.405 and leave out the dead condition, on equal to 0 the life event runs multiple times, though without dead condition this will cause problems when the unit's life is set while being dead but unprobable.

  • Death Destroy Summons
    • Events
    • Conditions
    • Actions
      • //Destroy summons, giving Triggering unit as the died hero
  • Events
    • Map initialization
  • Conditions
  • Actions
    • Custom script: set bj_wantDestroyGroup = true
    • Unit Group - Pick every unit in (Units in (Entire map) matching (((Matching unit) is A Hero) Equal To True)) and do (Actions)
      • Loop - Actions
        • Custom script: call TriggerRegisterUnitStateEvent(gg_trg_Death_Destroy_Summons, GetEnumUnit(), UNIT_STATE_LIFE, LESS_THAN, 0.405)
  • Events
    • Unit - A unit enters (Entire map)
  • Conditions
    • ((Triggering unit) is A Hero) Equal To True
  • Actions
    • Custom script: call TriggerRegisterUnitStateEvent(gg_trg_Death_Destroy_Summons, GetTriggerUnit(), UNIT_STATE_LIFE, LESS_THAN, 0.405)
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,273
Why should dieing with reincarnate kill all summons? The hero has not died, just temporarilly knowcked out.

Anyway, the process of doing it is to keep track of the units the hero summons and if the hero takes fatal damage (not stupid unit life events), get the damage source to deal fatal damage to all summons. This way the kills for all summons get properly creditied. As fatal damage is not blocked by reincarnate, it should trigger even if the hero does reincarnate after all summons were destroyed.
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
Though the hero might die without taking damage but this depends on the map. Maybe the reincarnation can also be self-made if it should trigger some death events anyway.

When doing it on damage event, be careful not to have another damage event which could block the damage finally/increase hp etc.

As we are not this precise now, of course the damage event could be combined with a null timer.
 
Level 4
Joined
Aug 27, 2007
Messages
127
OK, I'll try WaterKnight's trigger and see if it works. I trust he knows what he's doing :thumbs_up:

EDIT: PROBLEMS!!

Triggers won't compile. And I haz some screenshots that prove it.

ss1.jpg

ss2.jpg
 
Last edited:
Status
Not open for further replies.
Top