(version 2)
(include "sci.sh")
(exports
    0 rm13
)
(use "Main")
(use "Class_255_0")
(use "NewFeature")
(use "n958")
(use "Chase")
(use "Avoid")
(use "Cycle")
(use "Game")
(use "User")
(use "Obj")
(script 13)


(local
    gEgoX
    gEgoY
    local2

)
(instance public rm13 of Rm
    (properties
        picture 13
        horizon 72
        north 20
        east 14
        south 4
        west 12
        picAngle 60
    )

    (method (init)
        proc958_0(128 125 20)
        (if (not (send gEgo:has(16)))
            proc958_0(132 41 46)
        )
        (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(proc0_18(127 (send gEgo:x) 12) (+ horizon 2)))
            )
            (case south
                (send gEgo:y(188))
            )
            (case west
                (send gEgo:posn(3 proc0_17(189 proc0_18(112 (send gEgo:y) 103) (+ horizon 2))))
            )
            (case east
                (send gEgo:posn(317 proc0_17(189 proc0_18(175 (send gEgo:y) 165) 149)))
            )
            (default 
                (send gEgo:posn(317 proc0_17(189 proc0_18(175 (send gEgo:y) 165) 149)))
                = local2 1
            )
        )
        (send gEgo:init())
        proc0_1()
        (rock1:init())
        (rock2:init())
        (rock3:init())
        (rock4:init())
        (rock5:init())
        (rock6:init())
        (bush1:init())
        (rock7:init())
        (tree4:init())
        (tree3:init())
        (tree2:init())
        (tree1:init())
        (tree:init())
        (send (ScriptID(0 21)):
            number(91)
            loop(1)
            init()
            play()
        )
        (if (Random(0 1) or local2)
            (self:setScript(waitOne))
        )
    )


    (method (doit)
        (var temp0)
        (if (script and gTLHandsOff)
            (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 (script)
                    (send script:doit())
                )
            )
        )
    )


    (method (handleEvent pEvent)
        (if ((send pEvent:claimed))
            return 
        )(else
            (if (Said('look,look>'))
                (if (Said('[<at,around][/room,clearing]'))
                    proc255_0(13 0)
                )(else
                    (if (Said('/dog'))
                        proc255_0(13 1)
                    )
                )
            )(else
                (if (Said('use,shoot/shot,shot') or Said('shoot/dog'))
                    (if (((send gEgo:has(9)) and (send gEgo:has(10))) and (send gCast:contains(gMenace)))
                        proc255_0(13 2)
                    )(else
                        (if (((send gEgo:has(9)) and not (send gEgo:has(10))) and (send gCast:contains(gMenace)))
                            proc255_0(13 3)
                        )(else
                            (if (not (send gEgo:has(9)) and (send gEgo:has(10)))
                                proc255_0(13 4)
                            )(else
                                (if (not (send gCast:contains(gMenace)))
                                    proc255_0(13 5)
                                )(else
                                    proc255_0(13 6)
                                )
                            )
                        )
                    )
                )(else
                    (if (Said('cast,cast/pebble,pebble,boulder'))
                        (if ((send gEgo:has(9)))
                            proc255_0(13 7)
                        )(else
                            (if (not (send gCast:contains(gMenace)))
                                proc255_0(13 8)
                            )(else
                                proc255_0(13 9)
                            )
                        )
                    )(else
                        (super:handleEvent(pEvent))
                    )
                )
            )
        )
    )

)
(instance rock1 of NewFeature
    (properties
        x 66
        y 69
        noun 2797
        nsTop 54
        nsLeft 33
        nsBottom 84
        nsRight 99
        description 2869
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 2874
    )
)
(instance rock2 of NewFeature
    (properties
        x 194
        y 138
        noun 2797
        nsTop 126
        nsLeft 155
        nsBottom 150
        nsRight 234
        description 2869
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 2874
    )
)
(instance rock3 of NewFeature
    (properties
        x 203
        y 120
        noun 2797
        nsTop 114
        nsLeft 172
        nsBottom 126
        nsRight 235
        description 2869
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 2874
    )
)
(instance rock4 of NewFeature
    (properties
        x 223
        y 106
        noun 2797
        nsTop 98
        nsLeft 197
        nsBottom 114
        nsRight 250
        description 2869
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 2874
    )
)
(instance rock5 of NewFeature
    (properties
        x 266
        y 92
        noun 2797
        nsTop 87
        nsLeft 214
        nsBottom 98
        nsRight 319
        description 2869
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 2874
    )
)
(instance rock6 of NewFeature
    (properties
        x 270
        y 76
        noun 2797
        nsTop 65
        nsLeft 252
        nsBottom 87
        nsRight 288
        description 2869
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 2874
    )
)
(instance bush1 of NewFeature
    (properties
        x 277
        y 124
        noun 2801
        nsTop 104
        nsLeft 235
        nsBottom 145
        nsRight 320
        description 2984
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 2989
    )
)
(instance rock7 of NewFeature
    (properties
        x 287
        y 168
        noun 2797
        nsTop 157
        nsLeft 255
        nsBottom 179
        nsRight 320
        description 2869
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 2874
    )
)
(instance wolfStuff of Script
    (properties)

    (method (doit)
        (super:doit())
        (send gGoat:setLoop(
            (if (< (send gGoat:heading) 180)
                0
            )(else
                1
            )
))
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc255_0(13 15)
                (send (ScriptID(0 23)):
                    number(41)
                    loop(-1)
                    play()
                )
                (send gMenace:
                    view(125)
                    setCycle(Walk)
                    setAvoider(Avoid)
                    setStep(8 6)
                    setPri(-1)
                    setLoop(-1)
                    ignoreActors()
                    init()
                )
                = gEgoX (send gEgo:x)
                = gEgoY (send gEgo:y)
                (if ((>= gEgoX 130) and (<= gEgoY 97))
                    (send gMenace:posn(340 75))
                )(else
                    (if (<= gEgoY 148)
                        (send gMenace:posn(-20 150))
                    )(else
                        (if (<= gEgoX 142)
                            (send gMenace:posn(-20 170))
                        )(else
                            (if (<= gEgoY 170)
                                (send gMenace:posn(340 163))
                            )(else
                                (send gMenace:posn(340 163))
                            )
                        )
                    )
                )
                (self:cue())
            )
            (case 1
                (send gMenace:setMotion(Chase gEgo 42 self))
            )
            (case 2
                proc0_2()
                (send gMenace:hide())
                (send gEgo:
                    setMotion(0)
                    view(20)
                    cel(0)
                    loop(0)
                    setCycle(Fwd)
                )
                (if (== (send global2:script) ScriptID(782 0))
                    (send (ScriptID(782 1)):stop())
                )
                (send (ScriptID(0 21)):
                    number(46)
                    loop(1)
                    init()
                    play(self)
                )
            )
            (case 3
                (send gEgo:
                    loop(1)
                    cel(0)
                    setCycle(End)
                )
                (send gMenace:
                    loop(2)
                    posn((send gEgo:x) (send gEgo:y))
                    show()
                    setPri((send gEgo:priority))
                )
                (if (proc0_12(1))
                    proc255_0(13 16)
                )
                = cycles 38
            )
            (case 4
                (send (ScriptID(0 23)):fade())
                proc0_16("How many times have you been told not to wolf down your food?")
            )
        )
    )


    (method (handleEvent pEvent)
        (if ((send pEvent:claimed))
            return 
        )(else
            (if ((super:handleEvent(pEvent)))
                return 
            )(else
                (if (Said('kill,shoot,attack/dog'))
                    proc255_0(13 10)
                )(else
                    (if (Said('capture,get,get,get/dog'))
                        proc255_0(13 11)
                    )(else
                        (if (Said('eat,consume/dog'))
                            proc255_0(13 12)
                        )(else
                            (if (Said('ride/dog'))
                                proc255_0(13 13)
                            )(else
                                (if (Said('look,look/dog') or proc255_5(gMenace pEvent))
                                    proc255_0(13 14)
                                    (send pEvent:claimed(1))
                                )
                            )
                        )
                    )
                )
            )
        )
    )

)
(instance waitOne of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                = seconds Random(2 4)
            )
            (case 1
                (if ((((((not proc0_12(2) and (send gEgo:inRect(25 (+ (send global2:horizon) 12) 295 176))) and not proc0_12(1)) and not global124) and not (send gEgo:has(16))) and not (send gMenace:script)) and ((> (send gEgo:x) 130) or (> (send gEgo:y) 85)))
                    (send gMenace:setScript(wolfStuff))
                )(else
                    (self:changeState(0))
                )
            )
        )
    )

)
(instance tree4 of NewFeature
    (properties
        x 26
        y 27
        noun 2856
        nsTop -1
        nsBottom 55
        nsRight 52
        description 3148
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 3153
    )
)
(instance tree3 of NewFeature
    (properties
        x 10
        y 82
        noun 2856
        nsTop 55
        nsBottom 109
        nsRight 21
        description 3148
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 3153
    )
)
(instance tree2 of NewFeature
    (properties
        x 216
        y 13
        noun 2856
        nsTop -1
        nsLeft 114
        nsBottom 27
        nsRight 319
        description 3148
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 3153
    )
)
(instance tree1 of NewFeature
    (properties
        x 222
        y 39
        noun 2856
        nsTop 27
        nsLeft 124
        nsBottom 52
        nsRight 320
        description 3148
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 3153
    )
)
(instance tree of NewFeature
    (properties
        x 236
        y 57
        noun 2856
        nsTop 52
        nsLeft 153
        nsBottom 63
        nsRight 320
        description 3148
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 3153
    )
)
