(version 2)
(include "sci.sh")
(exports
    0 rm810
)
(use "Main")
(use "TargFeature")
(use "n026")
(use "JumpX")
(use "Inset")
(use "Scaler")
(use "PolyPath")
(use "Polygon")
(use "CueObj")
(use "ForwardCounter")
(use "n958")
(use "Rev")
(use "Sound")
(use "Cycle")
(use "Game")
(use "View")
(use "Obj")
(script 810)


(local
    local0
    local1
    gOwnerMoveSpeed

)
(procedure (localproc_0d92)
    (sFx:
        number(931)
        play()
    )
    (deader:
        init()
        setPri(11)
        ignoreActors(1)
        addToPic()
    )
    (switch (global448)
        (case 0
            0
        )
        (case 1
            (deader1:
                init()
                ignoreActors(1)
                addToPic()
            )
        )
        (case 2
            (deader1:
                init()
                ignoreActors(1)
                addToPic()
            )
            (deader2:
                init()
                ignoreActors(1)
                addToPic()
            )
        )
        (default 
            (deader1:
                init()
                ignoreActors(1)
                addToPic()
            )
            (deader2:
                init()
                ignoreActors(1)
                addToPic()
            )
            (deader3:
                init()
                ignoreActors(1)
                addToPic()
            )
        )
    )
    return ++global448
)


