(version 2)
(include "sci.sh")
(exports
    0 rm1
)
(use "Main")
(use "Class_255_0")
(use "NewFeature")
(use "n958")
(use "StopWalk")
(use "RFeature")
(use "Cycle")
(use "Game")
(use "User")
(use "MenuBar")
(use "PicView")
(use "Obj")
(script 1)


(local
    local0
    local1[3]
    local4[3] = (51 170 288 )
    local7[3] = (155 156 158 )

)
(instance public rm1 of Rm
    (properties
        picture 1
        horizon 78
        north 53
        east 83
        west 2
    )

    (method (init)
        proc958_0(128 201 202 267 186 0)
        proc958_0(132 78 79 80 11)
        (self:keep(0))
        (self:style(
            (switch (gGNumber)
                (case north
                    5
                )
                (case west
                    41
                )
                (case east
                    40
                )
                (case south
                    4
                )
                (default 
                    (MenuBar:state(1))
                    (if (proc0_24(1))
                        17
                    )(else
                        15
                    )
                )
            )
))
        (gate:
            illegalBits(0)
            ignoreHorizon()
            setPri(3)
            stopUpd()
        )
        (self:setRegions(605))
        = local0 0
        (while (< local0 3)
            (send (= local1[local0] Clone(Ripple)):
                view(202)
                cycleSpeed(1)
                setPri(3)
                x(local4[local0])
                y(local7[local0])
                setLoop(0)
                ignoreActors(1)
                sightAngle(180)
                closeRangeDist(500)
                longRangeDist(500)
                description("ripples")
                init()
                stopUpd()
            )
            (if (>= global101 1)
                (send local1[local0]:setCycle(Fwd))
            )
            ++local0
        )
        (super:init())
        (if (not 
        (if ((send gEgo:has(16)) and (send gEgo:has(14)))
            (send gEgo:has(1))
        )
)
            (send gAddToPics:
                add(g1 g2)
                eachElementDo(#init)
                doit()
            )
        )
        (send gAddToPics:
            add(urn1 urn2)
            eachElementDo(#init)
            doit()
        )
        (if (proc0_12(40))
            proc0_11(40)
            (MenuBar:draw())
            (SL:enable())
        )
        (switch (gGNumber)
            (case 200
                (send global2:setScript(exitCastle))
            )
            (case west
                (send gEgo:
                    posn(3 proc0_17(112 (send gEgo:y) 100))
                    init()
                )
                (gate:init())
                proc0_1()
            )
            (case east
                (send gEgo:
                    posn(317 proc0_17(113 (send gEgo:y) 100))
                    init()
                )
                (gate:init())
                proc0_1()
            )
            (default 
                (send global2:setScript(exitCastle))
            )
        )
        (vine1:init())
        (vine2:init())
        (vine3:init())
        (vine4:init())
    )


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


    (method (handleEvent pEvent)
        (asm
            pushi   #claimed
            pushi   0
            lap     pEvent
            send    4
            bnt     code_02bb
            ret     
            jmp     code_04c6
code_02bb:  pushi   #handleEvent
            pushi   1
            lsp     pEvent
            super   Rm, 6
            bnt     code_02ca
            ret     
            jmp     code_04c6
code_02ca:  pushi   1
            lofsa   'open,open/door,gate'
            push    
            callk   Said, 2
            bnt     code_035b
            pushi   #y
            pushi   0
            lag     gEgo
            send    4
            push    
            ldi     86
            gt?     
            bnt     code_02ed
            pushi   2
            pushi   1
            pushi   0
            calle   proc255_0, 4
            jmp     code_04c6
code_02ed:  pushi   1
            pushi   2
            callb   proc0_12, 2
            bnt     code_02ff
            pushi   2
            pushi   1
            pushi   1
            calle   proc255_0, 4
            jmp     code_04c6
code_02ff:  pushi   #has
            pushi   1
            pushi   14
            lag     gEgo
            send    6
            bnt     code_0350
            pushi   #has
            pushi   1
            pushi   1
            lag     gEgo
            send    6
            bnt     code_0350
            pushi   #has
            pushi   1
            pushi   16
            lag     gEgo
            send    6
            bnt     code_0350
            pushi   2
            pushi   1
            pushi   2
            calle   proc255_0, 4
            pushi   #fade
            pushi   0
            pushi   2
            pushi   0
            pushi   23
            callk   ScriptID, 4
            send    4
            pushi   2
            pushi   111
            pushi   3
            callb   proc0_19, 4
            pushi   #setScript
            pushi   1
            lofsa   enterCastle
            push    
            lofsa   gate
            send    6
            jmp     code_04c6
code_0350:  pushi   2
            pushi   1
            pushi   3
            calle   proc255_0, 4
            jmp     code_04c6
code_035b:  pushi   1
            lofsa   'close,close/gate,door'
            push    
            callk   Said, 2
            bnt     code_0371
            pushi   2
            pushi   1
            pushi   4
            calle   proc255_0, 4
            jmp     code_04c6
code_0371:  pushi   1
            lofsa   'knock/door,gate'
            push    
            callk   Said, 2
            bnt     code_039f
            pushi   #y
            pushi   0
            lag     gEgo
            send    4
            push    
            ldi     86
            lt?     
            bnt     code_0395
            pushi   2
            pushi   1
            pushi   5
            calle   proc255_0, 4
            jmp     code_04c6
code_0395:  pushi   2
            pushi   1
            pushi   0
            calle   proc255_0, 4
            jmp     code_04c6
code_039f:  pushi   1
            lofsa   'get,get,use/planter,caldron,planter'
            push    
            callk   Said, 2
            bnt     code_03b5
            pushi   2
            pushi   1
            pushi   6
            calle   proc255_0, 4
            jmp     code_04c6
code_03b5:  pushi   1
            lofsa   'get,get<in/planter,planter,caldron'
            push    
            callk   Said, 2
            bt      code_03cb
            pushi   1
            lofsa   'hide<in/planter,planter,caldron'
            push    
            callk   Said, 2
            bnt     code_03d6
code_03cb:  pushi   2
            pushi   1
            pushi   7
            calle   proc255_0, 4
            jmp     code_04c6
code_03d6:  pushi   1
            lofsa   'look,look,talk,speak,kick,kill,kiss,attack/guard'
            push    
            callk   Said, 2
            bnt     code_03ec
            pushi   2
            pushi   1
            pushi   8
            calle   proc255_0, 4
            jmp     code_04c6
code_03ec:  pushi   6
            lsp     pEvent
            pushi   101
            pushi   30
            pushi   120
            pushi   48
            pushi   3
            callb   proc0_14, 12
            bnt     code_040b
            pushi   2
            pushi   1
            pushi   9
            calle   proc255_0, 4
            jmp     code_04c6
code_040b:  pushi   1
            lofsa   'look,look/planter,caldron'
            push    
            callk   Said, 2
            bnt     code_0421
            pushi   2
            pushi   1
            pushi   10
            calle   proc255_0, 4
            jmp     code_04c6
code_0421:  pushi   1
            lofsa   'look,look/ceder,vine,bury'
            push    
            callk   Said, 2
            bnt     code_0437
            pushi   2
            pushi   1
            pushi   11
            calle   proc255_0, 4
            jmp     code_04c6
code_0437:  pushi   1
            lofsa   'look,look/blossom'
            push    
            callk   Said, 2
            bnt     code_0466
            pushi   #y
            pushi   0
            lag     gEgo
            send    4
            push    
            ldi     112
            lt?     
            bnt     code_045b
            pushi   2
            pushi   1
            pushi   12
            calle   proc255_0, 4
            jmp     code_04c6
code_045b:  pushi   2
            pushi   1
            pushi   13
            calle   proc255_0, 4
            jmp     code_04c6
code_0466:  pushi   1
            lofsa   'remove/ring'
            push    
            callk   Said, 2
            bnt     code_04be
            pushi   1
            pushi   1
            callb   proc0_12, 2
            bnt     code_04b3
            pushi   #has
            pushi   1
            pushi   16
            lag     gEgo
            send    6
            bnt     code_049c
            pushi   #has
            pushi   1
            pushi   14
            lag     gEgo
            send    6
            bnt     code_049c
            pushi   #has
            pushi   1
            pushi   1
            lag     gEgo
            send    6
code_049c:  not     
            bnt     code_04b3
            pushi   2
            pushi   1
            pushi   14
            calle   proc255_0, 4
            pushi   #claimed
            pushi   1
            pushi   0
            lap     pEvent
            send    6
            jmp     code_04c6
code_04b3:  pushi   #claimed
            pushi   1
            pushi   0
            lap     pEvent
            send    6
            jmp     code_04c6
code_04be:  pushi   #handleEvent
            pushi   1
            lsp     pEvent
            super   Rm, 6
code_04c6:  ret     
        )
    )

)
(instance enterCastle of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send (ScriptID(0 21)):
                    number(78)
                    priority(15)
                    loop(1)
                    init()
                    play()
                )
                (gate:
                    illegalBits(0)
                    ignoreActors()
                    ignoreHorizon()
                    startUpd()
                    setMotion(MoveTo 160 25 self)
                )
            )
            (case 1
                (send (ScriptID(0 21)):stop())
                (gate:stopUpd())
                (send (ScriptID(0 23)):
                    number(11)
                    loop(-1)
                    play()
                )
                (if (proc0_12(1))
                    proc255_0(1 15)
                    proc0_11(1)
                    (send gEgo:view(0))
                    proc0_1()
                )
                (send gEgo:
                    illegalBits(0)
                    ignoreActors()
                    setLoop(3)
                    setMotion(MoveTo (send gEgo:x) 76 self)
                )
            )
            (case 2
                proc0_19(111 3)
                proc0_3()
                (send global2:newRoom(53))
            )
        )
    )

)
(instance exitCastle of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (gate:
                    posn(160 25)
                    ignoreActors()
                    init()
                    stopUpd()
                )
                (send gEgo:
                    setPri(-1)
                    view(0)
                    loop(2)
                    illegalBits(0)
                    ignoreHorizon()
                    posn(164 76)
                    setCycle(StopWalk 2)
                    init()
                    setMotion(MoveTo 164 86 self)
                )
            )
            (case 1
                (send (ScriptID(0 21)):
                    number(79)
                    init()
                    play()
                )
                (gate:setMotion(MoveTo 160 75 self))
            )
            (case 2
                (send (ScriptID(0 21)):
                    number(80)
                    play()
                )
                (gate:setMotion(MoveTo 160 80 self))
            )
            (case 3
                (gate:
                    ignoreActors(0)
                    stopUpd()
                )
                proc0_3()
                proc0_1()
                (self:dispose())
            )
        )
    )

)
(instance g1 of RPicView
    (properties
        x 203
        y 85
        description 3519
        sightAngle 180
        closeRangeDist 300
        longRangeDist 300
        view 186
        signal $0004
    )

    (method (handleEvent pEvent)
        (if ((send pEvent:claimed))
            return 
        )(else
            (if ((super:handleEvent(pEvent)))
                return 
            )(else
                (if (Said('look,look/guard,man'))
                    (self:doVerb(1))
                )(else
                    (if (Said('talk,speak,ask/guard,man'))
                        proc255_0(1 16)
                    )(else
                        (if (Said('give[/*]/guard'))
                            proc255_0(1 17)
                        )(else
                            (if (Said('attack,kick,kill/guard'))
                                proc255_0(1 18)
                            )(else
                                (if (Said('kiss,hug/guard'))
                                    proc255_0(1 19)
                                )
                            )
                        )
                    )
                )
            )
        )
    )


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

)
(instance g2 of RPicView
    (properties
        x 119
        y 85
        description 3519
        sightAngle 180
        closeRangeDist 300
        longRangeDist 300
        view 186
        cel 1
        signal $0004
    )

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

)
(instance gate of Actor
    (properties
        x 160
        y 80
        view 201
        signal $0004
        illegalBits $0000
    )

    (method (init param1)
        (self:yStep(
            (if (proc0_24(2))
                2
            )(else
                (if (proc0_24(1))
                    4
                )(else
                    (if (proc0_24(0))
                        7
                    )
                )
            )
))
        (super:init(rest param1))
    )


    (method (handleEvent pEvent)
        (if ((send pEvent:claimed))
            return 
        )(else
            (if ((super:handleEvent(pEvent)))
                return 
            )(else
                (if (Said('look,look/gate,door'))
                    (self:doVerb(1))
                )(else
                    (if (Said('enter/castle,gate,door'))
                        proc255_0(1 21)
                    )
                )
            )
        )
    )


    (method (doVerb theVerb)
        (switch (theVerb)
            (case 1
                proc255_0(1 22)
            )
        )
    )

)
(instance urn1 of RPicView
    (properties
        x 35
        y 103
        description 3536
        sightAngle 180
        closeRangeDist 300
        longRangeDist 300
        view 267
    )

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


    (method (doVerb theVerb)
        (switch (theVerb)
            (case 1
                proc255_0(1 23)
            )
        )
    )

)
(instance urn2 of RPicView
    (properties
        x 292
        y 103
        description 3536
        sightAngle 180
        closeRangeDist 300
        longRangeDist 300
        view 267
    )

    (method (doVerb theVerb)
        (switch (theVerb)
            (case 1
                proc255_0(1 23)
            )
        )
    )

)
(instance Ripple of Prop
    (properties)

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


    (method (doVerb theVerb)
        (switch (theVerb)
            (case 1
                proc255_0(1 24)
            )
        )
    )

)
(instance vine1 of NewFeature
    (properties
        x 37
        y 24
        noun 3467
        nsTop -1
        nsBottom 50
        nsRight 74
        description 3557
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 3562
    )
)
(instance vine2 of NewFeature
    (properties
        x 35
        y 56
        noun 3467
        nsTop 50
        nsLeft 29
        nsBottom 62
        nsRight 41
        description 3557
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 3562
    )
)
(instance vine3 of NewFeature
    (properties
        x 282
        y 24
        noun 3467
        nsLeft 246
        nsBottom 49
        nsRight 319
        description 3557
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 3562
    )
)
(instance vine4 of NewFeature
    (properties
        x 284
        y 56
        noun 3467
        nsTop 50
        nsLeft 279
        nsBottom 62
        nsRight 290
        description 3557
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 3562
    )
)
