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



(instance public rm515 of SQRoom
    (properties
        lookStr "This maze of cables, ducts, pipes, and glowing panels give the super brain computer a sense of being alive..."
        picture 515
        style 30
        north 500
        east 520
        west 514
        vanishingX 530
        vanishingY 65086
    )

    (method (init)
        (var temp0)
        Load(rsVIEW 507)
        (switch (global12)
            (case north
                (self:
                    setScript(enterScript 0 1)
                    vanishingX(540)
                    vanishingY(65136)
                )
            )
            (case west
                (self:setScript(enterScript 0 4))
            )
            (default 
                proc0_3()
            )
        )
        (send gEgo:init())
        (self:setRegions(704))
        (super:init())
        (if (== global12 1)
            (brain:level(3))
            (send gEgo:
                setPri(-1)
                x(300)
                y(88)
            )
            = global12 520
        )
        (switch ((brain:level))
            (case 1
                (brain:makePolygon(0 0 319 0 319 131 117 131 115 142 117 153 77 153 77 159 319 159 319 189 0 189))
            )
            (case 2
                (brain:makePolygon(0 189 0 176 180 176 215 130 319 130 319 188))
                (brain:makePolygon(0 153 0 0 319 0 319 110 197 110 153 153))
            )
            (case 3
                (brain:makePolygon(0 0 149 0 95 48 96 57 93 63 57 63 57 70 83 70 72 75 63 75 55 80 71 97 319 97 319 189 0 189))
                (brain:makePolygon(136 38 319 38 319 75 99 75))
                (brain:makePolygon(154 24 177 0 319 0 319 24))
            )
        )
        (send (ScriptID(704 3)):
            x(137)
            y(123)
            nsLeft(132)
            nsTop(119)
            nsBottom(127)
            nsRight(142)
            sightAngle(90)
            init()
        )
        (send (ScriptID(704 4)):
            x(63)
            y(141)
            nsLeft(55)
            nsTop(135)
            nsBottom(147)
            nsRight(72)
            sightAngle(90)
            init()
        )
        (send (ScriptID(704 5)):
            x(170)
            y(61)
            nsLeft(164)
            nsTop(56)
            nsBottom(66)
            nsRight(177)
            sightAngle(90)
            init()
        )
        (tube:init())
    )


    (method (doit)
        (if (script)
        )(else
            (if ((send gEgo:script))
            )(else
                (if (proc0_5(gEgo 16))
                    (send gEgo:setScript((elevatorScript:new()) 0 0))
                )(else
                    (if ((== (brain:level) 1) and proc0_5(gEgo 32))
                        (send gEgo:setScript((elevatorScript:new()) 0 1))
                    )(else
                        (if (proc0_5(gEgo 8))
                            (if (< (send gEgo:y) 100)
                                (brain:exitDir(45))
                            )(else
                                (brain:exitDir(270))
                            )
                        )
                    )
                )
            )
        )
        (if (not (send (ScriptID(704 1)):script) and not (send (ScriptID(704 2)):script))
            (super:doit())
            (if (== (send (ScriptID(704 1)):room) 515)
                (if ((send (ScriptID(704 1)):script))
                )(else
                    (if (proc0_5(ScriptID(704 1) 16))
                        (send (ScriptID(704 1)):setScript((elevatorScript:new()) 0 0))
                    )(else
                        (if (proc0_5(ScriptID(704 1) 32) and (== (send (ScriptID(704 1)):level) 1))
                            (send (ScriptID(704 1)):setScript((elevatorScript:new()) 0 1))
                        )
                    )
                )
            )
            (if (== (send (ScriptID(704 2)):room) 515)
                (if ((send (ScriptID(704 2)):script))
                )(else
                    (if (proc0_5(ScriptID(704 2) 16))
                        (send (ScriptID(704 2)):setScript((elevatorScript:new()) 0 0))
                    )(else
                        (if (proc0_5(ScriptID(704 2) 32) and (== (send (ScriptID(704 2)):level) 1))
                            (send (ScriptID(704 2)):setScript((elevatorScript:new()) 0 1))
                        )
                    )
                )
            )
            (if (== (brain:level) 2)
                (if ((send gEgo:inRect(60 150 110 180)))
                    (send gEgo:setPri(5))
                )(else
                    (send gEgo:setPri(3))
                )
            )
        )
    )


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

)
(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 1
                        = temp2 172
                        = temp3 65529
                        = temp4 131
                        = temp5 37
                    )
                    (case 4
                        = temp2 5
                        = temp3 170
                        = temp4 30
                        = temp5 170
                    )
                )
                (send gEgo:
                    x(temp2)
                    y(temp3)
                    setMotion(PolyPath temp4 temp5 self)
                )
            )
            (case 1
                proc0_3()
                (self:dispose())
            )
        )
    )

)
(instance elevatorScript of Script
    (properties)

    (method (dispose)
        (if (<> client gEgo)
            (send ((send client:path)):value(
                (if (register)
                    75
                )(else
                    209
                )
))
            (send client:
                z(44)
                setLoop(0)
                setCycle(Fwd)
                mover((send client:path))
            )
            (send ((send client:body)):doit())
            (send ((send client:path)):moveDone())
        )
        (super:dispose())
    )


    (method (changeState newState)
        (var temp0)
        (switch (= state newState)
            (case 0
                (if (== client gEgo)
                    proc0_2()
                )
                (send client:setPri(2))
                (if (register)
                    (send client:setMotion(MoveTo 85 158 self))
                )(else
                    (send client:setMotion(MoveTo 63 67 self))
                )
            )
            (case 1
                (send client:setHeading(90 self))
            )
            (case 2
                (send gLongSong2:
                    number(847)
                    vol(127)
                    loop(1)
                    play()
                )
                (if (== client gEgo)
                    (brain:level(0))
                    (send gEgo:
                        normal(0)
                        view(507)
                        setLoop(0)
                        cycleSpeed(1)
                        setCycle(End self)
                    )
                )(else
                    (send ((send client:body)):hide())
                    (send client:
                        z(0)
                        setLoop(2)
                        setCel(0)
                        cycleSpeed(1)
                        setCycle(End self)
                    )
                )
            )
            (case 3
                (send client:hide())
                = cycles 10
            )
            (case 4
                (send gLongSong2:
                    number(847)
                    vol(127)
                    loop(1)
                    play()
                )
                (if (register)
                    (send client:posn(63 67))
                )(else
                    (send client:posn(85 158))
                )
                (if (== client gEgo)
                    = temp0 10
                )(else
                    = temp0 6
                )
                (send client:
                    show()
                    setPri(2)
                    setCel(temp0)
                    setCycle(Beg self)
                )
            )
            (case 5
                (if (== client gEgo)
                    (send ((send global2:obstacles)):dispose())
                    (brain:level(
                        (if (register)
                            3
                        )(else
                            1
                        )
))
                    (switch ((brain:level))
                        (case 1
                            (brain:makePolygon(0 0 319 0 319 131 117 131 115 142 117 153 77 153 77 159 319 159 319 189 0 189))
                        )
                        (case 3
                            (brain:makePolygon(0 0 149 0 95 48 96 57 93 63 57 63 57 70 83 70 72 75 63 75 55 80 71 97 319 97 319 189 0 189))
                            (brain:makePolygon(136 38 319 38 319 75 99 75))
                            (brain:makePolygon(154 24 177 0 319 0 319 24))
                        )
                    )
                    proc0_1(0 3 510)
                    (send gEgo:setPri(2))
                )(else
                    (send client:
                        z(44)
                        setLoop(0)
                        setCycle(Fwd)
                    )
                )
                (send client:setMotion(MoveFwd 30 self))
            )
            (case 6
                (if (register)
                    (send client:setPri(-1))
                )
                (if (== client gEgo)
                    (send global2:
                        vanishingX(
                            (if (register)
                                540
                            )(else
                                530
                            )
)
                        vanishingY(
                            (if (register)
                                65136
                            )(else
                                65086
                            )
)
                    )
                    proc0_3()
                )(else
                    (switch ((send client:level))
                        (case 1
                            (send client:setPri(2))
                        )
                        (case 2
                            (send client:setPri(3))
                        )
                        (case 3
                            (send client:setPri(-1))
                        )
                    )
                    (send ((send client:body)):doit())
                )
                (self:dispose())
            )
        )
    )

)
(instance tube of Feature
    (properties
        description "elevator tube"
        lookStr "The glass tube reminds you of the old vacuum tubes in the drive-up aisles at banks."
    )

    (method (doVerb param1 param2)
        (switch (param1)
            (case 1
                (super:doVerb(param1 rest param2))
            )
            (default 
                (send global2:doVerb(param1 rest param2))
            )
        )
    )


    (method (onMe param1)
        return == OnControl(1 (send param1:x) (send param1:y)) 16384
    )

)
