[Solved] De-Indexing this spell correctly (Soul Catcher)

Status
Not open for further replies.
Level 12
Joined
May 16, 2020
Messages
660
Hi guys,

The following spell removes X% current HP from enemies, and then returns 50% of the removed HP after 10 seconds (Soul Catcher from dota).
The problem is that currently it does not return the HP in the correct order if I cast the spell +3 times on an enemy.

I'm pretty sure the problem is related to how I de-index the stolen HP from enemies, i.e. this part in the trigger:

  • For each (Integer Z_Integer2) from 1 to Z_Index, do (Actions)
    • Loop - Actions
      • Unit Group - Pick every unit in Z_Group[Z_Integer2] and do (Actions)
        • Loop - Actions
          • Set VariableSet Z_CV_Target = (Custom value of (Picked unit))
          • Hashtable - Save (Load Z_Integer2 of Z_CV_Target from Z_Hashtable.) as (Z_Integer2 - 1) of Z_CV_Target in Z_Hashtable.

Can someone please help fix this?



Here the full trigger. There is some spell damage amplification involved, but for the purpose of this question I left this part out:

  • Soul Catcher
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Soul Catcher
    • Actions
      • Set VariableSet Z_Index = (Z_Index + 1)
      • Set VariableSet Z_Caster[Z_Index] = (Triggering unit)
      • Set VariableSet Z_Counter[Z_Index] = 0
      • Set VariableSet Z_CounterHero[Z_Index] = 0
      • -------- --------
      • Set VariableSet Z_Point = (Target point of ability being cast)
      • Special Effect - Create a special effect at Z_Point using AnnihilationBlast.mdx
      • Special Effect - Destroy (Last created special effect)
      • Special Effect - Create a special effect at Z_Point using Desecrate.mdx
      • Special Effect - Destroy (Last created special effect)
      • -------- --------
      • Unit - Create 1 Dummy (Fly/Speed 0) for Neutral Passive at Z_Point facing Default building facing degrees
      • Set VariableSet Z_Dummy = (Last created unit)
      • Unit - Add Soul Catcher (Ally) to Z_Dummy
      • Unit - Add Soul Catcher (Enemy) to Z_Dummy
      • Unit - Add a 0.50 second Generic expiration timer to Z_Dummy
      • -------- --------
      • Custom script: set udg_Z_Group[udg_Z_Index] = CreateGroup()
      • Set VariableSet Z_Level = (Level of Soul Catcher for Z_Caster[Z_Index])
      • Set VariableSet Z_Life_Percentage = (0.15 + (0.05 x (Real(Z_Level))))
      • Game - Display to (All players) the text: (String(Z_Index))
      • Unit Group - Pick every unit in Disruption_Group and do (Unit - Unhide (Picked unit))
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within (150.00 + (25.00 x (Real(Z_Level)))) of Z_Point.) and do (Actions)
        • Loop - Actions
          • Set VariableSet Z_Unit = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Z_Unit is alive) Equal to True
              • (Z_Unit is A structure) Equal to False
              • (Z_Unit is An Ancient) Equal to False
              • (Z_Unit is Magic Immune) Equal to False
              • (Z_Unit belongs to an enemy of (Owner of Z_Caster[Z_Index]).) Equal to True
            • Then - Actions
              • Set VariableSet Z_Life_Removed = ((Life of Z_Unit) x Z_Life_Percentage)
              • Set VariableSet Z_CV_Target = (Custom value of Z_Unit)
              • -------- --------
              • Hashtable - Save Z_Life_Removed as Z_Index of Z_CV_Target in Z_Hashtable.
              • Game - Display to (All players) the text: (Life Removed: + (String(Z_Life_Removed)))
              • Game - Display to (All players) the text: (String((Unit-type of Z_Unit)))
              • -------- --------
              • Unit - Set life of Z_Unit to ((Life of Z_Unit) - Z_Life_Removed)
              • Unit - Order Z_Dummy to Undead Necromancer - Cripple Z_Unit
              • Unit Group - Add Z_Unit to Z_Group[Z_Index]
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Z_Unit is A Hero) Equal to True
                  • (Z_Unit is an illusion) Equal to False
                • Then - Actions
                  • Set VariableSet Z_CounterHero[Z_Index] = (Z_CounterHero[Z_Index] + 1)
                • Else - Actions
            • Else - Actions
      • Unit Group - Pick every unit in Disruption_Group and do (Unit - Hide (Picked unit))
      • -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Z_CounterHero[Z_Index] Not equal to 0
        • Then - Actions
          • Set VariableSet Z_BooleanSpellAmp[Z_Index] = True
          • Set VariableSet Z_CV_Caster = (Custom value of Z_Caster[Z_Index])
          • Set VariableSet Z_DamageAmp[Z_CV_Caster] = (Z_DamageAmp[Z_CV_Caster] + (0.03 + (0.02 x (Real(Z_Level)))))
          • Unit - Order Z_Dummy to Orc Shaman - Bloodlust Z_Caster[Z_Index]
        • Else - Actions
      • -------- --------
      • Custom script: call RemoveLocation(udg_Z_Point)
      • -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Z_Index Equal to 1
        • Then - Actions
          • Countdown Timer - Start Z_Timer as a Repeating timer that will expire in 0.10 seconds
          • Trigger - Turn on Soul Catcher Spell Amp <gen>
          • Trigger - Turn on Soul Catcher Loop <gen>
        • Else - Actions
  • Soul Catcher Loop
    • Events
      • Time - Z_Timer expires
    • Conditions
    • Actions
      • For each (Integer Z_Integer) from 1 to Z_Index, do (Actions)
        • Loop - Actions
          • Set VariableSet Z_Counter[Z_Integer] = (Z_Counter[Z_Integer] + 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Z_Counter[Z_Integer] Less than or equal to 100
            • Then - Actions
              • -------- HERO HAS BUFF? --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Z_Caster[Z_Integer] has buff Soul Catcher (Ally)) Equal to False
                • Then - Actions
                  • Set VariableSet Z_BooleanSpellAmp[Z_Integer] = False
                  • Set VariableSet Z_CV_Caster = (Custom value of Z_Caster[Z_Integer])
                  • Set VariableSet Z_Level = (Level of Soul Catcher for Z_Caster[Z_Integer])
                  • Set VariableSet Z_DamageAmp[Z_CV_Caster] = (Z_DamageAmp[Z_CV_Caster] - (0.03 + (0.02 x (Real(Z_Level)))))
                • Else - Actions
              • -------- ENEMIES HAVE DEBUFF? --------
              • Unit Group - Pick every unit in Z_Group[Z_Integer] and do (Actions)
                • Loop - Actions
                  • Set VariableSet Z_Unit = (Picked unit)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Z_Unit has buff Soul Catcher (Enemy)) Equal to False
                    • Then - Actions
                      • Set VariableSet Z_CV_Target = (Custom value of Z_Unit)
                      • Unit - Set life of Z_Unit to ((Life of Z_Unit) + (0.50 x (Load Z_Integer of Z_CV_Target from Z_Hashtable.)))
                      • Game - Display to (All players) the text: (Life Returned: + (String((Load Z_Integer of Z_CV_Target from Z_Hashtable.))))
                      • Unit Group - Remove Z_Unit from Z_Group[Z_Integer].
                    • Else - Actions
            • Else - Actions
              • -------- REMOVE SPELL DAMAGE AMPLIFICATION --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Z_CounterHero[Z_Integer] Not equal to 0
                  • Z_BooleanSpellAmp[Z_Integer] Equal to True
                • Then - Actions
                  • Set VariableSet Z_CV_Caster = (Custom value of Z_Caster[Z_Integer])
                  • Set VariableSet Z_Level = (Level of Soul Catcher for Z_Caster[Z_Integer])
                  • Set VariableSet Z_DamageAmp[Z_CV_Caster] = (Z_DamageAmp[Z_CV_Caster] - (0.03 + (0.02 x (Real(Z_Level)))))
                • Else - Actions
              • -------- RETURN HP OF ENEMIES --------
              • Unit Group - Pick every unit in Z_Group[Z_Integer] and do (Actions)
                • Loop - Actions
                  • Set VariableSet Z_Unit = (Picked unit)
                  • Set VariableSet Z_CV_Target = (Custom value of Z_Unit)
                  • Unit - Set life of Z_Unit to ((Life of Z_Unit) + (0.50 x (Load Z_Integer of Z_CV_Target from Z_Hashtable.)))
                  • Game - Display to (All players) the text: (String(Z_Integer))
                  • Game - Display to (All players) the text: (Life Returned: + (String((Load Z_Integer of Z_CV_Target from Z_Hashtable.))))
                  • Unit Group - Remove Z_Unit from Z_Group[Z_Integer].
              • -------- --------
              • For each (Integer Z_Integer2) from 1 to Z_Index, do (Actions)
                • Loop - Actions
                  • Unit Group - Pick every unit in Z_Group[Z_Integer2] and do (Actions)
                    • Loop - Actions
                      • Set VariableSet Z_CV_Target = (Custom value of (Picked unit))
                      • Game - Display to (All players) the text: (String((Load Z_Integer2 of Z_CV_Target from Z_Hashtable.)))
                      • Hashtable - Save (Load Z_Integer2 of Z_CV_Target from Z_Hashtable.) as (Z_Integer2 - 1) of Z_CV_Target in Z_Hashtable.
                      • Game - Display to (All players) the text: (String((Load (Z_Integer2 - 1) of Z_CV_Target from Z_Hashtable.)))
              • Hashtable - Clear all child hashtables of child Z_Integer in Z_Hashtable.
              • Custom script: call DestroyGroup (udg_Z_Group[udg_Z_Integer])
              • -------- --------
              • Set VariableSet Z_Caster[Z_Integer] = Z_Caster[Z_Index]
              • Set VariableSet Z_Counter[Z_Integer] = Z_Counter[Z_Index]
              • Set VariableSet Z_CounterHero[Z_Integer] = Z_CounterHero[Z_Index]
              • Set VariableSet Z_Group[Z_Integer] = Z_Group[Z_Index]
              • Set VariableSet Z_BooleanSpellAmp[Z_Integer] = Z_BooleanSpellAmp[Z_Index]
              • -------- --------
              • Set VariableSet Z_Index = (Z_Index - 1)
              • Set VariableSet Z_Integer = (Z_Integer - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Z_Index Equal to 0
                • Then - Actions
                  • Game - Display to (All players) the text: OFF
                  • Countdown Timer - Pause Z_Timer
                  • Trigger - Turn off Soul Catcher Spell Amp <gen>
                  • Trigger - Turn off (This trigger)
                • Else - Actions
 
Last edited:

Uncle

Warcraft Moderator
Level 71
Joined
Aug 10, 2018
Messages
7,624
I can't see Z_Integer working as an Index in the Hashtable with how Dynamic Indexing works. You're going to be switching the Indices whenever something gets De-indexed.

A simple solution using your Hashtable:
Parent = Unit handle or Custom Value (unit handle is probably faster)
Child 0 = Total children (so the number of soul catcher debuffs the unit is affected by)
Child 1 = Life Loss value #1
Child 2 = Life Loss value #2
Child 3 = Life Loss value #3
etc...

Whenever you inflict a unit with Soul Catcher you increase it's Child 0 by 1. Then you store the Life Loss at this new value.

When the duration of a debuff expires, restore the Life Loss that is saved at Child 1 and proceed to drop down all of the Child keys by 1. So Save Child 2 at Child 1's position, Child 3 at Child 2's position, etc... Lastly, subtract 1 from Child 0 since you've removed one of the debuffs.

Also, I just wanted to remind you of the 256 Hashtable limit in case you forgot. I could see you potentially running out, lol.
 
Last edited:
Level 12
Joined
May 16, 2020
Messages
660
Thanks, understood the concept.
However... I'm struggling with adding this part to the trigger: "So Save Child 2 at Child 1's position, Child 3 at Child 2's position, etc". To me the below looks good, but in-game it doesn't work correctly for the 2nd cast on the same target (the to-be-returned HP is 0)

Remove HP:
  • Then - Actions
    • Set VariableSet Z_Life_Removed = ((Life of Z_Unit) x Z_Life_Percentage)
    • Set VariableSet Z_CV_Target = (Custom value of Z_Unit)
    • Set VariableSet Z_CounterTarget[Z_CV_Target] = (Z_CounterTarget[Z_CV_Target] + 1)
    • Custom script: set udg_Z_Handle_Target = udg_Z_Unit
    • -------- --------
    • Hashtable - Save Z_Life_Removed as (Key Z_Handle_Target.) of Z_CounterTarget[Z_CV_Target] in Z_Hashtable.
    • -------- --------
    • Unit - Set life of Z_Unit to ((Life of Z_Unit) - Z_Life_Removed)
    • Unit Group - Add Z_Unit to Z_Group[Z_Index]

Return HP:
  • Unit Group - Pick every unit in Z_Group[Z_Integer] and do (Actions)
    • Loop - Actions
      • Set VariableSet Z_Unit = (Picked unit)
      • Custom script: set udg_Z_Handle_Target = udg_Z_Unit
      • Unit - Set life of Z_Unit to ((Life of Z_Unit) + (0.50 x (Load (Key Z_Handle_Target.) of 1 from Z_Hashtable.)))
      • Unit Group - Remove Z_Unit from Z_Group[Z_Integer].
      • -------- --------
      • Set VariableSet Z_CV_Target = (Custom value of Z_Unit)
      • For each (Integer Z_Integer2) from 1 to Z_CounterTarget[Z_CV_Target], do (Actions)
        • Loop - Actions
          • Unit Group - Pick every unit in Z_Group[Z_Integer2] and do (Actions)
            • Loop - Actions
              • Hashtable - Save (Load (Key Z_Handle_Target.) of Z_Integer2 from Z_Hashtable.) as (Key Z_Handle_Target.) of (Z_Integer2 - 1) in Z_Hashtable.
      • -------- --------
      • Set VariableSet Z_CounterTarget[Z_CV_Target] = (Z_CounterTarget[Z_CV_Target] - 1)



Also, I just wanted to remind you of the 256 Hashtable limit in case you forgot. I could see you potentially running out, lol.
Is this for example counting as 1 of 256 Hashtables?
If so, then I'm still fine - got only 15 so far :thumbs_up:

  • Soul Catcher Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set VariableSet Z_Hashtable = (Last created hashtable)
 

Uncle

Warcraft Moderator
Level 71
Joined
Aug 10, 2018
Messages
7,624
So you have the Child/Parent keys reversed throughout your triggers (it still works but logically it makes less sense):
  • Hashtable - Save Z_Life_Removed as (Key Z_Handle_Target.) of Z_CounterTarget[Z_CV_Target] in Z_Hashtable.

Here's how I would do it:
  • Actions
    • -------- Increase child count: --------
    • Set VariableSet ChildCount = ((Load 0 of (Key Z_Handle_Target) from Z_Hashtable) + 1)
    • Hashtable - Save ChildCount as 0 of (Key Z_Handle_Target) in Z_Hashtable.
    • -------- Save life loss: --------
    • Hashtable - Save Z_Life_Removed as ChildCount of (Key Z_Handle_Target) in Z_Hashtable.

Then return the life:
  • -------- Return lost life: --------
  • Unit - Set life of Z_Unit to ((Life of Z_Unit) + (0.50 x (Load 1 of (Key Z_Handle_Target.) from Z_Hashtable.)))

Lastly, sort the Hashtable so that Child 1 is shaved off and the rest of the Children fall down an Index:
  • Actions
    • -------- Sort hashtable: --------
    • Set VariableSet ChildCount = (Load 0 of (Key Z_Handle_Target) from Z_Hashtable.)
    • For each (Integer Z_Sort) from 1 to ChildCount, do (Actions)
      • Loop - Actions
        • Set VariableSet Z_Life_Removed = (Load (Z_Sort + 1) of (Key Z_Handle_Target.) from Z_Hashtable.)
        • Hashtable - Save Z_Life_Removed as Z_Sort of (Key Z_Handle_Target.) in Z_Hashtable).
    • -------- Decrease child count: --------
    • Hashtable - Save (ChildCount - 1) as 0 of (Key Z_Handle_Target) in Z_Hashtable.

