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

Periodic Event isn't damaging all in unit group

Status
Not open for further replies.
Level 1
Joined
Jul 10, 2008
Messages
2
Hello, so I've been working on a leech seed ability with the GUI, the idea is that all units hit will split the damage and heal the caster over time. Unfortunately, unless I'm missing something, it seems that in the separate timer/periodic trigger it only selects one unit from the targets unit group and deals the damage.
Everything else works properly and I've tested to ensure all units are in the unit group. However the damage and floating text only affect one unit. Any help would be greatly appreciated!

  • LeechSeedCast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Leech Seed
    • Actions
      • Set LeechSeed_Caster[(Player number of (Owner of (Triggering unit)))] = (Triggering unit)
      • Unit Group - Pick every unit in (Units within 175.00 of (Target point of ability being cast) matching ((((Matching unit) is alive) Equal to True) and ((((Matching unit) is Mechanical) Equal to False) and ((((Matching unit) belongs to an enemy of (Owner of (Triggering unit))) Equal to True) and do (Actions)
        • Loop - Actions
          • Unit Group - Add (Picked unit) to LeechSeed_Targets[(Player number of (Owner of (Triggering unit)))]
          • Game - Display to (All players) the text: (Name of (Picked unit))
      • Set LeechSeed_Damage[(Player number of (Owner of (Triggering unit)))] = (((100.00 + (50.00 x (Real((Level of Leech Seed for (Triggering unit)))))) + ((Real((Intelligence of (Triggering unit) (Include bonuses)))) x 4.00)) / (16.00 x (Real((Number of units in LeechSeed_Targets[(Player number of (Owner of (Triggering unit)))])))))
      • Player Group - Add (Owner of (Triggering unit)) to LeechSeedPlayers
      • Unit Group - Pick every unit in LeechSeed_Targets[(Player number of (Owner of (Triggering unit)))] and do (Actions)
        • Loop - Actions
          • Unit - Create 1 Dummy for (Owner of (Triggering unit)) at (Position of (Triggering unit)) facing Default building facing degrees
          • Unit - Add LeechSeedEffect to (Last created unit)
          • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
          • Unit - Order (Last created unit) to Neutral Alchemist - Acid Bomb (Picked unit)
      • Trigger - Turn on LeechSeedTimer <gen>
and here's the event that is giving me trouble:

  • LeechSeedTimer
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Player Group - Pick every player in LeechSeedPlayers and do (Actions)
        • Loop - Actions
          • Unit Group - Pick every unit in LeechSeed_Targets[(Player number of (Picked player))] and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked unit) is dead) Equal to True
                • Then - Actions
                  • Unit Group - Remove (Picked unit) from LeechSeed_Targets[(Player number of (Picked player))]
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Number of units in LeechSeed_Targets[(Player number of (Picked player))]) Equal to 0
                • Then - Actions
                  • Player Group - Remove (Picked player) from LeechSeedPlayers
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • LeechSeed_Timer[(Player number of (Picked player))] Greater than or equal to 1.00
                • Then - Actions
                  • Set LeechSeed_Timer[(Player number of (Picked player))] = 0.00
                  • Set LeechSeed16Timer[(Player number of (Picked player))] = (LeechSeed16Timer[(Player number of (Picked player))] + 1)
                  • Set LeechSeed_Heal[(Player number of (Picked player))] = (LeechSeed_Damage[(Player number of (Picked player))] x (Real((Number of units in LeechSeed_Targets[(Player number of (Picked player))]))))
                  • Unit - Cause LeechSeed_Caster[(Player number of (Picked player))] to damage (Picked unit), dealing LeechSeed_Damage[(Player number of (Picked player))] damage of attack type Spells and damage type Normal
                  • Unit - Set life of LeechSeed_Caster[(Player number of (Picked player))] to (LeechSeed_Heal[(Player number of (Picked player))] + (Life of LeechSeed_Caster[(Player number of (Picked player))]))
                  • Floating Text - Create floating text that reads ((String((Integer(LeechSeed_Damage[(Player number of (Picked player))])))) + !) above (Picked unit) with Z offset 5.00, using font size 7.00, color (50.00%, 100.00%, 50.00%), and 0.00% transparency
                  • Floating Text - Show (Last created floating text) for (All players)
                  • Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
                  • Floating Text - Change (Last created floating text): Disable permanence
                  • Floating Text - Change the lifespan of (Last created floating text) to 0.50 seconds
                  • Floating Text - Change the fading age of (Last created floating text) to 0.20 seconds
                  • Floating Text - Create floating text that reads ((String((Integer(LeechSeed_Heal[(Player number of (Picked player))])))) + !) above LeechSeed_Caster[(Player number of (Picked player))] with Z offset 5.00, using font size 7.00, color (0.00%, 100.00%, 0.00%), and 0.00% transparency
                  • Floating Text - Show (Last created floating text) for (All players)
                  • Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
                  • Floating Text - Change (Last created floating text): Disable permanence
                  • Floating Text - Change the lifespan of (Last created floating text) to 0.50 seconds
                  • Floating Text - Change the fading age of (Last created floating text) to 0.20 seconds
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • LeechSeed16Timer[(Player number of (Picked player))] Equal to 16
                    • Then - Actions
                      • Set LeechSeed16Timer[(Player number of (Picked player))] = 0
                      • Unit Group - Remove all units from LeechSeed_Targets[(Player number of (Picked player))]
                      • Player Group - Remove (Picked player) from LeechSeedPlayers
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Number of players in LeechSeedPlayers) Equal to 0
                        • Then - Actions
                          • Trigger - Turn off (This trigger)
                        • Else - Actions
                    • Else - Actions
                • Else - Actions
                  • Set LeechSeed_Timer[(Player number of (Picked player))] = (LeechSeed_Timer[(Player number of (Picked player))] + 0.10)
Sorry I know it's a lot to sort through! Also, I'm sure it's riddled with leaks.. but I'll take care of that later
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
You check if the timer is 1 or greater than 1 and then set the value immediately to 0
The next unit will check the same value but then it is 0

You need something like this:
  • LeechSeedTimer
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Player Group - Pick every player in LeechSeedPlayers and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in LeechSeed_Targets[(Player number of (Picked player))]) Equal to 0
            • Then - Actions
              • Player Group - Remove (Picked player) from LeechSeedPlayers
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • LeechSeed_Timer[(Player number of (Picked player))] Greater than or equal to 1.00
                • Then - Actions
                  • Custom script: LeechSeed_Timer + 1
                  • Unit Group - Pick every unit in LeechSeed_Targets[(Player number of (Picked player))] and do (Actions)
                    • Loop - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • ((Picked unit) is dead) Equal to True
                        • Then - Actions
                          • Unit Group - Remove (Picked unit) from LeechSeed_Targets[(Player number of (Picked player))]
                        • Else - Actions
                • Else - Actions
I wont make the whole trigger, sorry but you understand better what it does than I do.
Just use this as an example and try to put as many things as far to the front.(outside loops or if statements)

For example the check if the units in the unit group are 0 the player is removed from the player group.
That check is made for every unit. that is not neccessary. You can add the same check if the picked unit is dead but for living units it is just wasting energy of your pc.
 
Level 1
Joined
Jul 10, 2008
Messages
2
Oh wow! I did not even think about that! Hah, it's working like a charm now, thanks so much! You are so very wise Wietlol and I appreciate the help!
 
Status
Not open for further replies.
Top