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


(local
    local0
    local1
    local2
    local3

)
(procedure (localproc_0910 param1 param2)
    return 
        (if ((send gEgo:has(param1)))
            (send gEgo:put(param1))
            (send gGame:changeScore((- 0 param2)))
            proc255_0(69 7)
            return 1
        )(else
            return 0
        )
)


(procedure (localproc_09a0)
    (if (proc0_12(1))
        (send gEgo:view(42))
    )(else
        (send gEgo:view(56))
    )
)


(instance public rm69 of Rm
    (properties
        picture 69
        horizon 20
        south 68
        west 59
    )

    (method (init)
        proc958_0(128 4 7 56 66 136)
        (if ((send gEgo:has(5)))
            proc958_0(128 38 39)
        )
        Load(rsSCRIPT 613)
        Load(rsSOUND 17)
        (self:style(
            (switch (gGNumber)
                (case west
                    3
                )
                (case south
                    4
                )
            )
))
        (super:init())
        (switch (gGNumber)
            (case south
                (send gEgo:
                    posn(189 187)
                    setLoop(0)
                    cel(0)
                )
            )
            (case west
                (send gEgo:
                    loop(0)
                    posn(1 39)
                )
            )
            (default 
                (send gEgo:posn(150 130))
            )
        )
        proc0_10(0)
        (send gEgo:init())
        proc0_1()
        (if (not proc0_12(28))
            (if (not proc0_12(31))
                (if (< Random(1 100) 51)
                    proc0_11(29)
                    proc0_11(30)
                )(else
                    (if (< Random(1 100) 51)
                        proc0_10(30)
                        proc0_11(29)
                    )(else
                        proc0_10(29)
                        proc0_11(30)
                    )
                )
                proc0_10(31)
            )
            (dwarf:
                view(136)
                setCycle(Walk)
                init()
                hide()
            )
        )
        (cave:init())
    )


    (method (doit)
        (var temp0)
        (if (((< (send gEgo:y) 96) and (>= (send gEgo:x) 219)) and not proc0_12(1))
            = local2 1
        )
        (if (((>= (send gEgo:y) 96) and (>= (send gEgo:x) 136)) and not proc0_12(1))
            = local3 1
        )
        (if (script)
            (send script:doit())
        )(else
            (if (((((proc0_12(30) and not proc0_12(28)) and (== (send gEgo:onControl(1)) 1024)) and not proc0_12(1)) and (>= (send gEgo:y) 95)) and local3)
                (self:setScript(takeWhatYouCan))
            )(else
                (if (((((proc0_12(30) and not proc0_12(28)) and (== (send gEgo:onControl(1)) 1024)) and not proc0_12(1)) and (< (send gEgo:y) 96)) and local2)
                    (self:setScript(takeWhatYouCan))
                )(else
                    (if (== (send gEgo:onControl(1)) 8)
                        (self:setScript(ScriptID(613 0)))
                    )(else
                        (if (== (send gEgo:onControl(1)) 16)
                            (self:setScript(ScriptID(613 1)))
                        )(else
                            (if (== (send gEgo:onControl(1)) 256)
                                (self:setScript(ScriptID(613 2)))
                            )(else
                                (if (== (send gEgo:onControl(1)) 2)
                                    (self:setScript(ScriptID(613 3)))
                                )(else
                                    (if (== (send gEgo:onControl(1)) 4)
                                        (self:setScript(ScriptID(613 4)))
                                    )(else
                                        (if (== (send gEgo:onControl(1)) 16384)
                                            (self:setScript(ScriptID(613 6)))
                                        )(else
                                            (if (== (send gEgo:onControl(1)) 64)
                                                (self:setScript(fadeOut))
                                            )(else
                                                (if (== (send gEgo:onControl(1)) 32)
                                                    (self:setScript(fadeIn))
                                                )(else
                                                    = temp0 
                                                        (switch ((send ((User:alterEgo)):edgeHit))
                                                            (case 1
                                                                north
                                                            )
                                                            (case 2
                                                                east
                                                            )
                                                            (case 3
                                                                south
                                                            )
                                                            (case 4
                                                                west
                                                            )
                                                        )
                                                    (if (temp0)
                                                        (if (== (send gEgo:edgeHit) 4)
                                                            proc0_11(31)
                                                        )
                                                        (self:newRoom(temp0))
                                                    )
                                                )
                                            )
                                        )
                                    )
                                )
                            )
                        )
                    )
                )
            )
        )
    )


    (method (handleEvent pEvent)
        (if ((send pEvent:claimed))
            return 
        )(else
            (if ((super:handleEvent(pEvent)))
                return 
            )(else
                (if ((((== (send pEvent:type) 1) and (& (send pEvent:modifiers) $0003)) and (& OnControl(4 (send pEvent:x) (send pEvent:y)) $0c00)) and (User:canInput()))
                    (send pEvent:claimed(1))
                    proc255_0(69 0)
                )(else
                    (if (Said('look,look>'))
                        (if (Said('[<at,around][/room,cave]'))
                            proc255_0(69 1)
                        )(else
                            (if (Said('/catwalk,path'))
                                proc255_0(69 0)
                            )(else
                                (if (Said('/dwarf,man'))
                                    proc255_0(69 2)
                                )
                            )
                        )
                    )
                )
            )
        )
    )

)
(instance fadeOut of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                = local2 0
                = local3 0
                localproc_09a0()
                (send gEgo:
                    illegalBits(0)
                    setLoop(1)
                    cel(0)
                    cycleSpeed(1)
                    setCycle(End self)
                )
            )
            (case 1
                (send gEgo:posn(153 57))
                = seconds 4
            )
            (case 2
                proc0_1()
                (send gEgo:
                    loop(0)
                    cel(0)
                    setPri(1)
                    setMotion(MoveTo 174 56 self)
                )
            )
            (case 3
                (send gEgo:setPri(-1))
                proc0_3()
                (self:dispose())
            )
        )
    )

)
(instance fadeIn of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                = local2 0
                = local3 0
                (send gEgo:
                    setPri(1)
                    setMotion(MoveTo 155 57 self)
                )
            )
            (case 1
                localproc_09a0()
                (send gEgo:
                    illegalBits(0)
                    setLoop(0)
                    cel(0)
                    setCycle(0)
                    setMotion(MoveTo 90 109 self)
                )
            )
            (case 2
                (send gEgo:
                    cycleSpeed(1)
                    setCycle(End self)
                )
            )
            (case 3
                proc0_1()
                (send gEgo:
                    loop(2)
                    cel(0)
                    setMotion(MoveTo 90 114 self)
                )
            )
            (case 4
                (send gEgo:setPri(-1))
                proc0_3()
                (self:dispose())
            )
        )
    )

)
(instance takeWhatYouCan of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send (ScriptID(0 21)):
                    number(93)
                    loop(1)
                    init()
                    play()
                )
                proc255_0(69 3)
                (dwarf:show())
                = local1 (< (send gEgo:y) 95)
                (if (local1)
                    (dwarf:
                        posn(156 61)
                        setMotion(MoveTo 201 52 self)
                    )
                )(else
                    (dwarf:
                        posn(94 106)
                        setMotion(MoveTo 91 113 self)
                    )
                )
            )
            (case 1
                (if (local1)
                    (self:cue())
                )(else
                    (dwarf:setMotion(MoveTo 107 125 self))
                )
            )
            (case 2
                (if (global124)
                    proc255_0(69 4)
                )(else
                    (if (proc0_12(1))
                        proc255_0(69 5)
                    )(else
                        (if (localproc_0910(16 8))
                        )(else
                            (if (localproc_0910(14 8))
                            )(else
                                (if (localproc_0910(1 8))
                                )(else
                                    (if (proc0_12(62) and localproc_0910(11 6))
                                    )(else
                                        (if (localproc_0910(11 3))
                                        )(else
                                            (if (proc0_12(67) and localproc_0910(18 6))
                                            )(else
                                                (if (localproc_0910(15 6))
                                                )(else
                                                    (if (localproc_0910(12 6))
                                                    )(else
                                                        proc255_0(69 6)
                                                    )
                                                )
                                            )
                                        )
                                    )
                                )
                            )
                        )
                    )
                )
                = cycles 10
            )
            (case 3
                (dwarf:
                    loop(3)
                    cel(0)
                )
                = cycles 2
            )
            (case 4
                (dwarf:setCycle(End self))
            )
            (case 5
                (send (ScriptID(0 21)):fade())
                proc0_10(28)
                (dwarf:dispose())
                proc0_3()
                (self:dispose())
            )
        )
    )

)
(instance dwarf of Actor
    (properties)
)
(instance cave of NewFeature
    (properties
        x 94
        y 89
        noun 2536
        nsTop 68
        nsLeft 71
        nsBottom 111
        nsRight 117
        description 2585
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 2590
    )
)
