I have an ability on one of my heroes that spawns units. I am trying to make it so that when he activates the ability it first kills all units of that type that are currently alive, then spawn the units. Basically I am looking for a "max" on the number of units that are spawned. As of now, I have tried detecting the order issued but that seems to trigger after the units have already been spawned.
If anyone has any tips as to how to do this, it would be awesome.
I'm not sure what you are talking about, wasn't explained very well. If I have to guess, you are talking about spirit wolf ability from wc3.
1st method trigger:
Add a dummy behavior on the summoned units
You just have to make a trigger when ability is cast (event), remove the summoned units with behavior that behavior belonging to
2nd method data editor:
Make a behavior (behavior - buff - periodic effect) with suicide effect. Make a validator on the behavior, checking if there are any units of that type from the player.
I'm sure there is a better method than above but I'm so tired and both methods will work nevertheless.
I apologize for the unclear explanation. This is what I am trying to do:
I click the button on the summon ability
the trigger checks for any existing units of that type
- if any exist, kill them
spawn the units
However, in the trigger editor if you use:
Event: Unit - Any Unit is issued an order to Hero Summon
Action: Unit Group - For each unit unit in (Zergling units in (Entire map) owned by player Any Player matching Excluded: Missile, Dead, Hidden, with at most Any Amount) do:
- Kill Unit unit
That will kill even the newly summoned zergling. How do I prevent this from happening? How do I kill the existing ones prior to the new ones being summoned?
I just solved this by adding a buff to each summoned unit "New Summon" that has a 1 second duration, it then checks for that buff prior to killing the unit.
I see you found a fix, but I was thinking you could just remove the New Summon buff and ALSO remove the effect the Hero Summon has and instead place a create x units for the player using the ability. This way you have fewer dummy effects and buffs going off and on. Not sure if this is important just something I personally would try.
An alternative would be to implement the entire thing in the data editor instead of using triggers. Link the ability to a Persistent effect, and set its Initial Effect to a Search Area effect that searches the entire map and then destroys the units you want destroyed, and then set the Persistent effect's Expire Effect to the Create Unit effect. No need for triggers at all.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
I have an ability on one of my heroes that spawns units. I am trying to make it so that when he activates the ability it first kills all units of that type that are currently alive, then spawn the units. Basically I am looking for a "max" on the number of units that are spawned. As of now, I have tried detecting the order issued but that seems to trigger after the units have already been spawned.
If anyone has any tips as to how to do this, it would be awesome.
I'm not sure what you are talking about, wasn't explained very well. If I have to guess, you are talking about spirit wolf ability from wc3.
1st method trigger:
Add a dummy behavior on the summoned units
You just have to make a trigger when ability is cast (event), remove the summoned units with behavior that behavior belonging to
2nd method data editor:
Make a behavior (behavior - buff - periodic effect) with suicide effect. Make a validator on the behavior, checking if there are any units of that type from the player.
I'm sure there is a better method than above but I'm so tired and both methods will work nevertheless.
I apologize for the unclear explanation. This is what I am trying to do:
I click the button on the summon ability
the trigger checks for any existing units of that type
- if any exist, kill them
spawn the units
However, in the trigger editor if you use:
Event: Unit - Any Unit is issued an order to Hero Summon
Action: Unit Group - For each unit unit in (Zergling units in (Entire map) owned by player Any Player matching Excluded: Missile, Dead, Hidden, with at most Any Amount) do:
- Kill Unit unit
That will kill even the newly summoned zergling. How do I prevent this from happening? How do I kill the existing ones prior to the new ones being summoned?
I just solved this by adding a buff to each summoned unit "New Summon" that has a 1 second duration, it then checks for that buff prior to killing the unit.
I see you found a fix, but I was thinking you could just remove the New Summon buff and ALSO remove the effect the Hero Summon has and instead place a create x units for the player using the ability. This way you have fewer dummy effects and buffs going off and on. Not sure if this is important just something I personally would try.
GL with the map thou
An alternative would be to implement the entire thing in the data editor instead of using triggers. Link the ability to a Persistent effect, and set its Initial Effect to a Search Area effect that searches the entire map and then destroys the units you want destroyed, and then set the Persistent effect's Expire Effect to the Create Unit effect. No need for triggers at all.