HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Minions Pathing

12-13-2010, 06:27 AM#1
syrathia
Im having trouble with this my minions acting properly. Its not particularly robust system but it's just something to start with for me. What happens is that occasionally a minion gets stuck pathing back and forth between two of the points in their path. I'm not sure where its going wrong.

Using GroupUtils for the ENUM_GROUP since it is used elsewhere in the map

Expand Zinc:

EDIT: point is public for now to access it in the test system.
12-13-2010, 11:07 AM#2
Anitarf
Is the first point on the path between the second and the third? In that case, it could intercepts units going to the third and send them back to the second.
12-13-2010, 02:50 PM#3
syrathia
Nope. I just put the system in a blank map and it seems to be working just fine. The points are all more than CHECK_RANGE*2 units apart

EDIT:
Some further poking at the system and fiddling with MOVE_INTERVAL it seems that when the units reach their next point before the next move update they start to run back to the point them came from. The strange part is that this doesn't occur in the test map but in the map that I'm working on. Reducing MOVE_INTERVAL's value to 1.7 catches the units and allows them time to perform their attack animations.

I'll look through the other systems that are in the map for now but I don't think I have anything else that affects units movement
Attached Files
File type: w3xMinionsTest.w3x (25.8 KB)
12-14-2010, 12:22 PM#4
Bribe
Collapse Zinc:
        static method onInit()
        {
            //Init the list array
            integer i;
            for (0 <= i < 12)
            {
                list[i] = 0;
            }
        }

This is unneeded. Arrays do not need to be initialised to 0 because they do that automatically. (list[i] = list[i] + 1) == 1 works just fine, even when list[i] was never inititalised. It is not like uninitialised integer i = i + 1, which does actually need an initialisation.

Collapse Zinc:
                while (i.next != 0)
                {
                    i = i.next;
                }
                i.next = p;

If you had a "prev" variable, you could just replace this with point(0).prev.next = p. I highly recommend it.
12-14-2010, 02:41 PM#5
syrathia
Quote:
Originally Posted by Bribe
Collapse Zinc:
        static method onInit()
        {
            //Init the list array
            integer i;
            for (0 <= i < 12)
            {
                list[i] = 0;
            }
        }

This is unneeded. Arrays do not need to be initialised to 0 because they do that automatically. (list[i] = list[i] + 1) == 1 works just fine, even when list[i] was never inititalised. It is not like uninitialised integer i = i + 1, which does actually need an initialisation.

Okay thanks I did not know that.

Quote:
Originally Posted by Bribe
Collapse Zinc:
                while (i.next != 0)
                {
                    i = i.next;
                }
                i.next = p;

If you had a "prev" variable, you could just replace this with point(0).prev.next = p. I highly recommend it.

So your suggesting that I use a doubly linked list?

Collapse Zinc:
if (i == 0)
{
    list[pid] = p;
    list[pid].next = p;
    list[pid].prev = p
}
else
{
    list[pid].prev.next = p
    list[pid].prev = p
}


Like that?
12-15-2010, 03:16 PM#6
Bribe
The best use of a doubly linked list:

allocate:
set thistype(0).next.prev=this
set this.next=thistype(0).next
set thistype(0).next=this
set this.prev=thistype(0)

deallocate:

set this.prev.next=this.next
set this.next.prev=this.prev

This is from Jesus4Lyf's Timer32; http://www.thehelper.net/forums/showthread.php?t=132538
12-15-2010, 04:03 PM#7
syrathia
I dont think this helps as there are more than one list of type point