(version 2)
(include "sci.sh")
(exports
    0 rm37
)
(use "Main")
(use "Class_255_0")
(use "NewFeature")
(use "n958")
(use "RFeature")
(use "Cycle")
(use "Game")
(use "PicView")
(use "Obj")
(script 37)


(local
    local0

)
(procedure (localproc_0844)
    proc255_0(37 5)
)


(instance public rm37 of Rm
    (properties
        picture 37
        horizon 73
        north 44
        east 36
        south 28
        west 38
    )

    (method (init)
        proc958_0(128 237 303)
        (self:style(
            (switch (gGNumber)
                (case north
                    5
                )
                (case west
                    3
                )
                (case east
                    2
                )
                (case south
                    4
                )
            )
))
        (super:init())
        (switch (gGNumber)
            (case north
                (if (> (send gEgo:x) 160)
                    (send gEgo:posn(proc0_18(293 (send gEgo:x) 215) (+ horizon 2)))
                )(else
                    (send gEgo:posn(proc0_18(125 (send gEgo:x) 89) (+ horizon 2)))
                )
            )
            (case west
                (send gEgo:posn(3 proc0_17(200 (send gEgo:y) (+ horizon 2))))
            )
            (case south
                (send gEgo:y(188))
            )
            (case east
                (send gEgo:posn(317 proc0_17(185 proc0_18(98 (send gEgo:y) 85) 76)))
            )
            (default 
                (send gEgo:posn(3 137))
            )
        )
        (send gEgo:init())
        proc0_1()
        (snakeBody:priority(12))
        (send gAddToPics:
            add(snakeBody)
            eachElementDo(#init)
            doit()
        )
        (snakeHead:
            setPri(12)
            init()
            stopUpd()
        )
        (snakeTongue:
            setPri(12)
            init()
            cel(2)
            stopUpd()
        )
        (tree1:init())
        (tree2:init())
        (tree3:init())
        (lake1:init())
        (lake2:init())
        = local0 2
        (if (>= global101 1)
            (wa1:
                setPri(0)
                setCycle(Fwd)
                init()
                ignoreActors()
            )
            (wa2:
                setPri(0)
                setCycle(Fwd)
                init()
                ignoreActors()
            )
            (wa3:
                setPri(0)
                setCycle(Fwd)
                init()
                ignoreActors()
            )
        )
        (self:setRegions(603))
        (if (not proc0_12(2) and (>= global101 1))
            (self:setLocales(611))
        )
    )


    (method (doit)
        (var temp0)
        (if (not (snakeHead:script) and (>= global101 1))
            (if ((< (send gEgo:x) (snakeHead:x)) and (<> local0 2))
                (snakeHead:setScript(headLeft))
            )(else
                (if ((>= (send gEgo:x) (snakeHead:x)) and (<> local0 3))
                    (snakeHead:setScript(headRight))
                )(else
                    (if ((> (send gEgo:distanceTo(snakeHead)) 95) and (<> (snakeTongue:cycler) 0))
                        (snakeTongue:setCycle(End))
                    )(else
                        (if ((> (send gEgo:distanceTo(snakeHead)) 95) and (== (snakeTongue:cycler) 0))
                            (if (< Random(1 100) 10)
                                (snakeTongue:setCycle(End))
                            )
                        )(else
                            (if (((<= (send gEgo:distanceTo(snakeHead)) 95) and (== (snakeTongue:cycler) 0)) and (< Random(1 100) 35))
                                (snakeTongue:setCycle(End))
                            )
                        )
                    )
                )
            )
        )
        (super:doit())
    )


    (method (handleEvent pEvent)
        (if ((send pEvent:claimed))
            return 
        )(else
            (if (Said('look,look>'))
                (if (Said('[<at,around][/room]'))
                    proc255_0(37 0)
                )
            )(else
                (if (Said('climb,climb/ceder'))
                    proc255_0(37 1)
                )(else
                    (if (Said('capture,kill,shoot,get,get,eat,consume/snake'))
                        proc255_0(37 2)
                    )(else
                        (super:handleEvent(pEvent))
                    )
                )
            )
        )
    )

)
(instance snakeBody of RPicView
    (properties
        x 178
        y 48
        description 2521
        view 303
    )

    (method (handleEvent pEvent)
        (if ((send pEvent:claimed))
            return 
        )(else
            (if (Said('look,look/snake') or proc255_5(self pEvent 3))
                (send pEvent:claimed(1))
                localproc_0844()
            )(else
                (if (Said('look,look/tongue'))
                    proc255_0(37 3)
                )(else
                    (if (Said('talk,speak,call/snake'))
                        proc255_0(37 4)
                    )(else
                        (super:handleEvent(pEvent))
                    )
                )
            )
        )
    )

)
(instance snakeHead of Prop
    (properties
        x 178
        y 48
        description 2521
        view 303
        loop 1
    )

    (method (doVerb theVerb)
        (switch (theVerb)
            (case 1
                localproc_0844()
            )
        )
    )

)
(instance snakeTongue of Prop
    (properties
        x 175
        y 59
        description 2521
        view 303
        loop 2
    )

    (method (doVerb theVerb)
        (switch (theVerb)
            (case 1
                localproc_0844()
            )
        )
    )

)
(instance wa1 of Prop
    (properties
        x 158
        y 114
        description 2559
        sightAngle 180
        closeRangeDist 500
        longRangeDist 500
        shiftClick 0
        view 237
        loop 1
        cycleSpeed 2
    )

    (method (handleEvent)
    )

)
(instance wa2 of Prop
    (properties
        x 126
        y 107
        description 2559
        sightAngle 180
        closeRangeDist 500
        longRangeDist 500
        shiftClick 0
        view 237
        loop 1
        cel 1
        cycleSpeed 2
    )

    (method (handleEvent)
    )

)
(instance wa3 of Prop
    (properties
        x 145
        y 134
        description 2559
        sightAngle 180
        closeRangeDist 500
        longRangeDist 500
        shiftClick 0
        view 237
        loop 2
        cycleSpeed 2
    )

    (method (handleEvent)
    )

)
(instance headLeft of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                = local0 2
                (snakeTongue:setCycle(End self))
            )
            (case 1
                (snakeHead:setCycle(Beg self))
            )
            (case 2
                (snakeTongue:
                    loop(2)
                    posn(175 59)
                )
                (self:cue())
            )
            (case 3
                (self:dispose())
            )
        )
    )

)
(instance headRight of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                = local0 3
                (snakeTongue:setCycle(End self))
            )
            (case 1
                (snakeHead:setCycle(End self))
            )
            (case 2
                (snakeTongue:
                    loop(3)
                    posn(185 58)
                )
                (self:cue())
            )
            (case 3
                (self:dispose())
            )
        )
    )

)
(instance lake1 of NewFeature
    (properties
        x 167
        y 110
        noun 2494
        nsTop 101
        nsLeft 35
        nsBottom 120
        nsRight 299
        description 2597
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        lookStr 2602
    )
)
(instance lake2 of NewFeature
    (properties
        x 158
        y 138
        noun 2494
        nsTop 121
        nsLeft 64
        nsBottom 156
        nsRight 252
        description 2597
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        lookStr 2602
    )
)
(instance tree1 of NewFeature
    (properties
        x 255
        y 101
        noun 2507
        nsTop 51
        nsLeft 222
        nsBottom 152
        nsRight 288
        description 2673
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 2678
    )
)
(instance tree2 of NewFeature
    (properties
        x 160
        y 24
        noun 2507
        nsBottom 50
        nsRight 320
        description 2673
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 2678
    )
)
(instance tree3 of NewFeature
    (properties
        x 69
        y 101
        noun 2507
        nsTop 51
        nsLeft 28
        nsBottom 151
        nsRight 111
        description 2673
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 2678
    )
)
