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

[Trigger] [GUI] Trigger gets broken by Dummy Unit

Status
Not open for further replies.
Level 14
Joined
Jan 24, 2017
Messages
246
I made an ability for my map. There is a activation trigger, that sets the boolean flamethower = true. And it starts the ability loop, which damages units and applies a debuff.
As you can see the activation trigger sets the boolean to false after 14 seconds which is supposed to turn of the loop. This was all working fine, since I added spawning a dummy unit to apply a slow debuff inside of the damage loop. And now when the spell hits a unit it wont turn off and the boolean will stay true. And I cannot figure out why spawning a dummy unit would effect that. It only breaks when a unit is hit and damaged and it spawns a dummy unit. I suspect the Pick every unit in (Units in (Playable map area)) being the problem here which ends in an infinite loop. But then I dont understand why the boolean is not set to false. If you have any ideas please let me know.
  • Flamethrower Activate
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Flamethrower - Goblin Gunship
    • Actions
      • Trigger - Turn on Flamethrower Loop <gen>
      • Set VariableSet flamethrower_boolean[(Player number of (Owner of (Casting unit)))] = True
      • Set VariableSet flamethrower_caster[(Player number of (Owner of (Casting unit)))] = (Casting unit)
      • Set VariableSet flamethrower_level[(Player number of (Owner of (Casting unit)))] = (Level of Flamethrower - Goblin Gunship for (Casting unit))
      • Special Effect - Create a special effect attached to the weapon of (Casting unit) using Flamethrower.mdx
      • Set VariableSet flamethrower_specialeffect[(Player number of (Owner of (Casting unit)))] = (Last created special effect)
      • Wait 14.00 seconds
      • Set VariableSet flamethrower_boolean[(Player number of (Owner of (Casting unit)))] = False
  • Flamethrower Loop
    • Events
      • Time - Every 0.20 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • And - All (Conditions) are true
            • Conditions
              • flamethrower_boolean[1] Equal to False
              • flamethrower_boolean[2] Equal to False
              • flamethrower_boolean[3] Equal to False
              • flamethrower_boolean[4] Equal to False
              • flamethrower_boolean[5] Equal to False
              • flamethrower_boolean[6] Equal to False
              • flamethrower_boolean[7] Equal to False
              • flamethrower_boolean[8] Equal to False
              • flamethrower_boolean[9] Equal to False
              • flamethrower_boolean[10] Equal to False
              • flamethrower_boolean[11] Equal to False
              • flamethrower_boolean[12] Equal to False
              • flamethrower_boolean[13] Equal to False
              • flamethrower_boolean[14] Equal to False
              • flamethrower_boolean[15] Equal to False
              • flamethrower_boolean[16] Equal to False
              • flamethrower_boolean[17] Equal to False
              • flamethrower_boolean[18] Equal to False
              • flamethrower_boolean[19] Equal to False
              • flamethrower_boolean[20] Equal to False
              • flamethrower_boolean[21] Equal to False
              • flamethrower_boolean[22] Equal to False
              • flamethrower_boolean[23] Equal to False
              • flamethrower_boolean[24] Equal to False
        • Then - Actions
          • For each (Integer A) from 1 to 24, do (Actions)
            • Loop - Actions
              • Set VariableSet flamethrower_caster[(Integer A)] = No unit
              • Special Effect - Destroy flamethrower_specialeffect[(Integer A)]
          • Trigger - Turn off (This trigger)
        • Else - Actions
          • For each (Integer A) from 1 to 24, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • And - All (Conditions) are true
                    • Conditions
                      • (flamethrower_caster[(Integer A)] is alive) Equal to True
                      • flamethrower_boolean[(Integer A)] Equal to True
                • Then - Actions
                  • Set VariableSet temppunkt = ((Position of flamethrower_caster[(Integer A)]) offset by flamethrower_min_lenght towards (Facing of flamethrower_caster[(Integer A)]) degrees.)
                  • Set VariableSet temppunkt = (temppunkt offset by flamethrower_width towards ((Facing of flamethrower_caster[(Integer A)]) + 90.00) degrees.)
                  • Set VariableSet temppunkt2 = ((Position of flamethrower_caster[(Integer A)]) offset by (flamethrower_min_lenght + flamethrower_lenght) towards (Facing of flamethrower_caster[(Integer A)]) degrees.)
                  • Set VariableSet temppunkt2 = (temppunkt2 offset by flamethrower_width towards ((Facing of flamethrower_caster[(Integer A)]) - 90.00) degrees.)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (X of temppunkt) Greater than or equal to (X of temppunkt2)
                    • Then - Actions
                      • Set VariableSet flamethrower_x_big = (X of temppunkt)
                      • Set VariableSet flamethrower_x_small = (X of temppunkt2)
                    • Else - Actions
                      • Set VariableSet flamethrower_x_big = (X of temppunkt2)
                      • Set VariableSet flamethrower_x_small = (X of temppunkt)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Y of temppunkt) Greater than or equal to (Y of temppunkt2)
                    • Then - Actions
                      • Set VariableSet flamethrower_y_big = (Y of temppunkt)
                      • Set VariableSet flamethrower_y_small = (Y of temppunkt2)
                    • Else - Actions
                      • Set VariableSet flamethrower_y_big = (Y of temppunkt2)
                      • Set VariableSet flamethrower_y_small = (Y of temppunkt)
                  • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
                    • Loop - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • And - All (Conditions) are true
                            • Conditions
                              • (X of (Position of (Picked unit))) Greater than or equal to flamethrower_x_small
                              • (X of (Position of (Picked unit))) Less than or equal to flamethrower_x_big
                              • (Y of (Position of (Picked unit))) Greater than or equal to flamethrower_y_small
                              • (Y of (Position of (Picked unit))) Less than or equal to flamethrower_y_big
                              • ((Picked unit) belongs to an enemy of (Owner of flamethrower_caster[(Integer A)]).) Equal to True
                              • ((Picked unit) is Magic Immune) Equal to False
                              • ((Picked unit) is A structure) Equal to False
                              • ((Picked unit) is alive) Equal to True
                              • (flamethrower_caster[(Integer A)] is alive) Equal to True
                              • flamethrower_boolean[(Integer A)] Equal to True
                        • Then - Actions
                          • Unit - Cause flamethrower_caster[(Integer A)] to damage (Picked unit), dealing (14.00 + (8.00 x (Real(flamethrower_level[(Integer A)])))) damage of attack type Normal and damage type Magic
                          • Unit - Create 1 Dummy[Caster] for (Owner of flamethrower_caster[(Integer A)]) at (Position of flamethrower_caster[(Integer A)]) facing Default building facing degrees
                          • Unit - Add Flamethrower Slow - Goblin Gunship to (Last created unit)
                          • Unit - Order (Last created unit) to Human Sorceress - Slow (Picked unit)
                          • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
                        • Else - Actions
                • Else - Actions
                  • Set VariableSet flamethrower_boolean[(Integer A)] = False
                  • Special Effect - Destroy flamethrower_specialeffect[(Integer A)]
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,183
I honestly suggest rewriting the whole thing for learning purposes.

