- Joined
- Feb 1, 2024
- Messages
- 44
Hello, I've simulated the animation of Chain Lightning with the following trigger:
(This is just part of the triggers, and it is not MUI but I'll add it later)
But I don't understand why if I add the following lines in between two lines of dash in the first trigger it will not add any unit into CLGroup[3] (store already hit targets so it will not bounce to them again) and it will run endlessly:
As I think if I don't set a Unit Group it will leak, so I created 2 groups, then emptied these groups to store units.
(This is just part of the triggers, and it is not MUI but I'll add it later)
-
Chain Lightning cast
-
Events
-
Unit - A unit Starts the effect of an ability
-
-
Conditions
-
(Ability being cast) Equal to Chain Lightning
-
-
Actions
-
Set CLCaster[0] = (Triggering unit)
-
Set CLTarget[0] = (Target unit of ability being cast)
-
Set CLAoE[0] = (750.00 + (100.00 x (Real((Level of (Ability being cast) for (Triggering unit))))))
-
Set CLPoint[0] = (Position of (Target unit of ability being cast))
-
Set CLPoint[1] = (Position of (Triggering unit))
-
Set CLTimer[0] = 0.00
-
Set CLTimer[1] = 10.00
-
Set CLLightningCount[0] = 0
-
Set CLDamage[0] = (10.00 + (5.00 x (Real((Level of (Ability being cast) for (Triggering unit))))))
-
-
-
------------------------------------------------------------------------------------------------------------------
-
------------------------------------------------------------------------------------------------------------------
-
Unit Group - Add (Triggering unit) to CLGroup[3]
-
Lightning - Create a Chain Lightning effect from source CLPoint[1] to target CLPoint[0]
-
Set CLLightning[CLLightningCount[0]] = (Last created lightning effect)
-
Unit Group - Add CLTarget[0] to CLGroup[3]
-
Custom script: call RemoveLocation(udg_CLPoint[0])
-
Custom script: call RemoveLocation(udg_CLPoint[1])
-
Trigger - Turn on Chain Lightning bounce <gen>
-
-
Chain Lightning bounce
-
Events
-
Time - Every 0.25 seconds of game time
-
-
Conditions
-
Actions
-
Set CLPoint[0] = (Position of CLTarget[CLLightningCount[0]])
-
Set CLCount = 0
-
Set CLGroup[0] = (Units within CLAoE[0] of CLPoint[0])
-
Unit Group - Pick every unit in CLGroup[0] and do (Actions)
-
Loop - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
((Picked unit) is in CLGroup[3]) Equal to False
-
-
Then - Actions
-
Unit Group - Add (Picked unit) to CLGroup[2]
-
-
Else - Actions
-
-
-
-
Set CLGroup[1] = (Random 1 units from CLGroup[2])
-
Unit Group - Pick every unit in CLGroup[1] and do (Actions)
-
Loop - Actions
-
Unit Group - Add (Picked unit) to CLGroup[3]
-
Set CLCount = (CLCount + 1)
-
Set CLPoint[1] = (Position of (Picked unit))
-
Set CLLightningCount[0] = (CLLightningCount[0] + 1)
-
Set CLTarget[CLLightningCount[0]] = (Picked unit)
-
-
-
Unit Group - Remove all units of CLGroup[2] from CLGroup[2]
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
CLCount Equal to 0
-
-
Then - Actions
-
Trigger - Turn off (This trigger)
-
-
Else - Actions
-
Lightning - Create a Chain Lightning effect from source CLPoint[0] to target CLPoint[1]
-
Set CLLightning[CLLightningCount[0]] = (Last created lightning effect)
-
-
-
Custom script: call RemoveLocation(udg_CLPoint[0])
-
Custom script: call RemoveLocation(udg_CLPoint[1])
-
Custom script: call DestroyGroup(udg_CLGroup[0])
-
Custom script: call DestroyGroup(udg_CLGroup[1])
-
-
But I don't understand why if I add the following lines in between two lines of dash in the first trigger it will not add any unit into CLGroup[3] (store already hit targets so it will not bounce to them again) and it will run endlessly:
-
Set CLGroup[2] = (Units within CLAoE[0] of CLPoint[0])
-
Set CLGroup[3] = CLGroup[2]
-
Unit Group - Remove all units of CLGroup[2] from CLGroup[2]
-
Unit Group - Remove all units of CLGroup[3] from CLGroup[3]
As I think if I don't set a Unit Group it will leak, so I created 2 groups, then emptied these groups to store units.