(version 2)
(include "sci.sh")
(exports
    0 rm53
)
(use "Main")
(use "Class_255_0")
(use "n958")
(use "StopWalk")
(use "DPath")
(use "Grooper")
(use "Cycle")
(use "Game")
(use "PicView")
(use "Obj")
(script 53)



(procedure (localproc_1d14)
    proc0_7()
    (if (gTheNewDialog)
        (send gTheNewDialog:dispose())
    )
)


(instance public rm53 of Rm
    (properties
        picture 54
        horizon 102
    )

    (method (init)
        (self:style(4))
        Load(rsSOUND 101)
        proc958_0(129 53 54 99)
        proc958_0(128 46 82 253 255 5 0 553 191 190 194 192 49)
        (super:init())
        (send gEgo:
            posn(262 187)
            loop(3)
            init()
        )
        proc0_1()
        (self:setScript(endCartoon))
    )

)
(instance endCartoon of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                proc255_0(53 0 67 -1 20 70 280 30 1 94)
                (send gEgo:
                    view(82)
                    loop(0)
                    cel(0)
                )
                (head:
                    posn(+ (send gEgo:x) 1 - (send gEgo:y) 38)
                    setLoop(1)
                    cel(3)
                    cycleSpeed(2)
                    init()
                    setCycle(End)
                )
                = seconds 6
            )
            (case 1
                localproc_1d14()
                (head:hide())
                (send gEgo:
                    view(46)
                    cycleSpeed(0)
                    setStep(3 3)
                    setCycle(Walk)
                    setLoop(0)
                    setMotion(MoveTo 158 102 self)
                )
            )
            (case 2
                proc255_0(53 1 67 -1 130 70 280 30 1 94)
                (send gEgo:
                    view(82)
                    loop(0)
                    cel(1)
                )
                (head:
                    posn(+ (send gEgo:x) 1 - (send gEgo:y) 38)
                    setLoop(2)
                    cel(4)
                    show()
                    setCycle(End)
                )
                = seconds 6
            )
            (case 3
                localproc_1d14()
                (head:dispose())
                (send gEgo:
                    view(46)
                    setLoop(0)
                    cycleSpeed(1)
                    moveSpeed(1)
                    setCycle(Walk)
                    setMotion(MoveTo 83 57 self)
                )
            )
            (case 4
                proc255_0(53 2 67 -1 130 70 280 30 1 94)
                = seconds 6
            )
            (case 5
                localproc_1d14()
                (send gEgo:
                    view(46)
                    cycleSpeed(0)
                    moveSpeed(0)
                    setLoop(0)
                    setCycle(Walk)
                    setMotion(MoveTo -10 34 self)
                )
            )
            (case 6
                (send global2:
                    picture(53)
                    style(2)
                    drawPic(53)
                )
                (send gEgo:
                    posn(330 144)
                    loop(1)
                )
                (king:init())
                (doctor:init())
                (rs1and2Body:init())
                (rs2Arm:
                    init()
                    setCycle(Fwd)
                )
                (rs2Head:init())
                (rs1Head:init())
                (crowd1:init())
                (send gAddToPics:
                    add(crowd2 crowd2Part1)
                    eachElementDo(#init)
                    doit()
                )
                (crowd3:init())
                (crowd1Head1:init())
                (crowd1Head2:init())
                (crowd1Head3:init())
                (crowd1Head4:init())
                (crowd2Head1:init())
                (crowd2Head2:init())
                (crowd2Head3:init())
                (crowd3Head1:init())
                (self:cue())
                proc0_1()
            )
            (case 7
                (head:
                    view(192)
                    posn(+ (doctor:x) 1 - (doctor:y) 38)
                    loop(9)
                    setPri(9)
                    cycleSpeed(1)
                    setCycle(Fwd)
                    init()
                )
                proc255_0(53 3 67 -1 20 70 280 30 1 94)
                = seconds 6
            )
            (case 8
                localproc_1d14()
                proc255_0(53 4 67 -1 115 70 280 30 1 94)
                = seconds 9
            )
            (case 9
                localproc_1d14()
                (head:hide())
                (send gEgo:
                    setCycle(StopWalk 2)
                    setMotion(MoveTo 312 144)
                )
                = seconds 3
            )
            (case 10
                (self:setScript(crowdTalk self))
                (doctor:setCycle(End))
                (send gEgo:
                    illegalBits(0)
                    setMotion(DPath 207 144 173 123 139 123 self)
                )
            )
            (case 11
                = cycles 0
            )
            (case 12
                (crowd2Head1:stopUpd())
                (crowd2Head2:stopUpd())
                (crowd2Head3:stopUpd())
                (send gEgo:
                    view(5)
                    setLoop(0)
                    setCel(0)
                    setCycle(End self)
                )
            )
            (case 13
                DisposeScript(964)
                proc255_0(53 5 67 -1 20 70 280 30 1 94)
                (gramHead:
                    init()
                    setCycle(Fwd)
                    cycleSpeed(1)
                    setPri(+ (send gEgo:priority) 1)
                )
                = seconds 5
            )
            (case 14
                (gramHead:hide())
                (king:setCycle(Beg self))
            )
            (case 15
                localproc_1d14()
                (talkingHead:
                    init()
                    startUpd()
                    setCycle(Fwd)
                    cycleSpeed(1)
                    setPri(10)
                )
                proc255_0(53 6 67 -1 20 70 280 30 1 94)
                = seconds 5
            )
            (case 16
                (talkingHead:dispose())
                (gramHead:show())
                proc255_0(53 7 67 -1 20 70 280 30 1 94)
                = seconds 4
            )
            (case 17
                localproc_1d14()
                (gramHead:dispose())
                proc255_0(53 8 67 -1 20 70 280 30 1 94)
                (send gEgo:setCycle(Beg self))
            )
            (case 18
                localproc_1d14()
                (send gEgo:
                    view(0)
                    setLoop(-1)
                    setCycle(StopWalk 2)
                    setMotion(MoveTo - (send gEgo:x) 10 + (send gEgo:y) 15 self)
                )
            )
            (case 19
                (send gEgo:setMotion(MoveTo 80 146 self))
            )
            (case 20
                (send gEgo:
                    view(49)
                    ignoreActors()
                    loop(0)
                    cel(0)
                    setCycle(CT 3 1 self)
                )
            )
            (case 21
                proc255_0(53 9 67 -1 20 70 280 30 1 94)
                = seconds 3
            )
            (case 22
                (send gAddToPics:
                    add(mirror)
                    eachElementDo(#init)
                    doit()
                )
                (send gEgo:setCycle(End self))
            )
            (case 23
                (send gEgo:
                    view(0)
                    looper(Grooper)
                    setCycle(StopWalk 2)
                    setMotion(MoveTo 104 146 self)
                )
            )
            (case 24
                localproc_1d14()
                (send gEgo:
                    view(49)
                    loop(2)
                    cel(0)
                    setCycle(CT 3 1 self)
                )
            )
            (case 25
                proc255_0(53 10 67 -1 20 70 280 30 1 94)
                = seconds 3
            )
            (case 26
                (send gAddToPics:
                    add(shield)
                    eachElementDo(#init)
                    doit()
                )
                (send gEgo:setCycle(End self))
            )
            (case 27
                (send gEgo:
                    view(0)
                    looper(Grooper)
                    setCycle(StopWalk 2)
                    setMotion(MoveTo 137 146 self)
                )
            )
            (case 28
                localproc_1d14()
                (send gEgo:
                    view(49)
                    loop(1)
                    cel(0)
                    setCycle(CT 4 1 self)
                )
            )
            (case 29
                proc255_0(53 11 67 -1 20 70 280 30 1 94)
                = seconds 3
            )
            (case 30
                (send gAddToPics:
                    add(chest)
                    eachElementDo(#init)
                    doit()
                )
                (send gEgo:setCycle(End self))
            )
            (case 31
                localproc_1d14()
                (send gEgo:
                    view(0)
                    ignoreActors(0)
                    looper(Grooper)
                    setCycle(StopWalk 2)
                    setMotion(MoveTo 139 123 self)
                )
            )
            (case 32
                (send gEgo:
                    view(5)
                    setLoop(0)
                    setCel(0)
                    setCycle(End self)
                )
            )
            (case 33
                localproc_1d14()
                (king:
                    cycleSpeed(2)
                    setCycle(End self)
                )
            )
            (case 34
                (king:
                    view(191)
                    setLoop(0)
                    setCycle(Fwd)
                    moveSpeed(2)
                    setMotion(MoveTo 98 118 self)
                )
            )
            (case 35
                (king:setMotion(MoveTo 127 127 self))
            )
            (case 36
                (king:
                    view(191)
                    cycleSpeed(1)
                    loop(1)
                    cel(0)
                    setPri(9)
                    setCycle(CT 3 1 self)
                )
            )
            (case 37
                (king:
                    cel(4)
                    setCycle(End)
                )
                (crown:
                    init()
                    view(194)
                    setLoop(0)
                    cel(0)
                    posn(160 115)
                    setCycle(Fwd)
                    setMotion(MoveTo 180 127 self)
                )
            )
            (case 38
                (crown:
                    setCel(0)
                    setCycle(0)
                )
                (rs1and2Body:setCel(1))
                (rs2Arm:
                    stopUpd()
                    hide()
                )
                (rs2Head:hide())
                (rs1Head:hide())
                (crowd1:setCel(1))
                (crowd1Head1:hide())
                (crowd1Head2:hide())
                (crowd1Head3:hide())
                (crowd1Head4:hide())
                (crowd3:setCel(1))
                (crowd3Head1:hide())
                (send gEgo:setCycle(Beg))
                (doctor:
                    setLoop(1)
                    setCycle(Walk)
                    setMotion(MoveTo 98 112 self)
                )
            )
            (case 39
                (send gEgo:
                    view(2)
                    loop(2)
                )
                (doctor:
                    moveSpeed(0)
                    setStep(4 2)
                    setMotion(MoveTo 127 121 self)
                )
            )
            (case 40
                (doctor:setMotion(MoveTo 160 121 self))
            )
            (case 41
                localproc_1d14()
                (doctor:
                    setLoop(2)
                    setStep(3 2)
                    setCycle(End)
                )
                (king:
                    view(193)
                    setLoop(3)
                    cycleSpeed(1)
                    setCycle(End self)
                )
            )
            (case 42
                (talkingHead:
                    view(193)
                    loop(1)
                    cel(0)
                    description("king")
                    init()
                    x(+ (king:x) 33)
                    y(- (king:y) 9)
                    setPri(+ (king:priority) 1)
                    setCycle(Fwd)
                )
                = cycles 1
            )
            (case 43
                proc255_0(53 12 67 -1 20 70 280 30 1 94)
                = seconds 12
            )
            (case 44
                localproc_1d14()
                proc255_0(53 13 67 -1 20 70 280 30 1 94)
                = seconds 6
            )
            (case 45
                localproc_1d14()
                (talkingHead:dispose())
                (king:
                    cycleSpeed(0)
                    setCycle(Beg self)
                )
            )
            (case 46
                (king:
                    setLoop(0)
                    setCel(0)
                    setCycle(0)
                    stopUpd()
                )
                = seconds 2
            )
            (case 47
                (doctor:setCycle(Beg self))
            )
            (case 48
                localproc_1d14()
                (head:
                    posn(+ (doctor:x) 1 - (doctor:y) 38)
                    show()
                    setCycle(Fwd)
                )
                proc255_0(53 14 67 -1 20 70 280 30 1 94)
                = seconds 5
            )
            (case 49
                localproc_1d14()
                (head:hide())
                (doctor:
                    setLoop(1)
                    ignoreActors()
                    illegalBits(0)
                    setCycle(Walk)
                    setMotion(MoveTo 173 121 self)
                )
                (rs1and2Body:setCel(0))
                (rs2Arm:
                    show()
                    setCycle(0)
                )
                (rs2Head:show())
                (rs1Head:show())
                (crowd1:setCel(0))
                (crowd1Head1:show())
                (crowd1Head2:show())
                (crowd1Head3:show())
                (crowd1Head4:show())
                (crowd3:setCel(0))
                (crowd3Head1:show())
            )
            (case 50
                (doctor:setMotion(MoveTo 180 127 self))
            )
            (case 51
                (doctor:
                    setLoop(2)
                    setCycle(End self)
                )
            )
            (case 52
                (crown:dispose())
                (doctor:
                    setLoop(3)
                    setCycle(End self)
                )
            )
            (case 53
                (send gEgo:
                    view(5)
                    loop(1)
                    setCycle(End)
                )
                (doctor:
                    setLoop(4)
                    setCycle(Walk)
                    setMotion(DPath 173 121 168 123 161 123 self)
                )
            )
            (case 54
                (self:setScript(endSongScript))
                (doctor:hide())
                (send gEgo:
                    view(192)
                    loop(5)
                    cel(0)
                    setCycle(End self)
                )
            )
            (case 55
                localproc_1d14()
                (head:
                    posn(+ (send gEgo:x) 22 - (send gEgo:y) 39)
                    setLoop(8)
                    setCycle(Fwd)
                    show()
                )
                proc255_0(53 15 67 -1 20 70 280 30 1 94)
                (rs2Arm:
                    show()
                    setCycle(Fwd)
                )
                = seconds 4
            )
            (case 56
                localproc_1d14()
                (head:dispose())
                proc255_0(53 16 67 -1 20 70 280 30 1 94)
                = seconds 4
            )
            (case 57
                localproc_1d14()
                (doctor:
                    setLoop(2)
                    cel(0)
                    show()
                    setCycle(End)
                )
                (send gEgo:
                    setLoop(6)
                    setCycle(End)
                )
                = seconds 2
            )
            (case 58
                (send gCast:eachElementDo(#dispose))
                (send global2:drawPic(99 8))
                (self:cue())
            )
            (case 59
                proc255_0(53 17 94)
                = register 1
            )
            (case 60
                proc255_0(53 18 94)
                = register 1
            )
            (case 61
                proc255_0(53 19 94)
                = register 1
            )
            (case 62
                proc0_3()
                (send global2:newRoom(85))
                (self:dispose())
            )
        )
    )


    (method (handleEvent pEvent)
        (super:handleEvent(pEvent))
        (if ((== (send pEvent:type) 1) or ((== (send pEvent:type) 4) and (== (send pEvent:message) 13)))
            (if (gTheNewDialog)
                proc0_7()
                (send gTheNewDialog:dispose())
                (if (seconds)
                    = seconds 0
                    = cycles 1
                )
                (if (register)
                    = register 0
                    = cycles 1
                )
            )
            (send pEvent:claimed(1))
        )
    )

)
(instance crowdTalk of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                localproc_1d14()
                proc255_0(53 20 67 208 24 94)
                = seconds 2
            )
            (case 1
                localproc_1d14()
                proc255_0(53 21 67 200 24 94)
                = seconds 2
            )
            (case 2
                localproc_1d14()
                proc255_0(53 22 67 208 24 94)
                = seconds 2
            )
            (case 3
                localproc_1d14()
                proc255_0(53 23 67 208 24 94)
                = seconds 3
            )
            (case 4
                localproc_1d14()
                proc255_0(53 24 67 208 24 94)
                = seconds 2
            )
            (case 5
                localproc_1d14()
                proc255_0(53 25 67 208 24 94)
                = seconds 2
            )
            (case 6
                localproc_1d14()
                (self:dispose())
            )
        )
    )

)
(instance endSongScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send (ScriptID(0 23)):loop(1))
                = cycles 1
            )
            (case 1
                (send (ScriptID(0 23)):
                    number(101)
                    play(self)
                )
            )
            (case 2
                (send (ScriptID(0 23)):
                    number(102)
                    play(self)
                )
            )
            (case 3
                (send (ScriptID(0 23)):
                    number(103)
                    play(self)
                )
            )
            (case 4
                (self:changeState(2))
            )
        )
    )

)
(instance head of Prop
    (properties
        view 82
    )
)
(instance shield of PicView
    (properties
        x 90
        y 146
        view 553
        loop 2
        signal $0001
    )
)
(instance chest of PicView
    (properties
        x 120
        y 146
        view 553
    )
)
(instance mirror of PicView
    (properties
        x 60
        y 146
        view 553
        loop 1
    )
)
(instance rs1and2Body of View
    (properties
        x 297
        y 128
        description 7534
        view 255
        signal $0004
    )
)
(instance rs2Arm of Prop
    (properties
        x 298
        y 97
        description 7560
        view 255
        loop 1
        priority 10
        signal $0014
    )
)
(class TurnHead of Prop
    (properties
        x 0
        y 0
        z 0
        heading 0
        noun 0
        nsTop 0
        nsLeft 0
        nsBottom 0
        nsRight 0
        description 7571
        sightAngle 90
        closeRangeDist 50
        longRangeDist 100
        shiftClick -32767
        contClick 7
        actions 0
        control 0
        verbChecks1 -17483
        verbChecks2 -17477
        verbChecks3 -17477
        yStep 2
        view 255
        loop 0
        cel 2
        priority 10
        underBits 0
        signal $0014
        lsTop 0
        lsLeft 0
        lsBottom 0
        lsRight 0
        brTop 0
        brLeft 0
        brBottom 0
        brRight 0
        palette 0
        cycleSpeed 0
        script 0
        cycler 0
        timer 0
    )

    (method (doit)
        (super:doit())
        (if (((< (+ x 8) (send gEgo:x)) and (< (send gEgo:x) 310)) and (<> cel 0))
            (self:setCycle(Beg self))
        )(else
            (if ((((< (- x 8) (send gEgo:x)) and (< (send gEgo:x) (+ x 8))) and (< (send gEgo:x) 310)) and (<> cel 1))
                = cel 1
            )(else
                (if (((< (send gEgo:x) (- x 8)) and (< (send gEgo:x) 310)) and (<> cel 2))
                    (self:setCycle(End self))
                )
            )
        )
    )


    (method (cue)
        (self:stopUpd())
    )

)
(instance rs1Head of TurnHead
    (properties
        x 289
        y 86
        loop 2
    )
)
(instance rs2Head of TurnHead
    (properties
        x 305
        y 93
        loop 3
    )
)
(instance crowd1 of View
    (properties
        x 240
        y 136
        description 7610
        view 255
        loop 4
        signal $0004
    )
)
(instance crowd1Head1 of TurnHead
    (properties
        x 210
        y 93
        loop 5
    )
)
(instance crowd1Head2 of TurnHead
    (properties
        x 272
        y 99
        loop 8
    )
)
(instance crowd1Head3 of TurnHead
    (properties
        x 250
        y 92
        loop 7
    )
)
(instance crowd1Head4 of TurnHead
    (properties
        x 233
        y 98
        loop 6
    )
)
(instance crowd2 of PicView
    (properties
        x 253
        y 185
        description 7610
        view 253
    )
)
(instance crowd2Part1 of PicView
    (properties
        x 303
        y 175
        description 7610
        view 253
        cel 1
    )
)
(instance crowd2Head1 of TurnHead
    (properties
        x 244
        y 147
        loop 11
        priority 15
        signal $4014
    )
)
(instance crowd2Head2 of TurnHead
    (properties
        x 263
        y 144
        loop 12
        priority 14
        signal $4014
    )
)
(instance crowd2Head3 of TurnHead
    (properties
        x 303
        y 138
        loop 13
        priority 13
        signal $4014
    )
)
(instance crowd3 of View
    (properties
        x 264
        y 122
        description 7610
        view 255
        loop 9
        signal $0004
    )
)
(instance crowd3Head1 of TurnHead
    (properties
        x 266
        y 83
        loop 10
    )
)
(instance gramHead of Prop
    (properties
        x 136
        y 95
        view 5
        loop 2
        signal $0004
    )

    (method (doVerb)
    )

)
(instance king of Actor
    (properties
        x 81
        y 118
        view 190
        loop 2
        cel 2
        priority 7
        signal $0014
    )
)
(instance talkingHead of Prop
    (properties
        x 65
        y 88
        description 7469
        view 190
        loop 1
    )

    (method (doVerb)
    )

)
(instance crown of Actor
    (properties)
)
(instance doctor of Actor
    (properties
        x 94
        y 112
        view 192
        signal $0004
    )
)
