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

Increase stacks with hastable / Post 2.0

Status
Not open for further replies.
Level 12
Joined
Feb 5, 2018
Messages
521
  • Might
    • Events
      • Game - PDD_damageEventTrigger becomes Equal to 0.00
    • Conditions
      • (Level of Might (Completed) for PDD_target) Greater than 0
      • (PDD_target belongs to an enemy of (Owner of PDD_source).) Equal to True
      • (Random integer number between 1 and 100) Less than or equal to 33
    • Actions
      • Hashtable - Save Handle Of(Triggering unit) as 3 of (Key (Triggering unit).) in MightHash.
      • Set VariableSet MightStacksMax = ((Level of Might (Completed) for (Load 3 of (Key (Triggering unit).) in MightHash.)) x 5)
      • Hashtable - Save MightStacksMax as 2 of (Key (Triggering unit).) in MightHash.
      • Game - Display to (All players) the text: ((String(MightStacks)) + ( / + (String(MightStacksMax))))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Load 3 of (Key (Triggering unit).) in MightHash.) is in MightUG.) Equal to False
        • Then - Actions
          • Unit Group - Add (Load 3 of (Key (Triggering unit).) in MightHash.) to MightUG
          • Game - Display to (All players) the text: Unit Added To Group
          • Hashtable - Save 15.00 as 1 of (Key (Load 3 of (Key (Triggering unit).) in MightHash.).) in MightHash.
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • MightStacks Less than MightStacksMax
        • Then - Actions
          • Hashtable - Save (MightStacks + 1) as 0 of (Key (Load 3 of (Key (Triggering unit).) in MightHash.).) in MightHash.
          • Hero - Modify Strength of (Load 3 of (Key (Triggering unit).) in MightHash.): Add 4.
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in MightUG) Equal to 1
        • Then - Actions
          • Trigger - Turn on Might Check <gen>
        • Else - Actions
  • Might Check
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in MightUG and do (Actions)
        • Loop - Actions
          • Set VariableSet MightTime = (Load 1 of (Key (Picked unit).) from MightHash.)
          • Set VariableSet MightStacks = (Load 0 of (Key (Picked unit).) from MightHash.)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • MightTime Greater than 0.00
            • Then - Actions
              • Hashtable - Save (MightTime - 1.00) as 1 of (Key (Picked unit).) in MightHash.
              • Game - Display to (All players) the text: (String(MightTime))
            • Else - Actions
              • Hero - Modify Strength of (Picked unit): Subtract 4.
              • Hashtable - Save (MightStacks - 1) as 0 of (Key (Load 3 of (Key (Picked unit).) in MightHash.).) in MightHash.
              • Game - Display to (All players) the text: End of Timer --- Re...
So I am trying to make a simple passive ability that gives the unit 4 strength. Stacking up to 5 times/ability level. Also needs to have an end condition in the loop trigger. Thanks :)

It was a lot harder than I supposed it to be and my brain is exploding.

There are not really much here on abilities with stacks. I also tried to google. No answers were found.

A Complete Beginners Guide to Hashtables

Hashtables and MUI
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,534
Okay, so with your current setup you're refreshing the Might duration (15.00 seconds) every single time the unit takes damage. ALL of your Might stacks use this duration but by the looks of it you don't want it to work this way. So I want to clarify, which of these two methods do you want?

Stacking Method #1) All stacks use the same duration. Getting a new stack of Might refreshes the duration for ALL of them. If 15.00 seconds passes without getting a Might stack then ALL stacks are lost.

Stacking Method #2) All stacks use their own duration and are independent from one another. Whenever a Stack expires the Hero loses 4 strength. When you take damage at Max Stacks, your oldest stack is replaced by the newest stack. Note that Method #2 is a lot more complex because we have to keep track of the Duration for each individual stack.

