(include "sci.sh")
(use "Main")
(use "Class_255_0")
(use "brain")
(use "SQRoom")
(use "Class_950_0")
(use "Cycle")
(use "Obj")
(script 505)



(instance public rm505 of SQRoom
    (properties
        picture 505
        style 30
        north 150
        east 510
        south 520
        west 500
        vanishingY 65286
    )

    (method (init)
        (switch (global12)
            (case north
                (self:setScript(enterScript 0 0))
            )
            (case south
                (self:setScript(enterScript 0 (brain:level)))
            )
            (default 
                proc0_3()
            )
        )
        (send gEgo:init())
        (self:setRegions(704))
        (super:init())
        (switch ((brain:level))
            (case 2
                (brain:makePolygon(65 189 74 166 236 166 248 189))
                (brain:makePolygon(281 189 281 166 319 166 319 189))
                (brain:makePolygon(0 189 0 0 319 0 319 149 49 149 27 189))
            )
            (case 3
                (brain:makePolygon(0 108 0 0 80 0 33 108))
                (brain:makePolygon(231 0 319 0 319 108 277 108))
                (brain:makePolygon(0 125 56 125 96 0 219 0 262 125 319 125 319 189 0 189))
            )
        )
        (send (ScriptID(704 4)):
            x(83)
            y(135)
            nsLeft(76)
            nsTop(130)
            nsBottom(140)
            nsRight(90)
            sightAngle(90)
            init()
        )
        (roomFeature:init())
    )


    (method (doit)
        (super:doit())
        (if (script)
        )(else
            (if (proc0_5(gEgo 8))
                (if (> (send gEgo:y) 100)
                    (brain:
                        level(1)
                        exitDir(180)
                    )
                )(else
                    (if (> (send gEgo:x) 160)
                        (brain:exitDir(315))
                    )(else
                        (brain:exitDir(45))
                    )
                )
            )
        )
    )

)
(instance enterScript of Script
    (properties)

    (method (changeState newState)
        (var temp0[2], temp2, temp3, temp4, temp5)
        (switch (= state newState)
            (case 0
                proc0_2()
                (switch (register)
                    (case 0
                        (if (< (send gEgo:x) 275)
                            = temp2 64
                            = temp3 25
                            = temp4 64
                            = temp5 50
                        )(else
                            = temp2 256
                            = temp3 25
                            = temp4 256
                            = temp5 50
                        )
                    )
                    (case 2
                        (if (< (send gEgo:x) 120)
                            = temp2 51
                            = temp3 230
                            = temp4 67
                            = temp5 162
                        )(else
                            = temp2 275
                            = temp3 230
                            = temp4 259
                            = temp5 162
                        )
                    )
                )
                (send gEgo:
                    x(temp2)
                    y(temp3)
                    setMotion(MoveTo temp4 temp5 self)
                )
            )
            (case 1
                proc0_3()
                (self:dispose())
            )
        )
    )

)
(instance roomFeature of Feature
    (properties
        nsBottom 200
        nsRight 320
        description "super brain computer"
        lookStr "This maze of cables, ducts, pipes, and glowing panels give the super brain computer a sense of being alive..."
    )

    (method (doVerb param1 param2)
        (switch (param1)
            (case 4
                Print("You'd better not.  Something might answer.")
            )
            (default 
                (super:doVerb(param1 rest param2))
            )
        )
    )

)
