(include "sci.sh")
(use "Main")
(use "SQRoom")
(use "Cycle")
(use "PicView")
(use "Obj")
(script 119)



(instance public rm119 of SQRoom
    (properties
        picture 119
    )

    (method (init)
        Load(rsVIEW 120)
        (send gLongSong2:hold(2))
        (if (== global12 59)
            (ship:
                x(72)
                y(-1)
            )
            (self:setScript(flyInScript))
        )(else
            (ship:
                x(171)
                y(52)
            )
            (self:setScript(flyOutScript))
        )
        (ship:
            init()
            setCycle(Fwd)
        )
        (super:init())
    )

)
(instance flyInScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                = cycles 2
            )
            (case 1
                (ship:
                    loop(0)
                    setMotion(MoveTo 168 46 self)
                )
            )
            (case 2
                (send global2:newRoom(120))
            )
        )
    )

)
(instance flyOutScript of Script
    (properties)

    (method (doit param1)
        (super:doit(rest param1))
        ++register
        (ship:x((- (ship:x) (/ register 4))))
        (ship:y((- (ship:y) (/ register 4))))
        (if ((== state 1) and (== (send gLongSong:prevSignal) -1))
            (self:cue())
        )
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                = cycles 1
                (send gLongSong2:stop())
                (send gLongSong:prevSignal(0))
                --register
            )
            (case 1
                (send gLongSong:
                    number(74)
                    loop(1)
                    vol(127)
                    playBed()
                )
                (ship:
                    loop(1)
                    setMotion(MoveTo 70 65533)
                )
            )
            (case 2
                (send global2:newRoom(72))
            )
        )
    )

)
(instance ship of Actor
    (properties
        yStep 4
        view 120
        signal 8192
        xStep 2
    )
)
