(version 2)
(include "sci.sh")
(exports
    0 intro
)
(use "Main")
(use "Class_255_0")
(use "n958")
(use "StopWalk")
(use "Follow")
(use "RFeature")
(use "Gauge")
(use "Cycle")
(use "Game")
(use "PicView")
(use "Obj")
(script 200)


(local
    local0
    local1[6]
    local7[6] = (263 224 62 24 203 123 )
    local13[6] = (167 171 169 159 178 178 )
    local19[6] = (3 3 3 3 2 1 )
    local25
    local26[3]
    local29[3] = (51 170 288 )
    local32[3] = (155 156 158 )

)
(procedure (localproc_114c)
    (if (gTheNewDialog)
        (send gTheNewDialog:dispose())
    )
)


(instance public intro of Rm
    (properties
        picture 83
        style $000a
    )

    (method (init)
        proc958_0(128 190 186 185 201 657 5 2 0 80 81 267 202)
        proc958_0(129 83 1 53)
        proc958_0(132 81 82 78)
        Load(rsSCRIPT 778)
        (super:init())
        (send gAddToPics:
            add(urn)
            eachElementDo(#init)
            doit()
        )
        Load(rsSCRIPT 778)
        (send gEgo:
            posn(330 117)
            init()
            setScript(songScript)
        )
        (if (>= global101 1)
            (send gMenace:
                view(80)
                setPri(1)
                loop((send gEgo:loop))
                x((send gEgo:x))
                cel((send gEgo:cel))
                y(+ (send gEgo:y) 20)
                ignoreActors()
                init()
            )
        )
        = local0 0
        (while (< local0 6)
            (send (= local1[local0] Clone(Prop)):
                view(202)
                cycleSpeed(1)
                setPri(3)
                x(local7[local0])
                y(local13[local0])
                setLoop(local19[local0])
                ignoreActors(1)
                ignoreActors(1)
                sightAngle(180)
                closeRangeDist(500)
                longRangeDist(500)
                description("ripples")
                init()
                stopUpd()
            )
            (if (>= global101 1)
                (send local1[local0]:setCycle(Fwd))
            )
            ++local0
        )
        (self:setScript(beginScript))
    )


    (method (dispose)
        (if (gTheNewDialog)
            (send gTheNewDialog:dispose())
        )
        (send (ScriptID(0 23)):fade())
        (send (ScriptID(0 21)):fade())
        (super:dispose())
    )

)
(instance songScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send (ScriptID(0 23)):
                    number(81)
                    init()
                    play(self)
                )
            )
            (case 1
                (send (ScriptID(0 23)):
                    number(82)
                    play(self)
                )
            )
            (case 2
                (self:dispose())
            )
        )
    )

)
(instance beginScript of Script
    (properties)

    (method (doit)
        (super:doit())
        SetCursor(gCursorNumber 0)
        (if (((== (send global2:picture) 83) and (< (send gEgo:x) 58)) and (>= global101 1))
            (send gMenace:dispose())
        )
        (if ((== state 7) and (<= (send gEgo:x) 5))
            localproc_114c()
        )
        (if (>= global101 1)
            (if (== (send gEgo:view) 0)
                (send gMenace:
                    view(80)
                    loop((send gEgo:loop))
                    x((send gEgo:x))
                    cel((send gEgo:cel))
                    y(+ (send gEgo:y) 20)
                )
            )(else
                (send gMenace:
                    view(81)
                    loop((send gEgo:loop))
                    x((send gEgo:x))
                    cel(0)
                    y(+ (send gEgo:y) 20)
                )
            )
        )
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                = cycles 20
            )
            (case 1
                SetCursor(gCursorNumber 0)
                (send gEgo:
                    view(0)
                    illegalBits(0)
                    ignoreActors()
                    setCycle(StopWalk 2)
                    signal(4)
                    setMotion(MoveTo 245 117 self)
                )
            )
            (case 2
                (send gEgo:loop(2))
                (self:cue())
            )
            (case 3
                proc255_0(200 0 67 16 20 25 10 94)
                = cycles 30
            )
            (case 4
                (send gEgo:setMotion(MoveTo 195 117 self))
            )
            (case 5
                localproc_114c()
                proc255_0(200 1 67 32 125 70 248 94)
                (send gEgo:setMotion(MoveTo 88 117 self))
            )
            (case 6
                (send gEgo:setMotion(MoveTo 65 105 self))
            )
            (case 7
                (send gEgo:setMotion(MoveTo -10 105 self))
            )
            (case 8
                localproc_114c()
                (send global2:
                    picture(1)
                    style(40)
                    drawPic(1)
                )
                (gate:
                    init()
                    setPri(3)
                    stopUpd()
                )
                (send gAddToPics:
                    add(guard2 urn1 urn2)
                    eachElementDo(#init)
                    doit()
                )
                (guard1:
                    init()
                    stopUpd()
                )
                (send gEgo:
                    posn(318 105)
                    setMotion(MoveTo 245 105)
                )
                = local0 0
                (while (< local0 6)
                    (send local1[local0]:dispose())
                    ++local0
                )
                = local25 0
                (while (< local25 3)
                    (send (= local26[local25] Clone(Prop)):
                        view(202)
                        cycleSpeed(1)
                        setPri(3)
                        x(local29[local25])
                        y(local32[local25])
                        setLoop(0)
                        ignoreActors(1)
                        sightAngle(180)
                        closeRangeDist(500)
                        longRangeDist(500)
                        description("ripples")
                        init()
                        stopUpd()
                        shiftClick(0)
                    )
                    (if (>= global101 1)
                        (send local26[local25]:setCycle(Fwd))
                    )
                    ++local25
                )
                = cycles 2
            )
            (case 9
                (guard1:
                    setCycle(Walk)
                    setMotion(MoveTo 160 105 self)
                )
            )
            (case 10
                (guard1:setMotion(MoveTo 225 105 self))
            )
            (case 11
                proc255_0(200 2 67 16 20 94)
                (guard1:
                    loop(4)
                    cel(2)
                )
                (guardFace:
                    posn(- (guard1:x) 2 - (guard1:y) 38)
                    setPri(7)
                    setCycle(Fwd)
                    init()
                )
                = seconds 7
            )
            (case 12
                (guardFace:dispose())
                localproc_114c()
                proc255_0(200 3 67 16 20 25 4 94)
                (gramHead:
                    setPri(9)
                    posn(242 67)
                    setCycle(Fwd)
                    init()
                )
                (guard1:setMotion(MoveTo 160 100 self))
            )
            (case 13
                localproc_114c()
                (gramHead:hide())
                (guard1:setMotion(MoveTo 160 95))
                (send gEgo:setMotion(MoveTo 160 100 self))
            )
            (case 14
                (guard1:
                    stopUpd()
                    loop(4)
                    cel(3)
                )
                (send gEgo:loop(3))
                proc255_0(200 4 67 16 20 94)
                = seconds 2
            )
            (case 15
                (send (ScriptID(0 21)):
                    number(78)
                    play()
                )
                (guard1:stopUpd())
                (send gEgo:stopUpd())
                (gate:
                    illegalBits(0)
                    ignoreActors()
                    yStep(
                        (switch (global101)
                            (case 0
                                4
                            )
                            (default 
                                1
                            )
                        )
)
                    setMotion(MoveTo 160 25 self)
                )
            )
            (case 16
                localproc_114c()
                (send (ScriptID(0 21)):stop())
                (gate:stopUpd())
                (send gEgo:
                    ignoreHorizon()
                    setMotion(Follow guard1 23)
                )
                (guard1:
                    setPri(2)
                    setMotion(MoveTo 160 70 self)
                )
            )
            (case 17
                (guard1:setMotion(MoveTo 100 70))
                (send gEgo:
                    setPri(2)
                    setMotion(MoveTo 160 70 self)
                )
            )
            (case 18
                (send gEgo:setMotion(MoveTo 120 70 self))
            )
            (case 19
                localproc_114c()
                (guard1:
                    posn(337 154)
                    setMotion(MoveTo 280 166 self)
                )
                (send gEgo:
                    posn(330 144)
                    setMotion(MoveTo 207 137 self)
                )
                (gate:dispose())
                = local25 0
                (while (< local25 3)
                    (send local26[local25]:dispose())
                    ++local25
                )
                (send global2:
                    picture(53)
                    style(2)
                    drawPic(53)
                )
                (king:
                    init()
                    setPri(5)
                    stopUpd()
                )
            )
            (case 20
                (guard1:
                    setLoop(4)
                    setCel(1)
                    stopUpd()
                )
            )
            (case 21
                (send gEgo:setMotion(MoveTo 173 123 self))
            )
            (case 22
                (send gEgo:setMotion(MoveTo 139 123 self))
            )
            (case 23
                (send gEgo:
                    view(5)
                    setLoop(0)
                    setCel(0)
                    setCycle(End self)
                )
            )
            (case 24
                localproc_114c()
                proc255_0(200 5 67 16 20 70 276 94)
                (send gEgo:stopUpd())
                (gramHead:
                    show()
                    posn(136 95)
                    setCycle(Fwd)
                )
                = seconds 5
            )
            (case 25
                (gramHead:hide())
                (talkingHead:
                    init()
                    setCycle(Fwd)
                    cycleSpeed(1)
                )
                localproc_114c()
                proc255_0(200 6 67 16 20 70 276 94)
                = seconds 10
            )
            (case 26
                localproc_114c()
                proc255_0(200 7 67 16 20 70 276 94)
                = seconds 6
            )
            (case 27
                localproc_114c()
                proc255_0(200 8 67 16 20 70 276 94)
                = seconds 4
            )
            (case 28
                localproc_114c()
                proc255_0(200 9 67 16 20 70 276 94)
                = seconds 8
            )
            (case 29
                localproc_114c()
                proc255_0(200 10 67 16 20 70 276 94)
                = seconds 7
            )
            (case 30
                localproc_114c()
                proc255_0(200 11 67 16 20 70 276 94)
                = seconds 6
            )
            (case 31
                localproc_114c()
                proc255_0(200 12 67 16 20 70 276 94)
                = seconds 6
            )
            (case 32
                localproc_114c()
                proc255_0(200 13 67 16 20 70 230 94 82 503 2 0)
                = seconds 8
            )
            (case 33
                localproc_114c()
                proc255_0(200 14 67 16 20 70 230 94 82 522 0 2)
                = seconds 8
            )
            (case 34
                localproc_114c()
                proc255_0(200 15 67 16 20 70 230 94 82 505 0 1)
                = seconds 8
            )
            (case 35
                localproc_114c()
                proc255_0(200 16 67 16 20 70 276 94)
                = seconds 8
            )
            (case 36
                localproc_114c()
                proc255_0(200 17 67 16 20 70 276 94)
                = seconds 7
            )
            (case 37
                localproc_114c()
                proc255_0(200 18 67 16 20 70 276 94)
                = seconds 8
            )
            (case 38
                localproc_114c()
                proc255_0(200 19 67 16 20 70 276 94)
                = seconds 6
            )
            (case 39
                (talkingHead:
                    setCel(0)
                    stopUpd()
                )
                localproc_114c()
                proc255_0(200 20 67 16 20 70 276 94)
                (gramHead:
                    show()
                    setCycle(Fwd)
                )
                = seconds 5
            )
            (case 40
                (gramHead:dispose())
                (send gEgo:setCycle(Beg self))
            )
            (case 41
                localproc_114c()
                (send gEgo:
                    view(0)
                    setLoop(1)
                    setCycle(StopWalk 2)
                )
                = seconds 2
            )
            (case 42
                (send gEgo:
                    setLoop(-1)
                    setMotion(MoveTo 173 123 self)
                )
            )
            (case 43
                (send gEgo:setMotion(MoveTo 207 137 self))
            )
            (case 44
                (send gEgo:setMotion(MoveTo 255 136 self))
            )
            (case 45
                (guard1:
                    setLoop(-1)
                    startUpd()
                    setCycle(Walk)
                    setMotion(MoveTo 340 154)
                )
                (send gEgo:setMotion(MoveTo 330 144 self))
            )
            (case 46
                localproc_114c()
                proc0_3()
                (send global2:newRoom(86))
            )
        )
    )


    (method (handleEvent pEvent)
        (var temp0)
        (super:handleEvent(pEvent))
        (if (== (send pEvent:type) 4)
            (switch ((send pEvent:message))
                (case 13
                    (if ((((== (send global2:picture) 83) and (> (send gEgo:x) 0)) or ((== (send global2:picture) 1) and (> (send gEgo:x) 123))) or ((== (send global2:picture) 53) and (< (send gEgo:x) 320)))
                        (send pEvent:claimed(1))
                        (send global2:newRoom(86))
                    )(else
                        (send pEvent:claimed(1))
                    )
                )
                (case 15360
                    (if (GetMenu(1282 113))
                        DoSound(sndSET_SOUND 0)
                        SetMenu(1282 113 0 110 "Turn on")
                    )(else
                        DoSound(sndSET_SOUND 1)
                        SetMenu(1282 113 1 110 "Turn off")
                    )
                )
                (case 22
                    = temp0 (send ((Gauge:new())):
                            description("Use the mouse or right and left arrow keys to set the sound volume.")
                            text("Sound Volume")
                            minimum(0)
                            normal(12)
                            maximum(15)
                            higher("Louder")
                            lower("Softer")
                            doit(DoSound(sndVOLUME))
                        )
                    DoSound(sndVOLUME temp0)
                    DisposeScript(987)
                )
                (case 16640
                    SetCursor(gCursorNumber 1)
                    (send gGame:restore())
                )
                (default 
                    (send pEvent:claimed(1))
                )
            )
        )
    )

)
(instance gate of Actor
    (properties
        x 160
        y 80
        view 201
    )
)
(instance guard1 of Actor
    (properties
        x 136
        y 92
        description 4930
        view 185
        loop 4
    )
)
(instance guard2 of RPicView
    (properties
        x 197
        y 92
        description 4930
        view 186
        loop 4
    )
)
(instance king of Prop
    (properties
        x 80
        y 119
        view 190
        loop 2
    )
)
(instance talkingHead of Prop
    (properties
        x 66
        y 87
        view 190
        loop 1
    )

    (method (doVerb)
    )

)
(instance gramHead of Prop
    (properties
        view 5
        loop 2
        cycleSpeed 1
    )

    (method (doVerb)
    )

)
(instance urn of RPicView
    (properties
        x 34
        y 103
        description 4976
        view 267
    )
)
(instance urn1 of RPicView
    (properties
        x 35
        y 103
        description 4976
        view 267
    )
)
(instance urn2 of RPicView
    (properties
        x 292
        y 103
        description 4976
        view 267
    )
)
(instance guardFace of Prop
    (properties
        view 185
        loop 5
        cycleSpeed 1
    )
)
