(version 2)
(include "sci.sh")
(exports
    0 rm99
)
(use "Main")
(use "Timer")
(use "Game")
(use "TheMenuBar")
(use "Feature")
(use "Obj")
(script 99)


(local
    newSpiralStar[4]
    local4
    local5
    local6
    local7
    local8
    local9

)
(instance public rm99 of Rm
    (properties
        picture 99
        style 0
    )

    (method (init)
        proc0_2()
        = global159 1
        (TheMenuBar:hide())
        (SL:disable())
        = global193 1
        Load(128 801)
        Load(128 101)
        Load(132 94)
        Load(132 93)
        (super:init())
        proc0_10()
        = local4 0
        (while (< local4 4)
            (send (= newSpiralStar[local4] (SpiralStar:new())):init())
            ++local4
        )
        (send gLongSong:
            number(94)
            loop(-1)
            play()
        )
        (send global2:setScript(startShip))
    )

)
(instance startShip of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (Timer:setReal(self 10))
            )
            (case 1
                = local7 1
                (send gLongSong:
                    number(93)
                    loop(-1)
                    play()
                )
                (Timer:setReal(self 2))
            )
            (case 2
                = local6 1
            )
            (case 3
                (Timer:setReal(self 1))
            )
            (case 4
                = local8 4
                (Timer:setReal(self 1))
            )
            (case 5
                (if (local8)
                    --state
                    (Timer:setCycle(self 1))
                )(else
                    (self:cue())
                )
            )
            (case 6
                = local9 Display("The overwhelming force of the black hole\ndraws your ship in. Helpless to do any-\nthing, you and your passengers strap in\nand hope for the best." 106 250 100 35 65 101 1 105 300 102 14 107)
                (Timer:setReal(self 10))
            )
            (case 7
                = local8 5
                (Timer:setReal(self 1))
            )
            (case 8
                (if (> local8 1)
                    --state
                    (Timer:setCycle(self 3))
                )(else
                    (self:cue())
                )
            )
            (case 9
                Display(99 0 108 local9)
                (send global2:newRoom(98))
            )
        )
    )

)
(class SpiralStar of Prop
    (properties
        y 0
        x 0
        z 0
        heading 0
        yStep 2
        view 101
        loop 0
        cel 0
        priority 13
        underBits 0
        signal 0
        nsTop 0
        nsLeft 0
        nsBottom 0
        nsRight 0
        lsTop 0
        lsLeft 0
        lsBottom 0
        lsRight 0
        brTop 0
        brLeft 0
        brBottom 0
        brRight 0
        cycleSpeed 0
        script 0
        cycler 0
        timer 0
        radius 0
        sel_341 0
        sel_342 0
        sel_343 0
        type 0
    )

    (method (doit)
        (super:doit())
        (if (< radius sel_341)
            (self:sel_344())
        )(else
            (if (local8 and (> radius 187))
                = radius (+ radius sel_341)
            )
            = radius (- radius sel_341)
            = sel_342 (% (+ (+ sel_342 sel_343) 360) 360)
            (self:posn((+ 160 CosMult(sel_342 radius)) (+ 95 SinMult(sel_342 radius))))
            (switch (type)
                (case 0
                    (if ((< radius 50) and (< cel (self:lastCel())))
                        ++cel
                        (self:sel_341(8))
                    )
                )
                (case 1
                    (if ((< radius 100) and (< cel (self:lastCel())))
                        ++cel
                    )
                )
                (case 2
                    (if ((< radius 80) and (< cel (self:lastCel())))
                        ++cel
                    )
                )
            )
            (self:stopUpd())
        )
    )


    (method (sel_344)
        (switch (type)
            (case 0
            )
            (case 1
                = local5 0
            )
            (case 2
                = local7 0
                (startShip:cue())
            )
        )
        (if (local6)
            = local6 0
            (self:
                type(2)
                view(801)
                setPri(15)
                setLoop(0)
                setCel(0)
                radius(120)
                sel_341(7)
                sel_342(125)
                sel_343(-5)
            )
        )(else
            (if ((not local5 and not local7) and (== 1 Random(1 2)))
                = local5 1
                (self:
                    type(1)
                    view(101)
                    setPri(14)
                    setLoop(1)
                    setCel(0)
                    radius(+ 187 local8)
                    sel_341(16)
                    sel_342(* (- Random(1 72) 1) 5)
                    sel_343(-5)
                )
            )(else
                (self:
                    type(0)
                    view(101)
                    setPri(13)
                    setLoop(0)
                    setCel(0)
                    radius(+ 187 local8)
                    sel_341(Random(5 8))
                    sel_342(* (- Random(1 72) 1) 5)
                    sel_343(* Random(1 2) 5)
                )
            )
            (if (local8)
                --local8
            )
        )
        (self:doit())
    )

)
