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


(local
    local0
    local1

)
(instance public rm21 of Rm
    (properties
        picture 21
        horizon 57
        north 28
        east 20
        south 12
        west 22
    )

    (method (init)
        Load(rsVIEW 117)
        (if (not (send gEgo:has(16)))
            Load(rsSOUND 36)
        )
        (self:style(
            (switch (gGNumber)
                (case north
                    5
                )
                (case west
                    3
                )
                (case east
                    2
                )
                (case south
                    4
                )
            )
))
        (if (((not proc0_12(74) and not global124) and not (send gEgo:has(16))) and (= local0 Random(0 4)))
            Load(rsVIEW 
                (if (proc0_12(0))
                    23
                )(else
                    16
                )
)
        )
        (super:init())
        (switch (gGNumber)
            (case north
                (send gEgo:posn(proc0_17(202 proc0_18(73 (send gEgo:x) 43) 13) (+ horizon 2)))
            )
            (case south
                (send gEgo:posn(proc0_17(319 (send gEgo:x) 120) 188))
            )
            (case west
                (send gEgo:posn(3 proc0_17(175 proc0_18(123 (send gEgo:y) 111) (+ 2 horizon))))
            )
            (case east
                (send gEgo:posn(317 proc0_18(95 proc0_18(114 (send gEgo:y) 105) 77)))
            )
            (default 
                (send gEgo:posn(3 137))
            )
        )
        (send gEgo:init())
        proc0_1()
        (tree:init())
        (tree1:init())
        (tree2:init())
        (tree3:init())
        (tree4:init())
        (tree5:init())
        (tree6:init())
        (tree7:init())
        (tree8:init())
        (tree9:init())
        (tree10:init())
        (tree11:init())
        (rock:init())
        (rock1:init())
        (rock2:init())
        (bush:init())
    )


    (method (doit)
        (var temp0)
        (asm
            pushi   #contains
            pushi   1
            lofsa   witch
            push    
            lag     gCast
            send    6
            bnt     code_028b
            lsg     global123
            ldi     2
            ne?     
            bnt     code_028b
            pushi   #view
            pushi   0
            lag     gEgo
            send    4
            push    
            pushi   1
            pushi   0
            callb   proc0_12, 2
            bnt     code_0233
            ldi     23
            jmp     code_0235
code_0233:  ldi     16
code_0235:  ne?     
            bnt     code_028b
            pushi   1
            pushi   1
            callb   proc0_12, 2
            not     
            bnt     code_028b
            pushi   30
            pushi   #y
            pushi   0
            lag     gEgo
            send    4
            push    
            pushi   #y
            pushi   0
            lofsa   witch
            send    4
            sub     
            lt?     
            bnt     code_028b
            pprev   
            ldi     54
            lt?     
            bnt     code_028b
            pushi   1
            pushi   #x
            pushi   0
            lofsa   witch
            send    4
            push    
            pushi   #x
            pushi   0
            lag     gEgo
            send    4
            sub     
            push    
            callk   Abs, 2
            push    
            ldi     4
            lt?     
            bnt     code_028b
            pushi   #setScript
            pushi   1
            lofsa   witchRide
            push    
            lag     global2
            send    6
            jmp     code_0423
code_028b:  pTos    script
            lofsa   witchRide
            eq?     
            bnt     code_02b6
            pushi   #x
            pushi   0
            lag     gEgo
            send    4
            push    
            ldi     65504
            lt?     
            bnt     code_02b6
            pushi   #dispose
            pushi   0
            lag     gEgo
            send    4
            pushi   #newRoom
            pushi   1
            pushi   80
            lag     global2
            send    6
            jmp     code_0423
code_02b6:  pToa    script
            bnt     code_02c3
            pushi   #doit
            pushi   0
            send    4
            jmp     code_0423
code_02c3:  pushi   #edgeHit
            pushi   0
            pushi   #alterEgo
            pushi   0
            class   User
            send    4
            send    4
            push    
            dup     
            ldi     1
            eq?     
            bnt     code_02de
            pToa    north
            jmp     code_02ff
code_02de:  dup     
            ldi     2
            eq?     
            bnt     code_02ea
            pToa    east
            jmp     code_02ff
code_02ea:  dup     
            ldi     3
            eq?     
            bnt     code_02f6
            pToa    south
            jmp     code_02ff
code_02f6:  dup     
            ldi     4
            eq?     
            bnt     code_02ff
            pToa    west
code_02ff:  toss    
            sat     temp0
            bnt     code_0314
            pushi   0
            callb   proc0_26, 0
            pushi   #newRoom
            pushi   1
            lst     temp0
            self    6
            jmp     code_0423
code_0314:  lal     local0
            not     
            bnt     code_032c
            pushi   #has
            pushi   1
            pushi   16
            lag     gEgo
            send    6
            bnt     code_032c
            ldi     0
            jmp     code_0423
code_032c:  pushi   #contains
            pushi   1
            lofsa   witch
            push    
            lag     gCast
            send    6
            not     
            bnt     code_03a9
            pushi   #onControl
            pushi   1
            pushi   1
            lag     gEgo
            send    6
            push    
            ldi     4096
            eq?     
            bnt     code_03a9
            lal     local0
            bnt     code_03a9
            pushi   1
            pushi   1
            callb   proc0_12, 2
            not     
            bnt     code_03a9
            lal     local1
            not     
            bnt     code_037a
            ldi     1
            sal     local1
            pushi   #number
            pushi   1
            pushi   36
            pushi   6
            pushi   1
            pushi   65535
            pushi   42
            pushi   0
            pushi   2
            pushi   0
            pushi   23
            callk   ScriptID, 4
            send    16
code_037a:  pushi   #init
            pushi   0
            pushi   18
            pushi   1
            pushi   0
            pushi   242
            pushi   1
            pushi   1
            pushi   231
            pushi   1
            pushi   1
            pushi   250
            pushi   2
            pushi   10
            pushi   6
            pushi   131
            pushi   1
            class   Fwd
            push    
            pushi   127
            pushi   1
            lofsa   longSwoop
            push    
            lofsa   witch
            send    42
            jmp     code_0423
code_03a9:  pushi   #contains
            pushi   1
            lofsa   witch
            push    
            lag     gCast
            send    6
            not     
            bnt     code_0423
            pushi   #onControl
            pushi   1
            pushi   1
            lag     gEgo
            send    6
            push    
            ldi     8192
            eq?     
            bnt     code_0423
            lal     local0
            bnt     code_0423
            pushi   1
            pushi   1
            callb   proc0_12, 2
            not     
            bnt     code_0423
            lal     local1
            not     
            bnt     code_03f7
            ldi     1
            sal     local1
            pushi   #number
            pushi   1
            pushi   36
            pushi   6
            pushi   1
            pushi   65535
            pushi   42
            pushi   0
            pushi   2
            pushi   0
            pushi   23
            callk   ScriptID, 4
            send    16
code_03f7:  pushi   #init
            pushi   0
            pushi   18
            pushi   1
            pushi   0
            pushi   242
            pushi   1
            pushi   1
            pushi   231
            pushi   1
            pushi   1
            pushi   250
            pushi   2
            pushi   10
            pushi   6
            pushi   131
            pushi   1
            class   Fwd
            push    
            pushi   127
            pushi   1
            lofsa   shortSwoop
            push    
            lofsa   witch
            send    42
code_0423:  ret     
        )
    )


    (method (handleEvent pEvent)
        (if ((send pEvent:claimed))
            return 
        )(else
            (if ((super:handleEvent(pEvent)))
                return 
            )(else
                (if (Said('/witch'))
                    proc255_0(21 0)
                )(else
                    (if (Said('look,look>') and Said('[<at,around][/room,ceder]'))
                        proc255_0(21 1)
                    )
                )
            )
        )
    )

)
(instance witch of Actor
    (properties
        view 117
    )

    (method (handleEvent pEvent)
        (if ((send pEvent:claimed))
            return 
        )(else
            (if ((super:handleEvent(pEvent)))
            )(else
                (if (Said('look,look/witch') or proc255_5(self pEvent 3))
                    proc255_0(21 2)
                )(else
                    (if (Said('kill/witch'))
                        (if ((send gCast:contains(witch)))
                            proc255_0(21 3)
                        )(else
                            proc255_0(21 4)
                        )
                    )(else
                        (if ((Said('talk,speak') or Said('<hello')) or Said('say/hello'))
                            proc255_0(21 5)
                        )(else
                            (if (Said('get,get,capture,eat,consume,bite/witch'))
                                (if (proc0_12(12))
                                    proc255_0(21 6)
                                )(else
                                    (if ((send gCast:contains(witch)))
                                        proc255_0(21 7)
                                    )(else
                                        (send pEvent:claimed(0))
                                    )
                                )
                            )(else
                                (if (Said('jump'))
                                    (if (proc0_12(12))
                                        proc255_0(21 8)
                                    )(else
                                        (if ((send gCast:contains(witch)))
                                            proc255_0(21 9)
                                        )(else
                                            (send pEvent:claimed(0))
                                        )
                                    )
                                )(else
                                    (if (Said('attack,kick/witch'))
                                        proc255_0(21 10)
                                    )
                                )
                            )
                        )
                    )
                )
            )
        )
    )


    (method (doVerb theVerb param2)
        (switch (theVerb)
            (case 1
                proc255_0(21 2)
            )
            (default 
                (super:doVerb(theVerb rest param2))
            )
        )
    )

)
(instance longSwoop of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send gEgo:setMotion(0))
                proc255_0(21 11)
                (witch:
                    setPri(5)
                    setLoop(0)
                    posn(28 1)
                    setMotion(MoveTo 114 66 self)
                )
            )
            (case 1
                (if (proc0_12(1))
                    proc255_0(21 12)
                )
                (witch:setMotion(MoveTo 183 58 self))
            )
            (case 2
                (witch:setMotion(MoveTo 256 39 self))
            )
            (case 3
                (witch:setMotion(MoveTo 349 68 self))
            )
            (case 4
                (witch:
                    setLoop(1)
                    setPri(14)
                    setMotion(MoveTo 282 106 self)
                )
            )
            (case 5
                (witch:setMotion(MoveTo (send gEgo:x) (- (send gEgo:y) 40) self))
            )
            (case 6
                (if ((> (send gEgo:x) 160) and (> (send gEgo:y) 140))
                    (witch:setMotion(MoveTo 121 126 self))
                )(else
                    (self:cue())
                )
            )
            (case 7
                (witch:setMotion(MoveTo -40 64 self))
            )
            (case 8
                --local0
                (witch:dispose())
                (if (not local0)
                    (send (ScriptID(0 23)):fade())
                    = local1 0
                )
                (self:dispose())
            )
        )
    )

)
(instance shortSwoop of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send gEgo:setMotion(0))
                proc255_0(21 11)
                (witch:
                    setPri(9)
                    setLoop(1)
                    posn(320 12)
                    setMotion(MoveTo 207 86 self)
                )
            )
            (case 1
                (if (proc0_12(1))
                    proc255_0(21 12)
                )
                (witch:setMotion(MoveTo (send gEgo:x) (- (send gEgo:y) 34) self))
            )
            (case 2
                (witch:setMotion(MoveTo -40 49 self))
            )
            (case 3
                --local0
                (witch:dispose())
                (if (not local0)
                    (send (ScriptID(0 23)):fade())
                    = local1 0
                )
                (self:dispose())
            )
        )
    )

)
(instance witchRide of Script
    (properties)

    (method (doit param1)
        (super:doit(rest param1))
        (send gEgo:posn((- (witch:x) 15) (+ (witch:y) 22)))
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                = global123 2
                (send (ScriptID(0 23)):
                    loop(1)
                    fade()
                )
                proc255_0(21 13)
                proc0_2()
                (send gEgo:
                    view(117)
                    loop(3)
                    setCycle(Fwd)
                    setMotion(0)
                    ignoreHorizon(1)
                    ignoreActors(1)
                    illegalBits(0)
                    setPri((witch:priority))
                )
            )
        )
    )

)
(instance rock2 of NewFeature
    (properties
        x 40
        y 175
        noun 3608
        nsTop 161
        nsBottom 189
        nsRight 81
        description 3666
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 3671
    )
)
(instance rock1 of NewFeature
    (properties
        x 17
        y 154
        noun 3608
        nsTop 147
        nsBottom 161
        nsRight 34
        description 3666
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 3671
    )
)
(instance rock of NewFeature
    (properties
        x 95
        y 183
        noun 3608
        nsTop 177
        nsLeft 81
        nsBottom 189
        nsRight 110
        description 3666
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 3671
    )
)
(instance tree11 of NewFeature
    (properties
        x 227
        y 144
        noun 3612
        nsTop 135
        nsLeft 157
        nsBottom 153
        nsRight 297
        description 3753
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 3758
    )
)
(instance tree10 of NewFeature
    (properties
        x 235
        y 156
        noun 3612
        nsTop 153
        nsLeft 185
        nsBottom 159
        nsRight 286
        description 3753
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 3758
    )
)
(instance tree9 of NewFeature
    (properties
        x 222
        y 66
        noun 3612
        nsTop -1
        nsLeft 198
        nsBottom 134
        nsRight 246
        description 3753
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 3758
    )
)
(instance tree8 of NewFeature
    (properties
        x 153
        y 41
        noun 3612
        nsTop -1
        nsLeft 109
        nsBottom 84
        nsRight 197
        description 3753
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 3758
    )
)
(instance tree7 of NewFeature
    (properties
        x 269
        y 19
        noun 3612
        nsTop -1
        nsLeft 245
        nsBottom 40
        nsRight 293
        description 3753
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 3758
    )
)
(instance tree6 of NewFeature
    (properties
        x 257
        y 59
        noun 3612
        nsTop 45
        nsLeft 246
        nsBottom 74
        nsRight 269
        description 3753
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 3758
    )
)
(instance tree5 of NewFeature
    (properties
        x 252
        y 85
        noun 3612
        nsTop 74
        nsLeft 247
        nsBottom 96
        nsRight 258
        description 3753
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 3758
    )
)
(instance tree4 of NewFeature
    (properties
        x 10
        y 59
        noun 3612
        nsTop -1
        nsBottom 119
        nsRight 20
        description 3753
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 3758
    )
)
(instance tree3 of NewFeature
    (properties
        x 27
        y 112
        noun 3612
        nsTop 105
        nsLeft 20
        nsBottom 119
        nsRight 34
        description 3753
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 3758
    )
)
(instance tree2 of NewFeature
    (properties
        x 64
        y 18
        noun 3612
        nsTop -1
        nsLeft 20
        nsBottom 37
        nsRight 108
        description 3753
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 3758
    )
)
(instance tree1 of NewFeature
    (properties
        x 65
        y 56
        noun 3612
        nsTop 37
        nsLeft 40
        nsBottom 76
        nsRight 91
        description 3753
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 3758
    )
)
(instance tree of NewFeature
    (properties
        x 63
        y 72
        noun 3612
        nsTop 66
        nsLeft 26
        nsBottom 78
        nsRight 100
        description 3753
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 3758
    )
)
(instance bush of NewFeature
    (properties
        x 298
        y 79
        noun 3616
        nsTop 40
        nsLeft 278
        nsBottom 119
        nsRight 319
        description 3933
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 3938
    )
)
