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

[Trigger] Why doesn't this loop work right?

Status
Not open for further replies.
Level 6
Joined
Apr 23, 2009
Messages
94
  • Untitled Trigger 003
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Set InitialP1 = (Units owned by Player 1 (Red) of type Webbed One)
      • Unit Group - Pick every unit in InitialP1 and do (Actions)
        • Loop - Actions
          • Set WebCaster = (Picked unit)
          • Set WebCasterLoc = (Position of WebCaster)
          • Set EnemyP1 = (Units within 350.00 of WebCasterLoc matching (((Owner of (Matching unit)) is an enemy of (Owner of WebCaster)) Equal to True))
          • Unit Group - Pick every unit in EnemyP1 and do (Actions)
            • Loop - Actions
              • Set WebEnemy = (Position of (Picked unit))
              • Set WebCasterLoc = (Position of WebCaster)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Number of units in NumberUnits) Less than (Number of units in (Units within 350.00 of WebCasterLoc matching (((Owner of (Matching unit)) is an enemy of (Owner of WebCaster)) Equal to True)))
                • Then - Actions
                  • Unit - Create 1 Explode for Player 1 (Red) at WebCasterLoc facing Default building facing degrees
                  • Unit - Order (Last created unit) to Neutral Dark Ranger - Life Drain (Picked unit)
                  • Unit Group - Add (Picked unit) to NumberUnits
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Distance between WebEnemy and WebCasterLoc) Less than or equal to 45.00
                • Then - Actions
                  • Custom script: call RemoveLocation(udg_WebEnemy)
                  • Custom script: call RemoveLocation(udg_WebCasterLoc)
                • Else - Actions
                  • Unit - Move (Picked unit) instantly to (WebEnemy offset by 2.00 towards (Angle from WebEnemy to WebCasterLoc) degrees), facing Default building facing degrees
                  • Custom script: call RemoveLocation(udg_WebEnemy)
                  • Custom script: call RemoveLocation(udg_WebCasterLoc)
      • Custom script: call DestroyGroup(udg_InitialP1)
      • Custom script: call DestroyGroup(udg_EnemyP1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (WebCaster is dead) Equal to True
        • Then - Actions
          • Custom script: call DestroyGroup(udg_InitialP1)
          • Custom script: call DestroyGroup(udg_EnemyP1)
          • Custom script: call RemoveLocation(udg_WebEnemy)
          • Custom script: call RemoveLocation(udg_WebCasterLoc)
          • Trigger - Turn off (This trigger)
        • Else - Actions
          • Do nothing
Heres the situation:
You cast a spell, this trigger is turned on.
They all move where they need to, but the units created that cast Drain Life only do it like 75% of the time.. Sometimes it seems random. They ALWAYS do it the first time, but after that it gets sporadic.
What am i overlooking?
 
Level 7
Joined
Jul 20, 2008
Messages
377
One, you may not have adjusted the dummy units to have no casting backswing/point.

Two, you don't seem to be destroying these dummy units. In fact, you're adding these dummy units to your NumberUnits group. In other words, the more you use that ability, the less likely these dummies will be created. You need to get rid of the dummies when you're done with them (but first removing them from the unit group, I'm picky like that).

Also, this bit:

Unit - Move (Picked unit) instantly to (WebEnemy offset by 2.00 towards (Angle from WebEnemy to WebCasterLoc) degrees), facing Default building facing degrees

This will leak. Assign it to another point variable.

I think that's about it... keep us updated.
 
Level 6
Joined
Apr 23, 2009
Messages
94
For number one, i'll check that in a moment.

For number two, the dummies have negative regen, and once the trigger is finished it destroys the NumberUnits with custom script, also once 1 dummy dies it removes all the units in NumberUnits in another trigger.

As for the leak, i have just started cleaning all the leaks, and actually, that's what caused this to stop working correctly. Before i set everything to variables, it worked like a charm.. Kinda frustrating trying to figure out what 1 thing i did to make it stop working correctly.

EDIT: So i looked at what you said again once changing the backswing didn't work.. And i read "but first removing them from the unit group". And i went back and thought, "Hey, maybe i should remove them from the unit group BEFORE they die and AFTER the trigger is done." Worked like a charm, again.. haha. Thanks.

The finished product:
  • Untitled Trigger 003
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Set InitialP1 = (Units owned by Player 1 (Red) of type Webbed One)
      • Unit Group - Pick every unit in InitialP1 and do (Actions)
        • Loop - Actions
          • Set WebCaster = (Picked unit)
          • Set WebCasterLoc = (Position of WebCaster)
          • Set EnemyP1 = (Units within 350.00 of WebCasterLoc matching (((Owner of (Matching unit)) is an enemy of (Owner of WebCaster)) Equal to True))
          • Unit Group - Pick every unit in EnemyP1 and do (Actions)
            • Loop - Actions
              • Set WebEnemy = (Position of (Picked unit))
              • Set WebCasterLoc = (Position of WebCaster)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Number of units in NumberUnits) Less than (Number of units in (Units within 350.00 of WebCasterLoc matching (((Owner of (Matching unit)) is an enemy of (Owner of WebCaster)) Equal to True)))
                • Then - Actions
                  • Unit - Create 1 Explode for Player 1 (Red) at WebCasterLoc facing Default building facing degrees
                  • Unit - Order (Last created unit) to Neutral Dark Ranger - Life Drain (Picked unit)
                  • Unit Group - Add (Picked unit) to NumberUnits
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Distance between WebEnemy and WebCasterLoc) Less than or equal to 45.00
                • Then - Actions
                  • Custom script: call RemoveLocation(udg_WebEnemy)
                  • Custom script: call RemoveLocation(udg_WebCasterLoc)
                • Else - Actions
                  • Set MovePointWeb = (WebEnemy offset by 2.00 towards (Angle from WebEnemy to WebCasterLoc) degrees)
                  • Unit - Move (Picked unit) instantly to MovePointWeb, facing Default building facing degrees
                  • Custom script: call RemoveLocation(udg_MovePointWeb)
                  • Custom script: call RemoveLocation(udg_WebEnemy)
                  • Custom script: call RemoveLocation(udg_WebCasterLoc)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (WebCaster is dead) Equal to True
        • Then - Actions
          • Unit Group - Remove all units of NumberUnits from NumberUnits
          • Custom script: call DestroyGroup(udg_InitialP1)
          • Custom script: call DestroyGroup(udg_EnemyP1)
          • Custom script: call RemoveLocation(udg_WebEnemy)
          • Custom script: call RemoveLocation(udg_WebCasterLoc)
          • Trigger - Turn off (This trigger)
        • Else - Actions
          • Do nothing
 
Last edited:
Level 7
Joined
Jul 20, 2008
Messages
377
Oh, d'oh! I misread it a bit. Well, in the trigger in your first post, you were not adding dummies to NumberUnits. I got that wrong.

However, you're not destroying NumberUnits when that trigger finishes. I do not see the proper DestroyGroup call there.

How much HP and what is the negative HP regen rate your dummies have?
 
Level 6
Joined
Apr 23, 2009
Messages
94
Oh, d'oh! I misread it a bit. Well, in the trigger in your first post, you were not adding dummies to NumberUnits. I got that wrong.

However, you're not destroying NumberUnits when that trigger finishes. I do not see the proper DestroyGroup call there.

How much HP and what is the negative HP regen rate your dummies have?

Haha it's pointless now, but they have 100HP with -25 regen.
But thanks a million.
 
Status
Not open for further replies.
Top