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


(local
    local0
    local1
    local2
    local3

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


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


(instance public rm68 of Rm
    (properties
        picture 68
        horizon 59
        north 69
        south 67
    )

    (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 north
                    5
                )
                (case south
                    4
                )
            )
))
        (super:init())
        (switch (gGNumber)
            (case north
                (send gEgo:
                    posn(43 45)
                    setLoop(2)
                    cel(0)
                )
            )
            (case south
                (send gEgo:posn(80 187))
            )
            (default 
                (send gEgo:posn(196 115))
            )
        )
        (send gEgo:init())
        proc0_1()
        (if (== gGNumber north)
            (self:setScript(fadeInRoom))
        )
        (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(29)
                        proc0_11(30)
                    )(else
                        proc0_10(30)
                        proc0_11(29)
                    )
                )
                proc0_10(31)
            )
            (dwarf:
                view(136)
                setCycle(Walk)
                init()
                hide()
            )
        )
        (cave1:init())
        (cave2:init())
    )


    (method (doit)
        (var temp0)
        (if (((< (send gEgo:y) 96) and (< (send gEgo:x) 172)) and not proc0_12(1))
            = local2 1
        )
        (if (((>= (send gEgo:y) 96) and (< (send gEgo:x) 247)) and not proc0_12(1))
            = local3 1
        )
        (if (script)
            (send script:doit())
        )(else
            (if (((((proc0_12(29) 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(29) 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
                                                    (if (== (send gEgo:onControl(1)) 128)
                                                        (self:setScript(fadeOutRoom))
                                                    )(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) 3)
                                                                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(68 0)
                )(else
                    (if (Said('look,look>'))
                        (if (Said('[<at,around][/room,cave]'))
                            proc255_0(68 1)
                        )(else
                            (if (Said('/catwalk,path'))
                                proc255_0(68 0)
                            )(else
                                (if (Said('/dwarf,man'))
                                    proc255_0(68 2)
                                )
                            )
                        )
                    )
                )
            )
        )
    )

)
(instance fadeOutRoom of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                localproc_0b44()
                (send gEgo:
                    setLoop(1)
                    illegalBits(0)
                    cel(0)
                    setMotion(MoveTo (send gEgo:x) 60)
                    cycleSpeed(1)
                    setCycle(End self)
                )
            )
            (case 1
                (send gEgo:posn(49 60))
                = seconds 2
            )
            (case 2
                proc0_3()
                (self:dispose())
                (send global2:newRoom(69))
            )
        )
    )

)
(instance fadeOut of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                = local2 0
                = local3 0
                localproc_0b44()
                (send gEgo:
                    setLoop(1)
                    cel(0)
                    cycleSpeed(1)
                    illegalBits(0)
                    setCycle(End)
                    setMotion(MoveTo (send gEgo:x) 77 self)
                )
            )
            (case 1
                proc0_1()
                (send gEgo:
                    loop(1)
                    cel(0)
                    setMotion(MoveTo 237 77 self)
                )
            )
            (case 2
                proc0_3()
                (self:dispose())
            )
        )
    )

)
(instance fadeInRoom of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                localproc_0b44()
                (send gEgo:
                    setLoop(0)
                    cel(0)
                    setCycle(0)
                    setMotion(MoveTo 45 57 self)
                )
            )
            (case 1
                (send gEgo:
                    cycleSpeed(1)
                    setCycle(End self)
                )
            )
            (case 2
                proc0_1()
                (send gEgo:
                    loop(2)
                    cel(0)
                    setMotion(MoveTo 45 69 self)
                )
            )
            (case 3
                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:setMotion(MoveTo 300 (send gEgo:y) self))
            )
            (case 1
                localproc_0b44()
                (send gEgo:
                    setLoop(0)
                    cel(0)
                    setCycle(0)
                    setMotion(MoveTo 300 95 self)
                )
            )
            (case 2
                (send gEgo:
                    cycleSpeed(1)
                    setCycle(End self)
                )
            )
            (case 3
                proc0_1()
                (send gEgo:
                    loop(2)
                    cel(0)
                    setMotion(MoveTo 300 114 self)
                )
            )
            (case 4
                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(68 3)
                (dwarf:show())
                = local1 (< (send gEgo:y) 96)
                (if (local1)
                    (dwarf:
                        posn(243 74)
                        setMotion(MoveTo 189 74 self)
                    )
                )(else
                    (dwarf:
                        posn(308 108)
                        setMotion(MoveTo 288 119 self)
                    )
                )
            )
            (case 1
                (if (local1)
                    (self:cue())
                )(else
                    (dwarf:setMotion(MoveTo 264 121 self))
                )
            )
            (case 2
                (if (global124)
                    proc255_0(68 4)
                )(else
                    (if (proc0_12(1))
                        proc255_0(68 5)
                    )(else
                        (if (localproc_0a98(16 8))
                        )(else
                            (if (localproc_0a98(14 8))
                            )(else
                                (if (localproc_0a98(1 8))
                                )(else
                                    (if (proc0_12(62) and localproc_0a98(11 6))
                                    )(else
                                        (if (localproc_0a98(11 3))
                                        )(else
                                            (if (proc0_12(67) and localproc_0a98(18 6))
                                            )(else
                                                (if (localproc_0a98(15 6))
                                                )(else
                                                    (if (localproc_0a98(12 6))
                                                    )(else
                                                        proc255_0(68 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 cave1 of NewFeature
    (properties
        x 49
        y 38
        noun 2956
        nsTop 10
        nsLeft 26
        nsBottom 66
        nsRight 73
        description 3028
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 3033
    )
)
(instance cave2 of NewFeature
    (properties
        x 293
        y 79
        noun 2956
        nsTop 48
        nsLeft 269
        nsBottom 111
        nsRight 318
        description 3028
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 3033
    )
)
