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

Creeps stop moving after casing spells in my TD

Status
Not open for further replies.
Level 4
Joined
Dec 19, 2011
Messages
29
Hello there,

I have a creep that when die will spawn a unit, also a boss that cast spells every often.

Now In order to keep them moving, I made a large trigger, and its boring to do that trigger for every single creep FOR every single player !

here is what I did and I am sure there is a better way around, that's what i need.

  • Pit Lord Anti Stuck
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Ability being cast) Equal to Holy Light (lvl 10 boss)
          • (Ability being cast) Equal to Pit Lord Summoning
    • Actions
      • Wait 0.25 seconds
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Go to 1 red <gen> contains (Casting unit)) Equal to True
        • Then - Actions
          • Unit - Order (Casting unit) to Move To (Center of Moving Red 1 <gen>)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (go to 2 red <gen> contains (Casting unit)) Equal to True
        • Then - Actions
          • Unit - Order (Casting unit) to Move To (Center of Moving Red 2 <gen>)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (go to 3 red <gen> contains (Casting unit)) Equal to True
        • Then - Actions
          • Unit - Order (Casting unit) to Move To (Center of Moving Red 3 <gen>)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (go to 4 red <gen> contains (Casting unit)) Equal to True
        • Then - Actions
          • Unit - Order (Casting unit) to Move To (Center of Moving Red 4 <gen>)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (go to 5 red <gen> contains (Casting unit)) Equal to True
        • Then - Actions
          • Unit - Order (Casting unit) to Move To (Center of Moving Red 5 <gen>)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (go to 6 red <gen> contains (Casting unit)) Equal to True
        • Then - Actions
          • Unit - Order (Casting unit) to Move To (Center of Moving Red 6 <gen>)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (go to 7 red <gen> contains (Casting unit)) Equal to True
        • Then - Actions
          • Unit - Order (Casting unit) to Move To (Center of Moving Red 7 <gen>)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (go to 8 red <gen> contains (Casting unit)) Equal to True
        • Then - Actions
          • Unit - Order (Casting unit) to Move To (Center of Moving Red 8 <gen>)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (go to END red <gen> contains (Casting unit)) Equal to True
        • Then - Actions
          • Unit - Order (Casting unit) to Move To (Center of Wave Ends Red <gen>)
        • Else - Actions
Here is an image
http://postimage.org/image/5i8g8hw0h/

where the small Squares are "Moving red 1", and the large ones are "Go to red 1"
 

Attachments

  • Untitled.gif
    Untitled.gif
    491.8 KB · Views: 90
Level 37
Joined
Mar 6, 2006
Messages
9,240
*Get rid of leaks -> http://www.hiveworkshop.com/forums/triggers-scripts-269/things-leak-35124/
*Use triggering unit instead of casting unit. Triggerin unit = mui, casting unit = only works for the last unit that triggered the event
*Try longer wait than 0.25 seconds (in reality that is already 0.35-0.45 seconds). Set it to 1 second. This is to ensure that the unit finishes the casting properly
 
Level 4
Joined
Dec 19, 2011
Messages
29
*Get rid of leaks -> http://www.hiveworkshop.com/forums/triggers-scripts-269/things-leak-35124/
*Use triggering unit instead of casting unit. Triggerin unit = mui, casting unit = only works for the last unit that triggered the event
*Try longer wait than 0.25 seconds (in reality that is already 0.35-0.45 seconds). Set it to 1 second. This is to ensure that the unit finishes the casting properly

thanks for the fast replay.

I'll do what you said, but my trigger works perfectly, I am just asking if there is other way to do it instead of this long trigger.
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
If you initialize all those regions to an array, then you can do this:

  • For each (Integer A) from 1 to array_size do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (myRegion[(Integer A)] contains (Triggering unit)) Equal to True
        • Then - Actions
          • Unit - Order (Casting unit) to Move To (Center of Wave Ends Red <gen>)
        • Else - Actions
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
  • For each (Integer A) from 1 to array_size do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (myRegion[(Integer A)] contains (Triggering unit)) Equal to True
        • Then - Actions
          • Unit - Order (Triggering unit) to Move To Center of myRegion[(Integer A)+1])
          • Skip remaining actions
        • Else - Actions
*Casting unit -> triggering unit. Casting unit is not MUI
*Uses integer A + 1
*Skips remaining actions, no need to check the rest of the regions

The center of...leaks.
 
Level 4
Joined
Dec 19, 2011
Messages
29
If you initialize all those regions to an array, then you can do this:

  • For each (Integer A) from 1 to array_size do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (myRegion[(Integer A)] contains (Triggering unit)) Equal to True
        • Then - Actions
          • Unit - Order (Casting unit) to Move To (Center of Wave Ends Red <gen>)
        • Else - Actions

If i order them to move to "Wave Ends Red" then the creeps will skip the "moving red" (the small square regions) and only go to the ends.



  • For each (Integer A) from 1 to array_size do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (myRegion[(Integer A)] contains (Triggering unit)) Equal to True
        • Then - Actions
          • Unit - Order (Triggering unit) to Move To Center of myRegion[(Integer A)+1])
          • Skip remaining actions
        • Else - Actions
*Casting unit -> triggering unit. Casting unit is not MUI
*Uses integer A + 1
*Skips remaining actions, no need to check the rest of the regions

The center of...leaks.

why the "Integer A + 1" ?

Edit:

Actually I tried this and it works, thank you guys you give me the idea

  • Pit Lord Anti Stuck Copy
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Ability being cast) Equal to Holy Light (lvl 10 boss)
          • (Ability being cast) Equal to Pit Lord Summoning
    • Actions
      • Wait 0.25 seconds
      • For each (Integer A) from 1 to 9, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Go_To_RED[(Integer A)] contains (Triggering unit)) Equal to True
            • Then - Actions
              • Unit - Order (Triggering unit) to Move To (Center of Moving_RED[(Integer A)])
            • Else - Actions
  • Regions
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Go_To_RED[1] = Go to 1 red <gen>
      • Set Go_To_RED[2] = go to 2 red <gen>
      • Set Go_To_RED[3] = go to 3 red <gen>
      • Set Go_To_RED[4] = go to 4 red <gen>
      • Set Go_To_RED[5] = go to 5 red <gen>
      • Set Go_To_RED[6] = go to 6 red <gen>
      • Set Go_To_RED[7] = go to 7 red <gen>
      • Set Go_To_RED[8] = go to 8 red <gen>
      • Set Go_To_RED[9] = go to END red <gen>
      • Set Moving_RED[1] = Moving Red 1 <gen>
      • Set Moving_RED[2] = Moving Red 2 <gen>
      • Set Moving_RED[3] = Moving Red 3 <gen>
      • Set Moving_RED[4] = Moving Red 4 <gen>
      • Set Moving_RED[5] = Moving Red 5 <gen>
      • Set Moving_RED[6] = Moving Red 6 <gen>
      • Set Moving_RED[7] = Moving Red 7 <gen>
      • Set Moving_RED[8] = Moving Red 8 <gen>
      • Set Moving_RED[9] = Wave Ends Red <gen>
 
Last edited:
Level 37
Joined
Mar 6, 2006
Messages
9,240
Depending on ho you set it up, use a different value

set region[1] = Go to 1
set region[2] = Go to 2
...
set region[9] = Go to end

set region[10] = moving 1
set region[11] = moving 2
...

Then you'd use
if region[integer A] contains unit
then order unit to move to center of region[integer A + arraySize]
 
Status
Not open for further replies.
Top