• 🏆 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!
  • ✅ Time to vote for the top 3 models! The POLL for Hive's 6th HD Modeling Contest: Mechanical is now open! 📅 Poll close on July 16, 2024! 🔗 Cast your vote now!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

[Solved] Looping trigger with AoE Damage

Status
Not open for further replies.
Level 7
Joined
Feb 23, 2020
Messages
253
How do i make this trigger function? The damage isn't applying to the picked target.

  • Attraction Potion Work
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Attraction Potion
    • Actions
      • Set VariableSet AttractionPotion_Caster = (Triggering unit)
      • Set VariableSet AttractionPotion_Point = (Position of AttractionPotion_Caster)
      • Unit - Create 1 Dummy Attraction Potion for (Owner of AttractionPotion_Caster) at AttractionPotion_Point facing Default building facing degrees
      • Set VariableSet AttractionPotion_Dummy = (Last created unit)
      • Unit - Add a 1.00 second Generic expiration timer to AttractionPotion_Dummy
      • -------- Damage --------
      • Set VariableSet AttractionPotion_Damage[1] = (100 + (Intelligence of AttractionPotion_Caster (Include bonuses)))
      • Set VariableSet AttractionPotion_Damage[2] = (125 + (Intelligence of AttractionPotion_Caster (Include bonuses)))
      • Set VariableSet AttractionPotion_Damage[3] = (150 + (Intelligence of AttractionPotion_Caster (Include bonuses)))
      • Set VariableSet AttractionPotion_Damage[4] = (175 + (Intelligence of AttractionPotion_Caster (Include bonuses)))
      • Set VariableSet AttractionPotion_Damage[5] = (200 + (Intelligence of AttractionPotion_Caster (Include bonuses)))
      • -------- --------
      • Set VariableSet AttractionPotion_Duration = 10
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • AttractionPotion_Timer Equal to 0
        • Then - Actions
          • Trigger - Turn on AttractionPotion Loop <gen>
        • Else - Actions
      • Custom script: call RemoveLocation (udg_AttractionPotion_Point)
  • AttractionPotion Loop
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Set VariableSet AttractionPotion_Timer = (AttractionPotion_Timer + 1)
      • Set VariableSet AttractionPotion_Group = (Units within 5000.00 of AttractionPotion_Point.)
      • Unit Group - Pick every unit in AttractionPotion_Group and do (Actions)
        • Loop - Actions
          • Set VariableSet AttractionPotion_Target = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (AttractionPotion_Target belongs to an enemy of (Owner of AttractionPotion_Caster).) Equal to True
              • (AttractionPotion_Target is alive) Equal to True
            • Then - Actions
              • For each (Integer A) from 1 to AttractionPotion_Duration, do (Actions)
                • Loop - Actions
                  • Unit - Cause AttractionPotion_Caster to damage AttractionPotion_Target, dealing (Real(AttractionPotion_Damage[(Level of Attraction Potion for AttractionPotion_Caster)])) damage of attack type Spells and damage type Normal
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • AttractionPotion_Timer Equal to AttractionPotion_Duration
                    • Then - Actions
                      • Set VariableSet AttractionPotion_Timer = 0
                      • Trigger - Turn off (This trigger)
                    • Else - Actions
            • Else - Actions
      • Custom script: call DestroyGroup (udg_AttractionPotion_Group)
 
You're not setting this point "AttractionPotion_Point" anywhere in this trigger. And where is "AttractionPotion_Caster" set? In another trigger?

