(version 2)
(include "sci.sh")
(exports
    0 rm350
    1 sekhmetTalker
)
(use "Main")
(use "TellerIcon")
(use "Blink")
(use "PolyPath")
(use "Polygon")
(use "CueObj")
(use "n958")
(use "Cycle")
(use "Game")
(use "View")
(use "Obj")
(script 350)


(local
    local0[4] = (0 -12 -13 999 )
    local4[7] = (0 -14 -15 -16 -17 -18 999 )
    local11[5]
    local16[7]
    local23
    local24
    local25
    local26
    local27
    local28
    local29
    local30
    local31
    local32

)
(instance public rm350 of Rm
    (properties
        noun 5
        picture 350
        vanishingY -35
    )

    (method (init param1)
        (send gLongSong:
            number(350)
            setLoop(-1)
            play(100)
        )
        proc0_2()
        (send global2:addObstacle((send ((Polygon:new())):
                type(3)
                init(0 189 180 189 142 159 113 164 86 142 106 139 48 90 61 90 53 80 35 80 35 53 25 53 25 82 0 82)
                yourself()
            )
))
        (if ((send gOwner:has(36)))
            (send gOwner:
                addHonor(20)
                solvePuzzle(253 10)
            )
        )
        (send gOwner:
            view(0)
            setLoop(2)
            x(27)
            y(92)
            noun(4)
            xStep(2)
            yStep(1)
            setScale(220)
            init()
            changeGait(0)
        )
        (flame1:
            setCycle(Fwd)
            init()
        )
        (flame2:
            setCycle(Fwd)
            init()
        )
        (stairs:
            setPri(10)
            init()
            stopUpd()
        )
        (if (global121)
            (nPal:init())
            (stairs:
                x(31)
                y(98)
                cel(0)
                setLoop(3)
                stopUpd()
            )
        )
        (send ((Prop:new())):
            view(350)
            loop(4)
            cel(0)
            x(248)
            y(108)
            detailLevel(3)
            priority(2)
            signal(16)
            setCycle(Fwd)
            noun(6)
            init()
        )
        (send ((Prop:new())):
            view(350)
            loop(5)
            cel(0)
            x(236)
            y(56)
            detailLevel(3)
            signal(16384)
            setCycle(Fwd)
            noun(6)
            init()
        )
        (send ((Prop:new())):
            view(350)
            loop(6)
            cel(1)
            x(155)
            y(96)
            detailLevel(3)
            setCycle(Fwd)
            noun(6)
            init()
        )
        (send ((Prop:new())):
            view(350)
            loop(7)
            cel(1)
            x(230)
            y(126)
            detailLevel(3)
            setCycle(Fwd)
            noun(6)
            init()
        )
        (send ((Prop:new())):
            view(350)
            loop(8)
            cel(1)
            x(131)
            y(117)
            detailLevel(3)
            setCycle(Fwd)
            noun(6)
            init()
        )
        (send ((Prop:new())):
            view(350)
            loop(9)
            cel(1)
            x(185)
            y(145)
            detailLevel(3)
            setCycle(Fwd)
            noun(6)
            init()
        )
        (send ((Prop:new())):
            view(350)
            loop(10)
            cel(1)
            x(80)
            y(78)
            priority(5)
            signal(16)
            detailLevel(3)
            setCycle(Fwd)
            noun(6)
            init()
        )
        (send ((Prop:new())):
            view(350)
            loop(11)
            cel(1)
            x(159)
            y(76)
            detailLevel(3)
            priority(4)
            signal(16400)
            setCycle(Fwd)
            noun(6)
            init()
        )
        (super:init(rest param1))
        (if (proc0_6(12))
            (acolyte1:
                init()
                stopUpd()
            )
            (self:setScript(letSGo))
        )(else
            (if (not proc0_6(60))
                (fTable:init())
                (pan:init())
                (statue:init())
                (hieroglyphics:init())
                (doorway:init())
                (leftfire:init())
                (rightfire:init())
                (tent:init())
                = local11[0] @local0
                = local16[0] @local4
                (send gQg3Walkers:addToFront(self))
                (priestess:
                    noun(2)
                    init()
                    setLoop(0)
                    stopUpd()
                )
                (send gOwner:code(checkCode))
                (self:setScript(sEnter))
            )(else
                (if ((send gOwner:has(36)))
                    (acolyte1:
                        init()
                        stopUpd()
                    )
                    (acolyte2:
                        init()
                        setPri(12)
                        stopUpd()
                    )
                    (priestess:
                        init()
                        x(107)
                        y(176)
                        stopUpd()
                    )
                    (chalice:
                        init()
                        stopUpd()
                    )
                    (send global2:addObstacle((send ((Polygon:new())):
                            type(2)
                            init(49 123 71 118 88 128 59 134)
                            yourself()
                        )
))
                    (send gOwner:useSkill(14 20))
                    (self:setScript(sEnter))
                )(else
                    (acolyte1:
                        init()
                        stopUpd()
                    )
                    (acolyte2:
                        init()
                        setPri(12)
                        stopUpd()
                    )
                    (self:setScript(sEnter))
                )
            )
        )
    )


    (method (dispose)
        (super:dispose())
        proc958_0(0 48)
        (send gQg3Walkers:delete(self))
    )


    (method (doVerb theVerb)
        (switch (theVerb)
            (case 3
                (if (local23)
                    (send global2:setScript(priestessShow))
                )(else
                    = local28 (send ((send gUser:curEvent)):x)
                    = local29 (send ((send gUser:curEvent)):y)
                    (send gOwner:setMotion(PolyPath local28 local29 priestess))
                )
            )
            (default 
                (super:doVerb(theVerb))
            )
        )
    )

)
(instance priestTalk of Script
    (properties)

    (method (doit)
        (super:doit())
        (if (not state and (< (priestess:distanceTo(gOwner)) 23))
            (priestess:setMotion(0))
            (self:cue())
        )
        (if ((== state 5) and (send gOwner:mover))
            (send gOwner:setMotion(0))
            (self:cue())
        )
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (egoTell:init(gOwner @local0 @local11))
                (priestessTell:init(priestess @local4 @local16))
                (send gOwner:code(0))
                (if (> (send gOwner:y) 147)
                    (send gOwner:setMotion(PolyPath 87 145 self))
                )(else
                    (send gOwner:setMotion(0))
                    = cycles 5
                )
            )
            (case 1
                proc0_12(gOwner priestess)
                (priestess:
                    setLoop(5)
                    moveSpeed(3)
                    cycleSpeed(3)
                    setCycle(Walk)
                    setStep(1 1)
                    setMotion(MoveTo 110 168 self)
                )
            )
            (case 2
                (priestess:
                    setLoop(0)
                    cel(0)
                    setCycle(End self)
                )
            )
            (case 3
                (send gQg3Messager:say(2 6 2 0 self))
            )
            (case 4
                (priestess:setCycle(CT 0 -1 self))
            )
            (case 5
                proc0_3(5 6 6)
                = seconds 5
            )
            (case 6
                (send global2:setScript(priestessShow))
            )
        )
    )

)
(instance priestessShow of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send gQg3Messager:say(2 6 3 0 self))
            )
            (case 1
                proc0_2()
                (priestess:
                    setLoop(1)
                    setCel(4)
                    setCycle(CT 0 -1 self)
                )
            )
            (case 2
                (send gQg3Messager:say(3 6 4 0 self))
            )
            (case 3
                (priestess:
                    cycleSpeed(6)
                    setLoop(1)
                    setCel(0)
                    setCycle(End self)
                )
            )
            (case 4
                proc0_4(60)
                (send global2:setScript(stepDown 0 1))
            )
        )
    )

)
(instance stepDown of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (if (register)
                    (send gOwner:setMotion(PolyPath 30 78 self))
                )(else
                    (self:cue())
                )
            )
            (case 1
                (acolyte2:setPri(10))
                (stairs:setPri(10))
                (send gOwner:setMotion(MoveTo (send gOwner:x) 76 self))
            )
            (case 2
                (send gOwner:
                    setLoop(3)
                    setMotion(MoveTo (send gOwner:x) + (send gOwner:y) 15 self)
                )
            )
            (case 3
                (send gOwner:setLoop(-1))
                (send global2:newRoom(320))
            )
        )
    )

)
(instance WestOut of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send gQg3Messager:say(4 3 19 0 self))
            )
            (case 1
                (send gOwner:setMotion(PolyPath (+ (send gOwner:x) 5) 
                    (if (> (send gOwner:y) 177)
                        (- (send gOwner:y) 5)
                    )(else
                        (send gOwner:y)
                    )
 self))
            )
            (case 2
                proc0_3(5 6 6)
                (self:dispose())
            )
        )
    )

)
(instance SouthOut of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send gQg3Messager:say(4 3 20 0 self))
            )
            (case 1
                (send gOwner:setMotion(PolyPath 
                    (if (< (send gOwner:x) 5)
                        (+ (send gOwner:x) 5)
                    )(else
                        (send gOwner:x)
                    )
 (- (send gOwner:y) 5) self))
            )
            (case 2
                proc0_3(5 6 6)
                (self:dispose())
            )
        )
    )

)
(instance sEnter of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                = local26 GetTime()
                = cycles 1
            )
            (case 1
                = cycles 5
            )
            (case 2
                = local27 GetTime()
                = local25 (- local27 local26)
                (send gOwner:setMotion(MoveTo 29 75 self))
            )
            (case 3
                (send gOwner:
                    setLoop(-1)
                    setMotion(MoveTo 33 78 self)
                )
                (stairs:setPri(0))
                (acolyte2:setPri(8))
            )
            (case 4
                (send gOwner:setMotion(MoveTo 36 82 self))
            )
            (case 5
                (send gOwner:normalize())
                (if (not proc0_6(60))
                    (send gQg3Messager:say(1 6 1 0 self))
                )(else
                    (if ((send gOwner:has(36)))
                        (send global2:setScript(sGem))
                    )(else
                        (acolyte1:setCycle(Beg))
                        (send global2:setScript(sNoGem))
                    )
                )
            )
            (case 6
                proc0_3(5 6 6)
                (self:dispose())
            )
        )
    )

)
(instance sNoGem of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send gQg3Messager:say(1 6 5 0 self))
            )
            (case 1
                (send gOwner:setMotion(PolyPath 68 100 self))
            )
            (case 2
                (acolyte2:setCycle(Beg self))
            )
            (case 3
                (send gQg3Messager:say(1 6 6 0 self))
            )
            (case 4
                (send global2:setScript(stepDown 0 1))
            )
        )
    )

)
(instance sGem of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (acolyte1:setCycle(Beg self))
            )
            (case 1
                (send gOwner:setMotion(PolyPath (send gOwner:x) (+ (send gOwner:y) 10) self))
            )
            (case 2
                (send gQg3Messager:say(1 6 5 0 self))
            )
            (case 3
                (send gOwner:setMotion(PolyPath 92 165))
            )
            (case 4
                (send gQg3Messager:say(1 6 7 0 self))
            )
            (case 5
                (send gOwner:setMotion(PolyPath 86 171 self))
            )
            (case 6
                proc0_12(gOwner + (send gOwner:x) 10 (send gOwner:y) self)
            )
            (case 7
                (priestess:
                    loop(1)
                    setCel(0)
                    cycleSpeed(10)
                    setCycle(Beg self)
                )
            )
            (case 8
                (send gQg3Messager:say(2 6 8 0 self))
            )
            (case 9
                (priestess:
                    loop(3)
                    setCel(0)
                    cycleSpeed(12)
                    setCycle(End self)
                )
                (chalice:dispose())
            )
            (case 10
                (priestess:
                    loop(1)
                    setCel(0)
                    cycleSpeed(10)
                    setCycle(End self)
                )
            )
            (case 11
                (priestess:
                    loop(2)
                    setCel(0)
                    cycleSpeed(12)
                    setCycle(End self)
                )
            )
            (case 12
                (send gQg3Messager:say(2 6 9 0 self))
            )
            (case 13
                (send gOwner:
                    view(353)
                    loop(0)
                    setCel(0)
                    setScale(0)
                    cycleSpeed(12)
                    setCycle(End self)
                )
            )
            (case 14
                (priestess:setCycle(Beg self))
            )
            (case 15
                (send gLongSong2:stop())
                = seconds 3
            )
            (case 16
                (send gOwner:
                    loop(1)
                    setCel(0)
                    setCycle(End self)
                )
            )
            (case 17
                (send gLongSong2:
                    number(920)
                    setLoop(1)
                    play(127)
                )
                = cycles 3
            )
            (case 18
                (send gOwner:cycleSpeed(6))
                proc0_4(12)
                (send gOwner:drop(36 1))
                (send global2:newRoom(360))
            )
        )
    )

)
(instance letSGo of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send gOwner:setMotion(MoveTo 29 75 self))
            )
            (case 1
                (send gOwner:
                    setLoop(-1)
                    setMotion(MoveTo 33 78 self)
                )
                (stairs:setPri(0))
            )
            (case 2
                (acolyte1:setCycle(Beg self))
            )
            (case 3
                (send gQg3Messager:say(1 6 10 0 self))
            )
            (case 4
                (send global2:setScript(stepDown 0 1))
            )
        )
    )

)
(instance checkCode of Code
    (properties)

    (method (doit)
        (if ((send global2:script))
            0
        )(else
            (if (< (send gOwner:x) 5)
                proc0_2()
                (send global2:setScript(WestOut))
            )(else
                (if (> (send gOwner:y) 187)
                    proc0_2()
                    (send global2:setScript(SouthOut))
                )(else
                    (if (& (send gOwner:onControl()) $0010)
                        proc0_2()
                        (send global2:setScript(stepDown 0 0))
                    )(else
                        (if (((& (send gOwner:onControl()) $0008) and not local23) and not proc0_6(60))
                            proc0_2()
                            = local23 1
                            (send global2:setScript(priestTalk))
                        )
                    )
                )
            )
        )
    )

)
(instance acolyte1 of Actor
    (properties
        x 65
        y 80
        view 351
        signal $4000
    )
)
(instance acolyte2 of Actor
    (properties
        x 76
        y 128
        view 351
        loop 1
        priority 8
        signal $4010
    )

    (method (doit)
        (super:doit())
        (if (not local24 and (< (send gOwner:distanceTo(self)) 35))
            (self:setCycle(Beg sGem))
            = local24 1
        )
    )

)
(instance priestess of Actor
    (properties
        x 187
        y 243
        view 355
        signal $4000
    )

    (method (cue)
        (send gOwner:normalize())
    )

)
(instance flame1 of Prop
    (properties
        x 232
        y 106
        view 350
        detailLevel 3
    )
)
(instance flame2 of Prop
    (properties
        x 162
        y 78
        view 350
        cel 4
        priority 5
        signal $0010
        detailLevel 3
    )
)
(instance chalice of Prop
    (properties
        x 123
        y 148
        view 350
        loop 1
        priority 13
        signal $4011
    )
)
(instance stairs of View
    (properties
        x 4
        y 115
        view 350
        loop 2
        signal $4041
    )
)
(instance nPal of View
    (properties
        x 31
        y 76
        view 350
        loop 3
        cel 1
        priority 1
        signal $4011
    )
)
(instance fTable of Feature
    (properties
        x 116
        y 147
        noun 7
        nsTop 136
        nsLeft 98
        nsBottom 159
        nsRight 134
    )
)
(instance pan of Feature
    (properties
        x 207
        y 177
        noun 8
        nsTop 165
        nsLeft 197
        nsBottom 189
        nsRight 217
        approachDist 30
    )

    (method (init param1)
        (super:init(rest param1))
        (self:approachVerbs(2 4))
    )

)
(instance statue of Feature
    (properties
        x 246
        y 58
        noun 6
        nsTop 6
        nsLeft 201
        nsBottom 111
        nsRight 292
    )
)
(instance hieroglyphics of Feature
    (properties
        x 114
        y 54
        noun 9
        nsTop 39
        nsLeft 82
        nsBottom 70
        nsRight 146
    )
)
(instance doorway of Feature
    (properties
        x 32
        y 57
        noun 10
        nsTop 41
        nsBottom 74
        nsRight 64
    )
)
(instance leftfire of Feature
    (properties
        x 163
        y 86
        noun 11
        nsTop 78
        nsLeft 150
        nsBottom 95
        nsRight 177
    )
)
(instance rightfire of Feature
    (properties
        x 233
        y 116
        noun 12
        nsTop 111
        nsLeft 216
        nsBottom 121
        nsRight 251
    )
)
(instance tent of Feature
    (properties
        x 278
        y 174
        noun 13
        nsTop 161
        nsLeft 237
        nsBottom 188
        nsRight 319
    )
)
(instance egoTell of Teller
    (properties)

    (method (doChild param1)
        (if (== param1 -12)
            (send gQg3Messager:say(4 5 12 0 priestTalk))
        )(else
            (if (== param1 -13)
                (send gQg3Messager:say(4 5 13 0 priestTalk))
            )
        )
        return 0
    )

)
(instance priestessTell of Teller
    (properties)

    (method (doChild)
        (send gQg3Messager:say(2 5 11 0 priestTalk))
        (priestTalk:cycles(0))
        return 0
    )

)
(instance public sekhmetTalker of Talker
    (properties
        x 201
        y 30
        view 352
        loop 1
        signal $4000
        talkWidth 260
        color 45
        back 57
        textX -175
        textY 150
    )

    (method (init param1)
        (super:init(sekhmetBust sekhmetEye sekhmetMouth rest param1))
        = local30 0
    )


    (method (doit)
        (if (not % ++local30 40)
            (if (> ++local31 12)
                = local31 0
            )
            (flame1:cel(local31))
            (flame2:cel(local31))
            Animate((send gGQg3KDHandler:elements) 0)
        )
        (super:doit())
    )

)
(instance sekhmetEye of Prop
    (properties
        nsTop -12
        nsLeft 9
        view 352
        loop 2
        cel 3
        signal $4000
    )
)
(instance sekhmetMouth of Prop
    (properties
        nsTop 2
        nsLeft 8
        view 352
        priority 14
        signal $4010
    )
)
(instance sekhmetBust of Prop
    (properties
        view 352
        loop 3
    )
)
