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

Enable ability after integer counts down

Status
Not open for further replies.
Level 7
Joined
May 30, 2018
Messages
290
Hello, can somebody tell me why the second half of the following trigger doesn't work (the ability does not get enabled again). It's supossed to be kind of an attemp to "fake" an ability that has charges. Thanks!

  • Untitled Trigger 005
    • Events
      • Unit - A unit Finishes casting an ability
    • Conditions
      • (Ability being cast) Equal to Summon Flame Barbarian (Archimonde)
    • Actions
      • Set VariableSet BarbarianCounter = (BarbarianCounter - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • BarbarianCounter Equal to 0
        • Then - Actions
          • Unit - For (Triggering unit), Ability Summon Flame Barbarian (Archimonde), Disable ability: True, Hide UI: False
          • Countdown Timer - Start ChargeTimer as a Repeating timer that will expire in 5.00 seconds
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Remaining time for ChargeTimer) Equal to 0.00
            • Then - Actions
              • Set VariableSet BarbarianCounter = (BarbarianCounter + 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • BarbarianCounter Greater than 0
                • Then - Actions
                  • Unit - For (Triggering unit), Ability Summon Flame Barbarian (Archimonde), Disable ability: False, Hide UI: False
                • Else - Actions
            • Else - Actions
        • Else - Actions
 
Level 19
Joined
Feb 27, 2019
Messages
580
The trigger only runs when the ability is cast. If BarbarianCounter = 0 then it sets the Countdown Timer ChargeTimer to 5 seconds, if its not 0 it does nothing. Directly after this it checks if ChargeTimer is equal to 0 which it will never be since its set to 5 right before it checks if its equal to 0. You probably placed this check in the wrong place. Maybe you want to put the check for remaining time before you restart it with 5 seconds or you want to place it in some of the other else actions. I dont know really. I feel like I am missing where the BarbarianCounter gets +1. Thats its a periodic event or something like that.
 
Level 19
Joined
Feb 27, 2019
Messages
580
Its a bit of a tricky one this one, at least the way I found to do it.

I made these triggers and put the limit to 2 charges.

Apparently if I disable the ability 2 times I need to enable it 2 times or else it wont work. Or something like this. Therefor I created a Boolean.

I also needed to wait a frame after the ability was cast or else if I spam cast the ability it will disable the ability before it finishes casting. It may work differently depending on which ability you use, I dont know. This is done by using 2 triggers and a timer as in Sum Abil 1 and 2.

Using timers for certain units and referencing those timers for Sum AbilSum expires may be a bit difficult. I dont have a good solution for this.

  • Map Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set VariableSet SumCnt = 2
  • Sum Abil 1
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • Set VariableSet SumUnit = (Triggering unit)
      • Countdown Timer - Start SumTmr1 as a One-shot timer that will expire in 0.00 seconds
  • Sum Abil 2
    • Events
      • Time - SumTmr1 expires
    • Conditions
    • Actions
      • Set VariableSet SumCnt = (SumCnt - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • SumCnt Equal to 0
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • SumAbilB Equal to False
            • Then - Actions
              • Set VariableSet SumAbilB = True
              • Unit - For SumUnit, Ability Summon Sea Elemental, Disable ability: True, Hide UI: False
            • Else - Actions
        • Else - Actions
          • Countdown Timer - Start SumTmr2 as a One-shot timer that will expire in 5.00 seconds
      • Game - Display to (All players) the text: (String(SumCnt))
  • Sum AbilSum Expires
    • Events
      • Time - SumTmr2 expires
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • SumCnt Less than 2
        • Then - Actions
          • Set VariableSet SumCnt = (SumCnt + 1)
          • Countdown Timer - Start SumTmr2 as a One-shot timer that will expire in 5.00 seconds
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • SumAbilB Equal to True
            • Then - Actions
              • Set VariableSet SumAbilB = False
              • Unit - For Peasant 0000 <gen>, Ability Summon Sea Elemental, Disable ability: False, Hide UI: False
            • Else - Actions
        • Else - Actions
      • Game - Display to (All players) the text: (String(SumCnt))

I didnt know about this Disable ability function. Its a good one to know about.
 
Last edited:
Level 7
Joined
May 30, 2018
Messages
290
Its a bit of a tricky one this one, at least the way I found to do it.

I made these triggers and put the limit to 2 charges.

Apparently if I disable the ability 2 times I need to enable it 2 times or else it wont work. Or something like this. Therefor I created a Boolean.

I also needed to wait a frame after the ability was cast or else if I spam cast the ability it will disable the ability before it finishes casting. It may work differently depending on which ability you use, I dont know. This is done by using 2 triggers and a timer as in Sum Abil 1 and 2.

Using timers for certain units and referencing those timers for Sum AbilSum expires may be a bit difficult. I dont have a good solution for this.

  • Map Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set VariableSet SumCnt = 2
  • Sum Abil 1
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • Set VariableSet SumUnit = (Triggering unit)
      • Countdown Timer - Start SumTmr1 as a One-shot timer that will expire in 0.00 seconds
  • Sum Abil 2
    • Events
      • Time - SumTmr1 expires
    • Conditions
    • Actions
      • Set VariableSet SumCnt = (SumCnt - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • SumCnt Equal to 0
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • SumAbilB Equal to False
            • Then - Actions
              • Set VariableSet SumAbilB = True
              • Unit - For SumUnit, Ability Summon Sea Elemental, Disable ability: True, Hide UI: False
            • Else - Actions
        • Else - Actions
          • Countdown Timer - Start SumTmr2 as a One-shot timer that will expire in 5.00 seconds
      • Game - Display to (All players) the text: (String(SumCnt))
  • Sum AbilSum Expires
    • Events
      • Time - SumTmr2 expires
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • SumCnt Less than 2
        • Then - Actions
          • Set VariableSet SumCnt = (SumCnt + 1)
          • Countdown Timer - Start SumTmr2 as a One-shot timer that will expire in 5.00 seconds
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • SumAbilB Equal to True
            • Then - Actions
              • Set VariableSet SumAbilB = False
              • Unit - For Peasant 0000 <gen>, Ability Summon Sea Elemental, Disable ability: False, Hide UI: False
            • Else - Actions
        • Else - Actions
      • Game - Display to (All players) the text: (String(SumCnt))

I didnt know about this Disable ability function. Its a good one to know about.
Thanks for the effort man! Appreciated.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,512
These functions use an Integer system that keeps track of how many times an ability has been disabled/enabled.

So if you were to do this:
  • Unit - For Peasant 0000 <gen>, Ability Summon Sea Elemental, Disable ability: True, Hide UI: False
  • Unit - For Peasant 0000 <gen>, Ability Summon Sea Elemental, Disable ability: True, Hide UI: False
  • Unit - For Peasant 0000 <gen>, Ability Summon Sea Elemental, Disable ability: False, Hide UI: False
The ability would not become enabled despite the last action clearly enabling it. This is because there's a hidden counter keeping track of things:
Disable ability -> Disable Counter = 1 (+1)
Disable ability -> Disable Counter = 2 (+1)
Enable ability -> Disable Counter = 1 (-1)

You'd need to enable the ability a second time to get the Disable counter back down to 0. Once this counter reaches 0 the ability becomes enabled again.

So for example if you disable something 5 times then you'd need to enable it 5 times in order for it to be enabled again. The reverse is true as well.
 
Last edited:
Status
Not open for further replies.
Top