Cooldown of ability for normal unit

CuteCumber

Member
Reaction score
4
I've made myself a trigger that gives unit(non-hero) a set of abilities when buying an item, a trigger that revive the unit when it dies and a trigger that gives the item and abilities once the unit is revived(recreated actually). BUT the problem is, when the unit casts an ability and die before the cooldown of the ability finishes, my unit revive trigger will create a new unit and give the ability to it again. Since it is a newly added ability, the ability is active again. I found it annoying because when the unit dies, it actually revives with all cooldown rested. Please help me on this. I want the cooldown continue running when recreated. Thank you.
 

Necrach

You can change this now in User CP.
Reaction score
62
Mayb you can change your revive system, so that instead of creating a new unit via triggers, you give the unit an invisible Reincarnation ability and moves it (if necessery) as soon as it is revived :)
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
is your unit a hero? if not it will be a little bit tricky.

as necrach said, for normal units i would suggest using reincarnation and moving the unit outside the map when killed and back inside when revived.
 

Necrach

You can change this now in User CP.
Reaction score
62
@Accname, I have a question for you (on topic) which event (/conditions) should you use to detect when a unit dies but have reincarnation, and can you move the unit when not yet reincarnated? :eek:
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
damage detection systems work always when detecting whether a unit dies or not.

if the incoming damage (damage taken) is bigger then the health of a unit it is most probably dead.
and of course a unit can be moved even if its dead, many systems use dead units as missle dummys instead of living units with locust.

the only problem is that you cannot select the time when your units should revive by the reincarnation. you cannot tell them "revive now!", they will revive when the reincarnation timer runs out, you would have to keep them out of the game manually. (changing owner to neutral passive, moving out of map, etc)
 

CuteCumber

Member
Reaction score
4
Well. My unit is not a hero. How to actually 'move unit out of map' when it is dead. It must be for 10 players. Can somebody post a trigger on it. Thank you.
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
well, as i said you would need to add reincarnation to your unit, best to use without any time so the unit is revived instantly.

next step would be to implement Weeps GDD (GUI friendly damage detection) you can find it in the "turtorials and resources" sub-forum.

as an event you use the GDD unit takes damage event provided by that system.

then you check whether the damage dealt is bigger then the hitpoints of your unit. (your unit wont die because of the reincarnation)
if you want that unit to die just remove it, if not move it outside the map bounds. this, however is not possible with GUI, you would need to use jass here:
custom script: call SetUnitX(unit, x)
would be the line to set the x coordinate, same goes for y. some point outside the map and the unit is mostly unuseable. but it would be better to remove it from the selection of the players and to change the owner to passive since you might have more then one unit moved there at once.

for the visual stuff you should create another unit of the same kind as the dying units at the position and kill it instantly (of course you have to remove the reincarnation skill first) so a "death" animation will be played and a corpse will stay.

to revive your unit you just have to move it back inside the map and switch the owner back, for this purpose you should somehow save the owner, maybe in the custom value if its not used for something specific already.
otherwise you could even use a hashtable if you like.
 
General chit-chat
Help Users

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top