For starters, waits are basically banned if you want MUI or MPI code.
You should also use a player group instead of 24 if checks.
I also think your coordinate check are inefficient, seems to me it would be easier to just check if distance is less than X and angle between points is less than 90.

I know it's not the answer you're looking for but your code is rather unconventional which makes it annoying to debug.
 
Does the issue happen when there is more than 1 instance only or also when there's only one instance? Wait can be the source of the issue, though it is hard to exactly pinpoint that as the problem assuming your claim that it works correctly prior to the dummy addition.

Just to proof that the issue is not within the wait and only with the dummy, care to show the code before the dummy was added and confirm that code works properly for all players?
 
Level 14
Joined
Jan 24, 2017
Messages
246
Does the issue happen when there is more than 1 instance only or also when there's only one instance? Wait can be the source of the issue, though it is hard to exactly pinpoint that as the problem assuming your claim that it works correctly prior to the dummy addition.

Just to proof that the issue is not within the wait and only with the dummy, care to show the code before the dummy was added and confirm that code works properly for all players?
The issue happens also with only one instance running.
 
Level 25
Joined
Sep 26, 2009
Messages
2,378
(Casting unit) is a global variable that may refer to completely different unit after the wait or refer to no unit at all.
Replace (Casting unit) with (Triggering unit) which will refer to correct unit even after wait.

In your case, this is currently the flow of actions:
  • the first trigger reacts to ability Flamethrower - Goblin Gunship being cast.
  • (Casting unit) is the unit that cast the ability above and you set up your boolean based on owner of said unit.
  • During the 14 second wait the loop trigger runs and creates a dummy unit which is ordered to cast Flamethrower Slow
  • Now the (casting unit) in the entire map/for any trigger is the dummy unit
  • After 14 second wait you continue your first trigger and refer to (casting unit) - which at this point can be a dummy unit, no unit, or some completely unrelated unit belonging to some completely different player
  • You attempt to set boolean based on owner of wrong unit
 
Level 14
Joined
Jan 24, 2017
Messages
246
(Casting unit) is a global variable that may refer to completely different unit after the wait or refer to no unit at all.
Replace (Casting unit) with (Triggering unit) which will refer to correct unit even after wait.

In your case, this is currently the flow of actions:
  • the first trigger reacts to ability Flamethrower - Goblin Gunship being cast.
  • (Casting unit) is the unit that cast the ability above and you set up your boolean based on owner of said unit.
  • During the 14 second wait the loop trigger runs and creates a dummy unit which is ordered to cast Flamethrower Slow
  • Now the (casting unit) in the entire map/for any trigger is the dummy unit
  • After 14 second wait you continue your first trigger and refer to (casting unit) - which at this point can be a dummy unit, no unit, or some completely unrelated unit belonging to some completely different player
  • You attempt to set boolean based on owner of wrong unit
Thanks that was actually the issue. I did not know casting unit is global.
 
Status
Not open for further replies.
Top