• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

How to have charge system spell like items?

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
On version 1.31+ you can manually start the cooldown of an ability as well as modify it's tooltip at runtime. So by setting the ability cooldown to 0 in the Object Editor, relying on a Timer for the "charge interval", and managing the charges (+1, -1) as needed, you can create this effect for any ability.

Here's an example using Holy Light as the base ability.

Note that this only works for ONE hero with the Holy Light ability at a time:
  • Holy Light Learn
    • Events
      • Unit - A unit Learns a skill
    • Conditions
      • (Learned Hero Skill) Equal to Holy Light
    • Actions
      • -------- Track the hero, starting charges, max charges, and interval between gaining charges: --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Learned skill level) Equal to 1
        • Then - Actions
          • Set VariableSet Holy_Light_Hero = (Triggering unit)
          • Set VariableSet Holy_Light_Charges = 1
          • Set VariableSet Holy_Light_Charges_Max = 3
          • Set VariableSet Holy_Light_Charges_Interval = 6.00
          • Countdown Timer - Start Holy_Light_Timer as a Repeating timer that will expire in Holy_Light_Charges_Interval seconds
        • Else - Actions
      • -------- --------
      • -------- Update the extended tooltip of the ability to show the charges: --------
      • Trigger - Run Holy Light Update Tooltip <gen> (ignoring conditions)
  • Holy Light Gain Charge
    • Events
      • Time - Holy_Light_Timer expires
    • Conditions
    • Actions
      • -------- Add a charge every X seconds if not already at max: --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Holy_Light_Charges Less than Holy_Light_Charges_Max
        • Then - Actions
          • Set VariableSet Holy_Light_Charges = (Holy_Light_Charges + 1)
          • -------- --------
          • -------- Update the extended tooltip of the ability to show the charges: --------
          • Trigger - Run Holy Light Update Tooltip <gen> (ignoring conditions)
          • -------- --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Holy_Light_Charges Equal to Holy_Light_Charges_Max
            • Then - Actions
              • Countdown Timer - Pause Holy_Light_Timer
            • Else - Actions
        • Else - Actions
  • Holy Light Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Holy Light
    • Actions
      • -------- Subtract a charge and start the cooldown if you run out: --------
      • Set VariableSet Holy_Light_Charges = (Holy_Light_Charges - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Holy_Light_Charges Equal to 0
        • Then - Actions
          • Unit - For Unit Holy_Light_Hero, start cooldown of ability (Ability being cast) " over "(Remaining time for Holy_Light_Timer) seconds.
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Holy_Light_Charges Equal to (Holy_Light_Charges_Max - 1)
            • Then - Actions
              • Countdown Timer - Start Holy_Light_Timer as a Repeating timer that will expire in Holy_Light_Charges_Interval seconds
            • Else - Actions
      • -------- --------
      • -------- Update the extended tooltip of the ability to show the charges: --------
      • Trigger - Run Holy Light Update Tooltip <gen> (ignoring conditions)
  • Holy Light Update Tooltip
    • Events
    • Conditions
    • Actions
      • -------- Apply the tooltip to the ability: --------
      • Set VariableSet Holy_Light_Tooltip = (A holy light that can heal a friendly living unit for + ((String((200 x (Level of Holy Light for Holy_Light_Hero)))) + ( or deal half damage to an enemy Undead unit. + (|n|nCharges: + ((String(Holy_Light_Charges)) + (/ + (String(Holy_Light_Charges_Max)))))
      • Ability - Set Extended Tooltip of Holy Light to Holy_Light_Tooltip for level ((Level of Holy Light for Holy_Light_Hero) - 1)
 

Attachments

  • Holy Light with Charges.w3m
    20.3 KB · Views: 4
Last edited:
Level 26
Joined
Sep 7, 2018
Messages
540
On version 1.31+ you can manually start the cooldown of an ability as well as modify it's tooltip at runtime. So by setting the ability cooldown to 0 in the Object Editor, relying on a Timer for the "charge interval", and managing the charges (+1, -1) as needed, you can create this effect for any ability.

Here's an example using Holy Light as the base ability.

Note that this only works for ONE hero with the Holy Light ability at a time:
  • Holy Light Learn
    • Events
      • Unit - A unit Learns a skill
    • Conditions
      • (Learned Hero Skill) Equal to Holy Light
    • Actions
      • -------- Track the hero, starting charges, max charges, and interval between gaining charges: --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Learned skill level) Equal to 1
        • Then - Actions
          • Set VariableSet Holy_Light_Hero = (Triggering unit)
          • Set VariableSet Holy_Light_Charges = 1
          • Set VariableSet Holy_Light_Charges_Max = 3
          • Set VariableSet Holy_Light_Charges_Interval = 6.00
          • Countdown Timer - Start Holy_Light_Timer as a Repeating timer that will expire in Holy_Light_Charges_Interval seconds
        • Else - Actions
      • -------- --------
      • -------- Update the extended tooltip of the ability to show the charges: --------
      • Trigger - Run Holy Light Update Tooltip <gen> (ignoring conditions)
  • Holy Light Gain Charge
    • Events
      • Time - Holy_Light_Timer expires
    • Conditions
    • Actions
      • -------- Add a charge every X seconds if not already at max: --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Holy_Light_Charges Less than Holy_Light_Charges_Max
        • Then - Actions
          • Set VariableSet Holy_Light_Charges = (Holy_Light_Charges + 1)
          • -------- --------
          • -------- Update the extended tooltip of the ability to show the charges: --------
          • Trigger - Run Holy Light Update Tooltip <gen> (ignoring conditions)
          • -------- --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Holy_Light_Charges Equal to Holy_Light_Charges_Max
            • Then - Actions
              • Countdown Timer - Pause Holy_Light_Timer
            • Else - Actions
        • Else - Actions
  • Holy Light Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Holy Light
    • Actions
      • -------- Subtract a charge and start the cooldown if you run out: --------
      • Set VariableSet Holy_Light_Charges = (Holy_Light_Charges - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Holy_Light_Charges Equal to 0
        • Then - Actions
          • Unit - For Unit Holy_Light_Hero, start cooldown of ability (Ability being cast) " over "(Remaining time for Holy_Light_Timer) seconds.
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Holy_Light_Charges Equal to (Holy_Light_Charges_Max - 1)
            • Then - Actions
              • Countdown Timer - Start Holy_Light_Timer as a Repeating timer that will expire in Holy_Light_Charges_Interval seconds
            • Else - Actions
      • -------- --------
      • -------- Update the extended tooltip of the ability to show the charges: --------
      • Trigger - Run Holy Light Update Tooltip <gen> (ignoring conditions)
  • Holy Light Update Tooltip
    • Events
    • Conditions
    • Actions
      • -------- Apply the tooltip to the ability: --------
      • Set VariableSet Holy_Light_Tooltip = (A holy light that can heal a friendly living unit for + ((String((200 x (Level of Holy Light for Holy_Light_Hero)))) + ( or deal half damage to an enemy Undead unit. + (|n|nCharges: + ((String(Holy_Light_Charges)) + (/ + (String(Holy_Light_Charges_Max)))))
      • Ability - Set Extended Tooltip of Holy Light to Holy_Light_Tooltip for level ((Level of Holy Light for Holy_Light_Hero) - 1)
thanks a lot.
 
Level 26
Joined
Sep 7, 2018
Messages
540
On version 1.31+ you can manually start the cooldown of an ability as well as modify it's tooltip at runtime. So by setting the ability cooldown to 0 in the Object Editor, relying on a Timer for the "charge interval", and managing the charges (+1, -1) as needed, you can create this effect for any ability.

Here's an example using Holy Light as the base ability.

Note that this only works for ONE hero with the Holy Light ability at a time:
  • Holy Light Learn
    • Events
      • Unit - A unit Learns a skill
    • Conditions
      • (Learned Hero Skill) Equal to Holy Light
    • Actions
      • -------- Track the hero, starting charges, max charges, and interval between gaining charges: --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Learned skill level) Equal to 1
        • Then - Actions
          • Set VariableSet Holy_Light_Hero = (Triggering unit)
          • Set VariableSet Holy_Light_Charges = 1
          • Set VariableSet Holy_Light_Charges_Max = 3
          • Set VariableSet Holy_Light_Charges_Interval = 6.00
          • Countdown Timer - Start Holy_Light_Timer as a Repeating timer that will expire in Holy_Light_Charges_Interval seconds
        • Else - Actions
      • -------- --------
      • -------- Update the extended tooltip of the ability to show the charges: --------
      • Trigger - Run Holy Light Update Tooltip <gen> (ignoring conditions)
  • Holy Light Gain Charge
    • Events
      • Time - Holy_Light_Timer expires
    • Conditions
    • Actions
      • -------- Add a charge every X seconds if not already at max: --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Holy_Light_Charges Less than Holy_Light_Charges_Max
        • Then - Actions
          • Set VariableSet Holy_Light_Charges = (Holy_Light_Charges + 1)
          • -------- --------
          • -------- Update the extended tooltip of the ability to show the charges: --------
          • Trigger - Run Holy Light Update Tooltip <gen> (ignoring conditions)
          • -------- --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Holy_Light_Charges Equal to Holy_Light_Charges_Max
            • Then - Actions
              • Countdown Timer - Pause Holy_Light_Timer
            • Else - Actions
        • Else - Actions
  • Holy Light Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Holy Light
    • Actions
      • -------- Subtract a charge and start the cooldown if you run out: --------
      • Set VariableSet Holy_Light_Charges = (Holy_Light_Charges - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Holy_Light_Charges Equal to 0
        • Then - Actions
          • Unit - For Unit Holy_Light_Hero, start cooldown of ability (Ability being cast) " over "(Remaining time for Holy_Light_Timer) seconds.
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Holy_Light_Charges Equal to (Holy_Light_Charges_Max - 1)
            • Then - Actions
              • Countdown Timer - Start Holy_Light_Timer as a Repeating timer that will expire in Holy_Light_Charges_Interval seconds
            • Else - Actions
      • -------- --------
      • -------- Update the extended tooltip of the ability to show the charges: --------
      • Trigger - Run Holy Light Update Tooltip <gen> (ignoring conditions)
  • Holy Light Update Tooltip
    • Events
    • Conditions
    • Actions
      • -------- Apply the tooltip to the ability: --------
      • Set VariableSet Holy_Light_Tooltip = (A holy light that can heal a friendly living unit for + ((String((200 x (Level of Holy Light for Holy_Light_Hero)))) + ( or deal half damage to an enemy Undead unit. + (|n|nCharges: + ((String(Holy_Light_Charges)) + (/ + (String(Holy_Light_Charges_Max)))))
      • Ability - Set Extended Tooltip of Holy Light to Holy_Light_Tooltip for level ((Level of Holy Light for Holy_Light_Hero) - 1)
another question do you know how can i add small number count to ability icon with trigger?
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
another question do you know how can i add small number count to ability icon with trigger?
I think the best solution would be to create a series of custom icons that display the different number of charges. This is surprisingly easy to do with a little copy and paste in GIMP, Paint, Photoshop, etc. There's plenty of tutorials on Hive that help explain the process of creating your own icons.

Then you can use a String array variable to track the file paths of these newly imported icons:
  • Set Variable Holy_Light_Icon[0] = ReplaceableTextures\CommandButtons\BTNHolyBolt.blp
  • Set Variable Holy_Light_Icon[1] = ReplaceableTextures\CommandButtons\BTNHolyBolt1.blp
  • Set Variable Holy_Light_Icon[2] = ReplaceableTextures\CommandButtons\BTNHolyBolt2.blp
  • Set Variable Holy_Light_Icon[3] = ReplaceableTextures\CommandButtons\BTNHolyBolt3.blp
And update the icon using this Action in combination with your String array:
  • Ability - Set Icon of Holy Light to Holy_Light_Icon[Holy_Light_Charges]
This could take place in the Holy Light Update Tooltip trigger.

So in this example I have 3 new icons that represent Charges 1 to 3. When you run out of Charges it will use the default icon.

Note that the "Set Icon" action is a global change and will affect every single Holy Light ability. This has the same limitation as the "Set Extended Tooltip" action from my previous triggers. That being said, you could rely on GetLocalPlayer() to run these locally and make this entire system MPI -> Which means that it will work once for each Player. Additionally, if you discard the tooltip/icon modifications then all of this can be MUI -> Which means that it will work for each Unit. These changes would involve relying on Array versions of the current variables along with some techniques like Player/Unit Indexing.
 
Last edited:
Level 26
Joined
Sep 7, 2018
Messages
540
I think the best solution would be to create a series of custom icons that display the different number of charges. This is surprisingly easy to do with a little copy and paste in GIMP, Paint, Photoshop, etc. There's plenty of tutorials on Hive that help explain the process of creating your own icons.

Then you can use a String array variable to track the file paths of these newly imported icons:
  • Set Variable Holy_Light_Icon[0] = ReplaceableTextures\CommandButtons\BTNHolyBolt.blp
  • Set Variable Holy_Light_Icon[1] = ReplaceableTextures\CommandButtons\BTNHolyBolt1.blp
  • Set Variable Holy_Light_Icon[2] = ReplaceableTextures\CommandButtons\BTNHolyBolt2.blp
  • Set Variable Holy_Light_Icon[3] = ReplaceableTextures\CommandButtons\BTNHolyBolt3.blp
And update the icon using this Action in combination with your String array:
  • Ability - Set Icon of Holy Light to Holy_Light_Icon[Holy_Light_Charges]
This could take place in the Holy Light Update Tooltip trigger.

So in this example I have 3 new icons that represent Charges 1 to 3. When you run out of Charges it will use the default icon.

Note that this "Set Icon" Action is a global change and will affect every single Holy Light ability. I believe you can get around this by using GetLocalPlayer() but it'd still be limited to one Holy Light per Player.
Thanks alot.
 
Top