(version 2)
(include "sci.sh")
(exports
    0 rm3
)
(use "Main")
(use "Class_255_0")
(use "NewFeature")
(use "Blk")
(use "n958")
(use "Cycle")
(use "Game")
(use "PicView")
(use "Obj")
(script 3)


(local
    local0 =     1

)
(instance rockBlock of Blk
    (properties
        top 110
        left 143
        bottom 121
        right 181
    )
)
(instance public rm3 of Rm
    (properties
        picture 3
        horizon 100
        north 14
        east 2
        south 46
        west 4
    )

    (method (init)
        proc958_0(128 203 1 18)
        Load(rsSOUND 13)
        (self:style(
            (switch (gGNumber)
                (case north
                    5
                )
                (case west
                    3
                )
                (case east
                    2
                )
                (case south
                    4
                )
            )
))
        (super:init())
        (switch (gGNumber)
            (case north
                (send gEgo:posn(142 (+ horizon 2)))
            )
            (case south
                (if (< (send gEgo:y) 220)
                    (send gEgo:y(proc0_17(289 (send gEgo:y) 309)))
                )(else
                    (send gEgo:y(proc0_17(66 (send gEgo:y) 150)))
                )
                (send gEgo:y(188))
            )
            (case east
                (send gEgo:posn(317 158))
            )
            (case west
                (send gEgo:posn(3 137))
            )
            (default 
                (send gEgo:posn(3 137))
            )
        )
        (send gEgo:init())
        proc0_1()
        (send gEgo:observeBlocks(rockBlock))
        (if ((send gCast:contains(gGoat)))
            (send gGoat:observeBlocks(rockBlock))
        )
        (if (not proc0_12(90))
            Load(rsVIEW 1)
        )
        (if (proc0_12(89))
            (rock:
                cel(3)
                setPri(9)
                posn(172 122)
            )
            (rockBlock:
                left(151)
                top(118)
                right(189)
                bottom(127)
            )
        )(else
            Load(rsVIEW 18)
        )
        (rock:
            init()
            ignoreActors()
            stopUpd()
        )
        (rock1:init())
        (tree1:init())
        (tree2:init())
        (tree3:init())
        (tree4:init())
        (tree5:init())
        (tree6:init())
    )


    (method (doit)
        (var temp0)
        (if (<> local0 (send gEgo:onControl(1)))
            = local0 (send gEgo:onControl(1))
            (if (== local0 512)
                (send gEgo:
                    z(-8)
                    setPri(7)
                )
            )(else
                (send gEgo:
                    z(0)
                    setPri(-1)
                )
            )
        )
        (super:doit())
    )


    (method (handleEvent pEvent)
        (if ((send pEvent:claimed))
            return 
        )(else
            (if (proc0_14(pEvent 141 110 185 117))
                (if (proc0_12(89))
                    proc255_0(3 0)
                    (send pEvent:claimed(1))
                )
            )(else
                (if (Said('look,look>'))
                    (if (Said('[<at,around][/room,ceder,clearing]'))
                        (if (proc0_12(89))
                            proc255_0(3 1)
                        )(else
                            proc255_0(3 2)
                        )
                    )(else
                        (if (Said('<down') or Said('/grass'))
                            (if (proc0_12(89) and ((send gEgo:inRect(129 105 192 116)) or (send gEgo:inRect(146 115 183 125))))
                                (if (proc0_12(90))
                                    proc255_0(3 3)
                                )(else
                                    proc255_0(3 4)
                                )
                            )(else
                                (if (not proc0_12(89))
                                    proc255_0(3 5)
                                )(else
                                    proc255_0(3 6)
                                )
                            )
                        )(else
                            (if (Said('/hole[<dark,shallow]'))
                                (if (proc0_12(89) and ((send gEgo:inRect(129 105 192 116)) or (send gEgo:inRect(146 115 183 125))))
                                    (if (proc0_12(90))
                                        proc255_0(3 7)
                                    )(else
                                        proc255_0(3 4)
                                    )
                                )(else
                                    (if (proc0_12(89))
                                        proc255_0(3 8)
                                    )(else
                                        proc255_0(3 9)
                                    )
                                )
                            )(else
                                (if (Said('/dirt'))
                                    (if ((proc0_12(89) and proc0_12(90)) and ((send gEgo:inRect(129 105 192 116)) or (send gEgo:inRect(146 115 183 125))))
                                        proc255_0(3 10)
                                    )
                                )(else
                                    (if (Said('/dagger'))
                                        (if (not proc0_12(90) and proc0_12(89))
                                            proc255_0(3 11)
                                        )(else
                                            (if (not proc0_12(89))
                                                proc255_0(3 12)
                                            )(else
                                                (send pEvent:claimed(0))
                                            )
                                        )
                                    )(else
                                        (if (Said('/carving'))
                                            (if ((send gEgo:has(0)))
                                                proc255_0(3 13)
                                            )(else
                                                proc255_0(3 14)
                                            )
                                        )
                                    )
                                )
                            )
                        )
                    )
                )(else
                    (if (Said('climb,climb[<in]/hole[<shallow]'))
                        (if (<> 0 (send gEgo:z))
                            proc255_0(3 15)
                        )(else
                            (if (proc0_12(89))
                                proc255_0(3 16)
                            )(else
                                proc255_0(3 17)
                            )
                        )
                    )(else
                        (if (Said('get,get,pick/dagger'))
                            (if (== gGNumber_2 gNumber)
                                (send pEvent:claimed(0))
                            )(else
                                (if (proc0_12(90) and not (send gEgo:has(0)))
                                    proc255_0(3 18)
                                )(else
                                    (if (proc0_12(90))
                                        proc255_0(3 19)
                                    )(else
                                        (if (proc0_12(1))
                                            proc255_0(3 20)
                                        )(else
                                            (if (== (send gEgo:view) 
                                            (if (proc0_12(0))
                                                23
                                            )(else
                                                16
                                            )
)
                                                proc255_0(3 21)
                                            )(else
                                                (if (proc0_12(89))
                                                    (if ((send gEgo:inRect(130 105 191 124)))
                                                        (send global2:setScript(getDagger))
                                                    )(else
                                                        proc255_0(3 22)
                                                    )
                                                )(else
                                                    proc255_0(3 23)
                                                )
                                            )
                                        )
                                    )
                                )
                            )
                        )(else
                            (super:handleEvent(pEvent))
                        )
                    )
                )
            )
        )
    )

)
(instance rock of Actor
    (properties
        x 169
        y 120
        yStep 1
        view 203
        xStep 1
    )

    (method (handleEvent pEvent)
        (if ((send pEvent:claimed))
            return 
        )(else
            (if (Said('kick/boulder[<!*]'))
                proc255_0(3 24)
            )(else
                (if (Said('look,look/(boulder,pebble)[<!*]'))
                    (send pEvent:claimed(0))
                )(else
                    (if (Said('look,look/(boulder,pebble)[<!*]') or proc255_5(self pEvent 3))
                        (if (proc0_12(89))
                            proc255_0(3 25)
                            (send pEvent:claimed(1))
                        )(else
                            (send pEvent:claimed(1))
                            proc255_0(3 26)
                        )
                    )(else
                        (if (Said('get,get/(boulder,pebble)[<!*]'))
                            proc255_0(3 27)
                        )(else
                            (if (Said('get,get/(boulder,pebble)[<!*]'))
                                (if (< (send gEgo:distanceTo(rock)) 30)
                                    proc255_0(3 28)
                                )(else
                                    proc255_0(3 29)
                                )
                            )(else
                                (if (Said('lift/boulder[<!*]'))
                                    (if ((send gEgo:inRect(129 105 192 116)))
                                        proc255_0(3 30)
                                    )(else
                                        proc255_0(3 31)
                                    )
                                )(else
                                    (if (Said('move,move,move/(boulder,pebble)[<!*]'))
                                        (if (proc0_12(89))
                                            proc255_0(3 32)
                                        )(else
                                            (if (proc0_12(1))
                                                proc255_0(3 33)
                                            )(else
                                                (if (== (send gEgo:view) 
                                                (if (proc0_12(0))
                                                    23
                                                )(else
                                                    16
                                                )
)
                                                    proc255_0(3 21)
                                                )(else
                                                    (if ((send gEgo:inRect(129 105 192 116)))
                                                        (send global2:setScript(moveRock))
                                                    )(else
                                                        (if ((send gEgo:inRect(146 115 183 125)))
                                                            (send global2:setScript(crushedByRock))
                                                        )(else
                                                            proc255_0(3 31)
                                                        )
                                                    )
                                                )
                                            )
                                        )
                                    )(else
                                        (super:handleEvent(pEvent))
                                    )
                                )
                            )
                        )
                    )
                )
            )
        )
    )

)
(instance moveRock of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gEgo:loop(
                    (if (< (send gEgo:y) 112)
                        2
                    )(else
                        (if (> (send gEgo:y) 120)
                            3
                        )(else
                            (if (< (send gEgo:x) 144)
                                0
                            )(else
                                1
                            )
                        )
                    )
))
                = cycles 4
            )
            (case 1
                (send gEgo:
                    view(1)
                    ignoreActors()
                    setCycle(End self)
                )
            )
            (case 2
                proc0_19(89 2)
                (send (ScriptID(0 21)):
                    number(13)
                    loop(1)
                    init()
                    play()
                )
                (send gEgo:stopUpd())
                (rock:
                    xStep(
                        (if (>= global101 1)
                            1
                        )(else
                            4
                        )
)
                    yStep(
                        (if (>= global101 1)
                            1
                        )(else
                            4
                        )
)
                    cycleSpeed(1)
                    setCycle(End)
                    setPri(9)
                    setMotion(MoveTo 172 122 self)
                )
            )
            (case 3
                (rock:stopUpd())
                (send (ScriptID(0 21)):
                    number(106)
                    play()
                )
                (send gEgo:setCycle(Beg self))
            )
            (case 4
                proc0_1()
                (rockBlock:
                    left(151)
                    top(118)
                    right(189)
                    bottom(127)
                )
                proc0_7()
                proc255_0(3 34)
                proc0_3()
                (self:dispose())
            )
        )
    )

)
(instance crushedByRock of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                proc0_15(gEgo 169 120)
                = cycles 4
            )
            (case 1
                (send gEgo:
                    view(1)
                    ignoreActors()
                    setCycle(End self)
                )
                (rock:ignoreActors())
            )
            (case 2
                (send (ScriptID(0 21)):
                    number(18)
                    loop(1)
                    init()
                    play()
                )
                (send gEgo:
                    view(18)
                    setLoop(1)
                    cel(0)
                    cycleSpeed(1)
                    setCycle(End)
                )
                (rock:
                    illegalBits(0)
                    cycleSpeed(2)
                    setCycle(End)
                    setMotion(MoveTo 177 131 self)
                )
            )
            (case 3
                proc0_16("The moving rock rolls downhill...and right into you.   A crushing defeat.")
            )
        )
    )

)
(instance getDagger of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gEgo:
                    illegalBits(0)
                    setMotion(MoveTo 150 114 self)
                )
            )
            (case 1
                (send gEgo:
                    view(1)
                    setCycle(End self)
                )
            )
            (case 2
                proc0_19(90 5)
                (send gEgo:get(0))
                (send (ScriptID(0 21)):
                    number(105)
                    loop(1)
                    init()
                    play()
                )
                = cycles 6
            )
            (case 3
                (send gEgo:
                    illegalBits(-32768)
                    setCycle(Beg self)
                )
            )
            (case 4
                proc0_1()
                proc0_7()
                proc255_0(3 35)
                proc0_3()
                (self:dispose())
            )
        )
    )

)
(instance rock1 of NewFeature
    (properties
        x 131
        y 117
        noun 3606
        nsTop 110
        nsLeft 121
        nsBottom 124
        nsRight 142
        description 3636
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 3748
    )
)
(instance tree1 of NewFeature
    (properties
        x 160
        y 40
        noun 3613
        nsTop -1
        nsBottom 82
        nsRight 320
        description 3809
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 3814
    )
)
(instance tree2 of NewFeature
    (properties
        x 28
        y 135
        noun 3613
        nsTop 82
        nsBottom 189
        nsRight 56
        description 3809
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 3814
    )
)
(instance tree3 of NewFeature
    (properties
        x 72
        y 121
        noun 3613
        nsTop 82
        nsLeft 55
        nsBottom 160
        nsRight 90
        description 3809
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 3814
    )
)
(instance tree4 of NewFeature
    (properties
        x 235
        y 135
        noun 3613
        nsTop 82
        nsLeft 200
        nsBottom 189
        nsRight 270
        description 3809
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 3814
    )
)
(instance tree5 of NewFeature
    (properties
        x 104
        y 95
        noun 3613
        nsTop 82
        nsLeft 89
        nsBottom 109
        nsRight 119
        description 3809
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 3814
    )
)
(instance tree6 of NewFeature
    (properties
        x 294
        y 94
        noun 3613
        nsTop 82
        nsLeft 269
        nsBottom 106
        nsRight 319
        description 3809
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 3814
    )
)
