[Spell] How to remove Summoned Unit?

Level 9
Joined
Mar 26, 2020
Messages
205
I know there is a trigger that kills or remove summoned unit, but in my case its not working...i dont know why
i was making an ability where it summons a unit and after casting that summon ability, it changes into different ability using trigger, making the summoned unit exist, but i want when casting the second ability removes that unit after casting even if there is still duration left

ex: summon ward > summons unit > has 30 sec duration > ability changes to thunderclap after casting via trigger > cast thunderclap to remove unit (doesnt work, dunno why)
 
Unless you store your summoned unit in a variable you'll lose track of it in the second trigger, e.g.

  • Spell
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Thunder Clap
    • Actions
      • Unit - Remove (Summoned unit) from the game // <- This doesn't work because the event doesn't imply summoning an unit
 
I know there is a trigger that kills or remove summoned unit, but in my case its not working...i dont know why
i was making an ability where it summons a unit and after casting that summon ability, it changes into different ability using trigger, making the summoned unit exist, but i want when casting the second ability removes that unit after casting even if there is still duration left

ex: summon ward > summons unit > has 30 sec duration > ability changes to thunderclap after casting via trigger > cast thunderclap to remove unit (doesnt work, dunno why)
There is no 'trigger' to kill or remove summoned units.

But there's multiple Actions that can kill units in general:
  • Actions
    • Unit - Kill (Any unit)
    • Unit - Remove (Any unit) from the game <-- Skips the 'A unit Dies' event
    • Unit - Deal 999999.00 damage to (Any unit)...
    • Unit - Add a 5.00 second Generic expiration timer to (Any unit)
I say this just for the sake of clarity.

More importantly, the solution you want will depend. You have to answer these questions:
1) How many units will be able to have this summon ability?
2) If more than one unit, how many can exist on the map at any given moment?
3) If more than one unit can exist, is it limited to 1 per Player?

Assuming you said 'yes' to #3, you can use an MPI solution, meaning you're going to make this work for one caster per player:
  • Events
    • Unit - A unit Spawns a summoned unit
  • Conditions
    • (Unit-type of (Summoned unit)) Equal to YOUR SUMMON
  • Actions
    • Set Variable PN = (Player number of (Owner of (Triggering unit))
    • Set Variable Summoned_Unit[PN] = (Summoned unit)
^ Note that if you manually create the summoned unit then you can skip this trigger and simply Set Summoned_Unit to be the (Last created unit) instead.
  • Events
    • Unit - A unit Starts the effect of an ability
  • Conditions
    • (Ability being cast) Equal to YOUR OTHER ABILITY
  • Actions
    • Set Variable PN = (Player number of (Owner of (Triggering unit))
    • Unit - Kill Summoned_Unit[PN]
^ Summoned_Unit is a Unit array variable. PN is an Integer variable.

If you want any number of units to use these abilities without issues then you will need an MUI solution. I recommend Unit Indexing (link in my signature). The above two triggers could be reused, but you would set PN's value to the (Custom value of (Triggering unit)) instead.
 
Last edited:
More importantly, the solution you want will depend. You have to answer these questions:
1) How many units will be able to have this summon ability?
2) If more than one unit, how many can exist on the map at any given moment?
3) If more than one unit can exist, is it limited to 1 per Player?
wait, kill/remove triggers doesnt work?
also regarding to the questions...
just 1 summoned unit like most vanilla abilities where summoning a new one will replace the existing one, and yes its limit to one player
also how do you set that variable trigger thingy? never seen those before lol


Unless you store your summoned unit in a variable you'll lose track of it in the second trigger, e.g.

  • Spell
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Thunder Clap
    • Actions
      • Unit - Remove (Summoned unit) from the game // <- This doesn't work because the event doesn't imply summoning an unit

that's basically what i did, so it doesnt due to the event...i see
or perhaps should i call a trigger inside the trigger separate for the summoned unit?
 
Click on the X to create a new variable like this

1754996804246.png


Then you can assign something to that variable and you can refer to it in other triggers
 
Back
Top