(include "sci.sh")
(use "Main")
(use "Class_255_0")
(use "SQRoom")
(use "RandCycle")
(use "MCyc")
(use "PolyPath")
(use "Polygon")
(use "Class_950_0")
(use "Sound")
(use "Cycle")
(use "User")
(use "PicView")
(use "Obj")
(script 70)


(local
    local0
    local1
    local2[26] = (5 0 45 127 5 0 53 122 5 0 61 117 5 0 69 112 5 0 77 107 5 0 85 102 32768 )
    local28

)
(procedure (localproc_1096 param1 param2)
    = local0 Display(param1 106 300 100 6 1 101 0 105 69 102 global129 107)
    Display(param1 106 300 100 6 1 101 0 105 68 102 global130)
    = local1 Display(param2 106 300 100 6 85 101 0 105 69 102 global129 107)
    Display(param2 106 300 100 6 85 101 0 105 68 102 global130)
)


(procedure (localproc_1111)
    (if (local0)
        Display(70 10 108 local0)
        Display(70 10 108 local1)
        = local0 0
    )
)


(instance public rm070 of SQRoom
    (properties
        picture 70
    )

    (method (init)
        Load(rsVIEW 70)
        (super:init())
        (aSound:init())
        (if (== (send ((send global9:at(5))):owner) 70)
            (theJar:init())
        )
        (blotter:init())
        (door:
            init()
            stopUpd()
        )
        (grid:init())
        (theShadow:init())
        (theDesk:init())
        (theWires:init())
        (thePipes:init())
        (theRoom:init())
        (send gEgo:
            init()
            normal(0)
            view(70)
            loop(0)
            cel(0)
            illegalBits(32770)
            x(223)
            y(65534)
            xStep(3)
            yStep(15)
        )
        proc0_2()
        (self:setScript(fallScript))
        (send global2:addObstacle((send ((Polygon:new())):
                type(2)
                init(166 126 264 129 265 160 137 160)
                yourself()
            )
 (send ((Polygon:new())):
                type(2)
                init(275 82 319 10 319 183 296 162)
                yourself()
            )
 (send ((Polygon:new())):
                type(2)
                init(9 189 29 174 298 174 316 189)
                yourself()
            )
 (send ((Polygon:new())):
                type(2)
                init(0 162 43 162 49 171 0 171)
                yourself()
            )
 (send ((Polygon:new())):
                type(2)
                init(166 73 144 0 319 0 272 77)
                yourself()
            )
 (send ((Polygon:new())):
                type(2)
                init(138 0 162 74 87 127 71 127 46 144 56 144 47 151 45 160 0 160 0 0)
                yourself()
            )
))
    )


    (method (doit)
        (super:doit())
        (if (script)
        )(else
            (if (local28 and proc0_5(gEgo 2))
                (send global2:setScript(enterSewer))
            )
        )
    )

)
(instance fallScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                = cycles 2
            )
            (case 1
                (send gLongSong:
                    number(815)
                    vol(127)
                    loop(-1)
                    playBed()
                )
                (send gEgo:
                    setLoop(0)
                    setCycle(0)
                    setMotion(MoveTo 223 89 self)
                )
            )
            (case 2
                (aSound:
                    init()
                    number(115)
                    loop(1)
                    play()
                )
                (send gEgo:
                    cycleSpeed(1)
                    setCycle(End self)
                )
            )
            (case 3
                proc0_1(0 0)
                (send gEgo:
                    illegalBits(32770)
                    setHeading(180)
                )
                = seconds 2
            )
            (case 4
                proc0_3()
                (send client:setScript(0))
            )
        )
    )

)
(instance doorScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gEgo:
                    illegalBits(0)
                    setMotion(PolyPath 50 150 self)
                )
            )
            (case 1
                (send gEgo:
                    setPri(13)
                    setHeading(270 self)
                )
            )
            (case 2
                (aSound:
                    number(816)
                    play()
                )
                (send gEgo:
                    view(70)
                    normal(0)
                    setLoop(4)
                    cel(0)
                    illegalBits(0)
                    cycleSpeed(1)
                    setCycle(End self)
                )
            )
            (case 3
                (aSound:play())
                (send gEgo:
                    cel(0)
                    setCycle(End self)
                )
            )
            (case 4
                (aSound:play())
                (send gEgo:
                    cel(0)
                    setCycle(End self)
                )
            )
            (case 5
                (send gEgo:
                    view(0)
                    setLoop(1)
                )
                = cycles 1
            )
            (case 6
                (aSound:
                    number(810)
                    loop(1)
                    play()
                )
                (door:
                    description("open door")
                    setCycle(MCyc @local2 self)
                )
            )
            (case 7
                (door:
                    setPri(3)
                    stopUpd()
                )
                = local28 1
                (aSound:
                    number(811)
                    play()
                )
                = seconds 1
            )
            (case 8
                proc0_3()
                proc0_1(1)
                (send gEgo:illegalBits(32768))
                (send global32:
                    addToFront(doorOpening)
                    eachElementDo(102)
                    doit()
                )
                (self:dispose())
            )
        )
    )

)
(instance buttonScript of Script
    (properties)

    (method (init param1)
        (if (not (send gSq4KeyDownHandler:contains(self)))
            (send gSq4KeyDownHandler:addToFront(self))
        )
        (if (not (send gSq4MouseDownHandler:contains(self)))
            (send gSq4MouseDownHandler:addToFront(self))
        )
        (if (not (send gSq4DirectionHandler:contains(self)))
            (send gSq4DirectionHandler:addToFront(self))
        )
        (super:init(rest param1))
    )


    (method (dispose param1)
        (send gSq4KeyDownHandler:delete(self))
        (send gSq4MouseDownHandler:delete(self))
        (send gSq4DirectionHandler:delete(self))
        (super:dispose(rest param1))
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gEgo:setMotion(PolyPath 195 159 self))
            )
            (case 1
                (send gEgo:
                    setPri(+ (send gEgo:priority) 1)
                    setMotion(MoveTo (send gEgo:x) - (send gEgo:y) 2 self)
                )
            )
            (case 2
                (send gEgo:
                    view(70)
                    normal(0)
                    setLoop(7)
                    setCycle(Beg self)
                )
            )
            (case 3
                (if (not proc0_6(34))
                    Print("Ah! A button. Perhaps I'll give it a press.")
                )
                proc0_11(54 10)
                (send gEgo:
                    view(70)
                    setLoop(7)
                    setCycle(End self)
                )
                (if (not local28)
                    (send gEgo:illegalBits(32770))
                )(else
                    (send gEgo:illegalBits(32768))
                )
            )
            (case 4
                (aSound:
                    number(812)
                    loop(1)
                    play()
                )
                = seconds 2
            )
            (case 5
                (send gEgo:setCycle(Beg self))
            )
            (case 6
                = seconds 1
            )
            (case 7
                proc0_1(3 0)
                (send gEgo:
                    y(+ (send gEgo:y) 2)
                    setHeading(0 self)
                )
                (if (not local28)
                    (send gEgo:illegalBits(32770))
                )(else
                    (send gEgo:illegalBits(32768))
                )
            )
            (case 8
                (if (not proc0_6(34))
                    proc0_7(34)
                    (aSound:
                        init()
                        number(813)
                        loop(1)
                        play()
                    )
                    (if (== (send ((send global9:at(5))):owner) global11)
                        (theJar:stopUpd())
                    )
                    (send gEgo:stopUpd())
                    (hologram:
                        init()
                        cycleSpeed(1)
                        setCycle(End)
                    )
                    = seconds 3
                )(else
                    Print("Nothing happens.")
                    proc0_3()
                    (self:dispose())
                )
            )
            (case 9
                (hologramHead:
                    init()
                    cycleSpeed(1)
                    setCycle(RandCycle)
                )
                (hologram:
                    setLoop(2)
                    posn(170 83)
                    setCycle(RandCycle)
                )
                = cycles 1
            )
            (case 10
                (send gLongSong:
                    number(814)
                    loop(-1)
                    play()
                )
                localproc_1096("\"Data Entry 22795: This message is to whomever may be so fortunate as to find it. I am Professor Lloyd, lead designer of the Xenon Super Computer Project, the ultimate in artificial intelligence." "The computer was designed to enhance our lives but, instead, ended up being the ruin of us all.\"")
                = seconds 30
            )
            (case 11
                localproc_1111()
                = cycles 1
            )
            (case 12
                localproc_1096("\"We made the mistake of tying it into the most important facets of our existence here on Xenon including our weather control and defense systems." "It seemed like a sound idea at the time and all proceeded well for about three years.\"")
                = seconds 30
            )
            (case 13
                localproc_1111()
                = cycles 1
            )
            (case 14
                localproc_1096("\"It was around then that a deep space salvage operation recovered what appeared to be some sort of antiquated data storage unit contained in a flimsy cardboard box on which the words \"Leisure Suit Larry\" were imprinted." "On its back was the picture of a not particularly wholesome gentleman, but that's another story.\"")
                = seconds 30
            )
            (case 15
                localproc_1111()
                = cycles 1
            )
            (case 16
                localproc_1096("\"My counterparts exhibited shameful behavior as they tore open the box to get at its contents. I could not understand the commotion it generated. The data was uploaded into the Super Computer for analysis." "As a result, a crippling virus spread through the machine like a bad social disease. All control of the computer was lost.\"")
                = seconds 30
            )
            (case 17
                localproc_1111()
                = cycles 1
            )
            (case 18
                localproc_1096("\"All screens went blank, then these words were displayed by the monitors and uttered by the vocal outputs -\n\"WILCO MUST PAY!\"" "From that day forth the possessed computer waged war on the inhabitants of Xenon using our own weapons against us. Some managed to escape to other planets.\"")
                = seconds 30
            )
            (case 19
                localproc_1111()
                = cycles 1
            )
            (case 20
                localproc_1096("\"Those of us who remained stayed to fight the machines and robots under its control. It was a bloody war. Those of us that were not killed were taken captive and 'modified.'" "These 'cyborgs' infiltrated the loyal ranks of resistance, rooting out almost all of our hiding places and exposing us to the mechanical menace. Some of these poor souls still wander the streets.\"")
                = seconds 30
            )
            (case 21
                localproc_1111()
                = cycles 1
            )
            (case 22
                localproc_1096("\"As of this recording, we are down to only a handful of rebels. My health is deteriorating rapidly. To make matters worse, I've just learned that the computer has unraveled the mysteries of time travel." "I've sent my two best men to attempt to steal this new technology. If you are not a machine then perhaps they were successful. Please realize - YOU are Xenon's last hope.\"")
                = seconds 30
            )
            (case 23
                localproc_1111()
                = cycles 1
            )
            (case 24
                (send gLongSong:fade())
                (hologram:setCycle(0))
                (hologramHead:setCycle(0))
                = seconds 2
            )
            (case 25
                (aSound:play())
                (hologramHead:dispose())
                (hologram:
                    setLoop(1)
                    setCel(4)
                    posn(160 81)
                    setCycle(Beg self)
                )
            )
            (case 26
                (send gLongSong:
                    number(815)
                    vol(127)
                    play()
                )
                (hologram:dispose())
                proc0_3()
                (send ((send gEgo:_head)):startUpd())
                (send client:setScript(0))
            )
        )
    )


    (method (handleEvent pEvent)
        (if (local0)
            (send pEvent:claimed(1))
            localproc_1111()
            = seconds 0
            = cycles 1
        )(else
            (super:handleEvent(pEvent))
        )
    )

)
(instance jarScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gEgo:setMotion(PolyPath 197 165 self))
            )
            (case 1
                (if (not local28)
                    (send gEgo:illegalBits(32770))
                )(else
                    (send gEgo:illegalBits(32768))
                )
                proc0_13(gEgo theJar self)
            )
            (case 2
                Print("You take the jar into custody.")
                proc0_11(53 5)
                (send gEgo:get(5))
                (theJar:dispose())
                proc0_3()
                (self:dispose())
            )
        )
    )

)
(instance enterSewer of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gEgo:setMotion(PolyPath 63 136 self))
            )
            (case 1
                (send gEgo:setHeading(270 self))
            )
            (case 2
                (send gEgo:
                    view(70)
                    setLoop(8)
                    cel(0)
                    setCycle(End self)
                )
            )
            (case 3
                proc0_3()
                (send global2:newRoom(85))
            )
        )
    )

)
(instance door of Actor
    (properties
        x 45
        y 127
        z 65520
        description "sealed door"
        sightAngle 45
        lookStr "There's a hatch set into a cylindrical structure here. Your janitorial background helps you recognize it as an entrance to a sewer system. Your stomach churns just considering the wonderful things one can find in a sewer."
        view 70
        loop 5
        priority 9
        signal 18448
        illegalBits 0
    )

    (method (doVerb param1)
        (switch (param1)
            (case 2
                (if (not local28)
                    proc0_2()
                    (send global2:setScript(doorScript))
                )(else
                    Print("You realize that this is the only way out, so you decide to leave it open.")
                )
            )
            (case 1
                (if (local28)
                    Print("There's an open hatch set into a cylindrical structure here. You recognize it as the entrance to the sewer system.")
                )(else
                    (super:doVerb(param1))
                )
            )
            (default 
                (super:doVerb(param1))
            )
        )
    )

)
(instance doorOpening of Feature
    (properties
        x 49
        y 137
        z 33
        nsTop 85
        nsLeft 36
        nsBottom 123
        nsRight 63
        description "sewer entrance"
        sightAngle 45
        lookStr "You peer into the darker area beyond the hatch frame and see nothing particularly revolting."
    )

    (method (doVerb param1)
        (switch (param1)
            (case 2
                0
            )
            (case 1
                (if (not local28)
                    0
                )(else
                    (super:doVerb(param1))
                )
            )
            (case 11
                Print("It smells mysterious. You have the urge to play 'Name That Gas'.")
            )
            (default 
                (super:doVerb(param1))
            )
        )
    )

)
(instance theJar of View
    (properties
        x 197
        y 150
        z 22
        description "jar"
        sightAngle 45
        lookStr "It's an empty jar with a lid, neither of whaich does anything entertaining."
        view 70
        loop 6
        priority 12
        signal 16400
    )

    (method (doVerb param1)
        (switch (param1)
            (case 2
                (if (== (send ((send global9:at(5))):owner) 70)
                    (send gEgo:illegalBits(0))
                    (send global2:setScript(jarScript))
                )(else
                    (super:doVerb(param1))
                )
            )
            (default 
                (super:doVerb(param1))
            )
        )
    )

)
(instance hologram of Prop
    (properties)
)
(instance hologramHead of Prop
    (properties)
)
(instance theRoom of Feature
    (properties
        x 152
        z 65454
        nsBottom 189
        nsRight 319
        description "substation"
        sightAngle 180
        lookStr "You've reached the Sewer Maintenance Office. There's a thick layer of dust on everything, leading you to believe that there's very little maintenance going on. Apparently this office has been long abandoned. Your keen janitorial instincts urge you to sweep up and do a little dusting. Somehow you manage to suppress those urges and concentrate on the task at hand."
    )

    (method (doVerb param1)
        (switch (param1)
            (case 11
                Print("The smell down here isn't as bad as you thought.")
            )
            (default 
                (super:doVerb(param1))
            )
        )
    )

)
(instance blotter of Feature
    (properties
        x 230
        y 155
        z 31
        nsTop 115
        nsLeft 211
        nsBottom 133
        nsRight 249
        description "blotter"
        sightAngle 45
        lookStr "It's just an average old-fashioned desk blotter."
    )

    (method (doVerb param1)
        (switch (param1)
            (case 2
                proc0_2()
                (send gEgo:illegalBits(0))
                (send global2:setScript(buttonScript))
            )
            (default 
                (super:doVerb(param1))
            )
        )
    )

)
(instance grid of Feature
    (properties
        x 166
        y 83
        nsTop 76
        nsLeft 145
        nsBottom 91
        nsRight 188
        description "grid"
        sightAngle 45
        onMeCheck 16448
        lookStr "The strange little pedestal has wires running between it and the wall."
    )

    (method (doVerb param1)
        (switch (param1)
            (case 2
                Print("Nothing you can do to it here will be of benefit.")
            )
            (default 
                (super:doVerb(param1))
            )
        )
    )

)
(instance theDesk of Feature
    (properties
        x 212
        y 123
        z 30
        nsBottom 200
        nsRight 320
        description "desk"
        sightAngle 45
        onMeCheck 128
        lookStr "The desk is not exactly executive status caliber."
    )
)
(instance theWires of Feature
    (properties
        x 155
        y 75
        nsBottom 200
        nsRight 320
        description "wires"
        sightAngle 45
        onMeCheck 32
        lookStr "This heavy gauge wire disappears into the wall."
    )

    (method (doVerb param1)
        (switch (param1)
            (case 2
                Print("They won't come loose.")
            )
            (default 
                (super:doVerb(param1))
            )
        )
    )

)
(instance theShadow of Feature
    (properties
        x 227
        y 10
        nsLeft 198
        nsBottom 30
        nsRight 246
        description "grate shadow"
        sightAngle 45
        lookStr "You notice the shadow cast on the wall by the inaccessible grate above."
    )
)
(instance thePipes of Feature
    (properties
        nsBottom 200
        nsRight 320
        description "pipes"
        sightAngle 45
        onMeCheck 16
        lookStr "A variety of pipes, coolant and otherwise, pass in, through and around the room."
    )

    (method (doVerb param1)
        (self:
            x((send ((User:curEvent)):x))
            y((send ((User:curEvent)):y))
        )
        (switch (param1)
            (case 2
                Print("They're well affixed.")
            )
            (default 
                (super:doVerb(param1))
            )
        )
        (self:
            x(0)
            y(0)
        )
    )

)
(instance aSound of Sound
    (properties)
)
