(include "sci.sh")
(use "Main")
(use "Class_255_0")
(use "Sound")
(use "Cycle")
(use "Game")
(use "InvI")
(use "User")
(use "PV")
(use "Obj")
(script 69)


(local
    newProp_2
    newView
    newProp
    newAct
    newAct_2
    local5
    local6
    local7
    local8

)
(instance fallMusic of Sound
    (properties)
)
(instance mummyMusic of Sound
    (properties)
)
(instance ladderSpace of Blk
    (properties
        top 146
        left 90
        bottom 152
        right 96
    )
)
(instance public Room69 of Rm
    (properties
        picture 69
        style 16
    )

    (method (init)
        Load(rsVIEW 520)
        Load(rsVIEW 522)
        Load(rsVIEW 195)
        Load(rsVIEW 196)
        Load(rsVIEW 197)
        Load(rsVIEW 4)
        Load(rsVIEW 38)
        Load(rsVIEW 519)
        Load(rsVIEW 683)
        Load(rsVIEW 44)
        Load(rsVIEW 41)
        Load(rsVIEW 40)
        Load(rsVIEW 42)
        Load(rsVIEW 37)
        Load(rsVIEW 39)
        (super:init())
        = local7 0
        = local6 0
        = global101 1
        (send ((View:new())):
            view(522)
            loop(3)
            cel(0)
            posn(253 72)
            addToPic()
        )
        (send ((Prop:new())):
            view(522)
            loop(2)
            cel(0)
            posn(252 58)
            init()
            setCycle(Fwd)
        )
        (send (= newView (View:new())):
            view(520)
            loop(2)
            cel(0)
            setPri(7)
            posn(160 113)
            init()
            stopUpd()
        )
        (send (= newProp (Prop:new())):
            view(520)
            ignoreActors(1)
            setPri(8)
            loop(0)
            cel(0)
            posn(- (send newView:x()) 4 (send newView:y()))
            init()
            stopUpd()
        )
        (send (= newProp_2 (Prop:new())):
            view(522)
            setCel(
                (if (global170)
                    255
                )(else
                    0
                )
)
            setPri(11)
            ignoreActors(1)
            posn(98 88)
            init()
        )
        (send (= newAct (Act:new())):
            view(195)
            illegalBits(0)
            setPri(7)
            posn((send newView:x()) (send newView:y()))
            init()
        )
        (if ((send ((Inv:at(4))):ownedBy(69)))
            (send (= newAct_2 (Act:new())):
                view(519)
                illegalBits(0)
                ignoreActors(0)
                posn(260 172)
                init()
            )
        )
        (send gEgo:
            posn(41 87)
            view(4)
            loop(0)
            ignoreActors(1)
            setStep(4 1)
            illegalBits(32768)
            setPri(11)
            init()
        )
    )


    (method (doit)
        (super:doit())
        (if (& (send gEgo:onControl(0)) $0040)
            (User:
                canControl(1)
                canInput(1)
            )
            (send gEgo:setPri(-1))
            (send global2:newRoom(18))
        )
        (if ((& (send gEgo:onControl(1)) $0004) and (== (send gEgo:script()) 0))
            (User:
                canControl(0)
                canInput(0)
            )
            (send gEgo:setScript(cryptFall))
        )
    )


    (method (dispose)
        (send gSounds:eachElementDo(172))
        (super:dispose())
    )


    (method (handleEvent pEvent)
        return 
            (if ((send pEvent:claimed()))
                return 1
            )(else
                (if (== (send pEvent:type()) 128)
                    (if (Said('look[<around][/!*]') or Said('look/room,crypt'))
                        Print(Format(@global300 69 0 
                                (if (== global170 0)
                                    "A pile of rope is at the edge of the upper platform."
                                )(else
                                    " "
                                )
 
                                (if (== (send ((Inv:at(4))):owner()) 69)
                                    "You see an odd-looking, little chest here. It must be Pandora's Box."
                                )(else
                                    " "
                                )
))
                    )(else
                        (if (Said('look>'))
                            (if (Said('/epitaph'))
                                Print(69 1)
                            )(else
                                (if (Said('<in/casket[<elderly]') and (< (send gEgo:distanceTo(newView)) 25))
                                    Print(69 2)
                                )(else
                                    (if (Said('/casket'))
                                        Print(69 3)
                                    )(else
                                        (if (Said('/hemp,ladder') or Said('/hemp[<<]'))
                                            (if (== global170 0)
                                                Print(69 4)
                                            )(else
                                                Print(69 5)
                                            )
                                        )(else
                                            (if (Said('/platform'))
                                                (if (== global170 0)
                                                    Print(69 4)
                                                )(else
                                                    Print(69 6)
                                                )
                                            )(else
                                                (if (Said('/wall'))
                                                    Print(69 7)
                                                )(else
                                                    (if (Said('/dirt') or Said('<down'))
                                                        (if (== (send ((Inv:at(4))):owner()) 69)
                                                            Print(69 8)
                                                        )(else
                                                            Print(69 9)
                                                        )
                                                    )(else
                                                        (if (Said('/mummy'))
                                                            (if (local8)
                                                                Print(69 10)
                                                            )(else
                                                                Print(69 11)
                                                            )
                                                        )(else
                                                            (if (Said('/box[<pandora]'))
                                                                (if (== (send ((Inv:at(4))):owner()) 69)
                                                                    Print(69 8)
                                                                )(else
                                                                    (if ((send gEgo:has(4)))
                                                                        (send pEvent:claimed(0))
                                                                    )(else
                                                                        Print(69 12)
                                                                    )
                                                                )
                                                            )(else
                                                                (send pEvent:claimed(0))
                                                            )
                                                        )
                                                    )
                                                )
                                            )
                                        )
                                    )
                                )
                            )
                        )(else
                            (if (Said('get,move/hemp,ladder,<'))
                                (if (global170)
                                    Print(69 13)
                                )(else
                                    (if (> (send gEgo:distanceTo(newProp_2)) 25)
                                        Print(800 1)
                                    )(else
                                        Print(69 14)
                                        (send gGame:changeScore(2))
                                        (User:
                                            canControl(0)
                                            canInput(0)
                                        )
                                        (send gEgo:setMotion(0))
                                        = local6 1
                                        (send newProp_2:setScript(DropRope))
                                    )
                                )
                            )(else
                                (if (Said('climb[/(hemp,ladder)]>'))
                                    (if (not global170)
                                        (send pEvent:claimed(1))
                                        Print(800 3)
                                    )(else
                                        (if (Said('<down') or not local7)
                                            (send pEvent:claimed(1))
                                            (if (> (send gEgo:distanceTo(newProp_2)) 20)
                                                Print(800 1)
                                            )(else
                                                (send gEgo:setScript(DownLadder))
                                            )
                                        )(else
                                            (if (Said('<up') or local7)
                                                (send pEvent:claimed(1))
                                                (if (not (send gEgo:inRect(99 142 120 158)))
                                                    Print(800 1)
                                                )(else
                                                    (send gEgo:ignoreBlocks(ladderSpace))
                                                    (DownLadder:changeState(14))
                                                )
                                            )
                                        )
                                    )
                                )(else
                                    (if (Said('get/box'))
                                        (if (not local7)
                                            Print(69 15)
                                        )(else
                                            (if ((send gEgo:has(4)))
                                                Print(69 16)
                                            )(else
                                                (if (<> (send ((Inv:at(4))):owner()) 69)
                                                    Print(69 17)
                                                )(else
                                                    (if (> (send gEgo:distanceTo(newAct_2)) 20)
                                                        Print(800 1)
                                                    )(else
                                                        (send gEgo:setScript(stoop))
                                                    )
                                                )
                                            )
                                        )
                                    )(else
                                        (if (Said('place,drop/box'))
                                            (if (not (send gEgo:has(4)))
                                                Print(69 18)
                                            )(else
                                                (if (not local7)
                                                    Print(69 15)
                                                )(else
                                                    (send gEgo:setScript(putBack))
                                                )
                                            )
                                        )(else
                                            (if (Said('open/box'))
                                                (if (not (send gEgo:has(4)))
                                                    Print(69 18)
                                                )(else
                                                    (if (not local7)
                                                        Print(69 19)
                                                    )(else
                                                        (send pEvent:claimed(0))
                                                    )
                                                )
                                            )(else
                                                (if (Said('read/(epitaph,wall,casket,lid)'))
                                                    Print(69 1)
                                                )(else
                                                    (if (Said('get,rob,get,move/casket'))
                                                        Print(69 20)
                                                    )(else
                                                        (if (Said('bang[<on]/casket'))
                                                            (if (< (send gEgo:distanceTo(newView)) 15)
                                                                Print(69 21)
                                                            )(else
                                                                Print(69 22 134 -1 20)
                                                            )
                                                        )(else
                                                            (if (Said('open/casket,lid'))
                                                                (if (not local7)
                                                                    proc0_15()
                                                                )(else
                                                                    (if ((send newProp:cel()))
                                                                        Print(69 23 134 -1 20)
                                                                    )(else
                                                                        Print(69 2)
                                                                    )
                                                                )
                                                            )(else
                                                                (if (Said('get,move/casket'))
                                                                    (if (local7)
                                                                        Print(69 24)
                                                                    )(else
                                                                        proc0_15()
                                                                    )
                                                                )(else
                                                                    (if (Said('converse'))
                                                                        (if (local8)
                                                                            Print(69 25)
                                                                        )(else
                                                                            Print(69 26)
                                                                        )
                                                                    )(else
                                                                        (if (Said('/mummy>'))
                                                                            (if (not local8)
                                                                                (send pEvent:claimed(1))
                                                                                Print(69 11)
                                                                            )(else
                                                                                (if (Said('kill'))
                                                                                    Print(69 27)
                                                                                )(else
                                                                                    (if (Said('get,capture'))
                                                                                        Print(69 28)
                                                                                    )(else
                                                                                        (if (Said('kiss'))
                                                                                            Print(69 29)
                                                                                        )(else
                                                                                            (if (Said('help,,'))
                                                                                                Print(69 30)
                                                                                            )
                                                                                        )
                                                                                    )
                                                                                )
                                                                            )
                                                                        )(else
                                                                            (if (Said('deliver/*/mummy'))
                                                                                (if (local8)
                                                                                    Print(69 31)
                                                                                )(else
                                                                                    Print(69 11)
                                                                                )
                                                                            )
                                                                        )
                                                                    )
                                                                )
                                                            )
                                                        )
                                                    )
                                                )
                                            )
                                        )
                                    )
                                )
                            )
                        )
                    )
                )
            )
    )

)
(instance doMummy of Script
    (properties)

    (method (doit)
        (if ((== (self:state()) 2) and (< (send gEgo:distanceTo(newAct)) 25))
            (send newAct:setMotion(0))
            (self:changeState(3))
            (super:doit())
        )
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (Print(69 32 134 -1 20 50 3) (send newProp:priority(8)) = local8 1 (send newAct:show()) (send newProp:setCycle(End self))  )
            )
            (case 1
                ((send newAct:setCycle(End self))  )
            )
            (case 2
                ((send newAct:
                    view(196)
                    setCycle(Walk)
                    illegalBits(0)
                    cycleSpeed(0)
                    moveSpeed(0)
                    setPri(9)
                    setStep(3 2)
                    setMotion(MoveTo 145 135 self)
                )
 (mummyMusic:
                    number(27)
                    init()
                    loop(1)
                    play()
                )
  )
            )
            (case 3
                ((send newProp:
                    ignoreActors(0)
                    stopUpd()
                )
 
                (if ((send gEgo:has(7)))
                    Print(69 33 134 -1 20 50 4)
                    (self:changeState(5))
                )(else
                    Print(69 34 134 -1 20 50 5)
                    (self:changeState(20))
                )
 )
            )
            (case 5
                ((send newAct:
                    setPri(9)
                    ignoreActors(1)
                    setMotion(MoveTo (send newView:x()) (send newView:y()) self)
                )
  )
            )
            (case 6
                ((send newAct:
                    view(195)
                    setPri(7)
                    loop(0)
                    setCycle(Beg self)
                )
  )
            )
            (case 7
                ((send newProp:
                    ignoreActors(1)
                    setCycle(Beg self)
                )
  )
            )
            (case 8
                ((send newAct:hide()) = local8 0 (mummyMusic:dispose()) (send newProp:
                    setPri(7)
                    stopUpd()
                )
 = state -1 (send client:setScript(0))  )
            )
            (case 20
                ((send newAct:
                    moveSpeed(0)
                    setMotion(Chase gEgo 15 self)
                )
  )
            )
            (case 21
                (Print(69 35) = global127 1 )
            )
        )
    )

)
(instance DownLadder of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                ((User:
                    canControl(0)
                    canInput(0)
                )
 (send gEgo:setMotion(0)) (self:cue())  )
            )
            (case 1
                ((send gEgo:
                    view(38)
                    setLoop(0)
                    illegalBits(0)
                    posn(98 88)
                    setPri(14)
                    setCycle(End self)
                )
  )
            )
            (case 2
                ((send gEgo:
                    setLoop(1)
                    setCycle(End self)
                )
  )
            )
            (case 3
                ((send gEgo:
                    view(39)
                    x(98)
                    y(+ (send gEgo:y()) 35)
                    setLoop(1)
                    cel(0)
                    cycleSpeed(0)
                    moveSpeed(0)
                    setCycle(Rev)
                    setMotion(MoveTo 98 150 self)
                )
  )
            )
            (case 4
                ((send gEgo:
                    loop(0)
                    posn(104 150)
                    setCycle(Beg self)
                )
  )
            )
            (case 5
                ((send gEgo:
                    view(4)
                    posn(107 150)
                    setLoop(-1)
                    cycleSpeed(0)
                    moveSpeed(0)
                    loop(1)
                    setPri(-1)
                    setCycle(Walk)
                    illegalBits(32768)
                    ignoreActors(0)
                )
 (self:cue())  )
            )
            (case 6
                (= local7 1 = local6 0 (send gEgo:observeBlocks(ladderSpace)) (User:
                    canControl(1)
                    canInput(1)
                )
 (self:cue())  )
            )
            (case 7
                (
                (if (== (send newAct:script()) 0)
                    (send newAct:setScript(doMummy))
                )
 )
            )
            (case 14
                ((User:
                    canControl(0)
                    canInput(0)
                )
 (send gEgo:
                    view(39)
                    setLoop(0)
                    setMotion(0)
                    illegalBits(0)
                    posn(107 152)
                    script(DownLadder)
                    setCycle(End self)
                    forceUpd()
                )
  )
            )
            (case 15
                ((send gEgo:
                    view(39)
                    x(98)
                    setPri(11)
                    setLoop(1)
                    cel(0)
                    cycleSpeed(0)
                    moveSpeed(0)
                    ignoreActors(1)
                    setCycle(Walk)
                    setMotion(MoveTo + (send newProp_2:x()) 0 + (send newProp_2:y()) 35 self)
                )
  )
            )
            (case 16
                ((send gEgo:
                    view(38)
                    posn(96 (send newProp_2:y()))
                    cycleSpeed(0)
                    moveSpeed(0)
                    setLoop(1)
                    setCycle(Beg self)
                )
  )
            )
            (case 17
                ((self:cue())  )
            )
            (case 18
                ((send gEgo:
                    view(4)
                    posn(80 88)
                    setLoop(-1)
                    setCycle(Walk)
                    illegalBits(32768)
                )
 (User:
                    canControl(1)
                    canInput(1)
                )
 = state -1 = local6 0 = local7 0 (send gEgo:setScript(0)) )
            )
        )
    )

)
(instance DropRope of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                ((send gEgo:setMotion(MoveTo 70 88 self))  )
            )
            (case 1
                ((send gEgo:
                    view(37)
                    setLoop(0)
                    setCycle(End self)
                )
  )
            )
            (case 2
                ((send newProp_2:
                    cycleSpeed(1)
                    setCycle(End self)
                )
  )
            )
            (case 3
                ((send newProp_2:stopUpd()) = global170 1 (send gEgo:
                    view(41)
                    loop(0)
                    cel(0)
                    setCycle(End self)
                )
  )
            )
            (case 4
                ((send gEgo:
                    view(4)
                    setLoop(-1)
                    setCycle(Walk)
                )
 (User:
                    canControl(1)
                    canInput(1)
                )
 (send client:setScript(0)) )
            )
        )
    )

)
(instance cryptFall of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                ((send gEgo:
                    ignoreActors(1)
                    illegalBits(0)
                    setPri(
                        (if (< (send gEgo:y()) 84)
                            -1
                        )(else
                            12
                        )
)
                )
 (self:cue())  )
            )
            (case 1
                ((fallMusic:
                    number(51)
                    play()
                )
 (send gEgo:
                    view(44)
                    moveSpeed(0)
                    setLoop(0)
                    setCycle(End self)
                )
  )
            )
            (case 2
                ((send gEgo:
                    setLoop(2)
                    xStep(10)
                    yStep(10)
                    setCycle(Fwd)
                )
 
                (if (< (send gEgo:y()) 84)
                    (send gEgo:setMotion(MoveTo (+ (send gEgo:x()) 10) (+ (send gEgo:y()) 60) self))
                )(else
                    (send gEgo:setMotion(MoveTo (+ (send gEgo:x()) 10) (+ (send gEgo:y()) 70) self))
                )
 )
            )
            (case 3
                ((send gEgo:
                    view(42)
                    setLoop(0)
                    setCel(0)
                    setPri(-1)
                )
 proc0_20() (fallMusic:dispose()) kernel[106](5) = seconds 1  )
            )
            (case 4
                (Print(69 36 140 100 134 -1 20) = seconds 4  )
            )
            (case 5
                ((send client:setScript(0)) = global127 1 )
            )
        )
    )

)
(instance stoop of Script
    (properties)

    (method (init param1)
        (super:init(param1))
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (proc0_10() (send gEgo:
                    view(40)
                    cel(0)
                    setCycle(End self)
                )
 
                (if (> (send gEgo:x()) (send newAct_2:x()))
                    (send gEgo:loop(1))
                )(else
                    (send gEgo:loop(0))
                )
 )
            )
            (case 1
                ((send gEgo:get(4)) (send newAct_2:dispose()) 
                (if (not global218)
                    = global218 1
                    = global182 1
                    (send gGame:changeScore(4))
                )
 
                (if (== global169 0)
                    (send gGame:changeScore(65534))
                )
 (send gEgo:setCycle(Beg self))  )
            )
            (case 2
                ((send gEgo:
                    view(4)
                    setCycle(Walk)
                )
 proc0_11() (send client:setScript(0)) )
            )
        )
    )

)
(instance putBack of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (proc0_10() (send gEgo:
                    view(40)
                    cel(0)
                    setCycle(End self)
                )
 
                (if (> (send gEgo:x()) 160)
                    (send gEgo:loop(1))
                )(else
                    (send gEgo:loop(0))
                )
 )
            )
            (case 1
                ((send gEgo:put(4 69)) 
                (if (== global169 0)
                    (send gSounds:eachElementDo(172))
                    (send ((Sound:new())):
                        number(50)
                        loop(1)
                        play()
                    )
                    (send gGame:changeScore(2))
                )
 (send (= newAct_2 (Act:new())):
                    view(519)
                    posn(
                        (if (> (send gEgo:x()) 160)
                            - (send gEgo:x()) 20
                        )(else
                            + (send gEgo:x()) 20
                        )
 (send gEgo:y()))
                    init()
                )
 (send gEgo:setCycle(Beg self))  )
            )
            (case 2
                ((send gEgo:
                    view(4)
                    setCycle(Walk)
                )
 proc0_11() (send client:setScript(0)) )
            )
        )
    )

)
