(version 2)
(include "sci.sh")
(exports
    0 rm155
)
(use "Main")
(use "Sound")
(use "Cycle")
(use "Game")
(use "Feature")
(use "Obj")
(script 155)


(local
    local0
    local1

)
(instance public rm155 of Rm
    (properties
        picture 155
        horizon 1
    )

    (method (init)
        (var temp0[50])
        style
        16
        Load(129 156)
        Load(129 777)
        Load(128 8)
        Load(128 9)
        Load(132 100)
        Load(132 64)
        Load(132 65)
        Load(132 66)
        (super:init())
        (self:setScript(rmScript))
    )


    (method (handleEvent pEvent)
        (if ((send pEvent:claimed))
            return 
        )
        (if ((send pEvent:type))
            = global230 global20
            (send global1:setCursor(global20 HaveMouse()))
            Display(155 0 108 local0)
            (eyes:dispose())
            (bub0:dispose())
            (bub1:dispose())
            (bub2:dispose())
            (bub3:dispose())
            (send gLongSong:stop())
            (send global2:drawPic(777))
            proc0_10()
            (send global2:newRoom(2))
        )
    )

)
(instance rmScript of Script
    (properties)

    (method (doit)
        (if (== (send gLongSong:prevSignal) -1)
            (if (((== (send gLongSong:number) 64) and (<> (send gLongSong:state) 3)) and (== (self:state) 1))
                (self:cue())
            )
            (if ((== (send gLongSong:number) 66) and (<> (send gLongSong:state) 3))
                (if (< (self:state) 19)
                    (send gLongSong:play())
                )
                (if (== (self:state) 19)
                    (self:cue())
                )
            )
        )
        (super:doit())
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send gLongSong:
                    number(64)
                    loop(1)
                    play()
                )
                (eyes:init())
                = seconds 4
            )
            (case 1
                ShakeScreen(3)
                = local0 Display(155 1 106 250 100 36 100 101 1 105 300 102 14 107)
            )
            (case 2
                Display(155 0 108 local0)
                (send global2:drawPic(156 3))
                (doorSound:play())
                = seconds 4
            )
            (case 3
                (doorSound:stop())
                (send gLongSong:
                    number(66)
                    loop(1)
                    play()
                )
                (eyes:setCycle(CT 3 1 self))
            )
            (case 4
                = seconds 3
            )
            (case 5
                (eyes:
                    cel(0)
                    setCycle(CT 3 1 self)
                )
            )
            (case 6
                = cycles 15
            )
            (case 7
                (eyes:cel(0))
                = cycles 2
            )
            (case 8
                (eyes:setCycle(End self))
            )
            (case 9
                (bub0:init())
            )
            (case 10
                (eyes:
                    setLoop(1)
                    setCel(0)
                    cycleSpeed(2)
                    setCycle(End self)
                )
            )
            (case 11
                (eyes:setCycle(Beg self))
            )
            (case 12
                (eyes:setCycle(End self))
            )
            (case 13
                (eyes:setCycle(CT 2 -1 self))
            )
            (case 14
                (eyes:
                    setCel(2)
                    stopUpd()
                )
                = seconds 3
            )
            (case 15
                (eyes:
                    setLoop(0)
                    setCel(0)
                    cycleSpeed(0)
                    setCycle(End self)
                )
            )
            (case 16
                (eyes:setCycle(Beg self))
            )
            (case 17
                (eyes:setCycle(End self))
            )
            (case 18
                (eyes:stopUpd())
                = cycles 2
            )
            (case 19
                (eyes:stopUpd())
            )
            (case 20
                = global230 global20
                (send global1:setCursor(global20 HaveMouse()))
                (send gLongSong:stop())
                (eyes:dispose())
                (send global2:drawPic(777))
                proc0_10()
                (send global2:newRoom(2))
            )
        )
    )

)
(instance bubScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (bub1:
                    init()
                    stopUpd()
                )
                = cycles 3
            )
            (case 1
                (bub2:
                    init()
                    stopUpd()
                )
                = cycles 3
            )
            (case 2
                (whereSound:play())
                (bub3:
                    init()
                    stopUpd()
                )
                = seconds 5
            )
            (case 3
                (rmScript:cue())
                (bub0:dispose())
                (bub1:dispose())
                (bub2:dispose())
                (bub3:dispose())
            )
        )
    )

)
(instance bub0 of Prop
    (properties)

    (method (init)
        (super:init())
        (self:
            view(9)
            setCel(0)
            ignoreActors(1)
            posn(184 51)
            setPri(15)
            setScript(bubScript)
        )
    )

)
(instance bub1 of Prop
    (properties)

    (method (init)
        (super:init())
        (self:
            view(9)
            setCel(1)
            ignoreActors(1)
            posn(197 47)
            setPri(15)
        )
    )

)
(instance bub2 of Prop
    (properties)

    (method (init)
        (super:init())
        (self:
            view(9)
            setCel(2)
            ignoreActors(1)
            posn(215 42)
            setPri(15)
        )
    )

)
(instance bub3 of Prop
    (properties)

    (method (init)
        (super:init())
        (self:
            view(9)
            setCel(3)
            ignoreActors(1)
            posn(243 34)
            setPri(15)
        )
    )

)
(instance eyes of Act
    (properties
        y 88
        x 145
        view 8
    )

    (method (init)
        (super:init())
        (self:
            loop(0)
            cel(0)
            ignoreActors(1)
            setPri(9)
            cycleSpeed(4)
            illegalBits(0)
        )
    )

)
(instance whereSound of Sound
    (properties
        number 100
        priority 5
    )
)
(instance doorSound of Sound
    (properties
        number 65
        priority 5
    )
)
