• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Spell Problem

Status
Not open for further replies.
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:

  • 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])
      • Custom script: call RemoveLocation(udg_TTB_Points[1])
  • 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)
                  • 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
              • 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
Hopefully this isn't a stupid mistake o_O Btw the second trigger isn't leak cleared fully, so don't even mention it.
 
Level 13
Joined
Mar 16, 2008
Messages
941
Just a hint: in the first trigger is a "last created hashtable" ;)
How are they even flying around? There is no triggered movement so I bet they got wander? Another thing: This would cause problems if working because you create a unit every 0.2 seconds when another healable unit is near. If this happens, after 0.2 seconds the unit will be still there and healed for two units, creating two new. Then with four, eight, sixteen, and so on.

Your problem is that you don't store TTB_TIMER for the new units what causes them to be insta-removed with the next loop.
 
Just a hint: in the first trigger is a "last created hashtable" ;)

You got me on that one.

Your problem is that you don't store TTB_TIMER for the new units what causes them to be insta-removed with the next loop.
This was my problem :) Once I fixed it, the spam of units became giant within seconds. Needs editting. Thanks for the help
 
Status
Not open for further replies.
Top