Issues with your Triggers:
1) In response to PDD_damageEventTrigger you reference Triggering Unit a lot. I'm pretty sure there's no Triggering Unit here as it's a Custom Event. You'd have to reference a variable like "pdd_Target" instead. Unfortunately, you can't reference variables when using Keys so you'll have to find a way to do this. A solution I found was using "Damage Target" in the Key but I believe this will only work if the Damage Detection System is up to date. Bribe's system works -> Damage Engine 5.5.0.0

If you can't use Bribe's system for whatever reason then perhaps add pdd_Target to a Unit Group, then Pick every unit in that unit group (the group would only contain pdd_Target) and reference "Picked Unit" as the Key.

2) You reference MightStacks in the Might trigger but it's never set to anything. MightStacks should be set to Load 0 of Key(YourUnit) before you reference it.
3) You run the periodic timer every 1.00 second, I would recommend a smaller number since some units might end up getting Might stacks for almost 1 second longer than they should.
4) This is just a question and it's entirely up to you but do you want the Strength to be green text (like the Bonus Strength you get from +3 gauntlets of strength) or how you're doing it now? This could be important for cases where you do something like "Deal damage equal to Strength (Exclude Bonuses)".

That being said...
With Method #1 you can do this without a Hashtable. I would use a Unit Indexer. MightStacks[custom value], MightDuration[custom value], MaxStacks[custom value], etc...

With Method #2 a Hashtable makes more sense as we have to track EACH individual Stack's duration.

