(include "sci.sh")
(use "Main")
(use "Class_255_0")
(use "SQRoom")
(use "Class_950_0")
(use "Sound")
(use "Cycle")
(use "User")
(use "PicView")
(use "Obj")
(script 531)


(local
    theTheGWest
    local1
    local2
    theGWest
    UserCurEventX
    UserCurEventY
    newButn_2
    newButn[12]
    newDisplay[7]
    local26[30] = (245 129 255 129 265 129 275 129 285 129 245 139 255 139 265 139 275 139 285 139 245 149 255 149 265 149 275 149 285 149 )
    theGNewDisplayCel_2[36] = (5 4 3 2 1 0 20 20 20 20 20 20 2 20 20 20 20 20 10 10 10 10 10 10 6 11 1 7 13 9 4 14 6 9 1 11 )

)
(procedure (localproc_13bc param1)
    return 
        (if (((((== (send newDisplay[0]:cel) theGNewDisplayCel_2[param1]) and (== (send newDisplay[1]:cel) theGNewDisplayCel_2[++param1])) and (== (send newDisplay[2]:cel) theGNewDisplayCel_2[++param1])) and (== (send newDisplay[3]:cel) theGNewDisplayCel_2[++param1])) and (== (send newDisplay[4]:cel) theGNewDisplayCel_2[++param1]))
            == (send newDisplay[5]:cel) theGNewDisplayCel_2[++param1]
        )(else
            0
        )
)


(procedure (localproc_1426 param1)
    (var temp0)
    (send global2:overlay(
        (switch (param1)
            (case 305
                (windshield:lookStr("Peering through the port you see an unusual land. Although these alterations are much more exaggerated, it's wind-carved pinnacles and buttes bring back memories of the planet Kerona where this whole adventure mess started."))
                proc0_14(10)
(                = local2 6
)                533
            )
            (case 376
                (windshield:lookStr("This looks like some type of arcade where people mindlessly introduce coinage through insatiable slots to go adrenal amidst the electrons via the latest and not-so-late mind-toggling shoot-m-ups and maze games."))
                proc0_14(10)
(                = local2 12
)                534
            )
            (case 530
                (windshield:lookStr("You look out at the city you were born in decades ago. The capital building stands (just barely) with a huge hole in it. You're sure glad you weren't here when it happened. You might've gotten hurt. On the bright side, you won't have to pay those delinquent traffic tickets."))
                proc0_14(12)
(                = local2 18
)                532
            )
            (case 613
                (windshield:lookStr("Memories race through your mind. You know you've seen this place in your distant past. The rather low-res features look exactly like a place you once visited called Ulence Flats."))
                proc0_14(1)
(                = local2 24
)                631
            )
            (case 650
                (windshield:lookStr("This view provides a flashback to a recent adventure. It looks real hot out there. Hot enough for ThermoWeave(tm)."))
                proc0_14(3)
(                = local2 0
)                651
            )
            (default 
                (windshield:lookStr("You look out at the city you were born in decades ago. The capital building stands (just barely) with a huge hole in it. You're sure glad you weren't here when it happened. You might've gotten hurt. On the bright side, you won't have to pay those delinquent traffic tickets."))
                proc0_14(12)
(                = gWest 530
)(                = local2 18
)                532
            )
        )
))
)


