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.
  • WildTurkey WildTurkey:
    is there a stephen green in the house?
    +1
  • The Helper The Helper:
    What is up WildTurkey?
  • The Helper The Helper:
    Looks like Google fixed whatever mistake that made the recipes on the site go crazy and we are no longer trending towards a recipe site lol - I don't care though because it motivated me to spend alot of time on the site improving it and at least now the content people are looking at is not stupid and embarrassing like it was when I first got back into this like 5 years ago.
  • The Helper The Helper:
    Plus - I have a pretty bad ass recipe collection now! That section of the site is 10 thousand times better than it was before
  • The Helper The Helper:
    We now have a web designer at my job. A legit talented professional! I am going to get him to redesign the site theme. It is time.
  • Varine Varine:
    I got one more day of community service and then I'm free from this nonsense! I polished a cop car today for a funeral or something I guess
  • Varine Varine:
    They also were digging threw old shit at the sheriff's office and I tried to get them to give me the old electronic stuff, but they said no. They can't give it to people because they might use it to impersonate a cop or break into their network or some shit? idk but it was a shame to see them take a whole bunch of radios and shit to get shredded and landfilled
  • The Helper The Helper:
    whatever at least you are free
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?

      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