Tutorial How to create a cooldown for a passive spell

Galdiuz

Creator of Photon Command
Reaction score
98
How to create a cooldown for a passive spell.

This is a tutorial on how to create a passive spell with cooldown. This works with passive skills that is triggered (So no critical strike/bash etc. unless you trigger it), and is fully MUI. In this tutorial I'll make a spell that I'll call Mend, and I want my spell to heal units around the hero upon attack with a 2 second cooldown. (Of course, you could use other events as when a unit casts a spell etc.)

ABILITY EDITOR
First, we need to create 2 (3 if the spell is a hero skill) spells in the ability editor. These should have the same amount of levels, so if you want a 3 level skill, give 'em all 3 levels.
  • One icon spell based on an ability that can't be cast. I'll use Moon Glaive. This will be the icon when the spell is NOT on cooldown, and should have proper tooltips. I named my spell 'Mend (Icon)'.
  • One cooldown spell that doesn't stop what you're doing. I'll use Berserk. This will be the icon when the spell IS on cooldown, and you should set duration to 0.01 (unless you want to show a buff) and cooldown to the cooldown you want. This should have the same tooltips as the icon spell. I named my spell 'Mend (Cooldown)'.
  • If the spell is a hero skill, you'll also need one research spell that doesn't have an icon. I'll use Item Armor bonus. This will be the spell that you learn with your hero, and it should have a research tooltip and research icon. I named my spell 'Light - Mend'.

UNIT EDITOR
  • If your spell is a hero skill, add the Research spell.
  • If your spell is a unit skill that you start with, add the Icon spell.
  • If your spell is a unit skill that you get during the game, then add the Icon spell in a trigger.

TRIGGER EDITOR
First, if it's a hero spell we need a trigger that sets the level of the Icon and Cooldown spells when the Research spell is learned.
Trigger:
  • Mend Learn
    • Events
      • Unit - A unit Learns a skill
    • Conditions
      • (Learned Hero Skill) Equal to Light - Mend
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Learned skill level) Equal to 1
        • Then - Actions
          • Unit - Add Mend (Icon) to (Triggering unit)
        • Else - Actions
      • Unit - Set level of Mend (Cooldown) for (Triggering unit) to (Learned skill level)
      • Unit - Set level of Mend (Icon) for (Triggering unit) to (Learned skill level)

If the spell is a non-hero levelable skill, (Ie you level it by buying tomes etc.) just set the level of the Cooldown and Icon spells in your spell leveling/learning trigger.

Now, here's the actual trigger. Simply put, you add the cooldown spell, remove the icon spell and order your unit to cast the cooldown spell. Then you add whatever you want your spell to do, wait the cooldown, add the icon spell and remove the cooldown spell. (Don't forget to set spell levels!)
Trigger:
  • Mend
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Level of Mend (Icon) for (Attacking unit)) Not equal to 0
      • ((Owner of (Triggering unit)) is an enemy of (Owner of (Attacking unit))) Equal to True
    • Actions
      • Unit - Add Mend (Cooldown) to (Attacking unit)
      • Unit - Set level of Mend (Cooldown) for (Attacking unit) to (Level of Mend (Icon) for (Attacking unit))
      • Unit - Remove Mend (Icon) from (Attacking unit)
      • Unit - Order (Attacking unit) to Orc Troll Berserker - Berserk
      • Unit - Order (Attacking unit) to Attack (Attacked unit)
      • ----- Put anything you want your spell to do under this -----
      • Set Atemp_aloc = (Position of (Attacking unit))
      • Set Atemp_group = (Units within 150.00 of Atemp_aloc matching ((((Matching unit) is A structure) Equal to False) and (((Owner of (Matching unit)) is an ally of (Owner of (Attacking unit))) Equal to True)))
      • Unit Group - Pick every unit in Atemp_group and do (Actions)
        • Loop - Actions
          • Unit - Set life of (Picked unit) to (((Life of (Picked unit)) + 10.00) + (10.00 x (Real((Level of Mend (Cooldown) for (Attacking unit))))))
      • EGUI Leak - Destroy Atemp_group
      • EGUI Leak - Remove Atemp_aloc
      • ----- Put anything you want your spell to do over this -----
      • Wait 2.00 seconds
      • Unit - Add Mend (Icon) to (Attacking unit)
      • Unit - Set level of Mend (Icon) for (Attacking unit) to (Level of Mend (Cooldown) for (Attacking unit))
      • Unit - Remove Mend (Cooldown) from (Attacking unit)

The wait in this trigger is the cooldown. In my case, I want my spell to have 2 seconds cooldown, so I put a 2 second wait.

This concludes the tutorial. I hope that you find it usefull.
 

Executor

I see you
Reaction score
57
Does "Attacking Unit" work 100% after the wait?

I suppose not, that would mean you have to use global arrayed or local vars.
 

Galdiuz

Creator of Photon Command
Reaction score
98
Yep, it works for me at least. Never encountered any problems.
 

Executor

I see you
Reaction score
57
Well as far as I know most of the event responses couldn't be valid anymore after a wait, except GetTriggerUnit() which seems to be somehow local.

EDIT: Well tested GetAttacker() and seems to work.
 

avalya

New Member
Reaction score
37
Well, obviously no hero can cast when he or she is disabled, if you have a passive that activates when taking damage or something like that, it WILL bug.
 

Tru_Power22

You can change this now in User CP.
Reaction score
144
Couldn't you just use orb of thunder (new) and save yourself a whole bunch of work?
 

Tom_Kazansky

--- wraith it ! ---
Reaction score
157
well, this method can be applied to spell casts (not just attacks) and Orb of Lightning (new) can't do that.
 

Tru_Power22

You can change this now in User CP.
Reaction score
144
You should use Weeps GUI damage detection system. It it far better than unit is attacked.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top