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



(instance public rm535 of SQRoom
    (properties
        picture 535
        east 540
        west 530
    )

    (method (init)
        proc958_0(128 535 300 7)
        proc958_0(132 131 156 104 158 535 107)
        (switch (gWest)
            (case 120
                (self:setScript(shipScript))
                (send gEgo:posn(160 110))
                (send gLongSong2:hold(0))
            )
            (case east
                proc0_2()
                (if (> (send gEgo:y) 134)
                    (send gEgo:y(134))
                )
                (self:
                    setScript(enterScript)
                    style(40)
                )
            )
            (case west
                proc0_2()
                (send gEgo:y(
                    (if (> (send gEgo:y) 120)
                        120
                    )(else
                        (send gEgo:y)
                    )
))
                (self:
                    setScript(enterScript)
                    style(41)
                )
            )
            (default 
                (send gEgo:
                    x(160)
                    y(140)
                )
                (self:style(100))
                = gWest west
            )
        )
        (super:init())
        (send gEgo:
            view(0)
            init()
        )
        (send gFeatures:
            add(theRailView theLeftPump theRightPump theShuttle)
            eachElementDo(102)
            doit()
        )
        (self:setRegions(709))
        (send global2:addObstacle((send ((Polygon:new())):
                type(2)
                init(319 189 284 134 319 134)
                yourself()
            )
 (send ((Polygon:new())):
                type(2)
                init(0 129 21 129 25 120 64 120 75 129 64 136 37 136 0 189)
                yourself()
            )
 (send ((Polygon:new())):
                type(2)
                init(0 52 0 0 319 0 319 57 276 54 250 54 178 54 163 76 149 55)
                yourself()
            )
 (send ((Polygon:new())):
                type(2)
                init(79 109 139 109 139 128 106 128 90 128 79 123)
                yourself()
            )
 (send ((Polygon:new())):
                type(2)
                init(189 109 247 109 247 128 220 128 189 128)
                yourself()
            )
 (send ((Polygon:new())):
                type(2)
                init(242 63 274 63 274 73 242 73)
                yourself()
            )
))
        (if (== gWest 120)
            proc0_2()
            (leftEngine:
                setLoop(0)
                setCycle(Fwd)
                init()
            )
            (rightEngine:
                setLoop(0)
                setCycle(Fwd)
                init()
            )
            (leftGear:
                x(145)
                z(22)
                setCel(3)
                init()
            )
            (rightGear:
                x(182)
                z(22)
                setCel(3)
                init()
            )
        )(else
            (leftEngine:
                init()
                setLoop(2)
                setCel(11)
                stopUpd()
            )
            (rightEngine:
                init()
                setLoop(2)
                setCel(11)
                stopUpd()
            )
            (leftGear:
                x(123)
                z(0)
                setCel(0)
                init()
                stopUpd()
            )
            (rightGear:
                x(204)
                z(0)
                setCel(0)
                init()
                stopUpd()
            )
        )
    )


    (method (doit)
        (super:doit())
        (if (script)
        )(else
            (if ((< (send gEgo:x) 20) and (< (send gEgo:y) 144))
                proc0_2()
                (send global2:newRoom(530))
            )(else
                (if ((> (send gEgo:x) 300) and (< (send gEgo:y) 144))
                    proc0_2()
                    (send global2:newRoom(540))
                )
            )
        )
    )

)
(instance leftEngine of Prop
    (properties
        x 150
        y 77
        description "exhaust turbine"
        lookStr "This is an exhaust turbine."
        view 535
        priority 15
        signal 16400
    )
)
(instance rightEngine of Prop
    (properties
        x 178
        y 77
        description "exhaust turbine"
        lookStr "This is an exhaust turbine."
        view 535
        priority 15
        signal 16400
    )
)
(instance leftGear of Actor
    (properties
        y 72
        description "landing gear"
        lookStr "This is the shuttle's landing gear."
        view 535
        loop 3
        cel 3
        priority 8
        signal 24592
        illegalBits 0
    )

    (method (doit)
        (super:doit())
        (if (> z 21)
        )(else
            (if (> z 0)
                --z
                --x
            )
        )
    )


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

)
(instance rightGear of Actor
    (properties
        y 72
        description "landing gear"
        lookStr "This is the shuttle's landing gear."
        view 535
        loop 4
        cel 3
        priority 8
        signal 24592
        illegalBits 0
    )

    (method (doit)
        (super:doit())
        (if (> z 21)
        )(else
            (if (> z 0)
                (if (== --z 0)
                    (aSound:
                        number(156)
                        loop(0)
                        play()
                    )
                )
                ++x
            )
        )
    )


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

)
(instance sp of Actor
    (properties
        x 157
        y 83
        view 7
    )
)
(instance enterScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (if (== gWest (send global2:west))
                    (send gEgo:
                        init()
                        x(5)
                        setMotion(MoveTo 40 (send gEgo:y) self)
                    )
                )(else
                    (send gEgo:
                        init()
                        x(310)
                        setMotion(MoveTo 280 (send gEgo:y) self)
                    )
                )
            )
            (case 1
                proc0_3()
                (send client:setScript(0))
            )
        )
    )

)
(instance shipScript of Script
    (properties)

    (method (doit param1)
        (super:doit(rest param1))
        (if ((== state 0) and (== (send gLongSong2:prevSignal) -1))
            (self:cue())
        )
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                0
            )
            (case 1
                (send gLongSong:stop())
                (send gLongSong2:
                    number(104)
                    loop(0)
                    play(self)
                )
                = cycles 10
            )
            (case 2
                (aSound:
                    init()
                    number(158)
                    loop(-1)
                    play()
                )
                (leftGear:z(21))
                (rightGear:z(21))
                = cycles 12
            )
            (case 3
                (leftGear:setCycle(Beg))
                (rightGear:setCycle(Beg self))
            )
            (case 4
                (leftEngine:setLoop(1))
                (rightEngine:setLoop(1))
                (if (== (send gLongSong2:prevSignal) -1)
                    = seconds 2
                )(else
                    = seconds 4
                )
            )
            (case 5
                = seconds 0
                (send gLongSong2:
                    stop()
                    number(535)
                    vol(127)
                    loop(-1)
                    flags(1)
                    playBed()
                )
                (sp:
                    init()
                    setCycle(Walk)
                    setMotion(DPath 139 69 65531 80)
                )
                (leftEngine:
                    setLoop(2)
                    setCel(0)
                    setCycle(End self)
                )
                (rightEngine:
                    setLoop(2)
                    setCel(0)
                    setCycle(End)
                )
            )
            (case 6
                (leftGear:stopUpd())
                (rightGear:stopUpd())
                (leftEngine:stopUpd())
                (rightEngine:stopUpd())
                (send gEgo:
                    x(160)
                    y(100)
                    setMotion(PolyPath 205 155 self)
                )
            )
            (case 7
                proc0_3()
                (self:dispose())
            )
        )
    )

)
(instance toXenon of Script
    (properties)

    (method (doit param1)
        (super:doit(rest param1))
        (if ((== state 10) and (== (send gLongSong2:prevSignal) -1))
            (self:cue())
        )
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send gEgo:setMotion(PolyPath 160 110 self))
            )
            (case 1
                Print("You climb into the landing gear bay hoping it's still spacious with the landing gear stowed.")
                = seconds 5
            )
            (case 2
                (sp:
                    init()
                    x(65531)
                    y(80)
                    setCycle(Walk)
                    setMotion(PolyPath 140 85 self)
                )
            )
            (case 3
                = seconds 4
            )
            (case 4
                (leftEngine:
                    setLoop(0)
                    setCycle(Fwd)
                )
                (rightEngine:
                    setLoop(0)
                    setCycle(Fwd)
                )
                (aSound:
                    number(107)
                    loop(1)
                    play(self)
                )
            )
            (case 5
                (aSound:
                    init()
                    number(158)
                    loop(-1)
                    play()
                )
                (leftGear:
                    setCel(0)
                    setLoop(3)
                    setMotion(MoveTo 145 51 self)
                )
                (rightGear:
                    setCel(0)
                    setLoop(4)
                    setMotion(MoveTo 182 51 self)
                )
            )
            (case 6
                0
            )
            (case 7
                (leftGear:setCycle(End self))
                (rightGear:setCycle(End self))
            )
            (case 8
                0
            )
            (case 9
                (aSound:
                    stop()
                    loop(0)
                )
                (send gLongSong2:fade())
                (leftGear:hide())
                (rightGear:hide())
                = cycles 2
            )
            (case 10
                (sp:dispose())
            )
            (case 11
                (send client:setScript(0))
                (send global2:newRoom(119))
            )
        )
    )

)
(instance theLeftPump of Feature
    (properties
        x 53
        y 110
        nsBottom 189
        nsRight 319
        description "left pump"
        onMeCheck 16
        lookStr "This is a fueling unit for the patrol shuttle."
    )
)
(instance theRightPump of Feature
    (properties
        x 264
        y 58
        nsBottom 189
        nsRight 319
        description "back pump"
        onMeCheck 32
        lookStr "This is a maintenance unit for the shuttle. It's of no interest."
    )
)
(instance theShuttle of Feature
    (properties
        x 170
        y 90
        nsBottom 189
        nsRight 319
        description "patrol shuttle"
        onMeCheck 64
        lookStr "This is the patrol shuttle you hitched a ride on."
    )

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

)
(instance theRailView of Feature
    (properties
        x 161
        y 32
        nsTop 15
        nsLeft 37
        nsBottom 49
        nsRight 285
        description "rail"
        sightAngle 90
        lookStr "Hundreds of pipes and beams litter the view here."
    )
)
(instance aSound of Sound
    (properties)
)
