• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Spell] Help with replacing summoned units

Status
Not open for further replies.
Level 1
Joined
Aug 1, 2012
Messages
4
I've already made a pretty basic unit-summoning spell that summons 1 unit at random from a selection of 3 (which works fine). I'm just struggling with how I go about replacing the summoned unit whenever the spell is cast again, like the Feral Spirit and Summon Misha (Rexxar) spells work.

It differs from those spells just because I need it so that FOR EXAMPLE if unit1 is summoned first, then if the spell is cast again, unit1, unit2, or unit3 (whichever appears) would get rid of the previous unit1. I also have the summon-trigger broken into 3 triggers, 1 for each level of the Hero ability.

I'm relatively new to triggers but definitely familiar with the w3editor otherwise...

Also, new the site and searched awhile without finding any answers, so I apologize if this is a repeat! :/
Attached the summon-unit-at-random-trigger if it somehow helps what I'm looking for.
 

Attachments

  • Trigger_SummonRandomUnit.png
    Trigger_SummonRandomUnit.png
    72.4 KB · Views: 192
Level 5
Joined
Jul 12, 2011
Messages
118
I think this is how you do it.

Create a variable with Unit value (let's just call it LOL_UNIT). Add the action Set LOL_Unit = (Last Created Unit) to your summoning triggers.

Make a new trigger with an event that starts when you cast the spell. Then create a If-Then-Else condition. If LOL_UNIT is alive (Use Boolean), then Unit - Kill LOL_Unit.

That's all.

EDIT : Use the Temp_Point you made. I see you didn't.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
Basically what you require is a method that overwrites last variable.
For example you spawn a summon unit, save this unit to a variable.
The next time you cast the spell, kill the unit that is saved into the last variable, after that create a new summon unit and set the unit to new variable and this cycle will go on and on.
 
Level 1
Joined
Aug 1, 2012
Messages
4
Thanks both of you. Tried it out and the trigger was super simple like OmNomNom suggested. I appreciate it! I think I was more focused on "unit1/unit2/unit3 replaces last created unit" when I should have been more focused on just getting ridding of the last created unit like you both said. Appreciate it!
 
Status
Not open for further replies.
Top