(include "sci.sh")
(use "Main")
(use "Cycle")
(script 941)



(class RandCycle of Cycle
    (properties
        client 0
        caller 0
        cycleDir 1
        cycleCnt 0
        completed 0
        count -1
    )

    (method (init param1 theCount theCaller)
        (super:init(param1))
        (if (>= paramTotal 2)
            = count theCount
            (if (>= paramTotal 3)
                = caller theCaller
            )
        )(else
            = count -1
        )
    )


    (method (doit)
        ++cycleCnt
        (if (> cycleCnt (send client:cycleSpeed))
            (if (count)
                (if (> count 0)
                    --count
                )
                (send client:cel((self:nextCel())))
                = cycleCnt 0
            )(else
                (self:cycleDone())
            )
        )
    )


    (method (nextCel)
        (var temp0)
        (while (== (= temp0 Random(0 (send client:lastCel()))) (send client:cel))
        )
        return temp0
    )


    (method (cycleDone)
        = completed 1
        (if (caller)
            = global37 1
        )(else
            (self:motionCue())
        )
    )

)
