HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Very ODD map problem

04-12-2007, 12:54 AM#1
nomorholywar
So I have a maze map and I got trolls patrolling.

I have a line of 6 trolls patrolling together vertically. But every once in a while, one of the trolls will start turning, say, clockwise, when the others turn counter clockwise. This screws up the whole line and that one troll gets completely out of sync.

Is there anyway to add the specification to turn a certain way?

I tried offsetting the patrol point 50 pixels to the right (Xdirection) so that they patrol slightly diagonally (but its not noticable). I hoped that this would cause them to all turn in the same direction. But it DIDNT.

Any help would be very much appreciated and +rep given. Thanks.
04-12-2007, 01:02 AM#2
Dil999
The easiest way to do this would be to change the turn radius. I haven't experimented with that value, so I'm not totally sure if it will work.
If not, just make the units go slightly to the left or right before turning around, like this:

XXX
X..X
X..X
XXX

(Zoomed in of course, it should only be 20 or so wide)

This will make the units move in a square and not a line, but the square is so thin that you don't notice.

If THAT doesn't work:
Use (Instead of keeping the same unit throughout the entire game) when a unit reaches one of the 'ends' of its patrol, replace it with another, and order that one. Do the same, over and over.
04-12-2007, 01:15 AM#3
nomorholywar
thats a good idea (the square). thanks
04-12-2007, 04:53 AM#4
nomorholywar
Quote:
Originally Posted by Dil999
Just make the units go slightly to the left or right before turning around, like this:

XXX
X..X
X..X
XXX

(Zoomed in of course, it should only be 20 or so wide)

This will make the units move in a square and not a line, but the square is so thin that you don't notice.


How would you do that without using 4 regions? Is there any way to set up a "rally point-patrol"? to make it do that? Because making a trigger like "unit enters region, make unit move to next region" is painful.
04-12-2007, 12:14 PM#5
Pyrogasm
If you understand JASS, I have a rally-point script that you can use just for this. WARNING: Not finshed.
Collapse JASS:
function PatrolRectsBasic takes group Group, rect Patrol1, rect Patrol2, rect Patrol3, rect Patrol4, integer Circuits, boolean EndAtFirst returns nothing
    local group g = CreateGroup()
    local group g2 = CreateGroup()
    local unit u
    local rect array PatrolRect
    local boolean In = false
    local boolean In2 = false
    local integer i = 0
    local integer Target = 1
    local integer CircuitNumber = 1
    local integer TargetTotal = 4
    local real x = GetRectCenterX(Patrol1)
    local real y = GetRectCenterY(Patrol1)
    local real ux
    local real uy
    local real d
    local boolean Finite = true

    if Circuits == 0 then
        set Finite = false
    endif
    if Circuits < 0 then
        call DestroyGroup(g)
        call DestroyGroup(g2)
        set u = null
        set g = null
        set g2 = null
        return
    endif
    call GroupAddGroup(Group, g)
    call GroupAddGroup(g, g2)

    set PatrolRect[1] = Patrol1
    set PatrolRect[2] = Patrol2
    set PatrolRect[3] = Patrol3
    set PatrolRect[4] = Patrol4

    loop
        set i = i+1
        exitwhen i > 4
        if PatrolRect[i] == null then
            set TargetTotal = TargetTotal-1
        endif
    endloop

    loop
        set u = FirstOfGroup(g2)
        exitwhen u == null
        if IssuePointOrder(u, "attack", x, y) == false then
            call GroupRemoveUnit(g, u)
            call BJDebugMsg("Removed")
        endif
        call GroupRemoveUnit(g2, u)
    endloop
    call GroupClear(g2)
    call GroupPointOrder(g, "attack", x, y)

    loop
        exitwhen ((IsUnitGroupEmptyBJ(g)) or (CircuitNumber > Circuits and Finite))
        loop
            exitwhen ((Target > TargetTotal) or (IsUnitGroupEmptyBJ(g)))
            loop
                exitwhen (In2 or (IsUnitGroupEmptyBJ(g)))
                call GroupAddGroup(g, g2)
                set x = GetRectCenterX(PatrolRect[Target])
                set y = GetRectCenterY(PatrolRect[Target])
                loop
                    set u = FirstOfGroup(g2)
                    exitwhen ((u == null) or In or (IsUnitGroupEmptyBJ(g)))
                    if GetUnitCurrentOrder(u) != 851983 then
                        call GroupPointOrder(g, "attack", x, y)
                    endif
                    set ux = GetUnitX(u)
                    set uy = GetUnitY(u)
                    set d = SquareRoot(((ux-x)*(ux-x))+((uy-y)*(uy-y)))
                    set In = (d <= 125.00)
                    call GroupRemoveUnit(g2, u)
                endloop
                call GroupClear(g2)
                if In then
                    set In = false
                    if Target < TargetTotal then
                        set x = GetRectCenterX(PatrolRect[Target+1])
                        set y = GetRectCenterY(PatrolRect[Target+1])
                        call GroupPointOrder(g, "attack", x, y)
                    else
                        if ((Circuits == 0) or (CircuitNumber < Circuits) or EndAtFirst) then
                            set x = GetRectCenterX(PatrolRect[1])
                            set y = GetRectCenterY(PatrolRect[1])
                            call GroupPointOrder(g, "attack", x, y)
                        endif
                    endif
                    set In2 = true
                endif
                if In2 == false then
                    call PolledWait(0.20)
                endif
            endloop
            set Target = Target+1
            set In2 = false
        endloop
        set Target = 1
        set CircuitNumber = CircuitNumber+1
        call BJDebugMsg("CircuitNumber = " + I2S(CircuitNumber))
    endloop
    call BJDebugMsg("Circuit loop exited")

    if IsUnitGroupEmptyBJ(g) then
        set EndAtFirst = false
    endif

    if (EndAtFirst and (IsUnitGroupEmptyBJ(g) == false)) then
        set x = GetRectCenterX(PatrolRect[1])
        set y = GetRectCenterY(PatrolRect[1])
        call GroupPointOrder(g, "attack", x, y)
        call GroupAddGroup(g, g2)
        loop
            exitwhen In
            loop
                set u = FirstOfGroup(g2)
                exitwhen u == null or In
                if GetUnitCurrentOrder(u) != 851983 then
                    call GroupPointOrder(g, "attack", x, y)
                endif
                call GroupRemoveUnit(g2, u)
            endloop
            call GroupClear(g2)
            if In == false then
                call PolledWait(0.20)
            endif
        endloop
    endif
    

    set i = 0
    loop
        set i = i+1
        exitwhen i > 4
        set PatrolRect[i] = null
    endloop

    call DestroyGroup(g)
    set g = null
    set g2 = null
    set u = null
    call BJDebugMsg("Ended")
endfunction