Creeps get stuck on their path

Dr3

New Member
Reaction score
0
Hey people,

got a little problem here with my attempt to make a TD. The path has a
circle-like shape with 4 corners. The creeps are to move from their spawning
point to the circle and then... well run in circles. Actually it works, but every
now and then creeps stop at the corners with no idea what to do or decide
to run the other way.

Here is my trigger:
Code:
CircleRun
    Events
        Unit - A unit enters Region 1 <gen>
        Unit - A unit enters Region 2 <gen>
        Unit - A unit enters Region 3 <gen>
        Unit - A unit enters Region 4 <gen>
    Conditions
        (Owner of (Triggering unit)) Equal to creeps
    Actions
        -------- Set custom value. --------
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Custom value of (Triggering unit)) Equal to 4
            Then - Actions
                Set CustomValue = 1
            Else - Actions
                Set CustomValue = ((Custom value of (Triggering unit)) + 1)
        -------- Move order. --------
        Unit - Set the custom value of (Triggering unit) to CustomValue
        Set TempMovePoint = (Random point in Regions[CustomValue])
        Unit - Order (Triggering unit) to Move To TempMovePoint
        -------- Leak removal --------
        Custom script:   call RemoveLocation ( udg_TempMovePoint )

I checked the Regions[] array like a thousand times and I'm pretty sure they
are correct. :) Furthermore, 3 creeps are periodically created each time and
in total there are ~150 creeps circling in worst case (unkilled).

+rep Appreciate any help.
 

svenski

New Member
Reaction score
1
Well I haven't done much with TD's, but I'm making a Hero Defense type map with creep spawns. I use the same event trigger (unit entering a region), but instead of checking the custom value of the unit, I have it check whether or not the unit is an enemy of one of my human-controlled players. I have a different trigger for each checkpoint (namely, each one of your four corners). You could probably do this by using IF (entering this region) THEN (send to this region) ELSE (do nothing) statements for each region in one single trigger if you wanted...

Then instead of storing a "TempmovePoint" global variable, I would just send that "entering unit" to the desired "random point in region - next checkpoint". To make sure no units get stuck on the corner, you can have a trigger that turns on when your creeps begin to spawn that commands all the units in the corner regions to move to the next checkpoint every 1-5 seconds of periodic game time. Something like this...

Trigger:
  • Pathing1
    • Events
      • Time - Every 5.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in Corner 1 &lt;gen&gt; matching ((Owner of (Matching unit)) Equal to Player 12 (Brown))) and do (Unit - Order (Picked unit) to Move To (Center of Corner 2 &lt;gen&gt;))
      • Unit Group - Pick every unit in (Units in Corner 2 &lt;gen&gt; matching ((Owner of (Matching unit)) Equal to Player 12 (Brown))) and do (Unit - Order (Picked unit) to Move To (Center of Corner 3 &lt;gen&gt;))


etc.... You could just add that pathing trigger, apply it to all of your corner regions, and it would probably solve your current problem. If units get stuck anywhere else, just add another region that gets periodically checked for stuck units and orders them to move to the desired location every so often.

:)
 

Dr3

New Member
Reaction score
0
svenski said:
...I would just send that "entering unit" to the desired "random point in region - next checkpoint".
Wouldn't that create lots of Point leaks?

svenski said:
Yeah, I have a trigger of that kind (for a worst case situation) but it sucks to have triggers to fix faulty ones.
 

bOb666777

Stand against the ugly world domination face!
Reaction score
117
but instead of checking the custom value of the unit, I have it check whether or not the unit is an enemy of one of my human-controlled players. I have a different trigger for each checkpoint (namely, each one of your four corners). You could probably do this by using IF (entering this region) THEN (send to this region) ELSE (do nothing) statements for each region in one single trigger if you wanted...

That's probably the best way to do it
 

svenski

New Member
Reaction score
1
Wouldn't that create lots of Point leaks?

Quote:
Originally Posted by svenski
Trigger
Yeah, I have a trigger of that kind (for a worst case situation) but it sucks to have triggers to fix faulty ones.


Why would anything leak, I'm not setting any variables in my code, just giving orders.

And you don't have to have that trigger in place to fix the other trigger, you could use that repeating time trigger as all your pathing needs... unless you had some reason for giving all the units in a specific path a custom value for purposes of gold bounty or some other reason....



EDIT: And by the way, I am pretty sure that global variables are overwritten when they get set by your original trigger, so using the custom script "Removelocation..." is unnecessary. If you wanted to make it a better code, convert it all to custom text and script it in JASS using local variables, which are much better for that kind of trigger.
 

Emu.Man00

New Member
Reaction score
41
pick every unit in (ANYTHING except a variable here)

leaks for every single unit picked. just do
Code:
set tempGroup = (whatever)
picked every unit in tempGroup
(actions)

custom script: call DestroyGroup (udg_tempGroup)
 

svenski

New Member
Reaction score
1
pick every unit in (ANYTHING except a variable here)

leaks for every single unit picked. just do
Code:
set tempGroup = (whatever)
picked every unit in tempGroup
(actions)

custom script: call DestroyGroup (udg_tempGroup)

In other words you're saying, you can't "pick every unit" in anything but a variable?

How could you add units to a tempGroup from a region if you can't call the function that picks all those units in the region adds them to your group variable? Why would this function leak?

EDIT: http://www.thehelper.net/forums/showthread.php?t=27219&highlight=Leak+tutorial
 

Dr3

New Member
Reaction score
0
Yah, well putting the leaking issue aside.

In the meantime I probably used every possibility there is to assure the
creeps move without stopping.

Here is a method I came up with:
Trigger:
  • CircleRun
    • Events
      • Unit - A unit enters Region 0 &lt;gen&gt;
      • Unit - A unit enters Region 1 &lt;gen&gt;
      • Unit - A unit enters Region 2 &lt;gen&gt;
      • Unit - A unit enters Region 3 &lt;gen&gt;
    • Conditions
      • (Owner of (Triggering unit)) Equal to creeps
    • Actions
      • -------- Set custom value. --------
      • Unit - Set the custom value of (Triggering unit) to (((Custom value of (Triggering unit)) + 1) mod 4)
      • -------- Move order. --------
      • Set TempMovePoint = (Random point in Regions[(Custom value of (Triggering unit))])
      • Unit - Order (Triggering unit) to Move To TempMovePoint
      • -------- Leak removal --------
      • Custom script: call RemoveLocation ( udg_TempMovePoint )


Worked pretty fine, but every now and then a creep gets a custom value it's
not supposed to get and thus moves into wrong direction. Furthermore
every now and then a creep gets stuck. Really annoying stuff.

Well so I had to use the method I refrained from since the beginning. For
each corner I created a separate trigger:
Trigger:
  • CircleRun Corner
    • Events
      • Unit - A unit enters Region 2 &lt;gen&gt;
    • Conditions
      • (Owner of (Triggering unit)) Equal to creeps
    • Actions
      • -------- Set custom value. --------
      • Unit - Set the custom value of (Triggering unit) to 3
      • -------- Move order. --------
      • Set TempMovePoint = (Random point in Regions[3])
      • Unit - Order (Triggering unit) to Move To TempMovePoint
      • -------- Leak removal --------
      • Custom script: call RemoveLocation ( udg_TempMovePoint )


...and yes I have later use for the custom values.

Weird thing is, if I test the map online nothin' gets stuck or runs wild. But in
Single player or TestMap the known symptoms appear but only for this method.

Final thought: It really annoys me that I have to resort to this method
although it could easily be solved with less triggers and more beautifully but
just won't work for unclear reasons. :/

Thx everyone. :cool:
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top