(include "sci.sh")
(use "Obj")
(script 991)



(class Jump of Obj
    (properties
        gx 0
        gy 3
        xStep 20000
        yStep 0
        client 0
        caller 0
        x 20000
        y 20000
        signal 0
        illegalBits 0
        waitApogeeX 1
        waitApogeeY 1
        dx 0
        dy 0
    )

    (method (init theClient theCaller)
        (var clientHeading)
        = client theClient
        (if (== paramTotal 2)
            = caller theCaller
        )
        = illegalBits (send client:illegalBits())
        = signal (send client:signal())
        (send client:
            illegalBits(0)
            setPri()
        )
        (if (== xStep 20000)
            = xStep 
                (if (((> (= clientHeading (send client:heading())) 330) or (< clientHeading 30)) or ((< 150 clientHeading) and (< clientHeading 210)))
                    0
                )(else
                    (if (< clientHeading 180)
                        (send client:xStep())
                    )(else
                        neg (send client:xStep())
                    )
                )
        )
        (if (not 
        (if (waitApogeeX)
            < (* xStep gx) 0
        )
)
            = waitApogeeX 0
        )
        (if (not 
        (if (waitApogeeY)
            < (* yStep gy) 0
        )
)
            = waitApogeeY 0
        )
        (self:
            setTest()
            doit()
        )
    )


    (method (doit)
        (var theXStep, theYStep)
        (send client:
            x(+ (send client:x()) xStep)
            y(+ (send client:y()) yStep)
        )
        = theXStep xStep
        = theYStep yStep
        = xStep (+ xStep gx)
        = yStep (+ yStep gy)
        (if ((not waitApogeeX and (<> x 20000)) and (<= 0 (* dx (- (send client:x()) x))))
            (send client:x(x))
            (self:moveDone())
            return 
        )
        (if ((not waitApogeeY and (<> y 20000)) and (<= 0 (* dy (- (send client:y()) y))))
            (send client:y(y))
            (self:moveDone())
            return 
        )
        (if (<= (* theXStep xStep) 0)
            = waitApogeeX 0
            (self:setTest())
        )
        (if (<= (* theYStep yStep) 0)
            = waitApogeeY 0
            (self:setTest())
        )
    )


    (method (triedToMove)
        return 1
    )


    (method (moveDone)
        (send client:
            mover(0)
            illegalBits(illegalBits)
            signal(signal)
        )
        (if (caller)
            (send caller:cue())
        )
        (self:dispose())
    )


    (method (setTest)
        = dx 
            (if ((> (send client:x()) x) or ((== (send client:x()) x) and (> xStep 0)))
                -1
            )(else
                1
            )
        = dy 
            (if ((> (send client:y()) y) or ((== (send client:y()) y) and (> yStep 0)))
                -1
            )(else
                1
            )
    )

)
(class JumpTo of Jump
    (properties
        gx 0
        gy 3
        xStep 20000
        yStep 0
        client 0
        caller 0
        x 20000
        y 20000
        signal 0
        illegalBits 0
        waitApogeeX 1
        waitApogeeY 1
        dx 0
        dy 0
    )

    (method (init theClient theX theY param4)
        (var temp0, temp1, temp2[52])
        = client theClient
        = x theX
        = y theY
        (if ((== x (send theClient:x())) and (== y (send theClient:y())))
            = illegalBits (send client:illegalBits())
            = signal (send client:signal())
            (self:moveDone())
            return 
        )
        = temp0 (- x (send theClient:x()))
        = temp1 (- y (send theClient:y()))
        SetJump(self temp0 temp1 gy)
        (switch (paramTotal)
            (case 3
                ((super:init(theClient))  )
            )
            (case 4
                ((super:init(theClient param4)) )
            )
        )
    )


    (method (moveDone)
        (send client:
            x(x)
            y(y)
        )
        (super:moveDone())
    )

)
