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


(local
    local0
    local1
    local2

)
(procedure (localproc_0b42)
    (if (== local1 local2)
        (condor:dispose())
        (send (ScriptID(0 23)):fade())
    )
)


(instance public rm22 of Rm
    (properties
        picture 22
        horizon 57
        north 27
        east 21
        south 11
        west 23
    )

    (method (init)
        proc958_0(132 10 55)
        proc958_0(128 160 33)
        (self:style(
            (switch (gGNumber)
                (case north
                    5
                )
                (case west
                    3
                )
                (case east
                    2
                )
                (case south
                    4
                )
                (default 
                    7
                )
            )
))
        (super:init())
        (switch (gGNumber)
            (case north
                (send gEgo:posn(278 (+ horizon 2)))
            )
            (case south
                (send gEgo:posn(proc0_17(214 (send gEgo:x) 0) 188))
            )
            (case west
                (send gEgo:posn(3 proc0_17(189 (send gEgo:y) 67)))
            )
            (case east
                (send gEgo:posn(317 proc0_17(162 proc0_18(132 (send gEgo:y) 124) (+ 2 horizon))))
            )
            (default 
                (send gEgo:
                    posn(121 91)
                    loop(1)
                )
            )
        )
        (send gEgo:init())
        proc0_1()
        (tree1:init())
        (tree2:init())
        (tree3:init())
        (tree4:init())
        (tree5:init())
        (tree6:init())
        (tree7:init())
        (rock1:init())
        (rock2:init())
        (rock3:init())
        (rock4:init())
        (rock5:init())
        (rock6:init())
        (rock7:init())
        (rock8:init())
        (rock9:init())
        (rock10:init())
        (rock11:init())
        (rock12:init())
        (rock13:init())
        (rock14:init())
        (if (((((<> gGNumber_4 22) and not proc0_12(100)) and (= local2 Random(0 4))) and (send gEgo:has(14))) and (send gEgo:has(1)))
            Load(rsVIEW 
                (if (proc0_12(0))
                    23
                )(else
                    16
                )
)
            Load(rsVIEW 
                (if (proc0_12(0))
                    17
                )(else
                    15
                )
)
            Load(rsVIEW 33)
            (condor:
                illegalBits(0)
                ignoreActors(1)
                ignoreHorizon(1)
                init()
            )
        )
    )


    (method (doit)
        (var temp0)
        (asm
            pushi   #contains
            pushi   1
            lofsa   condor
            push    
            lag     gCast
            send    6
            bnt     code_02ee
            lsg     global123
            ldi     1
            ne?     
            bnt     code_02ee
            pushi   #y
            pushi   0
            lag     gEgo
            send    4
            push    
            pushi   #y
            pushi   0
            lofsa   condor
            send    4
            sub     
            push    
            ldi     80
            lt?     
            bnt     code_02ee
            pushi   1
            pushi   #x
            pushi   0
            lag     gEgo
            send    4
            push    
            pushi   #x
            pushi   0
            lofsa   condor
            send    4
            sub     
            push    
            callk   Abs, 2
            push    
            ldi     5
            lt?     
            bnt     code_02ee
            pushi   #view
            pushi   0
            lag     gEgo
            send    4
            push    
            pushi   1
            pushi   0
            callb   proc0_12, 2
            bnt     code_02b7
            ldi     17
            jmp     code_02b9
code_02b7:  ldi     15
code_02b9:  eq?     
            bnt     code_02ee
            pushi   #cel
            pushi   0
            lag     gEgo
            send    4
            push    
            ldi     5
            ge?     
            bnt     code_02ee
            pushi   #number
            pushi   1
            pushi   55
            pushi   6
            pushi   1
            pushi   1
            pushi   42
            pushi   0
            pushi   2
            pushi   0
            pushi   23
            callk   ScriptID, 4
            send    16
            pushi   #setScript
            pushi   1
            lofsa   birdRide
            push    
            lag     global2
            send    6
            jmp     code_0390
code_02ee:  pTos    script
            lofsa   birdRide
            eq?     
            bnt     code_0316
            pushi   #edgeHit
            pushi   0
            lag     gEgo
            send    4
            bnt     code_0316
            pushi   #dispose
            pushi   0
            lag     gEgo
            send    4
            pushi   #newRoom
            pushi   1
            pushi   80
            lag     global2
            send    6
            jmp     code_0390
code_0316:  pToa    script
            bnt     code_0323
            pushi   #doit
            pushi   0
            send    4
            jmp     code_0390
code_0323:  pushi   #onControl
            pushi   1
            pushi   1
            lag     gEgo
            send    6
            push    
            ldi     2
            eq?     
            bnt     code_0342
            pushi   0
            callb   proc0_26, 0
            pushi   #newRoom
            pushi   1
            pushi   50
            self    6
            jmp     code_0390
code_0342:  pushi   #edgeHit
            pushi   0
            pushi   #alterEgo
            pushi   0
            class   User
            send    4
            send    4
            push    
            dup     
            ldi     1
            eq?     
            bnt     code_035d
            pToa    north
            jmp     code_037e
code_035d:  dup     
            ldi     2
            eq?     
            bnt     code_0369
            pToa    east
            jmp     code_037e
code_0369:  dup     
            ldi     3
            eq?     
            bnt     code_0375
            pToa    south
            jmp     code_037e
code_0375:  dup     
            ldi     4
            eq?     
            bnt     code_037e
            pToa    west
code_037e:  toss    
            sat     temp0
            bnt     code_0390
            pushi   0
            callb   proc0_26, 0
            pushi   #newRoom
            pushi   1
            lst     temp0
            self    6
code_0390:  ret     
        )
    )


    (method (handleEvent pEvent)
        (if ((send pEvent:claimed))
            return 
        )(else
            (if ((super:handleEvent(pEvent)))
                return 
            )(else
                (if ((Said('look,look/cave,doorway,doorway') or proc0_14(pEvent 112 40 130 59)) or proc0_14(pEvent 106 60 115 86))
                    (if ((send gEgo:inRect(82 83 145 94)))
                        proc255_0(22 0)
                    )(else
                        proc255_0(22 1)
                    )
                )(else
                    (if (Said('look,look>'))
                        (if (Said('[<at,around][/room,clearing]'))
                            proc255_0(22 2)
                        )(else
                            (if (Said('/bird,bird,bird'))
                                (if ((<= 0 (condor:x)) and (<= (condor:x) 319))
                                    proc255_0(22 3)
                                )(else
                                    proc255_0(22 4)
                                )
                            )
                        )
                    )(else
                        (if (Said('get,get,get,capture/bird,bird,bird'))
                            (if ((<= 0 (condor:x)) and (<= (condor:x) 319))
                                proc255_0(22 5)
                            )(else
                                proc255_0(22 6)
                            )
                        )(else
                            (if (Said('climb,climb/hill,boulder,boulder'))
                                proc255_0(22 7)
                            )(else
                                (if (Said('kill/bird,bird,bird'))
                                    (if ((<= 0 (condor:x)) and (<= (condor:x) 319))
                                        proc255_0(22 8)
                                    )(else
                                        proc255_0(22 4)
                                    )
                                )(else
                                    (if (Said('talk,speak/bird,bird,bird'))
                                        (if ((<= 0 (condor:x)) and (<= (condor:x) 319))
                                            proc255_0(22 9)
                                        )(else
                                            proc255_0(22 4)
                                        )
                                    )(else
                                        (if (Said('hello') or Said('say/hello'))
                                            (if ((<= 0 (condor:x)) and (<= (condor:x) 319))
                                                proc255_0(22 9)
                                            )(else
                                                (if (proc0_12(2))
                                                    proc255_0(22 10)
                                                )(else
                                                    proc255_0(22 11)
                                                )
                                            )
                                        )
                                    )
                                )
                            )
                        )
                    )
                )
            )
        )
    )

)
(instance condor of Actor
    (properties
        x -10
        y -40
        yStep 5
        view 160
        xStep 8
    )

    (method (doit param1)
        (super:doit(rest param1))
        (if ((((send gEgo:inRect(88 108 187 144)) and not script) and (<> gGNumber_4 22)) and (< local1 local2))
            (if (== local1 0)
                ++local1
                ++local2
                (send (ScriptID(0 23)):
                    number(10)
                    loop(-1)
                    play()
                )
            )
            (self:setScript(
                (if (local0)
                    (switch (Random(0 1))
                        (case 0
                            ++local1
                            swoopWest
                        )
                        (default 
                            fakeWest
                        )
                    )
                )(else
                    (switch (Random(0 1))
                        (case 0
                            ++local1
                            swoopEast
                        )
                        (default 
                            fakeEast
                        )
                    )
                )
))
        )
    )


    (method (handleEvent pEvent)
        (if ((send pEvent:claimed))
            return 
        )(else
            (if ((super:handleEvent(pEvent)))
                return 
            )(else
                (if (Said('look,look/bird,bird,bird'))
                    (self:doVerb(1))
                )
            )
        )
    )


    (method (doVerb theVerb param2)
        (switch (theVerb)
            (case 1
                (if ((<= 0 (condor:x)) and (<= (condor:x) 319))
                    proc255_0(22 3)
                )(else
                    proc255_0(22 4)
                )
            )
            (default 
                (super:doVerb(theVerb rest param2))
            )
        )
    )

)
(instance swoopEast of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (condor:
                    posn(- (send gEgo:x) 140 -10)
                    setPri(8)
                    loop(0)
                    cel(1)
                    setCycle(0)
                    setMotion(MoveTo (send gEgo:x) - (send gEgo:y) 72 self)
                )
            )
            (case 1
                (condor:
                    setCycle(Fwd)
                    cycleSpeed(2)
                    setMotion(MoveTo + (send gEgo:x) 19 - (send gEgo:y) 74 self)
                )
            )
            (case 2
                (condor:
                    cycleSpeed(1)
                    setMotion(MoveTo + (send gEgo:x) 115 - (send gEgo:y) 82 self)
                )
                (User:canControl(1))
            )
            (case 3
                (condor:setMotion(MoveTo 348 (- (send gEgo:y) 137) self))
            )
            (case 4
                = local0 1
                localproc_0b42()
                (self:dispose())
            )
        )
    )

)
(instance swoopWest of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (condor:
                    posn(+ (send gEgo:x) 140 6)
                    setPri(8)
                    loop(1)
                    cel(1)
                    setCycle(0)
                    setMotion(MoveTo (send gEgo:x) - (send gEgo:y) 72 self)
                )
            )
            (case 1
                (condor:
                    setCycle(Fwd)
                    cycleSpeed(2)
                    setMotion(MoveTo - (send gEgo:x) 15 - (send gEgo:y) 74 self)
                )
            )
            (case 2
                (condor:
                    cycleSpeed(1)
                    setMotion(MoveTo - (send gEgo:x) 115 - (send gEgo:y) 82 self)
                )
                (User:canControl(1))
            )
            (case 3
                (condor:setMotion(MoveTo -44 (- (send gEgo:y) 137) self))
            )
            (case 4
                = local0 0
                localproc_0b42()
                (self:dispose())
            )
        )
    )

)
(instance fakeWest of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (condor:
                    posn(302 -10)
                    setPri(8)
                    loop(0)
                    cel(1)
                    setCycle(0)
                    setMotion(MoveTo 177 39 self)
                )
            )
            (case 1
                (condor:
                    setCycle(Fwd)
                    setMotion(MoveTo -40 -21 self)
                )
            )
            (case 2
                = local0 0
                localproc_0b42()
                (self:dispose())
            )
        )
    )

)
(instance fakeEast of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (condor:
                    posn(52 -10)
                    setPri(8)
                    loop(0)
                    cel(1)
                    setCycle(0)
                    setMotion(MoveTo 141 53 self)
                )
            )
            (case 1
                (condor:
                    setCycle(Fwd)
                    setMotion(MoveTo 348 -10 self)
                )
            )
            (case 2
                = local0 1
                localproc_0b42()
                (self:dispose())
            )
        )
    )

)
(instance birdRide of Script
    (properties)

    (method (doit param1)
        (super:doit(rest param1))
        (send gEgo:posn((condor:x) (+ (condor:y) 60)))
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_19(100 3)
                = global123 1
                proc0_2()
                (send gEgo:
                    view(33)
                    loop(
                        (if (local0)
                            1
                        )(else
                            0
                        )
)
                    setCycle(Fwd)
                    setMotion(0)
                    ignoreHorizon(1)
                    ignoreActors(1)
                    illegalBits(0)
                    setPri(7)
                )
            )
        )
    )

)
(instance tree1 of NewFeature
    (properties
        x 271
        y 125
        noun 4408
        nsTop 116
        nsLeft 242
        nsBottom 135
        nsRight 301
        description 4491
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 4496
    )
)
(instance tree2 of NewFeature
    (properties
        x 249
        y 148
        noun 4408
        nsTop 143
        nsLeft 226
        nsBottom 154
        nsRight 273
        description 4491
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 4496
    )
)
(instance tree3 of NewFeature
    (properties
        x 37
        y 51
        noun 4415
        nsTop 34
        nsLeft 23
        nsBottom 69
        nsRight 52
        description 4491
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 4594
    )
)
(instance tree4 of NewFeature
    (properties
        x 156
        y 14
        noun 4415
        nsLeft 132
        nsBottom 30
        nsRight 180
        description 4491
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 4594
    )
)
(instance tree5 of NewFeature
    (properties
        x 308
        y 62
        noun 4415
        nsLeft 297
        nsBottom 124
        nsRight 320
        description 4491
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 4594
    )
)
(instance tree6 of NewFeature
    (properties
        x 251
        y 9
        noun 4415
        nsLeft 212
        nsBottom 20
        nsRight 296
        description 4491
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 4594
    )
)
(instance tree7 of NewFeature
    (properties
        x 266
        y 136
        noun 4415
        nsTop 121
        nsLeft 224
        nsBottom 152
        nsRight 308
        description 4491
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 4594
    )
)
(instance rock1 of NewFeature
    (properties
        x 56
        y 19
        noun 4419
        nsTop -1
        nsBottom 40
        nsRight 112
        description 4694
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 4705
    )
)
(instance rock2 of NewFeature
    (properties
        x 55
        y 50
        noun 4419
        nsTop 40
        nsBottom 60
        nsRight 111
        description 4694
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 4705
    )
)
(instance rock3 of NewFeature
    (properties
        x 72
        y 73
        noun 4419
        nsTop 61
        nsLeft 40
        nsBottom 86
        nsRight 104
        description 4694
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 4705
    )
)
(instance rock4 of NewFeature
    (properties
        x 125
        y 25
        noun 4419
        nsTop 12
        nsLeft 112
        nsBottom 39
        nsRight 138
        description 4694
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 4705
    )
)
(instance rock5 of NewFeature
    (properties
        x 152
        y 82
        noun 4419
        nsTop 60
        nsLeft 115
        nsBottom 104
        nsRight 189
        description 4694
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 4705
    )
)
(instance rock6 of NewFeature
    (properties
        x 162
        y 43
        noun 4419
        nsTop 28
        nsLeft 138
        nsBottom 59
        nsRight 187
        description 4694
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 4705
    )
)
(instance rock7 of NewFeature
    (properties
        x 214
        y 66
        noun 4419
        nsTop 57
        nsLeft 188
        nsBottom 76
        nsRight 240
        description 4694
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 4705
    )
)
(instance rock8 of NewFeature
    (properties
        x 196
        y 50
        noun 4419
        nsTop 44
        nsLeft 187
        nsBottom 57
        nsRight 206
        description 4694
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 4705
    )
)
(instance rock9 of NewFeature
    (properties
        x 114
        y 137
        noun 4423
        nsTop 125
        nsLeft 78
        nsBottom 150
        nsRight 150
        description 4808
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 4813
    )
)
(instance rock10 of NewFeature
    (properties
        x 95
        y 163
        noun 4423
        nsTop 150
        nsLeft 51
        nsBottom 177
        nsRight 140
        description 4808
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 4813
    )
)
(instance rock11 of NewFeature
    (properties
        x 72
        y 144
        noun 4423
        nsTop 139
        nsLeft 66
        nsBottom 150
        nsRight 78
        description 4808
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 4813
    )
)
(instance rock12 of NewFeature
    (properties
        x 270
        y 181
        noun 4423
        nsTop 174
        nsLeft 223
        nsBottom 189
        nsRight 318
        description 4808
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 4813
    )
)
(instance rock13 of NewFeature
    (properties
        x 298
        y 162
        noun 4423
        nsTop 150
        nsLeft 277
        nsBottom 174
        nsRight 320
        description 4808
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 4813
    )
)
(instance rock14 of NewFeature
    (properties
        x 264
        y 170
        noun 4423
        nsTop 166
        nsLeft 252
        nsBottom 174
        nsRight 277
        description 4808
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 4813
    )
)
