(version 2)
(include "sci.sh")
(exports
    0 rm803
)
(use "Main")
(use "InterProp")
(use "Sync")
(use "Sound")
(use "Cycle")
(use "Game")
(use "View")
(use "Obj")
(script 803)

(local
    local0
    local1[6] = (0 0 83 144 239 145 )

)
(instance public rm803 of Rm
    (properties
        picture 111
        style $000a
    )

    (method (init)
        (var temp0[10])
        (super:init())
        (send global80:mapKeyToDir(0))
        (cHead:init())
        (sHead:init())
        (send gKH:addToFront(self))
        (send gMH:addToFront(self))
        (characters:init())
        (nSign:init())
        (ySign:init())
        (nHead:
            init()
            setCycle(Fwd)
        )
        (yHead:
            init()
            setCycle(Fwd)
        )
        (send global2:setScript(charlieScript))
    )


    (method (dispose)
        (send global80:mapKeyToDir(1))
        DisposeScript(929)
        (send gKH:delete(self))
        (send gMH:delete(self))
        (theSound:dispose())
        (mySound:dispose())
        (super:dispose())
    )


    (method (handleEvent pEvent)
        (if ((send pEvent:claimed))
            return 1
        )
        return 
            (switch ((send pEvent:type))
                (case evKEYBOARD
                    (send pEvent:claimed(1))
                    (switch ((send pEvent:message))
                        (case KEY_NUMPAD2
                            (if (> ++local0 2)
                                = local0 1
                            )
                            (send global1:setCursor(999 1 local1[(* local0 2)] local1[(+ (* local0 2) 1)]))
                        )
                        (case KEY_TAB
                            (if (> ++local0 2)
                                = local0 1
                            )
                            (send global1:setCursor(999 1 local1[(* local0 2)] local1[(+ (* local0 2) 1)]))
                        )
                        (case KEY_UP
                            (if (< --local0 1)
                                = local0 2
                            )
                            (send global1:setCursor(999 1 local1[(* local0 2)] local1[(+ (* local0 2) 1)]))
                        )
                        (case KEY_SHIFTTAB
                            (if (< --local0 1)
                                = local0 2
                            )
                            (send global1:setCursor(999 1 local1[(* local0 2)] local1[(+ (* local0 2) 1)]))
                        )
                        (case KEY_NUMPAD4
                            (if (< --local0 1)
                                = local0 2
                            )
                            (send global1:setCursor(999 1 local1[(* local0 2)] local1[(+ (* local0 2) 1)]))
                        )
                        (case KEY_RIGHT
                            (if (> ++local0 2)
                                = local0 1
                            )
                            (send global1:setCursor(999 1 local1[(* local0 2)] local1[(+ (* local0 2) 1)]))
                        )
                        (default 
                            (send pEvent:claimed(0))
                            (super:handleEvent(pEvent))
                        )
                    )
                )
                (default 
                    (super:handleEvent(pEvent))
                )
            )
    )


    (method (doVerb)
        return 0
    )

)
(instance goBackScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send global1:handsOff())
                (nSign:setCel(1))
                = cycles 1
            )
            (case 1
                (mySound:
                    number(910)
                    setLoop(1)
                    play()
                )
                = ticks 6
            )
            (case 2
                (nSign:setCel(0))
                = ticks 6
            )
            (case 3
                (mySound:
                    number(1146)
                    setLoop(1)
                    play(self)
                )
                (if (DoSound(sndGET_AUDIO_CAPABILITY))
                    (cHead:
                        setPri(15)
                        setCycle(CT 2 1)
                    )
                    (sHead:
                        setPri(15)
                        setCycle(CT 2 1)
                    )
                )
            )
            (case 4
                (if (DoSound(sndGET_AUDIO_CAPABILITY))
                    (cHead:
                        setCycle(0)
                        setCel(0)
                    )
                    (sHead:
                        setCycle(0)
                        setCel(0)
                    )
                )
                = cycles 2
            )
            (case 5
                (send global2:newRoom(801))
            )
        )
    )

)
(instance charlieScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send global1:handsOff())
                = ticks 30
            )
            (case 1
                (cHead:
                    setLoop(0)
                    setCel(0)
                    setPri(15)
                    setCycle(MouthSync 803 0 0 0 2)
                )
                = cycles 1
            )
            (case 2
                DoAudio(2 803 0 0 0 2)
                = ticks 54
            )
            (case 3
                (cHead:
                    setCycle(0)
                    setCel(0)
                )
                = cycles 2
            )
            (case 4
                (send global1:handsOn())
                (self:dispose())
            )
        )
    )

)
(instance sayOkScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send global1:handsOff())
                (ySign:setCel(1))
                = cycles 1
            )
            (case 1
                (mySound:
                    number(910)
                    setLoop(1)
                    play()
                )
                = ticks 6
            )
            (case 2
                (ySign:setCel(0))
                = ticks 6
            )
            (case 3
                (theSound:
                    number(1147)
                    loop(1)
                    play(self)
                )
                (if (DoSound(sndGET_AUDIO_CAPABILITY))
                    (cHead:
                        setPri(15)
                        setCycle(CT 2 1)
                    )
                    (sHead:
                        setPri(15)
                        setCycle(CT 2 1)
                    )
                )
            )
            (case 4
                (if (DoSound(sndGET_AUDIO_CAPABILITY))
                    (cHead:
                        setCycle(0)
                        setCel(0)
                    )
                    (sHead:
                        setCycle(0)
                        setCel(0)
                    )
                )
                = cycles 2
            )
            (case 5
                (send global1:handsOff())
                (send global1:quitGame(1))
            )
        )
    )

)
(instance characters of View
    (properties
        x 160
        y 89
        view 1
        signal $0011
    )
)
(instance cHead of Prop
    (properties
        x 144
        y 57
        view 992
    )
)
(instance sHead of Prop
    (properties
        x 179
        y 46
        view 991
        loop 1
        priority 15
        signal $0010
    )
)
(instance nSign of InterProp
    (properties
        x 80
        y 159
        view 1
        loop 6
        priority 2
        signal $0011
    )

    (method (doVerb)
        (send global1:handsOff())
        (send global2:setScript(goBackScript))
    )

)
(instance ySign of InterProp
    (properties
        x 239
        y 161
        view 1
        loop 7
        priority 2
        signal $0011
    )

    (method (doVerb)
        (send global2:setScript(sayOkScript))
    )

)
(instance nHead of Prop
    (properties
        x 79
        y 133
        view 1
        loop 2
        priority 3
        signal $0011
    )
)
(instance yHead of Prop
    (properties
        x 241
        y 135
        view 1
        loop 1
        priority 3
        signal $0011
    )
)
(instance theSound of Sound
    (properties)
)
(instance mySound of Sound
    (properties)
)