I uploaded 2 maps using Method #1. Note I'm using Bribe's Damage Detection System.
One uses a Hashtable so you can compare it to your own and another uses a Unit Indexer which is the better solution in my opinion (IF you go with Method #1 that is).
  • Might Set Max Stacks
    • Events
      • Unit - A unit Learns a skill
    • Conditions
      • (Learned Hero Skill) Equal to Might (Uncle)
    • Actions
      • Set VariableSet Might_MaxStacks = (5 x (Level of Might (Uncle) for (Triggering unit)))
      • Hashtable - Save Might_MaxStacks as 1 of (Key (Triggering unit).) in Might_Hashtable.
      • Game - Display to (All players) for 30.00 seconds the text: (Max Stacks: + (String(Might_MaxStacks)))
  • Might Take Damage
    • Events
      • Game - DamageEvent becomes Equal to 1.00
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Might (Uncle) for DamageEventTarget) Greater than or equal to 1
          • (DamageEventSource belongs to an enemy of (Owner of DamageEventTarget).) Equal to True
        • Then - Actions
          • -------- Add to Might Unit Group - (If not already in it) --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (DamageEventTarget is in Might_UG.) Equal to False
            • Then - Actions
              • Unit Group - Add DamageEventTarget to Might_UG
            • Else - Actions
          • -------- - --------
          • -------- Get Might Variables --------
          • Set VariableSet Might_Stacks = (Load 0 of (Key (Damage Target).) from Might_Hashtable.)
          • Set VariableSet Might_MaxStacks = (Load 1 of (Key (Damage Target).) from Might_Hashtable.)
          • -------- - --------
          • -------- Set Might Variables --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Might_Stacks Less than Might_MaxStacks
            • Then - Actions
              • -------- Add --------
              • Hero - Modify Strength of DamageEventTarget: Add 4.
              • Set VariableSet Might_Stacks = (Might_Stacks + 1)
              • Hashtable - Save Might_Stacks as 0 of (Key (Damage Target).) in Might_Hashtable.
            • Else - Actions
          • Hashtable - Save 15.00 as 2 of (Key (Damage Target).) in Might_Hashtable.
          • -------- - --------
          • -------- Turn On Timer --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Might Timer <gen> is on) Equal to False
            • Then - Actions
              • Trigger - Turn on Might Timer <gen>
            • Else - Actions
        • Else - Actions
  • Might Timer
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Might_UG and do (Actions)
        • Loop - Actions
          • -------- Get Might Variables --------
          • Set VariableSet Might_Stacks = (Load 0 of (Key (Picked unit).) from Might_Hashtable.)
          • Set VariableSet Might_MaxStacks = (Load 1 of (Key (Picked unit).) from Might_Hashtable.)
          • Set VariableSet Might_Duration = (Load 2 of (Key (Picked unit).) from Might_Hashtable.)
          • -------- - --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Might_Duration Greater than 0.00
            • Then - Actions
              • -------- Adjust Duration --------
              • Hashtable - Save (Might_Duration - 0.10) as 2 of (Key (Picked unit).) in Might_Hashtable.
              • Game - Display to (All players) for 5.00 seconds the text: (String((Might_Duration - 0.10)))
            • Else - Actions
              • -------- Remove --------
              • Hero - Modify Strength of (Picked unit): Subtract (4 x Might_Stacks).
              • Hashtable - Save 0 as 0 of (Key (Picked unit).) in Might_Hashtable.
              • Unit Group - Remove (Picked unit) from Might_UG.
      • -------- - --------
      • -------- Turn Off Timer --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in Might_UG) Equal to 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
  • Might Set Max Stacks
    • Events
      • Unit - A unit Learns a skill
    • Conditions
      • (Learned Hero Skill) Equal to Might (Uncle)
    • Actions
      • -------- Get Custom Value (Used for Unit Indexer) --------
      • Set VariableSet UDex = (Custom value of (Triggering unit))
      • -------- - --------
      • Set VariableSet Might_MaxStacks[UDex] = (5 x (Level of Might (Uncle) for (Triggering unit)))
      • Game - Display to (All players) for 30.00 seconds the text: (Max Stacks: + (String(Might_MaxStacks[UDex])))
  • Might Take Damage
    • Events
      • Game - DamageEvent becomes Equal to 1.00
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Might (Uncle) for DamageEventTarget) Greater than or equal to 1
          • (DamageEventSource belongs to an enemy of (Owner of DamageEventTarget).) Equal to True
        • Then - Actions
          • -------- Get Custom Value (Used for Unit Indexer) --------
          • Set VariableSet UDex = (Custom value of DamageEventTarget)
          • -------- - --------
          • -------- Add to Might Unit Group - (If not already in it) --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (DamageEventTarget is in Might_UG.) Equal to False
            • Then - Actions
              • Unit Group - Add DamageEventTarget to Might_UG
            • Else - Actions
          • -------- - --------
          • -------- Set Might Variables --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Might_Stacks[UDex] Less than Might_MaxStacks[UDex]
            • Then - Actions
              • -------- Add --------
              • Hero - Modify Strength of DamageEventTarget: Add 4.
              • Set VariableSet Might_Stacks[UDex] = (Might_Stacks[UDex] + 1)
            • Else - Actions
          • Set VariableSet Might_Duration[UDex] = 15.00
          • -------- - --------
          • -------- Turn On Timer --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Might Timer <gen> is on) Equal to False
            • Then - Actions
              • Trigger - Turn on Might Timer <gen>
            • Else - Actions
        • Else - Actions
  • Might Timer
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Might_UG and do (Actions)
        • Loop - Actions
          • -------- Get Custom Value (Used for Unit Indexer) --------
          • Set VariableSet UDex = (Custom value of (Picked unit))
          • -------- - --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Might_Duration[UDex] Greater than 0.00
            • Then - Actions
              • -------- Adjust Duration --------
              • Set VariableSet Might_Duration[UDex] = (Might_Duration[UDex] - 0.10)
              • Game - Display to (All players) for 5.00 seconds the text: (String(Might_Duration[UDex]))
            • Else - Actions
              • -------- Remove --------
              • Hero - Modify Strength of (Picked unit): Subtract (4 x Might_Stacks[UDex]).
              • Set VariableSet Might_Stacks[UDex] = 0
              • Unit Group - Remove (Picked unit) from Might_UG.
      • -------- - --------
      • -------- Turn Off Timer --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in Might_UG) Equal to 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
 

Attachments

  • Might Uncle Hashtable.w3m
    50.9 KB · Views: 19
  • Might Uncle Unit Indexer.w3m
    54.9 KB · Views: 15
Last edited:
Level 12
Joined
Feb 5, 2018
Messages
521
Yeas, I wanted each stack to has it's own individual duration, so using method#2 here would be better :)

