- Joined
- May 16, 2020
- Messages
- 663
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:
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:
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:

