(version 2)
(include "sci.sh")
(exports
    0 rm77
)
(use "Main")
(use "Class_255_0")
(use "NewFeature")
(use "n958")
(use "Cycle")
(use "Game")
(use "User")
(use "PicView")
(use "Obj")
(script 77)


(local
    local0

)
(procedure (localproc_18b4)
    (if (== (poofAway:caller) scared)
        (send (ScriptID(0 21)):
            number(27)
            loop(1)
            play()
        )
    )
)


(instance public rm77 of Rm
    (properties
        picture 77
        east 76
        west 78
    )

    (method (init)
        proc958_0(128 170 171 172 174 173 179 178)
        proc958_0(132 66 48)
        (self:style(
            (switch (gGNumber)
                (case west
                    3
                )
                (case east
                    2
                )
            )
))
        (super:init())
        = local0 0
        (switch (gGNumber)
            (case east
                (if (not proc0_12(7))
                    (send gEgo:setScript(
                        (if (proc0_12(103))
                            danceFever
                        )(else
                            (if ((send gEgo:has(6)))
                                scared
                            )(else
                                danceFever
                            )
                        )
))
                )
                (send gEgo:posn(315 proc0_17(187 (send gEgo:y) 173)))
            )
            (case west
                (send gEgo:posn(3 proc0_17(187 (send gEgo:y) 175)))
            )
            (default 
                (send gEgo:posn(150 180))
            )
        )
        (send gEgo:init())
        proc0_1()
        (if (not (send gEgo:has(16)))
            (shield:
                init()
                stopUpd()
            )
        )
        (if (proc0_12(14))
            (sceptre:
                init()
                stopUpd()
            )
        )
        (log1:init())
        (log2:init())
        (log3:init())
        (log4:init())
        (log5:init())
        (log6:init())
    )


    (method (doit)
        (var temp0)
        (if (script)
            (send script:doit())
        )(else
            = temp0 
                (switch ((send ((User:alterEgo)):edgeHit))
                    (case 1
                        north
                    )
                    (case 2
                        east
                    )
                    (case 3
                        south
                    )
                    (case 4
                        west
                    )
                )
            (if (temp0)
                (self:newRoom((= temp0 
                        (switch ((send ((User:alterEgo)):edgeHit))
                            (case 1
                                north
                            )
                            (case 2
                                east
                            )
                            (case 3
                                south
                            )
                            (case 4
                                west
                            )
                        )
)))
            )
        )
    )


    (method (dispose)
        proc0_10(7)
        (super:dispose())
    )


    (method (handleEvent pEvent)
        (if ((send pEvent:claimed))
            return 
        )(else
            (if (Said('get,get,get,move,move,lift/carpet,carpet') or Said('look,look<below/carpet,carpet'))
                proc255_0(77 0)
            )(else
                (if (Said('sit[<on,in,down][/throne]'))
                    (if (proc0_12(14))
                        proc255_0(77 1)
                    )(else
                        proc255_0(77 2)
                    )
                )(else
                    (if (Said('eat,consume/mushroom'))
                        (if ((send gEgo:has(19)))
                            proc255_0(77 3)
                        )(else
                            proc0_6()
                        )
                    )(else
                        (if (((((Said('look,look/carpet,carpet') or proc0_14(pEvent 152 112 186 161)) or proc0_14(pEvent 186 131 194 161)) or proc0_14(pEvent 143 131 151 161)) or proc0_14(pEvent 193 148 199 161)) or proc0_14(pEvent 137 149 142 161))
                            proc255_0(77 4)
                        )(else
                            (if (Said('look,look/throne') or proc0_14(pEvent 148 85 192 112))
                                (if ((send gCast:contains(king)))
                                    (if (<> (king:view) 171)
                                        proc255_0(77 5)
                                    )
                                )(else
                                    (if (proc0_12(14))
                                        proc255_0(77 6)
                                    )(else
                                        proc255_0(77 7)
                                    )
                                )
                            )(else
                                (if (Said('look,look/scepter') or proc255_5(sceptre pEvent 3))
                                    (if ((send gEgo:has(12)))
                                        (send pEvent:claimed(0))
                                    )(else
                                        (if (not proc0_12(14))
                                            proc255_0(77 8)
                                        )(else
                                            (if ((send gEgo:inRect(151 110 177 115)))
                                                proc255_0(77 9)
                                            )(else
                                                proc255_0(77 10)
                                            )
                                        )
                                    )
                                )(else
                                    (if (Said('look,look/shield') or proc255_5(shield pEvent 3))
                                        (if ((send gEgo:has(16)))
                                            (send pEvent:claimed(0))
                                        )(else
                                            (if ((send gEgo:inRect(180 110 210 119)))
                                                proc255_0(77 11)
                                            )(else
                                                proc255_0(77 12)
                                            )
                                        )
                                    )(else
                                        (if (Said('look,look>'))
                                            (if (Said('[<at,around][/room,cave]'))
                                                proc255_0(77 13)
                                                (if ((>= (king:signal) 2) and (<= (king:signal) 4))
                                                    (if ((send gEgo:has(16)))
                                                        proc255_0(77 14)
                                                    )(else
                                                        (if (not (send gEgo:has(16)))
                                                            proc255_0(77 15)
                                                        )
                                                    )
                                                )(else
                                                    (if (proc0_12(14) and (send gEgo:has(16)))
                                                        proc255_0(77 16)
                                                    )(else
                                                        (if (proc0_12(14) and not (send gEgo:has(16)))
                                                            proc255_0(77 17)
                                                        )(else
                                                            (if (not proc0_12(14) and not (send gEgo:has(16)))
                                                                proc255_0(77 18)
                                                            )
                                                        )
                                                    )
                                                )
                                            )(else
                                                (if (Said('/lep'))
                                                    proc255_0(77 19)
                                                )(else
                                                    (if (Said('/king,man'))
                                                        (if (not (send gCast:contains(king)))
                                                            proc255_0(77 20)
                                                        )(else
                                                            (if (== (king:view) 171)
                                                                proc255_0(77 21)
                                                            )(else
                                                                proc255_0(77 22)
                                                            )
                                                        )
                                                    )
                                                )
                                            )
                                        )(else
                                            (if ((Said('talk,speak/lep') or Said('hello')) or Said('say/hello'))
                                                (if ((send gCast:contains(king)))
                                                    proc255_0(77 23)
                                                )(else
                                                    proc255_0(77 24)
                                                )
                                            )(else
                                                (if ((Said('talk,speak/king,man') or Said('hello')) or Said('say/hello'))
                                                    (if (not (send gCast:contains(king)))
                                                        proc255_0(77 25)
                                                    )(else
                                                        proc255_0(77 26)
                                                    )
                                                )(else
                                                    (if (Said('get,get/shield'))
                                                        (if ((send global2:script))
                                                            proc0_22()
                                                        )(else
                                                            (if (proc0_12(71))
                                                                proc255_0(77 27)
                                                            )(else
                                                                (if (not (send gEgo:inRect(180 110 210 119)))
                                                                    proc0_4()
                                                                )(else
                                                                    proc255_0(77 28)
                                                                    (send (ScriptID(0 21)):
                                                                        number(66)
                                                                        play()
                                                                    )
                                                                    (send gEgo:
                                                                        loop(3)
                                                                        setMotion(0)
                                                                        get(16)
                                                                    )
                                                                    proc0_19(71 8)
                                                                    (shield:dispose())
                                                                )
                                                            )
                                                        )
                                                    )(else
                                                        (if (Said('get,get/scepter'))
                                                            (if ((send global2:script))
                                                                proc0_22()
                                                            )(else
                                                                (if (proc0_12(72))
                                                                    proc255_0(77 27)
                                                                )(else
                                                                    (if (not proc0_12(14))
                                                                        proc255_0(77 29)
                                                                    )(else
                                                                        (if (not (send gEgo:inRect(151 110 177 115)))
                                                                            proc0_4()
                                                                        )(else
                                                                            (send (ScriptID(0 21)):
                                                                                number(105)
                                                                                loop(1)
                                                                                init()
                                                                                play()
                                                                            )
                                                                            proc255_0(77 30)
                                                                            (send gEgo:
                                                                                loop(3)
                                                                                setMotion(0)
                                                                                get(12)
                                                                            )
                                                                            proc0_11(14)
                                                                            proc0_19(72 6)
                                                                            (sceptre:dispose())
                                                                        )
                                                                    )
                                                                )
                                                            )
                                                        )(else
                                                            (if (Said('kill,shoot,capture/king'))
                                                                (if ((send gCast:contains(king)))
                                                                    proc255_0(77 31)
                                                                )(else
                                                                    (send pEvent:claimed(0))
                                                                    (super:handleEvent(pEvent))
                                                                )
                                                            )(else
                                                                (if (((== (send pEvent:type) 1) and (& (send pEvent:modifiers) $0003)) and (& OnControl(2 (send pEvent:x) (send pEvent:y)) $a000))
                                                                    proc255_0(77 32)
                                                                )(else
                                                                    (if (Said('/stalactite,stalactite>'))
                                                                        (if (Said('get,bend'))
                                                                            proc255_0(77 33)
                                                                        )(else
                                                                            (if (Said('look,look'))
                                                                                proc255_0(77 32)
                                                                            )
                                                                        )
                                                                    )
                                                                )
                                                            )
                                                        )
                                                    )
                                                )
                                            )
                                        )
                                    )
                                )
                            )
                        )
                    )
                )
            )
        )
    )

)
(instance danceFever of Script
    (properties)

    (method (doit)
        (super:doit())
        (if (< local0 (send (ScriptID(0 21)):prevSignal))
            = local0 (send (ScriptID(0 21)):prevSignal)
            (send (ScriptID(0 21)):prevSignal(0))
            (playPoofAway:cue())
        )
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gEgo:stopUpd())
                (king:
                    init()
                    stopUpd()
                )
                (girl1:
                    init()
                    stopUpd()
                )
                (girl2:
                    init()
                    stopUpd()
                )
                (man1:
                    init()
                    stopUpd()
                )
                (man2:
                    init()
                    stopUpd()
                )
                (man3:
                    init()
                    stopUpd()
                )
                (drummer:
                    init()
                    stopUpd()
                )
                (harpist:
                    init()
                    stopUpd()
                )
                (man4:
                    init()
                    stopUpd()
                )
                = cycles 1
            )
            (case 1
                proc255_0(77 34)
                (if (>= global101 1)
                    (girl1:setCycle(Fwd))
                    (girl2:setCycle(Fwd))
                    (man1:setCycle(Fwd))
                    (man2:setCycle(Fwd))
                    (man3:setCycle(Fwd))
                    (king:setCycle(Fwd))
                    (drummer:setCycle(Fwd))
                    (harpist:setCycle(Fwd))
                )
                (send (ScriptID(0 21)):
                    number(48)
                    loop(1)
                    init()
                    play()
                )
                (if (>= global101 1)
                    (man4:setCycle(End self))
                )(else
                    (self:cue())
                )
            )
            (case 2
                (if (>= global101 1)
                    (man4:
                        loop(0)
                        cel(0)
                        setCycle(Fwd)
                    )
                    = seconds 3
                )(else
                    (self:cue())
                )
            )
            (case 3
                (self:setScript(playPoofAway self))
            )
            (case 4
                (if (gTheNewDialog)
                    (send gTheNewDialog:dispose())
                )
                (poof:dispose())
                proc0_10(14)
                (sceptre:init())
                (king:
                    setCycle(Fwd)
                    setLoop(2)
                    setMotion(MoveTo 178 120 self)
                )
            )
            (case 5
                (king:setMotion(MoveTo 152 160 self))
            )
            (case 6
                (king:setMotion(MoveTo 174 176 self))
            )
            (case 7
                proc0_3()
                (king:setMotion(MoveTo 104 186 self))
            )
            (case 8
                (king:setMotion(MoveTo -10 173 self))
            )
            (case 9
                (king:dispose())
                (self:dispose())
            )
        )
    )

)
(instance scared of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send gEgo:stopUpd())
                (king:
                    view(170)
                    loop(0)
                    cel(0)
                    init()
                    stopUpd()
                )
                (girl1:
                    loop(2)
                    cel(0)
                    init()
                    stopUpd()
                )
                (girl2:
                    loop(2)
                    cel(1)
                    init()
                    stopUpd()
                )
                (man1:
                    loop(3)
                    cel(0)
                    init()
                    stopUpd()
                )
                (man2:
                    loop(3)
                    cel(1)
                    init()
                    stopUpd()
                )
                (man4:
                    loop(2)
                    init()
                    stopUpd()
                )
                (drummer:
                    loop(1)
                    init()
                    stopUpd()
                )
                (harpist:
                    loop(1)
                    init()
                    stopUpd()
                )
                (man3:
                    init()
                    loop(2)
                    cel(0)
                    cycleSpeed(1)
                    stopUpd()
                )
                (if (>= global101 1)
                    (man3:setCycle(End self))
                )(else
                    (self:cue())
                )
            )
            (case 1
                proc255_0(77 35)
                (self:setScript(poofAway self))
            )
            (case 2
                proc0_2()
                (if (gTheNewDialog)
                    (send gTheNewDialog:dispose())
                )
                (poof:
                    cel(0)
                    posn((king:x) (king:y))
                    setCycle(CT 7 1 self)
                )
            )
            (case 3
                (king:dispose())
                proc0_3()
                (poof:setCycle(End self))
            )
            (case 4
                (poof:dispose())
                (self:dispose())
            )
        )
    )

)
(instance poofAway of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (poof:
                    init()
                    cel(0)
                    posn((man1:x) (man1:y))
                    setCycle(CT 7 1 self)
                )
            )
            (case 1
                (man1:dispose())
                (if (== (poofAway:caller) scared)
                    (send (ScriptID(0 21)):
                        number(27)
                        init()
                        loop(1)
                        play()
                    )
                )
                (poof:setCycle(End self))
            )
            (case 2
                (poof:
                    cel(0)
                    posn((man2:x) (man2:y))
                    setCycle(CT 7 1 self)
                )
            )
            (case 3
                (man2:dispose())
                localproc_18b4()
                (poof:setCycle(End self))
            )
            (case 4
                (poof:
                    cel(0)
                    posn((man3:x) (man3:y))
                    setCycle(CT 7 1 self)
                )
            )
            (case 5
                (man3:dispose())
                localproc_18b4()
                (poof:setCycle(End self))
            )
            (case 6
                (poof:
                    cel(0)
                    posn((girl1:x) (girl1:y))
                    setCycle(CT 7 1 self)
                )
            )
            (case 7
                (girl1:dispose())
                localproc_18b4()
                (poof:setCycle(End self))
            )
            (case 8
                (poof:
                    cel(0)
                    posn((girl2:x) (girl2:y))
                    setCycle(CT 7 1 self)
                )
            )
            (case 9
                (girl2:dispose())
                localproc_18b4()
                (poof:setCycle(End self))
            )
            (case 10
                (poof:
                    cel(0)
                    posn((man4:x) (man4:y))
                    setCycle(CT 7 1 self)
                )
            )
            (case 11
                (man4:dispose())
                localproc_18b4()
                (poof:setCycle(End self))
            )
            (case 12
                (poof:
                    cel(0)
                    posn((drummer:x) (drummer:y))
                    setCycle(CT 7 1 self)
                )
            )
            (case 13
                (drummer:dispose())
                localproc_18b4()
                (poof:setCycle(End self))
            )
            (case 14
                (poof:
                    cel(0)
                    posn((harpist:x) (harpist:y))
                    setCycle(CT 7 1 self)
                )
            )
            (case 15
                (harpist:dispose())
                localproc_18b4()
                (poof:setCycle(End self))
            )
            (case 16
                proc0_3()
                (self:dispose())
            )
        )
    )

)
(instance playPoofAway of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                = cycles 0
            )
            (case 1
                proc0_2()
                (poof:
                    init()
                    cel(0)
                    posn((man1:x) (man1:y))
                    setCycle(CT 7 1 self)
                )
            )
            (case 2
                (man1:dispose())
                (poof:setCycle(End self))
            )
            (case 3
                = cycles 0
            )
            (case 4
                (poof:
                    cel(0)
                    posn((man2:x) (man2:y))
                    setCycle(CT 7 1 self)
                )
            )
            (case 5
                (man2:dispose())
                (poof:setCycle(End self))
            )
            (case 6
                = cycles 0
            )
            (case 7
                (poof:
                    cel(0)
                    posn((man3:x) (man3:y))
                    setCycle(CT 7 1 self)
                )
            )
            (case 8
                (man3:dispose())
                (poof:setCycle(End self))
            )
            (case 9
                = cycles 0
            )
            (case 10
                (poof:
                    cel(0)
                    posn((girl1:x) (girl1:y))
                    setCycle(CT 7 1 self)
                )
            )
            (case 11
                (girl1:dispose())
                (poof:setCycle(End self))
            )
            (case 12
                = cycles 0
            )
            (case 13
                (poof:
                    cel(0)
                    posn((girl2:x) (girl2:y))
                    setCycle(CT 7 1 self)
                )
            )
            (case 14
                (girl2:dispose())
                (poof:setCycle(End self))
            )
            (case 15
                = cycles 0
            )
            (case 16
                (poof:
                    cel(0)
                    posn((man4:x) (man4:y))
                    setCycle(CT 7 1 self)
                )
            )
            (case 17
                (man4:dispose())
                (poof:setCycle(End self))
            )
            (case 18
                = cycles 0
            )
            (case 19
                (poof:
                    cel(0)
                    posn((drummer:x) (drummer:y))
                    setCycle(CT 7 1 self)
                )
            )
            (case 20
                (drummer:dispose())
                (poof:setCycle(End self))
            )
            (case 21
                = cycles 0
            )
            (case 22
                (poof:
                    cel(0)
                    posn((harpist:x) (harpist:y))
                    setCycle(CT 7 1 self)
                )
            )
            (case 23
                (harpist:dispose())
                (poof:setCycle(End self))
            )
            (case 24
                proc0_3()
                (self:dispose())
            )
        )
    )

)
(instance king of Actor
    (properties
        x 168
        y 97
        view 171
        illegalBits $0000
    )

    (method (doVerb theVerb param2)
        (switch (theVerb)
            (case 1
                proc255_0(77 36)
            )
            (default 
                (super:doVerb(theVerb rest param2))
            )
        )
    )

)
(instance shield of View
    (properties
        x 196
        y 108
        view 170
        cel 1
    )

    (method (doVerb theVerb)
        (switch (theVerb)
            (case 1
                proc255_0(77 11)
            )
        )
    )

)
(instance sceptre of View
    (properties
        x 165
        y 88
        view 171
        loop 1
    )

    (method (doVerb theVerb)
        (switch (theVerb)
            (case 1
                proc255_0(77 9)
            )
        )
    )

)
(instance girl1 of Prop
    (properties
        x 41
        y 88
        description 7009
        view 172
    )
)
(instance girl2 of Prop
    (properties
        x 250
        y 131
        description 7009
        view 172
        loop 1
    )
)
(instance man1 of Prop
    (properties
        x 25
        y 86
        description 7009
        view 174
    )
)
(instance man2 of Prop
    (properties
        x 137
        y 114
        description 7009
        view 174
        loop 1
    )
)
(instance man3 of Prop
    (properties
        x 167
        y 134
        description 7009
        view 174
        loop 2
    )
)
(instance man4 of Prop
    (properties
        x 116
        y 138
        description 7009
        view 173
        loop 1
    )
)
(instance drummer of Prop
    (properties
        x 211
        y 126
        view 179
    )
)
(instance harpist of Prop
    (properties
        x 231
        y 110
        view 178
    )
)
(instance poof of Prop
    (properties
        view 170
        loop 2
    )

    (method (doVerb)
    )

)
(instance log1 of NewFeature
    (properties
        x 59
        y 54
        noun 6923
        nsTop 24
        nsLeft 54
        nsBottom 85
        nsRight 64
        description 7073
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 7077
    )
)
(instance log2 of NewFeature
    (properties
        x 101
        y 78
        noun 6923
        nsTop 54
        nsLeft 97
        nsBottom 102
        nsRight 106
        description 7073
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 7077
    )
)
(instance log3 of NewFeature
    (properties
        x 135
        y 51
        noun 6923
        nsTop 21
        nsLeft 130
        nsBottom 82
        nsRight 140
        description 7073
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 7077
    )
)
(instance log4 of NewFeature
    (properties
        x 193
        y 47
        noun 6923
        nsTop 18
        nsLeft 189
        nsBottom 77
        nsRight 198
        description 7147
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 7077
    )
)
(instance log5 of NewFeature
    (properties
        x 247
        y 68
        noun 6923
        nsTop 32
        nsLeft 241
        nsBottom 104
        nsRight 253
        description 7073
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 7077
    )
)
(instance log6 of NewFeature
    (properties
        x 299
        y 98
        noun 6923
        nsTop 80
        nsLeft 295
        nsBottom 116
        nsRight 303
        description 7073
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 7077
    )
)