(instance public rm531 of SQRoom
    (properties
        picture 531
    )

    (method (init)
        (var temp0, temp1, temp2)
        (super:init())
        (if (== gWest 815)
            = gWest 530
        )
        (windshield:init())
        Load(rsPIC 529)
        = theGWest gWest
        localproc_1426(theGWest)
        = temp1 0
        (while (<= temp1 5)
            = theGNewDisplayCel_2[(+ 18 temp1)] gNewDisplayCel_2[temp1]
            ++temp1
        )
        (if (Btest(35))
            = temp1 0
            (while (<= temp1 5)
                = theGNewDisplayCel_2[(+ 12 temp1)] gNewDisplayCel_3[temp1]
                ++temp1
            )
        )
        (if (proc999_5(gWest 305 376 530) and Btest(2))
            Bclear(2)
        )
        (if (>= global128 1)
            = temp1 0
            (while (<= temp1 5)
                = theGNewDisplayCel_2[(+ 6 temp1)] gNewDisplayCel[temp1]
                ++temp1
            )
        )
        = temp1 0
        (while (<= temp1 14)
            = temp2 (* temp1 2)
            (send (= newButn[temp1] (butn:new())):
                posn(local26[temp2] local26[++temp2])
                cel(temp1)
                init()
                setPri(0)
                stopUpd()
            )
            ++temp1
        )
        = temp1 0
        (while (<= temp1 5)
            (send (= newDisplay[temp1] (display:new())):
                posn(- 289 (* temp1 7) 114)
                cel(theGNewDisplayCel_2[+ local2 temp1])
                init()
            )
            ++temp1
        )
        = newButn_2 (butn:new())
        (send newButn_2:
            lookStr("\"ENT\"? Must be a secret code. Perhaps it means \"SELF DESTRUCT\" or maybe \"CHANGE RETURN\"?")
            posn(295 148)
            cel(15)
            init()
            setPri(0)
            stopUpd()
        )
        (hand:init())
        (rogerHead:init())
        (keyDisplay:init())
        (mainScreen:init())
        (smallCompartment:init())
        (largeCompartment:init())
        (headRest:init())
        (frog:init())
        (entryPad:init())
        (soundFX:init())
        (exitButn:init())
        (restOfPod:init())
        (send gEgo:view(0))
        proc0_3()
        (User:canControl(0))
        (send gIconBar:disable(0 4 5))
    )


    (method (newRoom param1)
        (if ((send gSounds:contains(soundFX)))
            (soundFX:dispose())
        )
        (super:newRoom(rest param1))
    )

)
(instance raiseHandS of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (hand:setMotion(MoveTo UserCurEventX UserCurEventY self))
            )
            (case 1
                (send gGame:setCursor(69 1 UserCurEventX UserCurEventY))
                = local1 1
                = cycles 2
            )
            (case 2
                (self:dispose())
            )
        )
    )

)
(instance lowerHandS of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (hand:setMotion(MoveTo 270 204 self))
            )
            (case 1
                (send gGame:setCursor(20 1 UserCurEventX 170))
                (if (register)
                    = local1 0
                    (self:dispose())
                )(else
                    (send caller:cue())
                )
            )
        )
    )

)
(instance pushAndBackS of Script
    (properties)

    (method (changeState newState)
        (var temp0[2])
        (switch (= state newState)
            (case 0
                (hand:posn((+ (hand:x) 1) (+ (hand:y) 1)))
                = cycles 6
            )
            (case 1
                (hand:posn((- (hand:x) 1) (- (hand:y) 1)))
                (send gGame:setCursor(69 1 (hand:x) (hand:y)))
                (self:dispose())
            )
        )
    )

)
(instance displayMeS of Script
    (properties)

    (method (changeState newState)
        (var temp0, temp1)
        (switch (= state newState)
            (case 0
                (User:canInput(0))
                (soundFX:
                    number(102)
                    loop(0)
                    play()
                )
                (send client:setPri(10))
                = cycles 1
            )
            (case 1
                (if (<> (send newDisplay[5]:loop) 4)
                    = temp0 5
                    (while (>= temp0 0)
                        (send newDisplay[temp0]:loop(4))
                        --temp0
                    )
                )(else
                    = temp0 4
                    (while (>= temp0 0)
                        (if (<> (send newDisplay[temp0]:loop) 4)
                            (send newDisplay[+ temp0 1]:loop(2))
                            (send newDisplay[+ temp0 1]:cel((send newDisplay[temp0]:cel)))
                        )
                        --temp0
                    )
                )
                (send newDisplay[0]:
                    loop(2)
                    cel((send client:cel))
                )
                = cycles 7
            )
            (case 2
                (send client:setPri(0))
                (User:canInput(1))
                (self:dispose())
            )
        )
    )

)
(instance timeToTimeWarpS of Script
    (properties)

    (method (changeState newState)
        (var temp0)
        (switch (= state newState)
            (case 0
                (soundFX:
                    number(102)
                    loop(0)
                    playBed()
                )
                (send newButn_2:setPri(10))
                (if (localproc_13bc(30))
                    (heart:
                        init()
                        setScript(ILoveLunacyScript)
                    )
                    (self:dispose())
                )(else
                    = cycles 1
                )
            )
            (case 1
                = theTheGWest 
                    (if (localproc_13bc(0))
                        650
                    )(else
                        (if (localproc_13bc(12))
                            376
                        )(else
                            (if (localproc_13bc(18))
                                530
                            )(else
                                (if (localproc_13bc(24))
                                    proc0_11(86 5)
                                    613
                                )(else
                                    (if ((== global128 1) and localproc_13bc(6))
(                                        = temp0 0
)                                        (while (<= temp0 5)
                                            (send newDisplay[temp0]:loop(4))
                                            ++temp0
                                        )
                                        0
                                    )(else
                                        (if ((== global128 1) and (<> (send newDisplay[5]:loop) 4))
(                                            = global128 2
)(                                            = temp0 0
)                                            (while (<= temp0 5)
(                                                = gNewDisplayCel[temp0] (= theGNewDisplayCel_2[(+ 6 temp0)] (send newDisplay[temp0]:cel))
)                                                ++temp0
                                            )
                                            Bset(35)
                                            (if (> gNewDisplayCel 10)
(                                                = gNewDisplayCel_3 2
)                                            )(else
(                                                = gNewDisplayCel_3 13
)                                            )
(                                            = temp0 1
)                                            (while (<= temp0 5)
(                                                = gNewDisplayCel_3[temp0] Random(0 14)
)                                                ++temp0
                                            )
                                            305
                                        )(else
                                            (if ((== global128 0) and (<> (send newDisplay[5]:loop) 4))
(                                                = global128 1
)(                                                = temp0 0
)                                                (while (<= temp0 5)
(                                                    = gNewDisplayCel[temp0] (= theGNewDisplayCel_2[(+ 6 temp0)] (send newDisplay[temp0]:cel))
)                                                    ++temp0
                                                )
(                                                = temp0 0
)                                                (while (<= temp0 5)
                                                    (send newDisplay[temp0]:loop(4))
                                                    ++temp0
                                                )
                                                0
                                            )(else
                                                (if (localproc_13bc(6))
                                                    305
                                                )(else
(                                                    = temp0 0
)                                                    (while (<= temp0 5)
                                                        (send newDisplay[temp0]:loop(4))
                                                        ++temp0
                                                    )
                                                    0
                                                )
                                            )
                                        )
                                    )
                                )
                            )
                        )
                    )
                (hand:setScript(lowerHandS self 0))
            )
            (case 2
                = seconds 1
                (send gLongSong2:stop())
            )
            (case 3
                proc0_2()
                (send newButn_2:setPri(0))
                Print("The powerful quad-quark drives rev to life!")
                (if (theTheGWest and (<> theTheGWest theGWest))
                    (send gLongSong:
                        number(17)
                        loop(0)
                        vol(127)
                        flags(1)
                        playBed()
                    )
                )(else
                    (send gLongSong:
                        number(16)
                        loop(0)
                        vol(127)
                        flags(1)
                        playBed(musicDummy)
                    )
                )
                = seconds 2
            )
            (case 4
                Print("Time and space bend under the fibrilations of the time rip trans-fluxers. Your adrenalin (and stomach) reel with the hyperbolic hyperbole...!")
                = seconds 4
            )
            (case 5
                Print("And, finally... FINALLY...")
                = seconds 2
            )
            (case 6
                (if (gTheNewDialog)
                    (send gTheNewDialog:dispose())
                )
                (if (theTheGWest and (<> theTheGWest theGWest))
                    = temp0 0
                    (while (<= temp0 5)
                        (send newDisplay[temp0]:hide())
                        ++temp0
                    )
                    = cycles 2
                    (if (Btest(22))
                        Bclear(22)
                        Bset(8)
                        Bclear(10)
                        Bclear(11)
                        Bclear(13)
                        Bclear(12)
                        Bclear(20)
                        Bclear(19)
                        Bclear(30)
                        Bclear(23)
                        Bclear(30)
                        Bset(36)
                    )
                )(else
                    (User:canInput(1))
                    (send gIconBar:enable(2))
                    (send gIconBar:enable(3))
                    (send gIconBar:enable(1))
                    (lowerHandS:caller(0))
                    (hand:setScript(0))
                    (if (theTheGWest)
                        Print("... nothing happens. You're already there, Roger!")
                    )(else
                        Print("... nothing much happens. That must not have been a valid code. Even this far into the future controlled time travel has yet to be perfected.")
                    )
                    (send gGame:setCursor(20 1 UserCurEventX 170))
                    = temp0 0
                    (while (<= temp0 5)
                        (send newDisplay[temp0]:loop(4))
                        ++temp0
                    )
                    (self:dispose())
                )
            )
            (case 7
                (send global2:overlay(529))
                = cycles 1
            )
            (case 8
                (while (<> (send gLongSong:prevSignal) -1)
                    (send gLongSong:check())
                    Palette(6 234 254 -1)
                )
                Bclear(16)
                (lowerHandS:caller(0))
                (hand:setScript(0))
                (switch (theTheGWest)
                    (case 650
                        (send gLongSong2:
                            number(15)
                            loop(-1)
                            vol(90)
                            flags(1)
                            playBed()
                        )
                    )
                    (case 613
                        (send gLongSong2:
                            number(14)
                            vol(127)
                            loop(1)
                            flags(1)
                            playBed()
                        )
                    )
                    (case 530
                        (send gLongSong2:
                            number(535)
                            vol(80)
                            loop(-1)
                            flags(1)
                            playBed()
                        )
                    )
                    (case 376
                        (send gLongSong2:
                            number(19)
                            loop(-1)
                            vol(80)
                            flags(1)
                            playBed()
                        )
                    )
                )
                (if (proc999_5(theTheGWest 305 376 530))
                    Bset(2)
                    Bset(26)
                    (send global2:newRoom(theTheGWest))
                )(else
                    = theGWest theTheGWest
                    localproc_1426(theTheGWest)
                    proc0_3()
                    (User:canControl(0))
                    (send gIconBar:disable(0 4 5))
                    = temp0 0
                    (while (<= temp0 5)
                        (send newDisplay[temp0]:show())
                        ++temp0
                    )
                    (User:canInput(1))
                    (self:dispose())
                )
            )
        )
    )

)
(instance exitScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (hand:
                    x(55)
                    y(189)
                    setLoop(1)
                    setMotion(MoveTo 37 151 self)
                )
            )
            (case 1
                = cycles 3
            )
            (case 2
                (soundFX:
                    number(812)
                    loop(0)
                    play()
                )
                (hand:setMotion(MoveTo 41 151 self))
            )
            (case 3
                = cycles 3
            )
            (case 4
                (hand:setMotion(MoveTo 55 189 self))
            )
            (case 5
                (send global2:newRoom(theGWest))
            )
        )
    )

)
(instance hand of Actor
    (properties
        x 300
        y 200
        yStep 15
        view 531
        priority 14
        signal 30736
        illegalBits 0
        xStep 15
    )

    (method (doit)
        (var userCurEvent, temp1)
        (if (not script and (== (send ((send gIconBar:curIcon)):message) 2))
            = userCurEvent (User:curEvent)
            (if (not & (send userCurEvent:type) $0003)
                (send userCurEvent:localize())
                = UserCurEventX (send userCurEvent:x)
                = UserCurEventY (send userCurEvent:y)
                = temp1 proc999_4(230 118 308 164 UserCurEventX UserCurEventY)
                (if (not local1 and temp1)
                    (self:setScript(raiseHandS))
                )(else
                    (if (temp1)
                        (self:posn(UserCurEventX UserCurEventY))
                    )(else
                        (if (local1)
                            (self:setScript(lowerHandS 0 1))
                        )
                    )
                )
            )
        )(else
            (if (not script and local1)
                (self:setScript(lowerHandS 0 1))
            )
        )
        (super:doit())
    )

)
(instance butn of Prop
    (properties
        x 247
        y 128
        description "button"
        lookStr "It's a button with a strange symbol on it. You vaguely remember these symbols from your fifth grade Time Theory class with crazy Mrs. Drimple. Say now, wasn't that about the time you decided to become a janitor?"
        view 531
        loop 3
        priority 10
        signal 16384
    )

    (method (doVerb param1)
        (switch (param1)
            (case 3
                0
            )
            (case 4
                Print("This is a manual keypad.  The voice-activated model won't be out until SQ XIV or so.")
            )
            (case 2
                (if ((not script and not (hand:script)) and not (send global2:script))
                    (if (== cel 15)
                        (send global2:setScript(timeToTimeWarpS))
                    )(else
                        (hand:setScript(pushAndBackS))
                        (self:setScript(displayMeS))
                    )
                )
            )
            (default 
                (super:doVerb(param1))
            )
        )
    )


    (method (cue param1)
        (super:cue(rest param1))
    )

)
(instance display of View
    (properties
        description "time/space coordinate"
        lookStr "The read-out displays some interesting symbols similiar to those on the keypad. You wonder if these might bear some significance."
        view 531
        loop 2
        priority 10
    )
)
(instance windshield of Feature
    (properties
        description "windshield"
    )

    (method (onMe param1)
        return == OnControl(4 (send param1:x) (send param1:y)) 2
    )

)
(instance rogerHead of Feature
    (properties
        description "your head"
        lookStr "That's your head, Roger. Now use it for something."
    )

    (method (doVerb param1)
        (switch (param1)
            (case 4
                Print("You talk to yourself.")
            )
            (case 2
                Print("Scratching your head doesn't make it work any better. It only loosens unsightly dandruff.")
            )
            (default 
                (super:doVerb(param1))
            )
        )
    )


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

)
(instance mainScreen of Feature
    (properties
        description "main screen"
        lookStr "It's some sort of monitor. Probably used to monitor something or other."
    )

    (method (onMe param1)
        return == OnControl(4 (send param1:x) (send param1:y)) 8
    )

)
(instance keyDisplay of Feature
    (properties
        description "keypad display"
        lookStr "This appears to be the display for the keypad below it."
    )

    (method (onMe param1)
        return == OnControl(4 (send param1:x) (send param1:y)) 16
    )

)
(instance smallCompartment of Feature
    (properties
        description "small access panel"
        lookStr "This is a small panel which provides access to the innards of the time pod. For anyone with a 3P-223/4QR access panel wrench, that is."
    )

    (method (doVerb param1)
        (switch (param1)
            (case 3
                0
            )
            (case 2
                Print("The small access panel is inaccessible.")
            )
            (default 
                (super:doVerb(param1))
            )
        )
    )


    (method (onMe param1)
        return == OnControl(4 (send param1:x) (send param1:y)) 32
    )

)
(instance largeCompartment of Feature
    (properties
        description "large compartment"
        lookStr "It's a large compartment that's probably full of instruction manuals, code books, time maps, and the like. Too bad it's also locked."
    )

    (method (doVerb param1)
        (switch (param1)
            (case 3
                0
            )
            (case 2
                Print("The large compartment doesn't actually open.")
            )
            (default 
                (super:doVerb(param1))
            )
        )
    )


    (method (onMe param1)
        return == OnControl(4 (send param1:x) (send param1:y)) 64
    )

)
(instance headRest of Feature
    (properties
        description "headrest"
        lookStr "A standard time-pod headrest. Not very comfortable, but the regular operators have metal heads, so it's not a concern... for them."
    )

    (method (doVerb param1)
        (switch (param1)
            (case 3
                0
            )
            (case 2
                Print("The time pod's headrest is non-adjustable. Evidently, Sequel Police are all the same height.")
            )
            (default 
                (super:doVerb(param1))
            )
        )
    )


    (method (onMe param1)
        return == OnControl(4 (send param1:x) (send param1:y)) 128
    )

)
(instance cables of Feature
    (properties
        description "power cables"
        lookStr "Those are unshielded quark power cables. No telling what they're doing to your DNA's genetic structures right now."
    )

    (method (doVerb param1)
        (switch (param1)
            (case 3
                0
            )
            (case 2
                Print("You don't want to touch those. You might mutate your fingers.")
            )
            (default 
                (super:doVerb(param1))
            )
        )
    )


    (method (onMe param1)
        return == OnControl(4 (send param1:x) (send param1:y)) 256
    )

)
(instance entryPad of Feature
    (properties
        description "Time/Space Coordinate Entry Unit"
        lookStr "It's part of the TSCEU (Time/Space Coordinate Entry Unit)."
    )

    (method (onMe param1)
        return == OnControl(4 (send param1:x) (send param1:y)) 512
    )

)
(instance exitButn of Feature
    (properties
        description "canopy button"
        lookStr "That button opens the canopy."
    )

    (method (doVerb param1)
        (switch (param1)
            (case 2
                (if ((hand:script) or (send global2:script))
                )(else
                    proc0_2()
                    = local1 1
                    (hand:setScript(exitScript))
                )
            )
            (case 11
                Print("Placing your ample proboscus closer to the switch would result in severe quark burns from the unshielded cables below. It might, however, also rid you of those unsightly nose hairs.")
            )
            (case 10
                Print("Licking switches is never a good idea unless your into the kind of buzz that causes you to loose all control of your muscle system. This could results in the lose of control of all bodily functions.")
            )
            (default 
                (super:doVerb(param1))
            )
        )
    )


    (method (onMe param1)
        return == OnControl(4 (send param1:x) (send param1:y)) 1024
    )

)
(instance restOfPod of Feature
    (properties
        description "time pod"
        lookStr "You're sitting inside a time machine, remember?"
    )

    (method (doVerb param1)
        (switch (param1)
            (case 2
                Print("The time pod's interior feels smooth and cool to the touch.")
            )
            (case 11
                Print("Not only does the time pod look like a used tennis shoe, from the inside, it SMELLS like one, too!")
            )
            (default 
                (super:doVerb(param1))
            )
        )
    )


    (method (onMe)
        return 1
    )

)
(instance soundFX of Sound
    (properties
        number 102
        priority 5
    )
)
(instance frog of Feature
    (properties
        nsTop 183
        nsLeft 27
        nsBottom 189
        nsRight 62
        description "blue frog"
        lookStr "Blue frogs on my shoulder makes me hap-py..."
    )

    (method (doVerb)
        (var temp0)
        = local2 Print("Where To?")
        (if ((< global128 2) and (== local2 6))
            Print("Debug - can't cheat for Estros - You need to enter two complete entries - second entry will be Estros' code from now on.")
        )(else
            (if ((< global128 2) and (== local2 12))
                Print("Debug - can't go to the mall before you go to Estros")
            )(else
                = temp0 0
                (while (<= temp0 5)
                    (send newDisplay[temp0]:
                        loop(2)
                        cel(theGNewDisplayCel_2[+ local2 temp0])
                    )
                    ++temp0
                )
                (hand:posn(180 180))
                (send global2:setScript(timeToTimeWarpS))
            )
        )
    )

)
(instance heart of Prop
    (properties
        x 194
        y 131
        view 888
        cel 1
        priority 10
        signal 16400
    )
)
(instance ILoveLunacy of View
    (properties
        x 194
        y 131
        view 888
        loop 1
        priority 11
        signal 16400
    )
)
(instance ILoveLunacyScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (heart:
                    cycleSpeed(4)
                    setCycle(Fwd)
                )
                = cycles 2
            )
            (case 1
                (send newButn_2:setPri(0))
                = seconds 3
            )
            (case 2
                (ILoveLunacy:init())
                = seconds 5
            )
            (case 3
                (ILoveLunacy:dispose())
                = cycles 3
            )
            (case 4
                (heart:hide())
                = cycles 2
            )
            (case 5
                Print("It was the \"I Love Lunacy\" show! You must've briefly tuned into the electronic entrails of some long-lost civalization.")
                (User:canInput(1))
                (send gIconBar:enable(2))
                (send gIconBar:enable(3))
                (send gIconBar:enable(1))
                (heart:dispose())
            )
        )
    )

)
(instance musicDummy of Script
    (properties)

    (method (cue)
        (if (proc999_5((send gLongSong2:number) 19 535 15))
            (send gLongSong2:
                vol(80)
                loop(-1)
                flags(1)
                play()
            )
        )
    )

)
