(include "sci.sh")
(use "Main")
(use "Class_255_0")
(use "SQRoom")
(use "PolyPath")
(use "Polygon")
(use "Class_950_0")
(use "n958")
(use "StopWalk")
(use "Sound")
(use "Cycle")
(use "PicView")
(use "Obj")
(script 530)


(local
    local0
    local1
    local2[48] = (131 40 143 42 157 41 168 36 175 30 180 23 184 16 255 15 260 24 262 50 248 63 240 64 224 79 219 79 203 80 187 80 187 79 172 79 171 80 146 80 146 78 123 78 129 52 124 37 )

)
(procedure (localproc_1394 param1 param2 param3 param4)
    (var temp0, temp1, temp2)
    (aSound:
        number(105)
        loop(1)
        vol(127)
        play()
    )
    (if (< param1 param3)
        = temp0 (- param1 1)
        = temp1 (+ param3 1)
    )(else
        = temp0 (- param3 1)
        = temp1 (+ param1 1)
    )
    = temp2 Graph(7 temp0 (- param2 1) temp1 (+ param4 1) 1)
    Graph(4 param1 param2 param3 param4 global143 -1 -1)
    Graph(13 temp0 - param2 1 temp1 + param4 1)
    Wait(1)
    Wait(4)
    Graph(8 temp2)
    Graph(13 temp0 - param2 1 temp1 + param4 1)
)


(instance public rm530 of SQRoom
    (properties
        picture 530
        east 535
        vanishingX 319
        vanishingY 65476
    )

    (method (init)
        (if (== global12 815)
            = global12 531
        )
        proc0_2()
        proc958_0(128 0 378 530 300 26)
        proc958_0(132 124 125 131 838)
        (send global2:addObstacle((send ((Polygon:new())):
                type(2)
                init(257 172 270 152 319 152 319 172)
                yourself()
            )
 (send ((Polygon:new())):
                type(2)
                init(31 170 0 170 0 0 319 0 319 52 267 52 254 65 246 67 230 83 133 83 117 81 71 114 77 117 111 112 144 119 158 126 181 114 205 115 228 134 216 140 180 144 143 151 128 150 119 138 85 149 69 150 60 145)
                yourself()
            )
 (send ((Polygon:new())):
                type(0)
                init(167 165 167 189 127 189 127 166)
                yourself()
            )
))
        (timePod0:init())
        (terminal:init())
        (switch (global12)
            (case 531
                (self:setScript(
                    (if (proc0_6(2))
                        egoArrives
                    )(else
                        (if (not proc0_6(26))
                            proc958_0(128 7 13)
                            Load(rsSOUND 105)
                            (sp1:
                                loop(2)
                                init()
                            )
                            (sp2:
                                view(7)
                                loop(2)
                                x(185)
                                y(91)
                                init()
                            )
                        )
                        (send gEgo:
                            view(378)
                            loop(0)
                            cel(0)
                            posn(188 149)
                            setPri(11)
                            ignoreActors()
                            illegalBits(0)
                            cycleSpeed(1)
                            normal(0)
                            moveHead(0)
                            init()
                        )
                        egoExits
                    )
))
            )
            (default 
                proc958_0(128 7 13)
                Load(rsSOUND 105)
                (self:style(40))
                (if (proc0_6(1))
                    proc0_2()
                    (hatch:
                        init()
                        cel(
                            (if (proc0_6(26))
                                0
                            )(else
                                0
                            )
)
                    )
                    (pod:init())
                    (if (not proc0_6(26))
                        (sp1:
                            loop(0)
                            init()
                        )
                        (sp2:
                            view(7)
                            loop(0)
                            x(185)
                            y(91)
                            init()
                        )
                    )
                    (send gEgo:
                        x(282)
                        y(
                            (if (not proc0_6(26))
                                130
                            )(else
                                (if (> (send gEgo:y) 152)
                                    152
                                )(else
                                    (send gEgo:y)
                                )
                            )
)
                        init()
                    )
                    proc0_9()
                    (self:setScript(enterScript))
                )(else
                    (sp1:init())
                    (send gEgo:
                        x(284)
                        y(130)
                        init()
                    )
                    (sp1:setScript(policeArrive))
                )
            )
        )
        proc0_7(1)
        (send global32:
            add(theRedBall theRailView1 theRailView2 building)
            eachElementDo(102)
            doit()
        )
        (super:init())
        (self:setRegions(709))
        (buildingPoly:
            points(@local2)
            size(24)
        )
    )


    (method (doit param1)
        (super:doit(rest param1))
        (if (> (send gEgo:x) 300)
            proc0_2()
            (send global2:newRoom(535))
        )
    )

)
(instance enterScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                0
                = cycles 1
            )
            (case 1
                (send gEgo:
                    setCycle(StopWalk 4)
                    setMotion(MoveTo 255 (send gEgo:y) self)
                )
            )
            (case 2
                (if (proc0_6(26))
                    proc0_3()
                    (send client:setScript(0))
                )(else
                    (policeArrive:start(18))
                    (send client:setScript(policeArrive))
                )
            )
        )
    )

)
(instance egoArrives of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                = cycles 8
            )
            (case 1
                (sparks:
                    init()
                    setCycle(Fwd)
                )
                = cycles 10
            )
            (case 2
                (pod:
                    cel(0)
                    init()
                    setCycle(CT 6 1 self)
                )
            )
            (case 3
                = cycles 12
            )
            (case 4
                (sparks:dispose())
                = cycles 1
            )
            (case 5
                (send gLongSong2:fade(80 15 10 0))
                (send global2:newRoom(531))
            )
        )
    )

)
(instance policeArrive of Script
    (properties)

    (method (init param1)
        (super:init(rest param1))
        = register 200
    )


    (method (doit param1)
        (super:doit(rest param1))
        (if ((> 18 state) and (> state 13))
            --register
        )
        (if ((== register 0) or ((< (send gEgo:y) 128) and (< state 18)))
            = register -1
            = state 17
            = cycles (= seconds 0)
            (if (not local1)
                (self:cue())
            )(else
                (self:dispose())
            )
        )
        (if (== (send global2:script) ScriptID(709 1))
            (self:dispose())
        )
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                = cycles 8
            )
            (case 1
                (sp1:setHeading(90))
                (sparks:
                    init()
                    setCycle(Fwd)
                )
                = cycles 10
            )
            (case 2
                (pod:
                    cel(0)
                    init()
                    setCycle(CT 6 1 self)
                )
            )
            (case 3
                (sp1:setHeading(180))
                (hatch:
                    init()
                    cel(0)
                    setPri(+ (hatch:priority) 2)
                )
                (pod:setCycle(End))
                = cycles 12
            )
            (case 4
                (sp1:stopUpd())
                (sparks:dispose())
                (pod:stopUpd())
                = cycles 1
            )
            (case 5
                (send gLongSong:
                    number(124)
                    loop(1)
                    vol(127)
                    play(self)
                )
            )
            (case 6
                (hatch:setCycle(End self))
                (sp2:
                    view(378)
                    loop(2)
                    cel(0)
                    x(198)
                    y(148)
                    init()
                )
            )
            (case 7
                (hatch:stopUpd())
                (sp2:
                    cycleSpeed(1)
                    setCycle(End self)
                )
            )
            (case 8
                = cycles 2
            )
            (case 9
                (sp2:
                    view(7)
                    loop(0)
                    x(+ (sp2:x) 13)
                    y(+ (sp2:y) 5)
                    cycleSpeed(0)
                    setCycle(Walk)
                    setMotion(PolyPath 185 91 self)
                )
            )
            (case 10
                proc0_3()
                (send gEgo:setMotion(MoveTo 262 130))
                (sp1:setHeading(90 self))
            )
            (case 11
                (sp1:stopUpd())
                (sp2:setHeading(270 self))
            )
            (case 12
                (sp2:stopUpd())
                = local0 proc0_12("\"I have just completed\na scan of the Labion\nsector of Space Quest II.\"" 67 178 5 28 global135 29 global129)
                = seconds 4
            )
            (case 13
                proc0_12(local0)
                = local0 proc0_12("\"No sign of presence at\nthis time.\"" 67 178 15 28 global135 29 global129)
                = seconds 4
            )
            (case 14
                proc0_3()
                proc0_12(local0)
                = local0 proc0_12("\"Ghraa... slooh... uuhrp.\"" 67 25 25 28 global132 29 global129)
                = seconds 3
            )
            (case 15
                proc0_12(local0)
                = local0 proc0_12("\"Mrghl... pifhh... zaaft.\"" 67 178 25 28 global135 29 global129)
                = seconds 3
            )
            (case 16
                proc0_12(local0)
                = local0 proc0_12("\"Jobhr... fhelz... klogd.\"" 67 25 25 28 global132 29 global129)
                = seconds 3
            )
            (case 17
                proc0_12(local0)
            )
            (case 18
                proc0_2()
                proc0_13(sp1 gEgo)
                = cycles 3
            )
            (case 19
                proc0_13(sp2 gEgo)
                proc0_12(local0)
                (sp1:
                    view(13)
                    cel(0)
                    setCycle(End self)
                )
            )
            (case 20
                (if (< (sp1:x) (send gEgo:x))
                    localproc_1394(- (sp1:y) 27 (sp1:x) - (send gEgo:y) 32 (send gEgo:x))
                )(else
                    localproc_1394(- (send gEgo:y) 32 (send gEgo:x) - (sp1:y) 27 (sp1:x))
                )
                (send gEgo:)
            )
            (case 21
                (send gEgo:setCycle(CT 1 -1 self))
            )
            (case 22
                (send gEgo:setCycle(End self))
            )
            (case 23
                = seconds 2
            )
            (case 24
                = local0 proc0_12("\"HALT.\"" 67 85 25 28 global132 29 global129)
                = seconds 3
            )
            (case 25
                proc0_12(local0)
                = local0 proc0_12("\"Some people just\nwon't follow instructions.\"" 67 25 25 28 global132 29 global129)
                = seconds 4
            )
            (case 26
                proc0_12(local0)
                proc0_10(8)
            )
        )
    )

)
(instance egoExits of Script
    (properties)

    (method (init param1)
        (super:init(rest param1))
        (if ((send global5:contains(sp1)) and (== (sp1:script) policeArrive))
            (sp1:setScript(0))
        )
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gLongSong2:
                    number(535)
                    loop(-1)
                    vol(127)
                    changeState()
                )
                (pod:
                    setCel(7)
                    init()
                    stopUpd()
                )
                (hatch:
                    init()
                    cel(0)
                    setPri(+ (hatch:priority) 2)
                    setCycle(End self)
                )
            )
            (case 1
                = cycles 4
            )
            (case 2
                (send gEgo:setCycle(End self))
            )
            (case 3
                (send gEgo:
                    loop(1)
                    normal(1)
                    moveHead(1)
                    view(0)
                )
                proc0_1()
                = cycles 1
            )
            (case 4
                (if (proc0_6(26))
                    (hatch:
                        setPri(10)
                        setCycle(Beg self)
                    )
                )(else
                    (policeArrive:start(18))
                    (send client:setScript(policeArrive))
                )
            )
            (case 5
                proc0_3()
                (send client:setScript(0))
            )
        )
    )

)
(instance egoEntersPod of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                = local1 1
                (send gEgo:setMotion(PolyPath 188 150 self))
            )
            (case 1
                (if (not (hatch:cel))
                    (hatch:setCycle(End self))
                )(else
                    = cycles 1
                )
            )
            (case 2
                = global87 0
                (send gEgo:
                    view(378)
                    loop(1)
                    cel(0)
                    setPri(11)
                    posn(191 126)
                    ignoreActors()
                    illegalBits(0)
                    cycleSpeed(2)
                    normal(0)
                    moveHead(0)
                    setCycle(End self)
                )
            )
            (case 3
                = cycles 4
            )
            (case 4
                (hatch:
                    cel(5)
                    setPri(12)
                    setCycle(Beg self)
                )
            )
            (case 5
                (send gLongSong:
                    number(125)
                    loop(0)
                    play(self)
                )
                proc0_11(56 10)
                = global87 1
            )
            (case 6
                (send gLongSong2:fade(80 15 10 0))
                (if (proc0_6(78))
                    (send global2:newRoom(531))
                )(else
                    (send global2:newRoom(815))
                )
            )
        )
    )

)
(instance pod of Prop
    (properties
        x 127
        y 129
        description "time pod"
        view 530
        loop 1
        cel 7
        priority 10
        signal 16400
        cycleSpeed 2
    )

    (method (doVerb param1)
        (switch (param1)
            (case 1
                (if (not (hatch:cel))
                    Print("You give the Time Pod a long glance. It's not the most attractive vehicle you've ever seen. It resembles an overgrown titanium tennis shoe. A gold-tinted glass shield seals the top.")
                )(else
                    Print("You give the Time Pod a long glance. It's not the most attractive vehicle you've ever seen. It resembles an overgrown titanium tennis shoe.")
                )
            )
            (case 2
                (send global2:setScript(egoEntersPod))
            )
            (default 
                (super:doVerb(param1))
            )
        )
    )

)
(instance hatch of Prop
    (properties
        x 162
        y 131
        z 18
        description "gold tinted sheild"
        view 530
        loop 2
        cel 9
        priority 10
        signal 16400
    )

    (method (doVerb param1)
        (pod:doVerb(param1))
    )


    (method (motionCue param1)
        (hatchSound:
            stop()
            loop(0)
        )
        (super:motionCue(rest param1))
    )


    (method (setCycle param1)
        (super:setCycle(rest param1))
        (hatchSound:
            init()
            play()
        )
    )

)
(instance hatchSound of Sound
    (properties
        number 142
    )
)
(instance sparks of Prop
    (properties
        x 145
        y 108
        view 530
        priority 13
        signal 16400
    )

    (method (init param1)
        (super:init(rest param1))
        (aSound:
            number(838)
            loop(1)
            play()
        )
    )


    (method (dispose)
        (aSound:stop())
        (super:dispose())
    )

)
(instance sp1 of Actor
    (properties
        x 156
        y 91
        description "sequel police"
        lookStr "You look briefly, careful not to attract any attention. AS YOU CAN SEE, they are clad in dark uniforms, wearing helmets and carrying guns."
        view 7
        loop 3
        signal 16384
    )
)
(instance sp2 of Actor
    (properties
        description "sequel police"
        lookStr "You look briefly, careful not to attract any attention. AS YOU CAN SEE, they are clad in dark uniforms, wearing helmets and carrying guns."
        signal 16384
    )
)
(instance terminal of Feature
    (properties
        x 159
        y 61
        heading 180
        nsTop 43
        nsLeft 148
        nsBottom 80
        nsRight 170
        description "terminal"
        sightAngle 150
        lookStr "This is the Sequel Police dispatch monitor. At the moment nothing is being displayed."
    )

    (method (doVerb param1)
        (switch (param1)
            (case 2
                proc0_2()
                (send global2:setScript(doTerminal))
            )
            (default 
                (super:doVerb(param1))
            )
        )
    )

)
(instance doTerminal of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send gEgo:setMotion(PolyPath (terminal:x) (terminal:y) self))
            )
            (case 1
                Print("You are unable to do anything with that now.")
                proc0_3()
                (self:dispose())
            )
        )
    )

)
(instance theRedBall of Feature
    (properties
        x 147
        y 141
        z 120
        nsBottom 200
        nsRight 320
        description "red sphere"
        onMeCheck 16
        lookStr "Much like myself you must be curious as to the identity of, and the purpose for, the large red sphere."
    )

    (method (doVerb param1)
        (asm
            lsp     param1
            pushi   #doVerb
            pushi   1
            lsp     param1
            super   Feature, 6
            toss    
            ret     
        )
    )

)
(instance theRailView1 of Feature
    (properties
        x 59
        y 68
        nsBottom 200
        nsRight 320
        description "rail view"
        onMeCheck 32
        lookStr "The view beyond the railing reveals the mess of pipes and beams which this structure is composed of."
    )

    (method (doVerb param1)
        (asm
            lsp     param1
            pushi   #doVerb
            pushi   1
            lsp     param1
            super   Feature, 6
            toss    
            ret     
        )
    )

)
(instance theRailView2 of Feature
    (properties
        x 270
        y 33
        nsBottom 200
        nsRight 320
        description "rail view"
        sightAngle 180
        onMeCheck 64
        lookStr "The view beyond the railing reveals the mess of pipes and beams which this structure is composed of."
    )

    (method (doVerb param1)
        (asm
            lsp     param1
            pushi   #doVerb
            pushi   1
            lsp     param1
            super   Feature, 6
            toss    
            ret     
        )
    )

)
(instance timePod0 of Feature
    (properties
        description "Time Pod"
        lookStr "You give the Time Pod a long glance. It's not the most attractive vehicle you've ever seen. It resembles an overgrown titanium tennis shoe. A gold-tinted glass shield seals the top."
    )

    (method (onMe param1)
        return & OnControl(4 (send param1:x) (send param1:y)) $0002
    )

)
(instance building of Feature
    (properties
        description "dispatch building"
        sightAngle 90
        lookStr "It looks to be a sealed, reinforced structure which houses dispatch communications and monitoring equipment."
    )

    (method (init param1)
        (super:init(rest param1))
        (self:onMeCheck(buildingPoly))
    )


    (method (doVerb param1 param2)
        (switch (param1)
            (case 2
                Print("It feels remarkably similiar to a walled structure.")
            )
            (case 11
                Print("It has no noticeable aroma.")
            )
            (case 10
                Print("It tastes like nothing you'd ever want to put your tongue on again.")
            )
            (default 
                (super:doVerb(param1 rest param2))
            )
        )
    )

)
(instance buildingPoly of Polygon
    (properties)
)
(instance aSound of Sound
    (properties)
)
