(include "sci.sh")
(use "Main")
(use "Class_255_0")
(use "SQRoom")
(use "Class_950_0")
(use "n958")
(use "Jump")
(use "Cycle")
(use "PicView")
(use "Obj")
(script 72)


(local
    local0 = 282
    local1 = 56
    local2 = 291
    local3
    local4[2] = (277 62 )
    local9_2 = 195
    local9 = 54
    local9_2_2 = 325
    local9 = 72

)
(instance public rm072 of SQRoom
    (properties
        picture 72
    )

    (method (init)
        (var theJump)
        proc0_2()
        proc958_0(128 73 72)
        Load(rsSOUND 109)
        (switch (gWest)
            (case 45
                (if (Btest(0))
                    Load(rsSOUND 73)
                )(else
                    Load(rsSOUND 77)
                )
                proc0_2()
                (self:setScript(shipLeaves))
            )
            (case 90
                proc958_0(132 123 811)
                (if (Btest(16))
                    (ship:
                        x(267)
                        y(45)
                        init()
                    )
                    (gear:
                        x(267)
                        y(45)
                        cel(5)
                        init()
                    )
                    (manhole:setMotion(MoveTo 117 144 manhole))
                    (send gLongSong2:
                        number(123)
                        loop(1)
                        vol(127)
                        flags(0)
                        play()
                    )
                    (send gEgo:
                        z(1000)
                        init()
                    )
                    proc0_2()
                    (manholeScript:start(19))
                    (self:setScript(manholeScript))
                )(else
                    = theJump Jump
                    Load(rsSOUND 72)
                    proc0_2()
                    (self:setScript(manholeScript))
                )
            )
            (default 
                proc958_0(132 75 76)
                Bset(18)
                = theJump Jump
                proc0_2()
                Bclear(0)
                (self:setScript(xenonLanding))
            )
        )
        (theGreenBldg:init())
        (theWhiteBldg:init())
        (theManhole:init())
        (manhole:init())
        (manholeFeature:init())
        (theRoom:init())
        (rogersHead:init())
        (super:init())
    )


    (method (doit)
        (super:doit())
        (if ((== (send global2:script) manholeScript) and (send gEgo:mover))
            proc0_2()
            (send global2:setScript(goto40Script))
        )
    )


    (method (dispose)
        DisposeScript(991)
        (super:dispose())
    )


    (method (newRoom param1)
        (switch (param1)
            (case 40
                (send gLongSong2:fade())
            )
            (case 90
                (send gLongSong:fade())
            )
        )
        (if (== param1 90)
            Bset(16)
        )(else
            Bclear(16)
        )
        (super:newRoom(param1))
        (send gEgo:z(0))
    )

)
(instance manholeScript of Script
    (properties)

    (method (doit)
        (super:doit())
        (if ((== state 2) and (>= (send gLongSong:prevSignal) 128))
            (self:cue())
        )
        (if ((== state 5) and (>= (send gLongSong:prevSignal) 129))
            (self:cue())
        )
        (if ((== state 10) and (>= (send gLongSong:prevSignal) 130))
            (self:cue())
        )
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                = seconds 3
            )
            (case 1
                proc0_2()
                (send gLongSong:
                    number(72)
                    loop(1)
                    vol(127)
                    flags(0)
                    playBed()
                )
                (manhole:setMotion(MoveTo 117 144 self))
                (send gLongSong2:
                    number(123)
                    loop(1)
                    vol(127)
                    flags(0)
                    play()
                )
            )
            (case 2
                proc0_2()
                (if ((< (send gLongSong:prevSignal) 1) or (> (send gLongSong:prevSignal) 128))
                    (self:cue())
                )
            )
            (case 3
                (manhole:stopUpd())
                (send gEgo:
                    z(1000)
                    init()
                )
                (send gLongSong2:
                    number(109)
                    loop(-1)
                    vol(100)
                    flags(1)
                    play()
                )
                (ship:
                    init()
                    moveSpeed(1)
                    setMotion(MoveTo 267 24)
                )
                (dust:
                    init()
                    cycleSpeed(2)
                    setCycle(End self)
                )
            )
            (case 4
                (dust:
                    loop(1)
                    cycleSpeed(1)
                    setCycle(Fwd)
                )
                (ship:setMotion(MoveTo 267 24 self))
            )
            (case 5
                (if ((< (send gLongSong:prevSignal) 1) or (> (send gLongSong:prevSignal) 129))
                    (self:cue())
                )
            )
            (case 6
                (ship:
                    moveSpeed(0)
                    setMotion(MoveTo (ship:x) 45)
                )
                (gear:
                    posn((ship:x) (ship:y))
                    init()
                    setCycle(End)
                    setMotion(MoveTo (ship:x) 45)
                )
                = cycles 1
            )
            (case 7
                = cycles 4
            )
            (case 8
                (ship:setCel(0))
                = cycles 25
            )
            (case 9
                (send gLongSong2:fade())
                = cycles 30
            )
            (case 10
                (dust:dispose())
                (if ((< (send gLongSong:prevSignal) 1) or (> (send gLongSong:prevSignal) 130))
                    (self:cue())
                )
            )
            (case 11
                proc0_3()
                (sp2:init())
                (sp3:init())
                (sp4:init())
                (sp1:
                    posn(local0 local1)
                    setLoop(3)
                    init()
                    setMotion(JumpTo local2 local3 self)
                )
            )
            (case 12
                (sp1:
                    setStep(2 2)
                    setLoop(2)
                    setCycle(Walk)
                    setMotion(MoveTo local9_2 local9)
                )
                = cycles 6
            )
            (case 13
                (sp2:
                    posn(local0 local1)
                    setLoop(3)
                    setMotion(JumpTo local2 local3 self)
                )
            )
            (case 14
                (sp2:
                    setStep(2 2)
                    setLoop(2)
                    setCycle(Walk)
                    setMotion(MoveTo local9_2 local9)
                )
                = cycles 10
            )
            (case 15
                (sp3:
                    posn(local0 local1)
                    setMotion(JumpTo local2 local3 self)
                )
            )
            (case 16
                (sp4:
                    posn(local0 local1)
                    setMotion(JumpTo local2 local3 self)
                )
                (sp3:
                    setStep(2 2)
                    setCycle(Walk)
                    setMotion(MoveTo local9_2_2 local9)
                )
            )
            (case 17
                (sp4:
                    setStep(2 2)
                    setCycle(Walk)
                    setMotion(MoveTo local9_2_2 local9 self)
                )
            )
            (case 18
                = seconds 15
            )
            (case 19
                = seconds 10
            )
            (case 20
                Print("The manhole cover is getting heavy!")
                (manhole:
                    yStep(2)
                    setMotion(MoveTo (manhole:x) + (manhole:y) 8)
                )
                = seconds 3
            )
            (case 21
                (manhole:setMotion(MoveTo (manhole:x) (+ (manhole:y) 12) self))
                = seconds 3
            )
            (case 22
                proc0_2()
                Print("You slide down the slimy ladder as the manhole cover slams back into place.")
                (manhole:
                    yStep(12)
                    setMotion(MoveTo (manhole:x) 188 self)
                )
            )
            (case 23
                (send gLongSong2:
                    number(811)
                    loop(1)
                    vol(127)
                    flags(0)
                    play()
                )
                = cycles 1
            )
            (case 24
                (send global2:newRoom(90))
            )
        )
    )

)
(instance xenonLanding of Script
    (properties)

    (method (doit)
        (if ((== state 17) and (== (send gLongSong:prevSignal) -1))
            (self:cue())
        )
        (super:doit())
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (manhole:stopUpd())
                = seconds 2
            )
            (case 1
                (send gLongSong2:
                    number(109)
                    loop(-1)
                    vol(100)
                    flags(0)
                    play()
                )
                (ship:
                    init()
                    setMotion(MoveTo 267 24)
                )
                (dust:
                    init()
                    cycleSpeed(2)
                    setCycle(End self)
                )
            )
            (case 2
                (send gLongSong:
                    number(75)
                    loop(1)
                    vol(127)
                    flags(1)
                    play()
                )
                (dust:
                    loop(1)
                    cycleSpeed(1)
                    setCycle(Fwd)
                )
                (ship:setMotion(MoveTo 267 24 self))
            )
            (case 3
                = cycles 20
            )
            (case 4
                (ship:setMotion(MoveTo (ship:x) 45))
                (gear:
                    posn((ship:x) (ship:y))
                    init()
                    setCycle(End)
                    setMotion(MoveTo (ship:x) 45)
                )
                = cycles 1
            )
            (case 5
                = cycles 4
            )
            (case 6
                (ship:setCel(0))
                = cycles 25
            )
            (case 7
                (send gLongSong2:fade())
                = cycles 30
                (send gLongSong:
                    number(76)
                    loop(1)
                    vol(127)
                    flags(1)
                    playBed()
                )
            )
            (case 8
                (dust:dispose())
                = cycles 8
            )
            (case 9
                (sp1:
                    init()
                    setLoop(3)
                    setStep(2 2)
                    moveSpeed(1)
                    cycleSpeed(1)
                    setCycle(Walk)
                    x(local9_2)
                    y(local9)
                    setMotion(MoveTo local2 local3)
                )
                = cycles 12
            )
            (case 10
                (sp2:
                    init()
                    setLoop(3)
                    setStep(2 2)
                    moveSpeed(1)
                    cycleSpeed(1)
                    setCycle(Walk)
                    x(local9_2)
                    y(local9)
                    setMotion(MoveTo local2 local3)
                )
                = cycles 88
            )
            (case 11
                (sp1:
                    setLoop(2)
                    setMotion(JumpTo local0 - local1 4 sp1)
                )
                = cycles 12
            )
            (case 12
                (sp2:
                    setLoop(2)
                    setMotion(JumpTo local0 - local1 4 sp2)
                )
                = cycles 1
            )
            (case 13
                (sp3:
                    init()
                    x(local9_2_2)
                    y(local9)
                    setLoop(2)
                    setStep(2 2)
                    moveSpeed(1)
                    cycleSpeed(1)
                    setCycle(Walk)
                    setMotion(MoveTo local2 local3)
                )
                = cycles 12
            )
            (case 14
                (sp4:
                    init()
                    x(local9_2_2)
                    y(local9)
                    setLoop(2)
                    setStep(2 2)
                    setCycle(Walk)
                    moveSpeed(1)
                    cycleSpeed(1)
                    setMotion(MoveTo local2 local3)
                )
                = cycles 20
            )
            (case 15
                (sp3:setMotion(JumpTo local0 (- local1 4) sp3))
                = cycles 12
            )
            (case 16
                (sp4:setMotion(JumpTo local0 (- local1 4) sp4))
                = cycles 12
            )
            (case 17
                0
            )
            (case 18
                (send gLongSong2:
                    number(802)
                    loop(-1)
                    vol(127)
                    flags(1)
                    playBed()
                )
                (send global2:newRoom(45))
            )
        )
    )

)
(instance shipLeaves of Script
    (properties)

    (method (doit)
        (var temp0[5])
        (gear:
            x((ship:x))
            y(- (ship:y) 1)
        )
        (if ((== state 0) and (== (send gLongSong2:prevSignal) 128))
            (self:cue())
        )
        (super:doit())
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (manhole:stopUpd())
                (send gLongSong:
                    number(109)
                    loop(-1)
                    vol(100)
                    flags(0)
                    play()
                )
                (if (Btest(0))
                    (send gLongSong2:
                        number(73)
                        loop(1)
                        vol(127)
                        flags(0)
                        playBed()
                    )
                )(else
                    (send gLongSong2:
                        number(77)
                        loop(1)
                        vol(127)
                        flags(1)
                        playBed()
                    )
                    = cycles 30
                )
                (ship:
                    x(267)
                    y(45)
                    moveSpeed(1)
                    init()
                )
                (dust:
                    loop(1)
                    init()
                    cycleSpeed(1)
                    setCycle(Fwd)
                )
            )
            (case 1
                (if (not Btest(18))
                    (send gLongSong:fade())
                )
                (if (Btest(0))
                    (send gLongSong2:hold(1))
                )
                (ship:setMotion(MoveTo (ship:x) 65526 self))
            )
            (case 2
                (dust:
                    loop(0)
                    cel(9)
                    cycleSpeed(1)
                    setCycle(Beg self)
                )
                (if (Btest(18))
                    (send gLongSong2:
                        number(0)
                        stop()
                    )
                )
            )
            (case 3
                (if (Btest(18))
                    Bclear(18)
                    (send gLongSong:fade())
                    (send global2:newRoom(60))
                    (self:dispose())
                )(else
                    (send global2:newRoom(59))
                    (self:dispose())
                )
            )
        )
    )

)
(instance sewerScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (manhole:setMotion(MoveTo (manhole:x) 188 self))
            )
            (case 1
                (send gLongSong2:
                    number(811)
                    loop(1)
                    vol(127)
                    flags(0)
                    play()
                )
                = cycles 1
            )
            (case 2
                (send global2:newRoom(90))
            )
        )
    )

)
(instance manholeFeature of Feature
    (properties
        x 160
        y 186
        nsBottom 200
        nsRight 320
        description "manhole cover"
        onMeCheck 2
        lookStr "The manhole cover is simply an incredibly heavy slab of metal trying to tamp you back into the tube."
    )

    (method (doVerb param1)
        (switch (param1)
            (case 2
                (if (<> (send global2:script) xenonLanding)
                    proc0_2()
                    (send global2:setScript(sewerScript))
                )
            )
            (default 
                (super:doVerb(param1))
            )
        )
    )

)
(instance manhole of Actor
    (properties
        x 117
        y 186
        yStep 4
        view 72
        loop 4
        signal 2048
    )

    (method (cue)
        proc0_3()
        (manhole:stopUpd())
    )

)
(instance ship of Actor
    (properties
        x 210
        y 65530
        description "ship"
        lookStr "A sleek patrol transport occupies the area presently."
        yStep 1
        view 72
        priority 4
        signal 30736
        xStep 1
    )

    (method (doVerb param1)
        (switch (param1)
            (case 2
                (if (== (send global2:script) xenonLanding)
                    (send global2:newRoom(45))
                )(else
                    Print("If you can do anything with the ship you certainly can't do it from here.")
                )
            )
            (default 
                (super:doVerb(param1))
            )
        )
    )

)
(instance gear of Actor
    (properties
        yStep 1
        view 72
        loop 1
        priority 5
        signal 26640
        xStep 1
    )
)
(instance dust of Prop
    (properties
        x 213
        y 52
        view 73
        priority 3
        signal 24592
    )
)
(instance sp1 of Actor
    (properties
        yStep 1
        view 72
        loop 2
        priority 6
        signal 18448
        xStep 1
    )

    (method (cue)
        (super:cue())
        (self:dispose())
    )

)
(instance sp2 of Actor
    (properties
        yStep 1
        view 72
        loop 2
        priority 6
        signal 18448
        xStep 1
    )

    (method (cue)
        (super:cue())
        (self:dispose())
    )

)
(instance sp3 of Actor
    (properties
        yStep 1
        view 72
        loop 3
        priority 6
        signal 18448
        xStep 1
    )

    (method (cue)
        (super:cue())
        (self:dispose())
    )

)
(instance sp4 of Actor
    (properties
        yStep 1
        view 72
        loop 3
        priority 6
        signal 18448
        xStep 1
    )

    (method (cue)
        (super:cue())
        (self:dispose())
    )

)
(instance theGreenBldg of Feature
    (properties
        nsBottom 200
        nsRight 320
        description "green building"
        onMeCheck 16
        lookStr "There's that green building again."
    )
)
(instance theWhiteBldg of Feature
    (properties
        nsBottom 200
        nsRight 320
        description "white building"
        onMeCheck 32
        lookStr "That white building sits over yonder. You start to become properly oriented regarding your position."
    )
)
(instance theManhole of Feature
    (properties
        x 120
        y 187
        nsBottom 200
        nsRight 320
        description "manhole"
        onMeCheck 64
        lookStr "The dank and slimy conduit calls to you."
    )

    (method (doVerb param1)
        (switch (param1)
            (case 2
                (manholeFeature:doVerb(param1))
            )
            (default 
                (super:doVerb(param1))
            )
        )
    )

)
(instance rogersHead of Feature
    (properties
        x 120
        y 188
        nsBottom 189
        nsRight 319
        description "head"
        sightAngle 45
        onMeCheck 4
        lookStr "Your head is unusually well suited to serve as a manhole coaster."
    )

    (method (doVerb param1)
        (switch (param1)
            (case 2
                Print("The only thing you can do to avoid flattening your head any further is get in or get out.")
            )
            (default 
                (super:doVerb(param1))
            )
        )
    )

)
(instance theRoom of Feature
    (properties
        x 152
        nsBottom 189
        nsRight 319
        description "street"
        sightAngle 180
        lookStr "You have a low-level view of the street from your manhole perch."
    )

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

)
(instance goto40Script of Script
    (properties)

    (method (doit param1)
        (super:doit(rest param1))
        (if (not Btest(73))
            (if (== state 0)
                (if (== register 80)
                    (self:cue())
                )(else
                    ++register
                )
            )
        )(else
            (if (== state 0)
                (self:cue())
            )
        )
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_11(73 3)
                (send gLongSong2:fade())
            )
            (case 1
                (send global2:newRoom(40))
            )
        )
    )

)
