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

[Trigger] Help with groups and indexing

Status
Not open for further replies.
Level 3
Joined
Dec 22, 2009
Messages
39
Hi, I am just getting used in using Hanky's Dynamic Indexing method but now I am having a problem regarding a skill I made. The reason I am learning indexing is because i want my skills to be mui but it doesnt seem to go that way regarding groups.

Here is my triggers:

[trigger=Death Coil]Start
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to Death Coil
Actions
-------- IMPORTANT SYSTEM PART START --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Ab_DeathCoil_Index_Size Equal to 0
Then - Actions
Trigger - Turn on Death Coil Loop <gen>
Else - Actions
-------- Increase the index size --------
Set Ab_DeathCoil_Index_Size = (Ab_DeathCoil_Index_Size + 1)
-------- Dynamic Index --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Ab_DeathCoil_Index_Size Greater than Ab_DeathCoil_Index_maxSize
Then - Actions
Set Ab_DeathCoil_Index[Ab_DeathCoil_Index_Size] = Ab_DeathCoil_Index_Size
Set Ab_DeathCoil_Index_maxSize = Ab_DeathCoil_Index_Size
Else - Actions
-------- Dynamic Index End --------
-------- IMPORTANT SYSTEM PART END --------
Set TempInt = Ab_DeathCoil_Index[Ab_DeathCoil_Index_Size]
-------- Setup those arrays --------
Unit Group - Remove all units from Ab_DeathCoil_Targets[TempInt]
Set TempLoc = (Position of (Triggering unit))
Set Ab_DeathCoil_Caster[TempInt] = (Triggering unit)
Set Ab_DeathCoil_Target[TempInt] = (Target unit of ability being cast)
Unit - Create 1 Spell Dummy (Death Coil) for (Owner of Ab_DeathCoil_Caster[TempInt]) at TempLoc facing (Random angle) degrees
Set Ab_DeathCoil_Missile[TempInt] = (Last created unit)
Set Ab_DeathCoil_Rate[TempInt] = (0.04 + (0.02 x (Real(((Level of Death Coil for Ab_DeathCoil_Caster[TempInt]) - 1)))))
Set Ab_DeathCoil_Damage[TempInt] = (80.00 + (40.00 x (Real(((Level of Death Coil for Ab_DeathCoil_Caster[TempInt]) - 1)))))
Set Ab_DeathCoil_Size[TempInt] = 60.00
Custom script: call RemoveLocation(udg_TempLoc)
[/trigger]