Edit: You'll need to Clear things when ChildCount reaches 0:
  • Hashtable - Clear all child hashtables of child (Key Z_Handle_Target) in Z_Hashtable.

The Hashtable is worded like this:
Save VALUE as CHILD of PARENT in HASH
Load CHILD of PARENT from HASH

It makes the most sense for the Parent to be the Unit Handle and it's Children to be the values saved there.
 
Last edited:
Level 12
Joined
May 16, 2020
Messages
660
Thank you! Works perfectly now. And I guess the difference between CHILD and PARENT does make a small difference when clearing the child hashtables. So good to know.

Edit: You'll need to Clear things when ChildCount reaches 0:
  • set.gif
    Hashtable - Clear all child hashtables of child (Key Z_Handle_Target) in Z_Hashtable.

Is that OK like this?

Return the life:
  • Unit Group - Pick every unit in Z_Group[Z_Integer] and do (Actions)
    • Loop - Actions
      • Set VariableSet Z_Unit = (Picked unit)
      • Custom script: set udg_Z_Handle_Target = udg_Z_Unit
      • Unit - Set life of Z_Unit to ((Life of Z_Unit) + (0.50 x (Load 1 of (Key Z_Handle_Target.) from Z_Hashtable.)))
      • Unit Group - Remove Z_Unit from Z_Group[Z_Integer].
      • -------- --------
      • -------- SORT HASHTABLE --------
      • Set VariableSet Z_ChildCount = (Load 0 of (Key Z_Handle_Target.) from Z_Hashtable.)
      • For each (Integer Z_Integer_Sort) from 1 to Z_ChildCount, do (Actions)
        • Loop - Actions
          • Set VariableSet Z_Life_Removed = (Load (Z_Integer_Sort + 1) of (Key Z_Handle_Target.) from Z_Hashtable.)
          • Hashtable - Save Z_Life_Removed as Z_Integer_Sort of (Key Z_Handle_Target.) in Z_Hashtable.
      • -------- DECREASE CHILD COUNT --------
      • Hashtable - Save (Z_ChildCount - 1) as 0 of (Key Z_Handle_Target.) in Z_Hashtable.
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Z_ChildCount Equal to 0
        • Then - Actions
          • Hashtable - Clear all child hashtables of child (Key Z_Handle_Target.) in Z_Hashtable.
        • Else - Actions

If yes, here full trigger for reference:

  • Soul Catcher
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Soul Catcher
    • Actions
      • Set VariableSet SoulCatcher_Index = (SoulCatcher_Index + 1)
      • Set VariableSet SoulCatcher_Caster[SoulCatcher_Index] = (Triggering unit)
      • Set VariableSet SoulCatcher_Counter[SoulCatcher_Index] = 0
      • Set VariableSet SoulCatcher_CounterHero[SoulCatcher_Index] = 0
      • -------- --------
      • Set VariableSet SoulCatcher_Point = (Target point of ability being cast)
      • Special Effect - Create a special effect at SoulCatcher_Point using AnnihilationBlast.mdx
      • Special Effect - Destroy (Last created special effect)
      • Special Effect - Create a special effect at SoulCatcher_Point using Desecrate.mdx
      • Special Effect - Destroy (Last created special effect)
      • -------- --------
      • Unit - Create 1 Dummy (Fly/Speed 0) for Neutral Passive at SoulCatcher_Point facing Default building facing degrees
      • Set VariableSet SoulCatcher_Dummy = (Last created unit)
      • Unit - Add Soul Catcher (Ally) to SoulCatcher_Dummy
      • Unit - Add Soul Catcher (Enemy) to SoulCatcher_Dummy
      • Unit - Add a 0.50 second Generic expiration timer to SoulCatcher_Dummy
      • -------- --------
      • Custom script: set udg_SoulCatcher_Group[udg_SoulCatcher_Index] = CreateGroup()
      • Set VariableSet SoulCatcher_Level = (Level of Soul Catcher for SoulCatcher_Caster[SoulCatcher_Index])
      • Set VariableSet SoulCatcher_Life_Percentage = (0.15 + (0.05 x (Real(SoulCatcher_Level))))
      • Unit Group - Pick every unit in Disruption_Group and do (Unit - Unhide (Picked unit))
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within (150.00 + (25.00 x (Real(SoulCatcher_Level)))) of SoulCatcher_Point.) and do (Actions)
        • Loop - Actions
          • Set VariableSet SoulCatcher_Unit = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (SoulCatcher_Unit is alive) Equal to True
              • (SoulCatcher_Unit is A structure) Equal to False
              • (SoulCatcher_Unit is An Ancient) Equal to False
              • (SoulCatcher_Unit is Magic Immune) Equal to False
              • (SoulCatcher_Unit belongs to an enemy of (Owner of SoulCatcher_Caster[SoulCatcher_Index]).) Equal to True
            • Then - Actions
              • Set VariableSet SoulCatcher_Life_Removed = ((Life of SoulCatcher_Unit) x SoulCatcher_Life_Percentage)
              • -------- Increase child count --------
              • Custom script: set udg_SoulCatcher_Handle_Target = udg_SoulCatcher_Unit
              • Set VariableSet SoulCatcher_ChildCount = ((Load 0 of (Key SoulCatcher_Handle_Target.) from SoulCatcher_Hashtable.) + 1)
              • Hashtable - Save SoulCatcher_ChildCount as 0 of (Key SoulCatcher_Handle_Target.) in SoulCatcher_Hashtable.
              • -------- SAVE HP LOSS --------
              • Hashtable - Save SoulCatcher_Life_Removed as SoulCatcher_ChildCount of (Key SoulCatcher_Handle_Target.) in SoulCatcher_Hashtable.
              • -------- --------
              • Unit - Set life of SoulCatcher_Unit to ((Life of SoulCatcher_Unit) - SoulCatcher_Life_Removed)
              • Unit - Order SoulCatcher_Dummy to Undead Necromancer - Cripple SoulCatcher_Unit
              • Unit Group - Add SoulCatcher_Unit to SoulCatcher_Group[SoulCatcher_Index]
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (SoulCatcher_Unit is A Hero) Equal to True
                  • (SoulCatcher_Unit is an illusion) Equal to False
                • Then - Actions
                  • Set VariableSet SoulCatcher_CounterHero[SoulCatcher_Index] = (SoulCatcher_CounterHero[SoulCatcher_Index] + 1)
                • Else - Actions
            • Else - Actions
      • Unit Group - Pick every unit in Disruption_Group and do (Unit - Hide (Picked unit))
      • -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • SoulCatcher_CounterHero[SoulCatcher_Index] Not equal to 0
        • Then - Actions
          • Set VariableSet SoulCatcher_BooleanSpellAmp[SoulCatcher_Index] = True
          • Set VariableSet SoulCatcher_CV_Caster = (Custom value of SoulCatcher_Caster[SoulCatcher_Index])
          • Set VariableSet SoulCatcher_DamageAmp[SoulCatcher_CV_Caster] = (SoulCatcher_DamageAmp[SoulCatcher_CV_Caster] + ((Real(SoulCatcher_CounterHero[SoulCatcher_Index])) x (0.03 + (0.02 x (Real(SoulCatcher_Level))))))
          • Unit - Order SoulCatcher_Dummy to Orc Shaman - Bloodlust SoulCatcher_Caster[SoulCatcher_Index]
        • Else - Actions
      • -------- --------
      • Custom script: call RemoveLocation(udg_SoulCatcher_Point)
      • -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • SoulCatcher_Index Equal to 1
        • Then - Actions
          • Countdown Timer - Start SoulCatcher_Timer as a Repeating timer that will expire in 0.10 seconds
          • Trigger - Turn on Soul Catcher Spell Amp <gen>
          • Trigger - Turn on Soul Catcher Loop <gen>
        • Else - Actions
  • Soul Catcher Loop
    • Events
      • Time - SoulCatcher_Timer expires
    • Conditions
    • Actions
      • For each (Integer SoulCatcher_Integer) from 1 to SoulCatcher_Index, do (Actions)
        • Loop - Actions
          • Set VariableSet SoulCatcher_Counter[SoulCatcher_Integer] = (SoulCatcher_Counter[SoulCatcher_Integer] + 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • SoulCatcher_Counter[SoulCatcher_Integer] Less than or equal to 100
            • Then - Actions
              • -------- HERO HAS BUFF? --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (SoulCatcher_Caster[SoulCatcher_Integer] has buff Soul Catcher (Ally)) Equal to False
                • Then - Actions
                  • Set VariableSet SoulCatcher_BooleanSpellAmp[SoulCatcher_Integer] = False
                  • Set VariableSet SoulCatcher_CV_Caster = (Custom value of SoulCatcher_Caster[SoulCatcher_Integer])
                  • Set VariableSet SoulCatcher_Level = (Level of Soul Catcher for SoulCatcher_Caster[SoulCatcher_Integer])
                  • Set VariableSet SoulCatcher_DamageAmp[SoulCatcher_CV_Caster] = (SoulCatcher_DamageAmp[SoulCatcher_CV_Caster] - ((Real(SoulCatcher_CounterHero[SoulCatcher_Integer])) x (0.03 + (0.02 x (Real(SoulCatcher_Level))))))
                • Else - Actions
              • -------- ENEMIES HAVE DEBUFF? --------
              • Unit Group - Pick every unit in SoulCatcher_Group[SoulCatcher_Integer] and do (Actions)
                • Loop - Actions
                  • Set VariableSet SoulCatcher_Unit = (Picked unit)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (SoulCatcher_Unit has buff Soul Catcher (Enemy)) Equal to False
                    • Then - Actions
                      • Custom script: set udg_SoulCatcher_Handle_Target = udg_SoulCatcher_Unit
                      • Unit - Set life of SoulCatcher_Unit to ((Life of SoulCatcher_Unit) + (0.50 x (Load 1 of (Key SoulCatcher_Handle_Target.) from SoulCatcher_Hashtable.)))
                      • Unit Group - Remove SoulCatcher_Unit from SoulCatcher_Group[SoulCatcher_Integer].
                      • -------- --------
                      • -------- SORT HASHTABLE --------
                      • Set VariableSet SoulCatcher_ChildCount = (Load 0 of (Key SoulCatcher_Handle_Target.) from SoulCatcher_Hashtable.)
                      • For each (Integer SoulCatcher_Integer_Sort) from 1 to SoulCatcher_ChildCount, do (Actions)
                        • Loop - Actions
                          • Set VariableSet SoulCatcher_Life_Removed = (Load (SoulCatcher_Integer_Sort + 1) of (Key SoulCatcher_Handle_Target.) from SoulCatcher_Hashtable.)
                          • Hashtable - Save SoulCatcher_Life_Removed as SoulCatcher_Integer_Sort of (Key SoulCatcher_Handle_Target.) in SoulCatcher_Hashtable.
                      • -------- DECREASE CHILD COUNT --------
                      • Set VariableSet SoulCatcher_ChildCount = (SoulCatcher_ChildCount - 1)
                      • Hashtable - Save SoulCatcher_ChildCount as 0 of (Key SoulCatcher_Handle_Target.) in SoulCatcher_Hashtable.
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • SoulCatcher_ChildCount Equal to 0
                        • Then - Actions
                          • Hashtable - Clear all child hashtables of child (Key SoulCatcher_Handle_Target.) in SoulCatcher_Hashtable.
                        • Else - Actions
                    • Else - Actions
            • Else - Actions
              • -------- REMOVE SPELL DAMAGE AMPLIFICATION --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • SoulCatcher_CounterHero[SoulCatcher_Integer] Not equal to 0
                  • SoulCatcher_BooleanSpellAmp[SoulCatcher_Integer] Equal to True
                • Then - Actions
                  • Set VariableSet SoulCatcher_CV_Caster = (Custom value of SoulCatcher_Caster[SoulCatcher_Integer])
                  • Set VariableSet SoulCatcher_Level = (Level of Soul Catcher for SoulCatcher_Caster[SoulCatcher_Integer])
                  • Set VariableSet SoulCatcher_DamageAmp[SoulCatcher_CV_Caster] = (SoulCatcher_DamageAmp[SoulCatcher_CV_Caster] - ((Real(SoulCatcher_CounterHero[SoulCatcher_Integer])) x (0.03 + (0.02 x (Real(SoulCatcher_Level))))))
                • Else - Actions
              • -------- RETURN HP OF ENEMIES --------
              • Unit Group - Pick every unit in SoulCatcher_Group[SoulCatcher_Integer] and do (Actions)
                • Loop - Actions
                  • Set VariableSet SoulCatcher_Unit = (Picked unit)
                  • Custom script: set udg_SoulCatcher_Handle_Target = udg_SoulCatcher_Unit
                  • Unit - Set life of SoulCatcher_Unit to ((Life of SoulCatcher_Unit) + (0.50 x (Load 1 of (Key SoulCatcher_Handle_Target.) from SoulCatcher_Hashtable.)))
                  • Unit Group - Remove SoulCatcher_Unit from SoulCatcher_Group[SoulCatcher_Integer].
                  • -------- --------
                  • -------- SORT HASHTABLE --------
                  • Set VariableSet SoulCatcher_ChildCount = (Load 0 of (Key SoulCatcher_Handle_Target.) from SoulCatcher_Hashtable.)
                  • For each (Integer SoulCatcher_Integer_Sort) from 1 to SoulCatcher_ChildCount, do (Actions)
                    • Loop - Actions
                      • Set VariableSet SoulCatcher_Life_Removed = (Load (SoulCatcher_Integer_Sort + 1) of (Key SoulCatcher_Handle_Target.) from SoulCatcher_Hashtable.)
                      • Hashtable - Save SoulCatcher_Life_Removed as SoulCatcher_Integer_Sort of (Key SoulCatcher_Handle_Target.) in SoulCatcher_Hashtable.
                  • -------- DECREASE CHILD COUNT --------
                  • Set VariableSet SoulCatcher_ChildCount = (SoulCatcher_ChildCount - 1)
                  • Hashtable - Save SoulCatcher_ChildCount as 0 of (Key SoulCatcher_Handle_Target.) in SoulCatcher_Hashtable.
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • SoulCatcher_ChildCount Equal to 0
                    • Then - Actions
                      • Hashtable - Clear all child hashtables of child (Key SoulCatcher_Handle_Target.) in SoulCatcher_Hashtable.
                    • Else - Actions
              • -------- --------
              • Custom script: call DestroyGroup (udg_SoulCatcher_Group[udg_SoulCatcher_Integer])
              • -------- --------
              • Set VariableSet SoulCatcher_Caster[SoulCatcher_Integer] = SoulCatcher_Caster[SoulCatcher_Index]
              • Set VariableSet SoulCatcher_Counter[SoulCatcher_Integer] = SoulCatcher_Counter[SoulCatcher_Index]
              • Set VariableSet SoulCatcher_CounterHero[SoulCatcher_Integer] = SoulCatcher_CounterHero[SoulCatcher_Index]
              • Set VariableSet SoulCatcher_Group[SoulCatcher_Integer] = SoulCatcher_Group[SoulCatcher_Index]
              • Set VariableSet SoulCatcher_BooleanSpellAmp[SoulCatcher_Integer] = SoulCatcher_BooleanSpellAmp[SoulCatcher_Index]
              • -------- --------
              • Set VariableSet SoulCatcher_Index = (SoulCatcher_Index - 1)
              • Set VariableSet SoulCatcher_Integer = (SoulCatcher_Integer - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • SoulCatcher_Index Equal to 0
                • Then - Actions
                  • Countdown Timer - Pause SoulCatcher_Timer
                  • Trigger - Turn off Soul Catcher Spell Amp <gen>
                  • Trigger - Turn off (This trigger)
                • Else - Actions
 
Last edited:

Uncle

Warcraft Moderator
Level 71
Joined
Aug 10, 2018
Messages
7,624
You're checking if Z_ChildCount is Equal to 0 but that'll never be the case.

Look at what it's Equal to:
  • Set VariableSet Z_ChildCount = (Load 0 of (Key Z_Handle_Target.) from Z_Hashtable.)
It's at least 1 in this case.

You should do this:
  • -------- DECREASE CHILD COUNT --------
  • Set VariableSet Z_ChildCount = Z_ChildCount - 1
  • Hashtable - Save Z_ChildCount as 0 of (Key Z_Handle_Target.) in Z_Hashtable.
  • If Z_ChildCount Equal to 0 Then Hashtable - Clear all child hashtables of child (Key Z_Handle_Target.) in Z_Hashtable.
 
Level 12
Joined
May 16, 2020
Messages
660
Ah, I see now why... So I guess rather than loading the ChildCount again like this:
  • Hashtable - Save (Z_ChildCount - 1) as 0 of (Key Z_Handle_Target.) in Z_Hashtable.
  • Set VariableSet Z_ChildCount = (Load 0 of (Key Z_Handle_Target.) from Z_Hashtable.) <-- now it should be zero
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • Z_ChildCount Equal to 0
    • Then - Actions
      • Hashtable - Clear all child hashtables of child (Key Z_Handle_Target.) in Z_Hashtable.
    • Else - Actions

... I just put "Equal to 1"?
 
Status
Not open for further replies.
Top