• 🏆 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!

Passive ability with cooldown - Best method!

Level 9
Joined
Jul 30, 2012
Messages
156

Passive ability with cooldown - the easy way!

The hardest part of this tutorial is formatting it properly :(

Introduction

First of all, this tutorial is not a copy of [thread=211589]this[/thread]. This tutorial presents a new way to make passives with cooldown. This is not attack-based, instead it gives you a passive ability with a cooldown that you can trigger any time you want.

I've known this trick for a very long time, and I guess it's more than time to make it public, as I couldn't find it anywhere else.

Exhume Corpses - the magic passive

exhumecorpses.gif

The Exhume Corpses ability is the only passive ability with cooldown in the entire game!

I believe this has not been found before, because this ability does not have a cooldown by default. But in fact, it's just like any other spell: it can have a cooldown, a manacost, and it fires spell casting events whenever it's cast. The only difference is that it displays a button that cannot be clicked.

So how can we cast it? We don't need to do that, the Exhume Corpses ability automatically casts itself whenever possible!

Configuring Exhume Corpses

You can just make your custom ability based on Exhume Corpses and modify it as you like: you can change icons, tooltips, set a cooldown, and have multiple levels if you want.
attachment.php
Here I modify the icon and tooltips of Exhume Corpses to look like the Pocket Factory ability. I removed the techtree requirement and set a cooldown of 5 seconds.

Now the important thing is to set theDuration - Normal field to 0.01. This field determines how often the Exhume Corpses ability will check if it can be cast. Setting it to 0 would also work, but it causes the game to freeze some times (like if the unit is stunned), so the minimum safe value is 0.01.

The "Unit Type" and "Maximum Corpses" data fields can be ignored, we're not going to use them.

Triggering the cooldown

Exhume Corpses requires the Cargo Hold (Meat Wagon) ability ('Sch2') to be present on the unit. If this ability is not present, Exhume Corpses cannot be cast. Therefore, all you need to do is:

  • Unit - Add Cargo Hold (Meat Wagon) to <Your Unit>

After that, the Exhume Corpses ability will magically cast itself at every cooldown. But as you may know, Exhume Corpses creates a corpse with every cast. We need to remove this side effect, as we don't want the game to create a unit for no reason.

Fortunately that's very easy to achieve. To prevent the creation of the corpse we just need to disable the Cargo Hold ability. The easiest way to do that is with a requirement, just go to the Cargo Hold ability, select theTechtree - Requirements field, press Shift+Enter and type an invalid id:
attachment.php
Doing that, Cargo Hold will be always disabled for all players. Remeber that if your map uses Meat Wagons, this will interfere with them. You can fix that by using a custom Cargo Hold ability instead of the original (make sure that you use the Meat Wagon's Cargo Hold as the base)

Alternatively you can disable it directly with triggers:
  • Player - Disable Cargo Hold (Meat Wagon) for Player 1
But you would need to do that for all players. Using a requirement is much easier.

Triggering the effects

With everything ready, you can use your passive ability just like any other spell:
  • Pocket Factory
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Exhume Corpses
    • Actions
      • Unit - Create 1 Clockwerk Goblin for (Owner of (Triggering unit)) at (Position of (Triggering unit))
You can easily control when your passive will be cast simply by adding and removing Cargo Hold from the unit. And it does not interrupt the unit's orders when it goes on effect. In fact, this ability is really a spell, you just can't click on it.

Notice that when you add Cargo Hold to the unit, the ability will not be cast immediately, but only after a 0-second delay. So you should wait for the spell to finish if you want to remove Cargo Hold after that.


Tips and Tricks

Having multiple passives on the same unit


In normal ocasions, a unit can't have more than one custom ability with the same ability as base. But since Exhume Corpses is the only passive with cooldown, this is not an option if you want a unit to have multiple of it.

The only solution is, whenever you want to make one of those abilities go on cooldown, you temporarily disable all the others:

  • Cast Passive 1
    • Actions
      • Player - Disable Passive 2 for (Owner of (Triggering unit))
      • Unit - Add Cargo Hold (Meat Wagon) from (Triggering unit)
  • Cast Passive 2
    • Actions
      • Player - Disable Passive 1 for (Owner of (Triggering unit))
      • Unit - Add Cargo Hold (Meat Wagon) from (Triggering unit)

And then you make a trigger to re-enable all abilities after casting any of them:

  • Multiple passives
    • Events
      • Unit - A unit Finishes casting an ability
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Ability being cast) Equal to Passive 1
          • (Ability being cast) Equal to Passive 2
    • Actions
      • Unit - Remove Cargo Hold (Meat Wagon) from (Triggering unit)
      • Player - Enable Passive 1 for (Owner of (Triggering unit))
      • Player - Enable Passive 2 for (Owner of (Triggering unit))

Using Exhume Corpses with items


The Exhume Corpses ability can also be used with items. With this you can create a passive item that displays a cooldown, similar to the "Amulet of Spell Shield".

However, Exhume Corpses doesn't work if you put it directly on the item. So instead, you must put it in a Spellbook, and then put this spellbook on the item:

attachment.php
Make sure that Shared Spell Cooldown is set to true in the Spellbook. After that, you can put the Spellbook on an item that cannot be actively used:

attachment.php
Doing that, Exhume Corpses will work perfectly inside an item. When it gets cast, it will cause the item to go on cooldown, and it will even fire a "Unit uses item" event. And if the unit drops and re-acquires the item, the cooldown will still be there and work as expected.

Forcing the ability to cast immediately


When you add the Cargo Hold ability to a unit, your passive ability will not be cast immediately, but only after a small delay. This is the delay that you put in theDuration - Normal field, you can't set it to 0, and even if you did, it still wouldn't be instant.

But if for some reason you really need to bypass this delay and cast your ability instantly, you can simply give the order directly:

  • Custom script: call IssueImmediateOrderById(<Your Unit>, 852537)

The order id for Exhume Corpses is 852537. When you issue this order, if Cargo Hold present on the unit, Exhume Corpses will be cast immediately, ignoring the delay.

However this has the downside that it interruputs the current orders of the unit, so I do not recommend using this method unless you really know what you're doing.

Conclusion

I have attached a Test Map demostrating the passive with cooldown. In this example it creates a Clockwerk Goblin every 5 seconds, while displaying a cooldown indicator to the user.

If you have any questions or suggestions, please let me know. And I'm sorry for being too lazy to write this guide before, I have really found this trick a long time ago.

Changelog

02-04-2016

-Added information about using Exhume Corpses with items
-Added information about having multiple passives on a unit
-Added information about making the ability cast immediately
-Changed minimum delay of the ability to 0.01 to prevent game freeze

01-27-2016

-Initial release
 

Attachments

  • Exhume Corpses.png
    Exhume Corpses.png
    97.6 KB · Views: 1,938
  • Cargo Hold.png
    Cargo Hold.png
    86.8 KB · Views: 1,887
  • TestMap.w3x
    16.4 KB · Views: 536
  • Spellbook.png
    Spellbook.png
    100.1 KB · Views: 1,789
  • Item.png
    Item.png
    103.3 KB · Views: 1,805
Last edited:
Level 9
Joined
Jul 30, 2012
Messages
156
Wasn't aware of this either. Will it still work if the unit is stunned?

Not only it doesn't work, but it caused the game to freeze when the unit was stunned! Thanks to your post, I could find that bug, now I set the duration to 0.01 instead of 0, and it doesn't freeze the game anymore (but unfortunately, the ability doesn't go on cooldown while the unit is stunned)

I have modified some things in the guide, fixed this bug, and added some new bits of useful information. If you have something more to say, I'd like to hear it.
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,182
What do you mean "why", I just don't think the tutorial explains the easiest way to make a passive have a cooldown.

edit: on second though, my original approach was slightly invalid.
But regardless, using this method is not flexible. Making a passive with a cooldown is not the same as automatically procing every x seconds.

Example: "One attack every x seconds got 100% crit chance"
In which case this method does not work.
 
Last edited:
What do you mean "why", I just don't think the tutorial explains the easiest way to make a passive have a cooldown.

edit: on second though, my original approach was slightly invalid.
But regardless, using this method is not flexible. Making a passive with a cooldown is not the same as automatically procing every x seconds.

Example: "One attack every x seconds got 100% crit chance"
In which case this method does not work.

This tutorial just deals with getting a passive ability to show a cooldown (visually). So it should work with any example (including that one)--just trigger the passive and then run the cooldown so it can only proc every X seconds.

You can do it with active abilities as well (as you described)--and that is how a lot of maps have done it--but this method does it with an actual passive so it doesn't have the downside of being clickable, plus it can be triggered on demand without interrupting the unit's order.
 

Kyrbi0

Arena Moderator
Level 44
Joined
Jul 29, 2008
Messages
9,487
Leandrotp, as Leader of the Secret Council of Object Editor Delving, Sounding, and Otherwise Discovering (SCoOEDSOD for short), I must warn you: you stand at a precipice both great and terrible.

: D

Seriously, though, creating a whole Tutorial to broadcast such an impressive find? Great honor or great shame await you, for flouting our primary tenants; "Hold That Which Thou Findest Sacred, Even Unto Death or Hard-Drive Crash"

I am impressed; primarily because I did not know this. I have one big question, but first two smaller ones:

the only passive ability with cooldown in the entire game!
Come now. Perhaps you could say "the only passive ability w/ cooldown I know of in the entire game", but such a statement puts you right in the crosshairs of the Council of Mathematic Literacy and Correctness In Diverse Forums (CoMLaCIDF for short).

Alright I made that last group up.

Alright I made them all up. Don't have to be so rude about it. : P (Except for the first one, which totally exists in my head)

(To be fair, I don't know of a single solitary other one as well, and the testing would be insaaaaaane. But still)

leandrotp said:
Alternatively you can disable it directly with triggers:
...
But you would need to do that for all players. Using a requirement is much easier.
!!!

HOLD ON.

So wait. Does this work... For anything? Specifically Spellbooks?

Because if it does... You just totally made my day. : )

We're always talking of using a Disabled Spellbook to hide spells in a unit's command card... Well, I'm always trying to pare down my coding to the absolute essentials (& using the OE entirely whenever possible), so this might be just the trick. : )

~

The big question: "What can one do with this?"

Though I bring shame upon my family by asking, I must admit that though this sounds interesting & powerful, I'm at a loss for what exactly can be done with it. Normally I discover these little OE quirks & am all like "AW YEAH! NOW I CAN DO (insert thing here)!!", but this one... Ach, stumps me. Some examples, por favor?





Pssst.... Hey, buddy. Wanna join my club? The SCoOEDSOD could use a Vice Prez... xD
 

Kyrbi0

Arena Moderator
Level 44
Joined
Jul 29, 2008
Messages
9,487
Why is "Exhume Corpse" scanning for corpses in the environment around the triggering/casting unit? I get how the Meat Wagon is, but Exhume just automatically fills the Corpse Cargo Hold with corpses whenever it procs, right?

(maybe someone who can look at the underlying JASS could help elucidate)
 
Level 13
Joined
Oct 18, 2013
Messages
690
Why is "Exhume Corpse" scanning for corpses in the environment around the triggering/casting unit? I get how the Meat Wagon is, but Exhume just automatically fills the Corpse Cargo Hold with corpses whenever it procs, right?

(maybe someone who can look at the underlying JASS could help elucidate)
The underlying code is C+ not JASS lol. I didnt notice lag issues using this, but I think it might just crash on newer patches. I'll look into it further.
 

Uncle

Warcraft Moderator
Level 63
Joined
Aug 10, 2018
Messages
6,455
I've been using Exhume Corpses with the Start Cooldown function on the latest patch:
  • Unit - For Unit (Triggering unit), start cooldown of ability Exhume Corpses " over "5.00 seconds.
I've never noticed any performance issues but I could've easily been blind to it. I was only using it on a handful of heroes.

I wonder if changing the abilities fields could prevent the issue. Like if you set the maximum number of corpses to 0 or adjusted the Duration.

Also, Reincarnation seems like an out of the question alternative. I guess you could use a Damage Engine to detect lethal damage and remove the Reincarnation ability in response, but it's not a very pretty solution and it will come with some consequences.

Anyway, maybe there's another ability out there that can have it's cooldown started. $5 to the man that finds it :p
 
Last edited:

Uncle

Warcraft Moderator
Level 63
Joined
Aug 10, 2018
Messages
6,455
The Orb effect abilities have their own problems as well since they requires 2 abilities and mess with orb stacking.

I guess at the end of the day if Exhume Corpses is really problematic you could make the ability based on Channel and give it a 0 second cooldown. This would be clickable but nothing would happen if you did so. It'd only ever go on cooldown when you triggered it to.
 
Last edited:
  • Like
Reactions: KPC
Level 13
Joined
Oct 18, 2013
Messages
690
A funny dummy passive would be Spell Shield Amulet with a dummy caster proccing it immediately, though I'm not 100% that it displays Cooldown.
 
Level 3
Joined
Nov 30, 2012
Messages
30
I set manacost to 9999 then set ability level 2 manacost=0
setunitabilitylevel 2 makes the ability coolcown
when spelleffect,set real=unitmana then setunitabilitylevel 1 then after 0. second set unitmana=real
thisway can make one ability coolcown without unavailable other ability
 
Level 14
Joined
Aug 31, 2009
Messages
774
Can you provide an example of the Item implementation?

I followed the tutorial's example of adding an Item (Actively Used = False) with a Spellbook containing an ability based on Exhume Corpses, but it won't cast / display a cooldown.

Does the spellbook (or the hero carrying the item) not also need to contain a disabled Cargo Hold ability to function?

EDIT: Found the issue. As I suspected, the unit (or the spellbook) must also contain a Disabled Cargo Hold ability. Putting it in the spellbook itself is a little neater, but harder to disable at the right time.
 
Last edited:
Level 9
Joined
Jul 30, 2012
Messages
156
I've been using Exhume Corpses with the Start Cooldown function on the latest patch:
  • Unit - For Unit (Triggering unit), start cooldown of ability Exhume Corpses " over "5.00 seconds.
I've never noticed any performance issues but I could've easily been blind to it. I was only using it on a handful of heroes.

I wonder if changing the abilities fields could prevent the issue. Like if you set the maximum number of corpses to 0 or adjusted the Duration.

The Duration - Normal field controls how often the game will check for castability, if you set it to a really high value, the internal loop that checks castability will never run, eliminating any possible performance issue.

Of course the ability will also never be casted, but now that we have a function to put an ability into cooldown, this is no longer an issue.
 
Top