[trigger=DeathCoil]Loop
Events
Time - Every 0.03 seconds of game time
Conditions
Actions
For each (Integer Ab_DeathCoil_Loop) from 1 to Ab_DeathCoil_Index_Size, do (Actions)
Loop - Actions
-------- This let look everything cleaner. --------
Set TempInt = Ab_DeathCoil_Index[Ab_DeathCoil_Loop]
-------- Condition... --------
Set TempLoc = (Position of Ab_DeathCoil_Missile[TempInt])
Set TempLoc2 = (Position of Ab_DeathCoil_Target[TempInt])
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
And - All (Conditions) are true
Conditions
(Distance between TempLoc and TempLoc2) Greater than 100.00
(Ab_DeathCoil_Target[TempInt] is alive) Equal to True
Then - Actions
-------- Actions --------
Set TempLoc3 = (TempLoc offset by 15.00 towards (Angle from TempLoc to TempLoc2) degrees)
Unit - Move Ab_DeathCoil_Missile[TempInt] instantly to TempLoc3
Set TempGroup = (Units within 150.00 of TempLoc3)
Unit Group - Pick every unit in TempGroup and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
And - All (Conditions) are true
Conditions
((Picked unit) is A structure) Equal to False
((Picked unit) is Magic Immune) Equal to False
((Picked unit) is alive) Equal to True
((Picked unit) belongs to an enemy of (Owner of Ab_DeathCoil_Missile[TempInt])) Equal to True
((Picked unit) is in Ab_DeathCoil_Targets[TempInt]) Equal to False
(Picked unit) Not equal to Ab_DeathCoil_Target[TempInt]
Then - Actions
Unit Group - Add (Picked unit) to Ab_DeathCoil_Targets[TempInt]
Unit - Cause Ab_DeathCoil_Caster[TempInt] to damage (Picked unit), dealing ((Life of (Picked unit)) x Ab_DeathCoil_Rate[TempInt]) damage of attack type Spells and damage type Magic
Set Ab_DeathCoil_Damage[TempInt] = (Ab_DeathCoil_Damage[TempInt] + ((Life of (Picked unit)) x Ab_DeathCoil_Rate[TempInt]))
Set Ab_DeathCoil_Size[TempInt] = (Ab_DeathCoil_Size[TempInt] + 10.00)
Animation - Change Ab_DeathCoil_Missile[TempInt]'s size to (Ab_DeathCoil_Size[TempInt]%, Ab_DeathCoil_Size[TempInt]%, Ab_DeathCoil_Size[TempInt]%) of its original size
Special Effect - Create a special effect attached to the origin of (Picked unit) using Abilities\Spells\Undead\DeathCoil\DeathCoilSpecialArt.mdl
Special Effect - Destroy (Last created special effect)
Else - Actions
Custom script: call DestroyGroup(udg_TempGroup)
Custom script: call RemoveLocation(udg_TempLoc3)
Else - Actions
-------- Destroy handles --------
Unit - Kill Ab_DeathCoil_Missile[TempInt]
Unit - Cause Ab_DeathCoil_Caster[TempInt] to damage Ab_DeathCoil_Target[TempInt], dealing Ab_DeathCoil_Damage[TempInt] damage of attack type Spells and damage type Magic
Special Effect - Create a special effect attached to the origin of Ab_DeathCoil_Target[TempInt] using Abilities\Spells\Undead\AnimateDead\AnimateDeadTarget.mdl
Special Effect - Destroy (Last created special effect)
-------- IMPORTANT SYSTEM PART START --------
-------- RecycleIndex --------
Set Ab_DeathCoil_Index[Ab_DeathCoil_Loop] = Ab_DeathCoil_Index[Ab_DeathCoil_Index_Size]
Set Ab_DeathCoil_Index[Ab_DeathCoil_Index_Size] = TempInt
Set Ab_DeathCoil_Index_Size = (Ab_DeathCoil_Index_Size - 1)
Set Ab_DeathCoil_Loop = (Ab_DeathCoil_Loop - 1)
-------- Turn the trigger again off if the index_size is below 0... --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Ab_DeathCoil_Index_Size Equal to 0
Then - Actions
Trigger - Turn off (This trigger)
Skip remaining actions
Else - Actions
-------- IMPORTANT SYSTEM PART END --------
Custom script: call RemoveLocation(udg_TempLoc)
Custom script: call RemoveLocation(udg_TempLoc2)
[/trigger]

My skill works fine actually, even if cast simultaneously, the dummy unit will chase the target without errors. As you can see above, the dummy unit passess through enemies and then adds them to a group to prevent damage every 0.3 seconds. If i cast it one instance at a time, I get no problems, but once i cast another one while the first one was still active, i think the groups mess up and makes the dummy unit deal damage every 0.3 seconds.
I cant seem to find the problem. Help please. Thank you very much.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Use debug messages, Game - Display text message. Print things like the target's name.

Make sure these are created somewhere: Ab_DeathCoil_Targets[TempInt]. By default, only indexes 0 and 1 contain a group. Other indexes have null value.

  • Custom script : set udg_Ab_DeathCoil_Targets[udg_TempInt] = CreateGroup()
 
Level 3
Joined
Dec 22, 2009
Messages
39
Make sure these are created somewhere: Ab_DeathCoil_Targets[TempInt]. By default, only indexes 0 and 1 contain a group. Other indexes have null value.

Thank you very much for this info. I never knew that triggers where registering to null values thats why it messes up. ++
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
You should also make your triggers more efficient. Never use and all condition block unless it is inside an or all condition block. The ITE is always and all.

Store anything used twice or more inside a variable and use the variable. Example: Store Picked unit in a variable and use the variable in its place.

Remove this action.
  • Skip remaining actions
If you use that action when the count == 0 then the rest of the trigger will stop causing you to leak 2 locations every time that happens.
 
Status
Not open for further replies.
Top