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


(local
    local0[3]

)
(instance public rm17 of Rm
    (properties
        picture 17
        horizon 57
        north 32
        east 24
        south 16
        west 18
    )

    (method (init)
        proc958_0(128 54 13 14)
        proc958_0(132 17 14)
        (self:style(
            (switch (gGNumber)
                (case north
                    5
                )
                (case west
                    3
                )
                (case east
                    2
                )
                (case south
                    4
                )
            )
))
        (super:init())
        (send gEgo:init())
        (switch (gGNumber)
            (case north
                (send gEgo:posn(proc0_17(309 (send gEgo:x) 240) (+ horizon 2)))
            )
            (case south
                (send gEgo:y(188))
            )
            (case west
                (if (not global130)
                    (send gEgo:posn(3 proc0_17(188 (send gEgo:y) 182)))
                )(else
                    = global136 1000
                    (send gEgo:
                        illegalBits(128)
                        view(13)
                        setStep(3 1)
                        posn(3 proc0_17(186 (send gEgo:y) 104))
                        setCycle(Fwd)
                        setPri(4)
                        cycleSpeed(0)
                        moveSpeed(0)
                    )
                )
            )
            (default 
                (send gEgo:posn(317 proc0_17(189 (send gEgo:y) (+ horizon 2))))
            )
        )
        (if (not global130)
            proc0_1()
        )
        (cliff1:init())
        (cliff2:init())
        (cliff3:init())
        (cliff4:init())
        (lake1:init())
        (lake2:init())
        (lake3:init())
        (lake4:init())
        (lake5:init())
        (rock1:init())
        (tree1:init())
        (tree2:init())
        (tree3:init())
        (tree4:init())
        (tree5:init())
    )


    (method (doit)
        (var temp0)
        (if (script)
            (send script:doit())
        )(else
            = temp0 
                (switch ((send ((User:alterEgo)):edgeHit))
                    (case 1
                        north
                    )
                    (case 2
                        east
                    )
                    (case 3
                        south
                    )
                    (case 4
                        west
                    )
                )
            (if (temp0)
                (self:newRoom((= temp0 
                        (switch ((send ((User:alterEgo)):edgeHit))
                            (case 1
                                north
                            )
                            (case 2
                                east
                            )
                            (case 3
                                south
                            )
                            (case 4
                                west
                            )
                        )
)))
            )(else
                (if (== (send gEgo:view) 13)
                    (if (global136 and not --global136)
                        (send global2:setScript(drowning))
                    )
                    (if (>= (send gEgo:y) 159)
                        (send gEgo:setPri(1))
                    )(else
                        (send gEgo:setPri(-1))
                    )
                )(else
                    (if ((& (send gEgo:onControl(1)) $0016) and not global130)
                        (self:setScript(offCliff))
                    )
                )
            )
        )
    )


    (method (handleEvent pEvent)
        (if ((send pEvent:claimed))
            return 
        )(else
            (if ((super:handleEvent(pEvent)))
                return 
            )(else
                (if (Said('swim/'))
                    (if (== global130 6)
                        proc255_0(17 0)
                    )(else
                        (if (global130)
                            proc255_0(17 1)
                        )(else
                            proc255_0(17 2)
                        )
                    )
                )(else
                    (if (Said('dive'))
                        (if (global130)
                            proc255_0(17 3)
                        )(else
                            (send pEvent:claimed(0))
                        )
                    )(else
                        (if (Said('fill/bucket'))
                            (if (not global130)
                                proc255_0(17 4)
                            )(else
                                (if ((send gEgo:has(8)))
                                    (if (proc0_12(9))
                                        proc255_0(17 5)
                                    )(else
                                        (if (== global130 4)
                                            proc255_0(17 6)
                                        )(else
                                            proc255_0(17 7)
                                        )
                                        proc0_20(1)
                                    )
                                )(else
                                    proc255_0(17 8)
                                )
                            )
                        )(else
                            (if (Said('drink,get,get/drink,water'))
                                proc255_0(17 9)
                            )(else
                                (if (Said('climb,climb,move,move/boulder'))
                                    proc255_0(17 10)
                                )
                            )
                        )
                    )
                )
            )
        )
    )

)
(instance offCliff of Script
    (properties)

    (method (doit)
        (super:doit())
        (if (== state 0)
            (send gEgo:setStep(-1 (+ (send gEgo:yStep) 4)))
        )
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send (ScriptID(0 21)):
                    number(17)
                    loop(1)
                    init()
                    play()
                )
                (send gEgo:
                    view(54)
                    illegalBits(0)
                    setCycle(0)
                    cel(0)
                    ignoreActors()
                    ignoreHorizon()
                    setPri(
                        (switch ((send gEgo:onControl(1)))
                            (case 4
                                2
                            )
                            (default 
                                3
                            )
                        )
)
                    setStep(4 7)
                )
                (switch ((send gEgo:onControl(1)))
                    (case 16
                        (send gEgo:
                            yStep(1)
                            setLoop(3)
                            setMotion(MoveTo (send gEgo:x) 240 self)
                        )
                    )
                    (default 
                        (send gEgo:
                            setLoop(1)
                            setMotion(MoveTo - (send gEgo:x) 114 + (send gEgo:y) 180 self)
                        )
                    )
                )
                (if ((send gCast:contains(gGoat)))
                    proc0_15(gGoat gEgo)
                    (send gGoat:setMotion(0))
                )
            )
            (case 1
                (send (ScriptID(0 21)):
                    number(14)
                    loop(1)
                    play()
                )
                = seconds 2
            )
            (case 2
                proc0_16("Your attempt at cliffdiving was a smashing failure.")
            )
        )
    )

)
(instance cliff1 of NewFeature
    (properties
        x 203
        y 51
        noun 2509
        nsTop 39
        nsLeft 194
        nsBottom 63
        nsRight 213
        description 2614
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 2620
    )
)
(instance cliff2 of NewFeature
    (properties
        x 205
        y 76
        noun 2509
        nsTop 63
        nsLeft 199
        nsBottom 89
        nsRight 212
        description 2614
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 2620
    )
)
(instance cliff3 of NewFeature
    (properties
        x 224
        y 84
        noun 2509
        nsTop 70
        nsLeft 212
        nsBottom 99
        nsRight 236
        description 2614
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 2620
    )
)
(instance cliff4 of NewFeature
    (properties
        x 218
        y 136
        noun 2509
        nsTop 122
        nsLeft 198
        nsBottom 151
        nsRight 239
        description 2614
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 2620
    )
)
(instance lake1 of NewFeature
    (properties
        x 156
        y 52
        noun 2513
        nsTop 39
        nsLeft 118
        nsBottom 66
        nsRight 194
        description 2705
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        lookStr 2710
    )
)
(instance lake2 of NewFeature
    (properties
        x 121
        y 74
        noun 2513
        nsTop 65
        nsLeft 46
        nsBottom 83
        nsRight 197
        description 2705
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        lookStr 2710
    )
)
(instance lake3 of NewFeature
    (properties
        x 115
        y 121
        noun 2513
        nsTop 83
        nsLeft 32
        nsBottom 159
        nsRight 198
        description 2705
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        lookStr 2710
    )
)
(instance lake4 of NewFeature
    (properties
        x 15
        y 135
        noun 2513
        nsTop 95
        nsBottom 176
        nsRight 31
        description 2705
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        lookStr 2710
    )
)
(instance lake5 of NewFeature
    (properties
        x 94
        y 167
        noun 2513
        nsTop 159
        nsLeft 31
        nsBottom 176
        nsRight 157
        description 2705
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        lookStr 2710
    )
)
(instance rock1 of NewFeature
    (properties
        x 264
        y 32
        noun 2536
        nsTop 20
        nsLeft 234
        nsBottom 45
        nsRight 295
        description 2795
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 2800
    )
)
(instance drowning of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (User:canControl(0))
                (send gEgo:
                    setMotion(0)
                    setLoop(0)
                    view(14)
                    cel(5)
                    cycleSpeed(1)
                    setCycle(End self)
                )
            )
            (case 1
                (send gEgo:
                    cel(5)
                    setCycle(End self)
                )
            )
            (case 2
                (send gEgo:
                    cel(5)
                    setCycle(End self)
                )
            )
            (case 3
                (send gEgo:hide())
                = seconds 4
            )
            (case 4
                (if (not global136)
                    proc0_16("After swimming for a long time, your strength ebbs and your arms and legs grow weary.  As your life swims before your eyes, you decide to...")
                )(else
                    proc0_16("You splash around for awhile, but unfortunately that won't keep your head above water.  As you go down for the third time, a sense of peace washes over you...")
                )
            )
        )
    )

)
(instance tree1 of NewFeature
    (properties
        x 50
        y 13
        noun 2540
        nsTop -1
        nsBottom 28
        nsRight 101
        description 3169
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 3174
    )
)
(instance tree2 of NewFeature
    (properties
        x 230
        y 8
        noun 2540
        nsTop -1
        nsLeft 179
        nsBottom 17
        nsRight 281
        description 3169
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 3174
    )
)
(instance tree3 of NewFeature
    (properties
        x 171
        y 20
        noun 2540
        nsTop 14
        nsLeft 164
        nsBottom 26
        nsRight 179
        description 3169
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 3174
    )
)
(instance tree4 of NewFeature
    (properties
        x 224
        y 27
        noun 2540
        nsTop 17
        nsLeft 214
        nsBottom 37
        nsRight 234
        description 3169
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 3174
    )
)
(instance tree5 of NewFeature
    (properties
        x 310
        y 14
        noun 2540
        nsTop -1
        nsLeft 300
        nsBottom 30
        nsRight 320
        description 3169
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 3174
    )
)