Also before I tried to convert this trigger into MUI it was a simplified version and the Key(TriggeringUnit) worked fine with the PDD_event.
But if it's absolutely necessary, then I will do the unit group check.

I'ts better to do with hashtables, for me, so I learn a bit more about using them in the proper way and also the get the individual duration for each stack.

Also I am using Physical Damage Detection for GUI v1.3.0.0 it is out of date?
Since my map only contains a few triggers still I could change it to a new system, if needed.

Also my map contains unit indexer, that came with GUI Knockback 2.5D v4.2.5.0
Just never really messed around with unit indexers all that much. :D

It's a long way for me, I just got back to mapping with the launch of reforged.

My thanks to you for given me the time to clarify things out for me and for helping me with my efforts.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,534
Yeah, that Damage System I linked is very powerful and up to date. It was actually updated just a few days ago.

And I don't know how your Damage system works so maybe Triggering Unit does work. I would be wary of it though. If you use Bribe's Damage System then you can avoid this issue entirely and reference Key(Damage Target). I recommend making the switch. Also, I would recommend updating the Unit Indexer. I have a link to it in my signature (Unit Indexing).

And about your ability. So you want to go with "Method 2". I actually avoided it because I'm not even sure the best way of going about it. I guess I would try something like this:

Give each Stack in the Hashtable it's own unique Index. So let's say you added 5 Stacks to the Hero:
  • Actions
    • Hashtable - Save 15.00 as 1 of (Key (Triggering unit).) in Might_Hashtable.
    • Hashtable - Save 15.00 as 2 of (Key (Triggering unit).) in Might_Hashtable.
    • Hashtable - Save 15.00 as 3 of (Key (Triggering unit).) in Might_Hashtable.
    • Hashtable - Save 15.00 as 4 of (Key (Triggering unit).) in Might_Hashtable.
    • Hashtable - Save 15.00 as 5 of (Key (Triggering unit).) in Might_Hashtable.
You can't save them to the same Index or else they will share the same Duration. They each need to be saved to their own Index. The Index is the position that they're saved at, so in the trigger above the first Stack's Index would be 1 (I save 15.00 as 1 <---Index), the second would be 2, the third would be 3, etc...

Then you would Loop through all of them and adjust the Duration. Here's an example of reducing the Duration of 5 Stacks.
  • Actions
    • Unit Group - Pick every unit in Might_UG and do (Actions)
      • Loop - Actions
        • For each (Integer A) from 1 to 5, do (Actions)
          • Loop - Actions
            • Set VariableSet Might_Duration = (Load (Integer A) of (Key (Picked unit).) from Might_Hashtable.)
            • Hashtable - Save (Might_Duration - 0.10) as (Integer A) of (Key (Picked unit).) in Might_Hashtable.
So from 1 to 5, I load Index 1 and reduce it's duration by 0.10, then I load Index 2 and reduce it's duration by 0.10, and so on all the way to Index 5.

However, that's just an example. Since you're already using Index 0 for Might Stacks and Index 1 for Max Might Stacks then you would want to Save your Durations starting at 2. So Index 2+ would be reserved for Stack Durations.
Example: Index 2 = Stack 1's Duration, 3 = Stack 2's Duration, 4 = Stack 3's Duration, etc...

The tricky part would be to recycle these Indices so you can replace the Old stacks with the New stacks and so you don't keep saving to a higher Index every single time. If you didn't recycle these, then you would eventually be saving to Index 1,000+. We don't want that. The max it should ever go should be related to the Maximum Stacks. In this case something like 27. Since our Index starts at 2 and our Max Stacks at level 5 is 25 we get 27 -> 2 + 25 = 27.

Did I lose you? It's a bit much I know but I don't really know of an easier way to do it.
 
Last edited:
Level 12
Joined
Feb 5, 2018
Messages
521
Oh, seems a little bit much of work. The ability I mean. Maybe I will stay to method#1 for a while.

