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
  • 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 The Helper:
    Happy Thursday!
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though

      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