Edit:
Oh I see you edited this. To me it looks like your AttractionPotion Loop trigger fires and increments the AttractionPotion_Timer + 1 every second (if it isn't turned off by default). So no matter what the AttractionPotion_Timer is always greater than 0, because there's no AttractionPotion_Point set initially and therefore no unit group, so your "Attraction Potion Work" trigger wont get past the "if" statement.
 
Last edited:
Level 7
Joined
Feb 23, 2020
Messages
253
You're not setting this point "AttractionPotion_Point" anywhere in this trigger. And where is "AttractionPotion_Caster" set? In another trigger?

Edit:
Oh I see you edited this. To me it looks like your AttractionPotion Loop trigger fires and increments the AttractionPotion_Timer + 1 every second (if it isn't turned off by default). So no matter what the AttractionPotion_Timer is always greater than 0, because there's no AttractionPotion_Point set initially and your "Attraction Potion Work" trigger wont get past the "if" statement.
Yes, the loop trigger is initially off. The "if timer equal to 0" is not the problem, tested that :/
 

Uncle

Warcraft Moderator
Level 67
Joined
Aug 10, 2018
Messages
6,909
You remove AttractionPotion_Point and then try to reference it in the loop.
  • Custom script: call RemoveLocation (udg_AttractionPotion_Point)
  • Set VariableSet AttractionPotion_Group = (Units within 5000.00 of AttractionPotion_Point.)
Don't remove it in your first trigger.

Also, is there a reason you want to deal 10 instances of damage every 1.00 second instead of just 1 big instance of damage? That For Each Integer from 1 to 10 Loop seems extremely out of place.
 
Last edited:
Level 7
Joined
Feb 23, 2020
Messages
253
You remove AttractionPotion_Point and then try to reference it in the loop.
  • Custom script: call RemoveLocation (udg_AttractionPotion_Point)
  • Set VariableSet AttractionPotion_Group = (Units within 5000.00 of AttractionPotion_Point.)
Don't remove it in your first trigger.

Also, is there a reason you want to deal 10 instances of damage every 1.00 second instead of just 1 big instance of damage? That For Each Integer from 1 to 10 Loop seems extremely out of place.
Well the damage works now, but not as intended haha. Yes, i want the ability to have a Dot effect instead of just 1 big damage, should work like a burn. Maybe i'm doing this very wrong?
 

Uncle

Warcraft Moderator
Level 67
Joined
Aug 10, 2018
Messages
6,909
The Dot effect comes from the fact that it runs once every 1.00 second, so it will already deal damage once per second without the need of that Loop. Change the 1.00 second interval to adjust how often it deals damage.

So keep it mostly the same as it is now but remove the For Each Loop. Also, move that If Then Else statement that checks if the Timer is equal to Duration to the bottom of the trigger (so outside of the Pick every unit function).

Pick every unit runs ALL of it's Actions once for each picked unit, so with your current setup if you damaged 10 units, and Duration was equal to Timer, it would try to turn off the trigger 10 times.
 
Level 7
Joined
Feb 23, 2020
Messages
253
The Dot effect comes from the fact that it runs once every 1.00 second, so it will already deal damage once per second without the need of that Loop. Change the 1.00 second interval to adjust how often it deals damage.

So keep it mostly the same as it is now but remove the For Each Loop. Also, move that If Then Else statement that checks if the Timer is equal to Duration to the bottom of the trigger (so outside of the Pick every unit function).

Pick every unit runs ALL of it's Actions once for each picked unit, so with your current setup if you damaged 10 units, and Duration was equal to Timer, it would try to turn off the trigger 10 times.
  • AttractionPotion Loop
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Set VariableSet AttractionPotion_Timer = (AttractionPotion_Timer + 1)
      • Set VariableSet AttractionPotion_Group = (Units within 5000.00 of AttractionPotion_Point.)
      • Unit Group - Pick every unit in AttractionPotion_Group and do (Actions)
        • Loop - Actions
          • Set VariableSet AttractionPotion_Target = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (AttractionPotion_Target belongs to an enemy of (Owner of AttractionPotion_Caster).) Equal to True
              • (AttractionPotion_Target is alive) Equal to True
            • Then - Actions
              • Unit - Cause AttractionPotion_Caster to damage AttractionPotion_Target, dealing (Real(AttractionPotion_Damage[(Level of Attraction Potion for AttractionPotion_Caster)])) damage of attack type Spells and damage type Normal
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • AttractionPotion_Timer Equal to AttractionPotion_Duration
        • Then - Actions
          • Set VariableSet AttractionPotion_Timer = 0
          • Custom script: call DestroyGroup (udg_AttractionPotion_Group)
          • Custom script: call RemoveLocation (udg_AttractionPotion_Point)
          • Trigger - Turn off (This trigger)
        • Else - Actions
It works correctly now thank you! :)

Question: the custom scripts should be like this right? Cause i noticed that if they're outside of the "if then else", it doesnt work.
 

Uncle

Warcraft Moderator
Level 67
Joined
Aug 10, 2018
Messages
6,909
You need to Destroy AttractionPotion_Group like you were doing it before, so move it outside of the If Then Else. Otherwise, you'd only be destroying the Group once when the spell is finished, but as you can see you're creating a new Group every 1.00 second. So 9 out of 10 of those Groups will never be removed thus they will create Memory Leaks.
 
Level 7
Joined
Feb 23, 2020
Messages
253
You need to Destroy AttractionPotion_Group like you were doing it before, so move it outside of the If Then Else. Otherwise, you'd only be destroying the Group once when the spell is finished, but as you can see you're creating a new Group every 1.00 second. So 9 out of 10 of those Groups will never be removed thus they will create Memory Leaks.
oooh i see, thank you a lot for the help^^
 
Status
Not open for further replies.
Top