(version 2)
(include "sci.sh")
(use "Main")
(use "PolyPath")
(use "Obj")
(script 404)



(class MChase of PolyPath
    (properties
        client 0
        caller 0
        x 0
        y 0
        dx 0
        dy 0
        {b-moveCnt} 0
        {b-i1} 0
        {b-i2} 0
        {b-di} 0
        {b-xAxis} 0
        {b-incr} 0
        completed 0
        xLast 0
        yLast 0
        value 2
        points 0
        finalX 0
        finalY 0
        obstacles 0
        who 0
        distance 0
        targetX 0
        targetY 0
        doitSkips 10
    )

    (method (init theClient theWho theDistance theCaller theObstacles)
        (var temp0[20])
        (if (paramTotal)
            (if (>= paramTotal 5)
                = obstacles theObstacles
            )(else
                (if (not IsObject(obstacles))
                    = obstacles (send global2:obstacles)
                )
            )
            (if (>= paramTotal 1)
                = client theClient
                (if (>= paramTotal 2)
                    = who theWho
                    = targetX (send who:x)
                    = targetY (send who:y)
                    (if (>= paramTotal 3)
                        = distance theDistance
                        (if (>= paramTotal 4)
                            = caller theCaller
                        )
                    )
                )
            )
            (super:init(client targetX targetY caller 1 obstacles))
        )
    )


    (method (doit)
        (if (>= GetDistance(targetX targetY (send who:x) (send who:y)) distance)
            (if (not doitSkips)
                = doitSkips 10
                (if (points)
                    Memory(3 points)
                )
                = points 0
                = value 2
                (self:init(client who))
            )(else
                (if (>= Abs((- gLastTicks {b-moveCnt})) (send client:moveSpeed))
                    = {b-moveCnt} gLastTicks
                    DoBresen(self)
                )
                --doitSkips
            )
        )(else
            = global461 GetDistance((send client:x) (send client:y) (send who:x) (send who:y))
            (if (<= global461 distance)
                (self:moveDone())
            )(else
                = global461 GetDistance((send client:x) (send client:y) (send who:x) (send who:y))
                (if (>= global461 global462)
                    (self:moveDone())
                )(else
                    (if (>= Abs((- gLastTicks {b-moveCnt})) (send client:moveSpeed))
                        = {b-moveCnt} gLastTicks
                        DoBresen(self)
                    )
                )
            )
        )
    )


    (method (moveDone)
        (var temp0)
        (if ((<= global461 distance) or (> global461 global462))
            (send client:cue())
        )(else
            (if (== proc999_6(points value) 30583)
                (if (points)
                    Memory(3 points)
                )
                = points 0
                = value 2
                (self:init(client who))
            )(else
                (self:init(client))
            )
        )
    )

)