I'll update the damage engine and unit indexers. :)

Thanks.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,534
No problem.
I was having fun trying to get this to work and I managed to come up with a working system. It's definitely not the most efficient system in the world as it loops over unused Integers but it gets the job done.
  • Might Initialize
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set VariableSet Might_Hashtable = (Last created hashtable)
      • Set VariableSet Might_DefaultDuration = 15.00
      • Set VariableSet Might_DefaultStrength = 4
  • Might Take Damage
    • Events
      • Game - DamageEvent becomes Equal to 1.00
    • Conditions
      • (Level of Might (Uncle) for DamageEventTarget) Greater than 0
      • (DamageEventSource belongs to an enemy of (Owner of DamageEventTarget).) Equal to True
    • Actions
      • Set VariableSet Might_Stacks = (Load 0 of (Key (Damage Target).) from Might_Hashtable.)
      • Set VariableSet Might_MaxStacks = (Load 1 of (Key (Damage Target).) from Might_Hashtable.)
      • Set VariableSet Might_Index = (Load 2 of (Key (Damage Target).) from Might_Hashtable.)
      • -------- --------------------------------------------------------------------------------------------------------- --------
      • -------- Might Index + Duration --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Might_Index Less than (Might_MaxStacks + 2)
        • Then - Actions
          • Set VariableSet Might_Index = (Might_Index + 1)
          • Hashtable - Save Might_Index as 2 of (Key (Damage Target).) in Might_Hashtable.
          • Hashtable - Save Might_DefaultDuration as Might_Index of (Key (Damage Target).) in Might_Hashtable.
        • Else - Actions
          • Set VariableSet Might_Index = 3
          • Hashtable - Save Might_Index as 2 of (Key (Damage Target).) in Might_Hashtable.
          • Hashtable - Save Might_DefaultDuration as Might_Index of (Key (Damage Target).) in Might_Hashtable.
      • Set VariableSet Might_DontSkip[(Might_Index - 2)] = True
      • -------- --------------------------------------------------------------------------------------------------------- --------
      • -------- Might Stacks + Strength --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Might_Stacks Less than Might_MaxStacks
        • Then - Actions
          • Set VariableSet Might_Stacks = (Might_Stacks + 1)
          • Hashtable - Save Might_Stacks as 0 of (Key (Damage Target).) in Might_Hashtable.
          • Hero - Modify Strength of DamageEventTarget: Add Might_DefaultStrength.
        • Else - Actions
      • -------- --------------------------------------------------------------------------------------------------------- --------
      • -------- Add to Might Unit Group --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (DamageEventTarget is in Might_UG.) Equal to False
        • Then - Actions
          • Unit Group - Add DamageEventTarget to Might_UG
        • Else - Actions
      • -------- --------------------------------------------------------------------------------------------------------- --------
      • -------- Turn On Timer --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Might Timer <gen> is on) Equal to False
        • Then - Actions
          • Trigger - Turn on Might Timer <gen>
          • Game - Display to (All players) for 30.00 seconds the text: Timer On
        • Else - Actions
  • Might Timer
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Might_UG and do (Actions)
        • Loop - Actions
          • -------- Get Might Variables --------
          • Set VariableSet Might_Stacks = (Load 0 of (Key (Picked unit).) from Might_Hashtable.)
          • Set VariableSet Might_MaxStacks = (Load 1 of (Key (Picked unit).) from Might_Hashtable.)
          • Set VariableSet Might_Index = (Load 2 of (Key (Picked unit).) from Might_Hashtable.)
          • -------- --------------------------------------------------------------------------------------------------------- --------
          • For each (Integer A) from 1 to Might_MaxStacks, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Might_DontSkip[(Integer A)] Equal to True
                • Then - Actions
                  • -------- Since we're looping from 1 to MaxStacks and our Hashtable stores the Durations from 3 to 27, we need to compensate for this by adding 2 to Integer A --------
                  • Set VariableSet Might_IndexA = (2 + (Integer A))
                  • Set VariableSet Might_Duration = (Load Might_IndexA of (Key (Picked unit).) from Might_Hashtable.)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Might_Duration Greater than 0.00
                    • Then - Actions
                      • -------- Adjust Duration --------
                      • Hashtable - Save (Might_Duration - 0.10) as Might_IndexA of (Key (Picked unit).) in Might_Hashtable.
                      • Game - Display to (All players) for 5.00 seconds the text: (String((Might_Duration - 0.10)))
                    • Else - Actions
                      • -------- Subtract Strength / Stacks --------
                      • Game - Display to (All players) for 5.00 seconds the text: Remove Stack
                      • -------- --------------------------------------------------------------------------------------------------------- --------
                      • Hero - Modify Strength of (Picked unit): Subtract Might_DefaultStrength.
                      • Set VariableSet Might_Stacks = (Might_Stacks - 1)
                      • Hashtable - Save Might_Stacks as 0 of (Key (Picked unit).) in Might_Hashtable.
                      • Set VariableSet Might_DontSkip[(Integer A)] = False
                      • -------- --------------------------------------------------------------------------------------------------------- --------
                      • -------- Remove From Group --------
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • Might_Stacks Equal to 0
                        • Then - Actions
                          • Unit Group - Remove (Picked unit) from Might_UG.
                        • Else - Actions
                • Else - Actions
      • -------- - --------
      • -------- Turn Off Timer --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in Might_UG) Equal to 0
        • Then - Actions
          • Game - Display to (All players) for 30.00 seconds the text: Timer Off
          • Trigger - Turn off (This trigger)
        • Else - Actions
