(include "sci.sh")
(use "Class_255_0")
(use "User")
(use "PicView")
(use "Obj")
(script 976)



(class Cat of Actor
    (properties
        x 0
        y 0
        z 0
        heading 0
        noun 0
        nsTop 0
        nsLeft 0
        nsBottom 0
        nsRight 0
        description 0
        sightAngle 26505
        actions 26505
        onMeCheck 26505
        lookStr 0
        yStep 2
        view 0
        loop 0
        cel 0
        priority 0
        underBits 0
        signal 0
        lsTop 0
        lsLeft 0
        lsBottom 0
        lsRight 0
        brTop 0
        brLeft 0
        brBottom 0
        brRight 0
        palette 0
        cycleSpeed 0
        script 0
        cycler 0
        timer 0
        illegalBits 32768
        xLast 0
        yLast 0
        xStep 3
        moveSpeed 0
        blocks 0
        baseSetter 0
        mover 0
        looper 0
        viewer 0
        avoider 0
        code 0
        top -1
        left -1
        bottom -1
        right -1
        diagonal 0
        doCast 0
        outOfTouch 1
        caller 0
        active 0
        dx 0
        dy 0
    )

    (method (doit)
        (var userCurEvent)
        (if (not doCast)
            = active 0
        )(else
            (if (active)
                = userCurEvent (User:curEvent)
                (self:posn((+ (send userCurEvent:x) dx) (+ (send userCurEvent:y) dy) z))
            )
        )
        (super:doit())
    )


    (method (handleEvent pEvent)
        (if ((super:handleEvent(pEvent)))
        )(else
            (if (active and (== (send pEvent:type) 2))
                = active 0
                (send pEvent:claimed(1))
                LocalToGlobal(pEvent)
                (self:posn((+ (send pEvent:x) dx) (+ (send pEvent:y) dy) z))
                GlobalToLocal(pEvent)
                (if (caller)
                    (send caller:cue(self))
                )
            )(else
                (if (proc255_5(self pEvent))
                    (send pEvent:claimed(1))
                    (self:track(pEvent))
                )
            )
        )
    )


    (method (posn theX theY theZ)
        (var temp0)
        (if (paramTotal)
            = x theX
            (if (>= paramTotal 2)
                = y theY
                (if (>= paramTotal 3)
                    = z theZ
                )
            )
        )
        = temp0 proc999_0(diagonal)
        (if (not 
        (if (((== -1 top) and (== top bottom)) and (== bottom left))
            == left right
        )
)
            (switch (Abs(diagonal))
                (case 1
                    = y (+ 
                        (if (> temp0 0)
                            top
                        )(else
                            bottom
                        )
 (/ (* (* (- right x) (- bottom top)) temp0) (- right left)))
                )
                (case 2
                    = x (+ 
                        (if (> temp0 0)
                            left
                        )(else
                            right
                        )
 (/ (* (* (- bottom y) (- right left)) temp0) (- bottom top)))
                )
            )
            = x proc999_3(left proc999_2(right x))
            = y proc999_3(top proc999_2(bottom y))
        )
        (super:posn(x y z))
    )


    (method (findPosn)
        return 1
    )


    (method (canBeHere)
        return 1
    )


    (method (track param1)
        (var newCollect)
        LocalToGlobal(param1)
        = dx (- x (send param1:x))
        = dy (- y (send param1:y))
        (if (doCast)
            = active 1
        )(else
            = newCollect (Collect:new())
            (send newCollect:add(self))
            (while ((<> 2 (send param1:type)) and (outOfTouch or proc255_5(self (send param1:
                    type(1)
                    yourself()
                )
)))
                (self:posn((+ (send param1:x) dx) (+ (send param1:y) dy) z))
                Animate((send newCollect:elements) 1)
                GetEvent(32767 param1)
            )
            (send newCollect:
                release()
                dispose()
            )
            (if (caller)
                (send caller:cue(self))
            )
            GlobalToLocal(param1)
        )
    )

)