(instance public rm810 of Rm
    (properties
        noun 9
        picture 810
    )

    (method (init)
        (Scaler:backY(145))
        (send gOwner:
            x(-22)
            y(168)
            init()
            setScale(Scaler 100 50 189 125)
            normalize()
        )
        proc958_0(128 810 570 6)
        proc0_3()
        (super:init())
        (send gLongSong:
            number(810)
            setLoop(-1)
            play(127)
        )
        (send global2:addObstacle((send ((Polygon:new())):
                type(3)
                init(0 173 81 173 165 189 216 148 185 138 168 135 155 127 133 124 133 99 112 99 112 126 142 157 0 157)
                yourself()
            )
 (send ((Polygon:new())):
                type(3)
                init(148 81 212 81 212 71 148 71)
                yourself()
            )
))
        (pedestal:init())
        (stairs:init())
        (leftStairs:init())
        (ruins:init())
        (rocks:init())
        (noWayToGo:init())
        (anubisStatue:init())
        (if (not (send gOwner:has(34)) and not proc0_6(136))
            (opal:
                setPri(14)
                init()
                stopUpd()
            )
        )
        (if (proc0_6(136))
            (doorWay:
                init()
                loop(2)
                approachVerbs(4 1)
                ignoreActors(0)
            )
        )(else
            (doorWay:
                init()
                approachVerbs(4 1)
            )
        )
        (if (not (== global155 0) and (== gGClientModNum 550))
            (send gOwner:
                x(60)
                y(169)
                code(quikChek)
            )
            localproc_0d92()
        )(else
            (self:setScript(egoEnters))
        )
        (if ((== gGClientModNum 550) and (== global155 0))
            (self:setScript(egoIsDead))
        )
    )


    (method (dispose)
        (send gOwner:code(0))
        UnLoad(128 810)
        UnLoad(128 570)
        UnLoad(128 6)
        proc958_0(0 956 923 37 57)
        (if (gNewList)
            (send gNewList:eachElementDo(111))
        )
        (super:dispose())
    )


    (method (doVerb theVerb param2)
        (switch (theVerb)
            (case 81
                (send gOwner:setScript(castProj 0 theVerb))
            )
            (case 83
                (send gOwner:setScript(castProj 0 theVerb))
            )
            (case 32
                (send gOwner:setScript(castProj 0 theVerb))
            )
            (case 20
                (send gOwner:setScript(castProj 0 theVerb))
            )
            (case 65
                (send gQg3Messager:say(1 6 1))
            )
            (default 
                (super:doVerb(theVerb rest param2))
            )
        )
    )


    (method (setInset param1 param2 param3)
        (send gOwner:code(0))
        (send gMainIconBar:disable(6 1 5 3))
        (if (inset)
            (send inset:dispose())
        )
        (if (paramTotal and param1)
            (send param1:init(
                (if (>= paramTotal 2)
                    param2
                )(else
                    0
                )
 self 
                (if (>= paramTotal 3)
                    param3
                )(else
                    0
                )
))
        )
        (if (proc0_6(136))
            (opal:
                view(810)
                loop(1)
                setPri(14)
                x(158)
                y(83)
                init()
            )
        )
    )

)
(instance egoIsDead of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                = seconds 2
            )
            (case 1
                proc26_0()
            )
        )
    )

)
(instance castOpenOnDoor of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                proc0_14(125 101)
                (self:setScript(ScriptID(13 0) self))
            )
            (case 1
                (send gQg3Messager:say(1 6 6))
            )
            (case 2
                proc0_3()
                (send gOwner:normalize())
                (self:dispose())
            )
        )
    )

)
(instance egoFalls of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gOwner:
                    code(0)
                    view(35)
                    setLoop(3)
                    cel(0)
                    setCycle(CT 1 1 self)
                )
                = gOwnerMoveSpeed (send gOwner:moveSpeed)
            )
            (case 1
                (send gOwner:
                    moveSpeed(0)
                    ignoreActors(1)
                    illegalBits(0)
                    setMotion(JumpX -48 self)
                )
            )
            (case 2
                (send gOwner:
                    x(162)
                    y(131)
                    z(0)
                    setCycle(End self)
                )
            )
            (case 3
                (sFx:
                    number(920)
                    setLoop(1)
                    play()
                )
                ShakeScreen(10)
                = cycles 11
            )
            (case 4
                (send gOwner:
                    loop(5)
                    cel(0)
                    illegalBits(-32768)
                    setCycle(End self)
                )
            )
            (case 5
                (if ((send gGQg3KDHandler:contains(apeMan)) or (send gGQg3KDHandler:contains(apeMan1)))
                    = global365 575
                    = gGMonsterMonHP 180
                    (send global2:newRoom(550))
                )
                (send gOwner:
                    code(quikChek)
                    moveSpeed(gOwnerMoveSpeed)
                    normalize()
                )
                = local0 0
                proc0_3()
                (self:dispose())
            )
        )
    )

)
(instance cantExit of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gOwner:
                    setMotion(0)
                    code(0)
                )
                (apeMan1:
                    setScale(Scaler 100 50 189 125)
                    x(0)
                    y(168)
                    init()
                    setStep(4 4)
                    setCycle(Walk)
                    ignoreActors(1)
                    setMotion(MoveTo 30 168 self)
                )
            )
            (case 1
                = global365 575
                = gGMonsterMonHP 180
                (send global2:newRoom(550))
            )
        )
    )

)
(instance apeManCrossLeft of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (apeMan:
                    x(322)
                    y(79)
                    setPri(0)
                    setScale(Scaler 100 50 189 50)
                    setCycle(Walk)
                    init()
                    setStep(4 4)
                    setMotion(MoveTo 96 79 self)
                )
            )
            (case 1
                (apeMan:setHeading(180))
                = seconds 5
            )
            (case 2
                (apeMan:setMotion(MoveTo 322 79 self))
            )
            (case 3
                (apeMan:
                    setScale(189)
                    setPri(-1)
                    dispose()
                )
                (self:dispose())
            )
        )
    )

)
(instance castProj of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (self:setScript(ScriptID(32 0) self register))
            )
            (case 1
                (if ((send gGQg3KDHandler:contains(apeMan)))
                    = global365 575
                    = gGMonsterMonHP 180
                    (send global2:newRoom(550))
                )
                (send gOwner:normalize())
                proc0_3()
                (self:dispose())
            )
        )
    )

)
(instance apeManCrossRight of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (apeMan:
                    setScale(Scaler 100 50 189 125)
                    x(41)
                    y(134)
                    init()
                    setStep(4 4)
                    setCycle(Walk)
                    setMotion(MoveTo 340 162 self)
                )
            )
            (case 1
                (apeMan:dispose())
                (self:dispose())
            )
        )
    )

)
(instance climbDownPedestal of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gOwner:setMotion(MoveTo 166 70 self))
            )
            (case 1
                (sFx:
                    number(928)
                    play()
                )
                (send gOwner:
                    view(7)
                    cel(11)
                    loop(4)
                    setCycle(Beg self)
                )
            )
            (case 2
                (send gOwner:
                    code(quikChek)
                    view(7)
                    y(93)
                    setStep(2 1)
                    setLoop(3)
                    setCycle(Rev)
                    setMotion(MoveTo 162 131 self)
                )
            )
            (case 3
                (send gOwner:
                    view(5)
                    normalize()
                )
                proc0_3()
                = local0 0
                (if (not (send gGQg3KDHandler:contains(apeMan)))
                    (send global2:setScript(apeManCrossLeft))
                )(else
                    = global365 575
                    = gGMonsterMonHP 180
                    (send global2:newRoom(550))
                )
                (self:dispose())
            )
        )
    )

)
(instance climbUpPedestal of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gOwner:setMotion(PolyPath 162 131 self))
            )
            (case 1
                (send gOwner:
                    view(7)
                    setLoop(3)
                    setCycle(ForwardCounter 2 self)
                )
                (sFx:
                    number(928)
                    play()
                )
            )
            (case 2
                (send gOwner:
                    setCycle(Fwd)
                    cycleSpeed(5)
                    setStep(2 1)
                    setMotion(MoveTo 166 93 self)
                )
            )
            (case 3
                (send gOwner:
                    loop(4)
                    cel(0)
                    y(70)
                    setCycle(End self)
                )
            )
            (case 4
                (send gOwner:
                    view(13)
                    setHeading(180)
                    setCycle(End)
                )
                = seconds 3
            )
            (case 5
                (send gOwner:
                    code(fallChek)
                    setStep(3 2)
                    normalize()
                )
                = local0 1
                proc0_3()
                (if (not (send gGQg3KDHandler:contains(apeMan)))
                    (apeMan:
                        x(41)
                        y(144)
                        setScale(189)
                        init()
                        setStep(4 4)
                        setScript(apeManCrossRight)
                    )
                )
                (self:dispose())
            )
        )
    )

)
(instance egoEnters of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (apeMan:
                    setScale(Scaler 100 50 189 125)
                    init()
                    setStep(4 4)
                    setCycle(Walk)
                    setMotion(MoveTo 340 162 self)
                )
            )
            (case 1
                (apeMan:dispose())
                (send gOwner:
                    x(-20)
                    y(168)
                    setMotion(PolyPath 60 169 self)
                )
            )
            (case 2
                (if (proc0_6(150))
                    (send gQg3Messager:say(1 6 7 0 self))
                )(else
                    (self:cue())
                )
            )
            (case 3
                (send gOwner:code(quikChek))
                proc0_3()
                (self:dispose())
            )
        )
    )

)
(instance hoarkOpal of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gOwner:
                    get(34)
                    solvePuzzle(329 5 5)
                    setMotion(MoveTo 181 71 self)
                )
            )
            (case 1
                (opal:dispose())
                proc0_3()
                (self:dispose())
            )
        )
    )

)
(instance apeMan1 of Actor
    (properties
        view 570
    )
)
(instance apeMan of TargActor
    (properties
        x 41
        y 134
        view 570
    )

    (method (getHurt)
        = global365 575
        = gGMonsterMonHP 180
        (send global2:newRoom(550))
        (super:getHurt())
    )

)
(instance doorWay of View
    (properties
        x 116
        y 94
        noun 8
        nsTop 87
        nsLeft 114
        nsBottom 121
        nsRight 132
        sightAngle 40
        approachX 124
        approachY 137
        _approachVerbs 4
        view 811
        loop 1
    )

    (method (doVerb theVerb)
        (switch (theVerb)
            (case 4
                (if (== local0 0)
                    (if (not proc0_6(136))
                        (send global2:setInset(anubisInset))
                    )(else
                        (super:doVerb(theVerb))
                    )
                )(else
                    (send gQg3Messager:say(1 6 2))
                )
            )
            (case 1
                (if (== local0 0)
                    (send global2:setInset(anubisInset))
                )(else
                    (send gQg3Messager:say(1 6 3))
                )
            )
            (case 75
                (if (not (send gOwner:script))
                    (send gOwner:setScript(castOpenOnDoor))
                )
            )
            (case 45
                (if (== local0 0)
                    (send global2:setInset(anubisInset))
                )(else
                    (send gQg3Messager:say(1 6 2))
                )
            )
            (default 
                (super:doVerb(theVerb))
            )
        )
    )

)
(instance opal of View
    (properties
        x 185
        y 56
        view 811
        signal $4000
    )
)
(instance deader of View
    (properties
        x 46
        y 189
        view 572
        loop 1
    )
)
(instance deader1 of View
    (properties
        x 114
        y 86
        view 572
        loop 1
        cel 1
        scaleSignal $0001
        scaleX 81
        scaleY 81
    )
)
(instance deader2 of View
    (properties
        x 257
        y 75
        view 572
        loop 1
        cel 2
        scaleSignal $0001
        scaleX 110
        scaleY 110
    )
)
(instance deader3 of View
    (properties
        x 227
        y 172
        view 572
        loop 1
        cel 4
        scaleSignal $0001
        scaleX 111
        scaleY 111
    )
)
(instance anubisStatue of Feature
    (properties
        x 193
        y 57
        noun 2
        nsTop 46
        nsLeft 174
        nsBottom 69
        nsRight 212
        sightAngle 40
    )

    (method (doVerb theVerb)
        (switch (theVerb)
            (case 1
                (if ((send gGQg3KDHandler:contains(opal)))
                    (send gQg3Messager:say(10 1))
                )(else
                    (send gQg3Messager:say(1 6 4))
                )
            )
            (case 4
                (if (((== local0 1) and not proc0_6(136)) and not (send gOwner:has(34)))
                    (send gOwner:setScript(hoarkOpal))
                )
            )
            (case 82
                (if (not (send gOwner:has(34)))
                    (if (== local0 1)
                        (send gQg3Messager:say(1 6 5))
                    )(else
                        proc0_14(186 53)
                        (send global2:setScript(ScriptID(37 0) 0 anubisStatue))
                    )
                )
            )
            (case -82
                (opal:dispose())
                (send gOwner:
                    get(34)
                    solvePuzzle(329 5 6)
                )
            )
            (default 
                (super:doVerb(theVerb))
            )
        )
    )

)
(instance pedestal of Feature
    (properties
        x 168
        y 94
        noun 2
        nsTop 71
        nsLeft 150
        nsBottom 118
        nsRight 186
        sightAngle 40
    )

    (method (doVerb theVerb)
        (switch (theVerb)
            (case 4
                (if (== local0 0)
                    (send gOwner:setScript(climbUpPedestal))
                )(else
                    (send gOwner:setScript(climbDownPedestal))
                )
            )
            (default 
                (super:doVerb(theVerb))
            )
        )
    )

)
(instance stairs of Feature
    (properties
        x 233
        y 104
        noun 3
        nsTop 75
        nsLeft 215
        nsBottom 133
        nsRight 252
        sightAngle 180
    )
)
(instance leftStairs of Feature
    (properties
        x 73
        y 102
        noun 4
        nsTop 82
        nsLeft 53
        nsBottom 122
        nsRight 93
        sightAngle 180
    )
)
(instance ruins of Feature
    (properties
        x 123
        y 47
        noun 5
        nsTop 31
        nsLeft 87
        nsBottom 63
        nsRight 160
        sightAngle 180
    )
)
(instance rocks of Feature
    (properties
        x 43
        y 122
        noun 6
        nsTop 87
        nsLeft 3
        nsBottom 158
        nsRight 83
        sightAngle 180
    )
)
(instance noWayToGo of Feature
    (properties
        x 280
        y 151
        noun 7
        nsTop 114
        nsLeft 242
        nsBottom 189
        nsRight 319
        sightAngle 180
    )
)
(instance sFx of Sound
    (properties)
)
(instance fallChek of Code
    (properties)

    (method (doit)
        (if ((send gOwner:inRect(156 73 218 76)) or (< (send gOwner:x) 156))
            (send gOwner:setScript(egoFalls))
        )
    )

)
(instance quikChek of Code
    (properties)

    (method (doit)
        (if ((send gOwner:inRect(0 152 36 200)))
            (send gOwner:setScript(cantExit))
        )(else
            (if (proc0_6(136) and (send gOwner:inRect(115 118 134 120)))
                = global365 575
                = gGMonsterMonHP 180
                (send global2:newRoom(820))
            )
        )
    )

)
(instance anubisInset of Inset
    (properties
        view 810
        x 160
        y 135
        disposeNotOnMe 1
        noun 11
    )

    (method (dispose)
        (send gOwner:code(quikChek))
        (send gMainIconBar:enable(6 1 5 3))
        (if (proc0_6(136))
            (opal:dispose())
        )
        (super:dispose())
    )


    (method (doVerb theVerb param2)
        (switch (theVerb)
            (case 45
                (send gOwner:
                    drop(34)
                    solvePuzzle(330 8)
                )
                (opal:
                    view(810)
                    loop(1)
                    setPri(14)
                    x(158)
                    y(83)
                    init()
                )
                Animate((send gGQg3KDHandler:elements) 1)
                (doorWay:
                    loop(2)
                    ignoreActors(1)
                    approachY(110)
                )
                proc0_4(136)
                (self:dispose())
            )
            (default 
                (super:doVerb(theVerb rest param2))
            )
        )
    )

)