Long story short, whenever the unit takes damage I increase an Integer (Might_Index) by 1. Might_Index has a default starting value of 2 so the first time you take the damage it will increase from 2 to 3. After increasing it I save the Duration (15.00 seconds) as Might_Index of Key(OurUnit). So Might_Index is basically used to increase the Index at which we store our Duration, this way each Duration has it's own spot in the Hashtable.

So the first time the unit takes damage:
15.00 is saved at 3 (Might_Index = 3)
Second time:
15.00 is saved at 4 (Might_Index = 4)
Third time:
15.00 is saved at 5 (Might_Index = 5)

The reason we don't save at 0, 1, and 2 is because those spots are reserved for our other variables, Might_Stacks, Might_MaxStacks, and Might_Index.

So in our Hashtable:
0 = Might_Stacks
1 = Might_MaxStacks
2 = Might_Index
3+ = Might_Duration

When Might_Index surpasses Might_MaxStacks I reset it back to it's default starting value of 2 and the cycle starts all over again. This causes new stacks gained while at Maximum Stacks to replace the oldest stack.

Think of it like you're counting from 1 to to 10 and whenever you reach 11 you reset and start back at 1. But in this case we're counting from 3 to 7, or 3 to 12, or 3 to 17, or 3 to 22, or 3 to 27, because we need to account for the fact that our Durations are saved at Index 3+. So basically all you have to do is add 2 to Stacks and MaxStacks to compensate for the fact that Duration starts at 3.

Finally, and here's the inefficient part, I use a Boolean "DontSkip" to control which Durations are ignored/used while I'm looping through our Stacks.

So for example, if DontSkip[6] = True, this tells the Loop to NOT skip Index 6 in our Hashtable. If it's false, then it will ignore Index 6 and skip it.

Whenever we save a new Duration as Might_Index in our Hashtable we also set DontSkip[Might_Index] to True so the Loop knows not to skip that one. Then whenever a Duration is finished we set DontSkip[The duration's Index] to False.
 

Attachments

  • Might Uncle Hashtable 2.w3m
    52.9 KB · Views: 10
Last edited:
Level 12
Joined
Feb 5, 2018
Messages
521
I don't even know what to say anymore. God damn you are good :) once again THANKS! Total awesomeness

EDIT: It does not work with multiple units at the same time for whatever reason :(

And to clarify it does not reduce strength back to normal for all units. @Uncle
 
Last edited:
Status
Not open for further replies.
Top