- Joined
- Apr 4, 2011
- Messages
- 995
I am working on a spell, called Ten Thousand Butterflies, which creates butterflies when it is cast. Anytime a unit collides with a butterfly, it creates another butterfly, and the unit is healed. My problem is, the newly created unit isn't being added to the unit group properly, so it doesn't fly around and create even MORE copies.
Here are triggers:
Here are triggers:
-
TTB Cast
-
Events
- Unit - A unit Starts the effect of an ability
-
Conditions
- (Ability being cast) Equal to 10,000 Butterflies
-
Actions
- Set TTB_Caster = (Triggering unit)
- Set TTB_Level = (Level of 10,000 Butterflies for TTB_Caster)
- Set TTB_Timer = (8.00 + (2.00 x (Real(TTB_Level))))
- Set TTB_Points[1] = (Position of TTB_Caster)
- Set TTB_Loops = (TTB_Loops + 1)
-
For each (Integer TTB_Integer1) from 1 to 4, do (Actions)
-
Loop - Actions
- Set TTB_Points[2] = (TTB_Points[1] offset by (Random real number between 100.00 and 250.00) towards TTB_Angle degrees)
- Unit - Create 1 Butterfly for (Triggering player) at TTB_Points[2] facing Default building facing degrees
- Set TTB_Butterfly = (Last created unit)
- Unit - Add a TTB_Timer second Generic expiration timer to TTB_Butterfly
- Unit - Make TTB_Butterfly Explode on death
- Unit Group - Add TTB_Butterfly to TTB_ButterflyGroup
- Special Effect - Create a special effect attached to the chest of TTB_Butterfly using Abilities\Spells\NightElf\FaerieDragonInvis\FaerieDragon_Invis.mdl
- Hashtable - Save Handle Of(Last created special effect) as 1 of (Key (Last created unit)) in (Last created hashtable)
- Hashtable - Save TTB_Timer as 2 of (Key (Last created unit)) in TTB_Hash
- Custom script: call RemoveLocation(udg_TTB_Points[2])
-
Loop - Actions
- Custom script: call RemoveLocation(udg_TTB_Points[1])
-
Events
-
TTB Loop
-
Events
- Time - Every 0.20 seconds of game time
- Conditions
-
Actions
-
Unit Group - Pick every unit in TTB_ButterflyGroup and do (Actions)
-
Loop - Actions
- Set TTB_Butterfly = (Picked unit)
- Set TTB_Timer = (Load 2 of (Key (Picked unit)) from TTB_Hash)
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- TTB_Timer Greater than 0.00
-
Then - Actions
- Set TTB_Points[1] = (Position of TTB_Butterfly)
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- ((Units within 120.00 of TTB_Points[1] matching (((Matching unit) belongs to an ally of (Owner of TTB_Butterfly)) Equal to True)) is empty) Equal to False
-
Then - Actions
- Custom script: set bj_wantDestroyGroup = true
-
Unit Group - Pick every unit in (Units within 120.00 of TTB_Points[1] matching (((Matching unit) belongs to an ally of (Owner of TTB_Butterfly)) Equal to True)) and do (Actions)
-
Loop - Actions
- Unit - Set life of (Picked unit) to ((Life of (Picked unit)) + 5.00)
-
Loop - Actions
- Unit - Create 1 Butterfly for (Owner of TTB_Butterfly) at TTB_Points[1] facing Default building facing degrees
- Unit - Add a TTB_Timer second Generic expiration timer to (Last created unit)
- Unit - Make (Last created unit) Explode on death
- Unit Group - Add (Last created unit) to TTB_ButterflyGroup
- Else - Actions
-
If - Conditions
- Set TTB_Points[2] = (TTB_Points[1] offset by 500.00 towards (Random angle) degrees)
- Unit - Order TTB_Butterfly to Move To TTB_Points[2]
- Hashtable - Save (TTB_Timer - 0.20) as 2 of (Key (Picked unit)) in TTB_Hash
-
Else - Actions
- Hashtable - Clear all child hashtables of child (Key (Picked unit)) in TTB_Hash
- Unit Group - Remove TTB_Butterfly from TTB_ButterflyGroup
-
If - Conditions
-
Loop - Actions
-
Unit Group - Pick every unit in TTB_ButterflyGroup and do (Actions)
-
Events