• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Cancel KillUnit()

Status
Not open for further replies.
Level 19
Joined
Mar 18, 2012
Messages
1,716
Is there a way to cancel the KillUnit() native, so the unit doesn't die?
I tried setting widget life and adding invul.

I asked because KillUnit changes a unit behaviour in
GroupEnumUnitsIn... combined with 'Aloc'.

Locust units start to appear in the enumeration.
If there is a way to stop KillUnit from actually killing the unit,
that would be a way to make dummies enumerable, while having the
locust effect. I don't know what KillUnit() does appart from that,
so maybe it's not recommended to use it.
 
If a dummy unit has locust the behaviour changes somehow a bit with KillUnit() and also with ShowUnit().

We had this problem in ice escape maps, too.

After Hiding/Unhiding a unit Aloc can be removed (at least some features of it as Enum, Collision, but not all ;D),
and so can be applied probably to Unit Death event - to remove aloc.

So if you remove Aloc from the dead unit you will be allowed to successfully re-add Aloc again, and with all the feature set again.

Edit:

To the initial question acutally, no I don't know a way to cancel the KillUnit(). ^^
 
Level 9
Joined
Jul 30, 2012
Messages
156
Is there a way to cancel the KillUnit() native, so the unit doesn't die?

Yes, there is. It's called Phoenix:
me at playdota.com said:
The Phoenix ability ('Aphx') can prevent the death of a unit. Whenever a unit with 'Aphx' is going to die, the Phoenix ability will completely block it's death, and the unit will be ordered to "phoenixmorph". You just need to catch this order and remove the Phoenix ability, to prevent it from morphing.

The Phoenix ability can create the very interesting effect of making a unit have 0 life (or even negative life), while not being dead. And once you set a unit's life to 0 or less using this trick, the unit becomes completely immortal, not even KillUnit can kill it. Only after setting the life to a positive number, the unit becomes "mortal" again.

However it's very probable that this will not give the effect you want. It's possible that locust units only become enumerable when they die, and since they will not die at all using this trick, it's probable that nothing will happen. If that's the case, I suggest that you try using Reincarnation with 0 delay.
 
Level 19
Joined
Mar 18, 2012
Messages
1,716
Why are you using KillUnit on your locusts in the first place if you do not want that?
Locust units aren't considered in native GrouEnumUnitsInRange/Rect which is a very wanted side effect.

It turned out that KillUnit(locustUnit) removes that effect and the units appear group enumerations.

It could be useful for maps which need a custom missile system and missile collide missile detection.
It would be much more performant than comparing square of distance from missile A to B, A to C, A to D, ....

KillUnit could have more sideeffects, which I didn't discover.

Apart from that it is useful documentation, as many who aren't using a dummy recycler go with KillUnit(),
when the dummy is no longer needed.
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
Okay, so you do not want to prevent/cancel KillUnit but only have parts of its effect concerning locusts. As was already stated, you do not need to kill the unit to make the it pickable again. Locust consists of multiple effects, which are not properly updated when subject to UnitRemoveAbility but may be updated (completely or partially) under other circumstances such as death, morphing or hiding/showing because the game re-evaluates some properties there. So the question is what properties are necessary for you to keep.

I tried leandrotp's suggestion a bit. Phoenix Morph prevents the unit's death and the unit can be picked again, which is more likely due to the transformation, it cannot be selected but be targeted.
 
Level 9
Joined
Jul 30, 2012
Messages
156
Phoenix Morph prevents the unit's death and the unit can be picked again, which is more likely due to the transformation, it cannot be selected but be targeted.

You must cancel the transformation by registering a ISSUED_ORDER event and remove the Phoenix ability as soon as the unit receives the "phoenixmorph" order (852482). Doing that, the unit's HP will go to 0, but it will not die, and will not morph.
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
You must cancel the transformation by registering a ISSUED_ORDER event and remove the Phoenix ability as soon as the unit receives the "phoenixmorph" order (852482). Doing that, the unit's HP will go to 0, but it will not die, and will not morph.

Does not appear like it loses any trait of locust-y then. To make it immortal, you can also set the target unit type to have 0 initial max hp.

edit: And the unit should not be healed/regenerate hp over the threshold, else it will be considered mortal again.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
Dont use KillUnit().
If UnitApplyTimedLife() or UnitApplyDamage() make the same effect, then you can use tricks like this.

However, I assume that the effects are the same as morphing a unit while being locust, which can be much better for certain systems... aka a missile system.
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
did you try making them "Does not decay, can't be raised"? The unit should be removed quite quickly with this set. Alternatively, you can move the unit to the corner of the map after calling KillUnit, downside is you do not get death animation
 
Status
Not open for further replies.
Top