(include "sci.sh")
(use "Main")
(use "sewer")
(use "SQRoom")
(use "Polygon")
(use "Class_950_0")
(use "Cycle")
(use "Obj")
(script 80)



(instance public rm080 of SQRoom
    (properties
        picture 80
        east 85
        south 95
        west 75
        picAngle 70
    )

    (method (init)
        (var temp0)
        (sewer:roomVer(22891))
        proc0_3()
        Load(rsVIEW 80)
        (switch (global12)
            (case west
                (send gEgo:y(100))
                = temp0 41
            )
            (case south
                (if (< (send gEgo:x) 145)
                    (send gEgo:x(146))
                )
                (if (> (send gEgo:x) 172)
                    (send gEgo:x(171))
                )
                = temp0 43
                (if ((== (sewer:location) 80) and (== (sewer:status) 6))
                    proc0_2()
                    (send (ScriptID(702 2)):
                        init()
                        hide()
                        setCycle(Fwd)
                        cycleSpeed(0)
                        posn(157 160)
                    )
                    (sewer:status(4))
                )
            )
            (case east
                (if ((== (sewer:location) 80) and (== (sewer:status) 6))
                    (send (ScriptID(702 2)):
                        init()
                        hide()
                        setCycle(Fwd)
                        setLoop(2)
                        posn(255 91)
                        setScript(ScriptID(702 4))
                    )
                    (sewer:status(4))
                )(else
                    (sewer:
                        status(0)
                        location(0)
                    )
                )
                (self:setScript(enterRight))
                = temp0 40
            )
            (default 
                (send gLongSong:
                    number(805)
                    vol(127)
                    loop(-1)
                    playBed()
                )
                (send gEgo:posn(27 94))
            )
        )
        (self:style(temp0))
        (send (ScriptID(702 5)):
            init()
            setLoop(2)
            posn(113 62)
            setScript(daDripScript)
        )
        (send (ScriptID(702 6)):
            init()
            setLoop(3)
            posn(250 45)
            cycleSpeed(1)
            setCycle(Fwd)
        )
        (send gEgo:init())
        (super:init())
        (send (ScriptID(702 2)):show())
        (self:
            setRegions(702)
            addObstacle((send ((Polygon:new())):
                    type(2)
                    init(0 101 132 101 152 123 151 189 0 189)
                    yourself()
                )
 (send ((Polygon:new())):
                    type(2)
                    init(166 189 166 123 187 101 319 102 319 189)
                    yourself()
                )
 (send ((Polygon:new())):
                    type(2)
                    init(0 0 319 0 319 94 0 94)
                    yourself()
                )
)
        )
        (if ((<> global12 95) and (<> (sewer:location) 80))
            (sewer:status(1))
        )
    )


    (method (doit param1)
        (if (script)
            0
        )(else
            (if (== (send gEgo:edgeHit) 3)
                proc0_2()
                (self:setScript(exitSouth))
            )(else
                (if ((== (send gEgo:edgeHit) 2) or (== (send gEgo:edgeHit) 4))
                    (sewer:
                        location(0)
                        status(0)
                    )
                )
            )
        )
        (super:doit(rest param1))
        (if (((== (dripScript:state) -1) and (> (send gEgo:y) 170)) and (== (sewer:status) 1))
            (send (ScriptID(702 3)):
                init()
                hide()
                setScript(dripScript)
            )
        )
        (if (((== (sewer:status) 3) and (== (send (ScriptID(702 2)):loop) 3)) and (> (send (ScriptID(702 2)):y) 163))
            (if (< (send gEgo:y) (send (ScriptID(702 2)):y))
                (send (ScriptID(702 2)):setScript(slimeLeaving))
                (sewer:status(8))
            )(else
                (send (ScriptID(702 2)):
                    setMotion(0)
                    setScript(0)
                )
            )
        )
    )

)
(instance exitSouth of Script
    (properties)

    (method (changeState newState)
        (var temp0)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gEgo:setHeading(180 self))
            )
            (case 1
                (if (((== (sewer:status) 3) or (== (sewer:status) 4)) and (> (send (ScriptID(702 2)):y) 160))
                    (send (ScriptID(702 2)):
                        setMotion(0)
                        setScript(0)
                    )
                )
                (send gEgo:setMotion(MoveTo (send gEgo:x) 239 self))
            )
            (case 2
                (if (== (sewer:status) 2)
                    (sewer:status(3))
                    (send gLongSong2:
                        vol(127)
                        number(819)
                        loop(-1)
                        playBed()
                    )
                )
                (if (((== (sewer:location) 95) and (== (sewer:status) 6)) and (> (sewer:rmTimer) 7))
                    (sewer:status(8))
                )
                (send global2:newRoom(95))
            )
        )
    )

)
(instance theVent of Feature
    (properties
        nsBottom 200
        nsRight 320
        description "vent"
        onMeCheck 64
        lookStr "There's a small vent set into the side of the sewer tunnel. Unfortunately, it looks way too narrow for a space janitor, even a wiry, skinny one, to squeeze inside."
    )

    (method (doVerb param1 param2 param3)
        (switch (param1)
            (case 2
            )
            (case 4
            )
            (default 
                (super:doVerb(param1 rest param3))
            )
        )
    )

)
(instance dripScript of Script
    (properties)

    (method (changeState newState)
        (var temp0[2])
        (switch (= state newState)
            (case 0
                = cycles 1
            )
            (case 1
                (send gLongSong:
                    vol(0)
                    fade(0 10 10 0)
                )
                (send gLongSong2:
                    vol(127)
                    number(806)
                    loop(1)
                    play()
                )
                (sewer:location(80))
                (send (ScriptID(702 3)):
                    show()
                    setPri(5)
                    setLoop(4)
                    posn(159 38)
                    cel(0)
                    cycleSpeed(1)
                    setCycle(CT 10 1 self)
                )
                (send (ScriptID(702 2)):
                    init()
                    hide()
                    setLoop(3)
                    setPri(3)
                    setCycle(0)
                    posn(159 60)
                    cycleSpeed(0)
                    moveSpeed(0)
                )
            )
            (case 2
                (send (ScriptID(702 3)):setCel(11))
                (send (ScriptID(702 2)):
                    show()
                    posn(159 65)
                )
                = cycles 3
            )
            (case 3
                (send (ScriptID(702 3)):setCel(12))
                (send (ScriptID(702 2)):posn(159 70))
                = cycles 3
            )
            (case 4
                (send (ScriptID(702 3)):setCel(13))
                (send (ScriptID(702 2)):posn(159 75))
                = cycles 3
            )
            (case 5
                (send (ScriptID(702 3)):setCel(14))
                (send (ScriptID(702 2)):posn(159 80))
                = cycles 3
            )
            (case 6
                (send gLongSong2:
                    vol(127)
                    number(819)
                    loop(-1)
                    playBed()
                )
                (send (ScriptID(702 3)):hide())
                (send (ScriptID(702 2)):posn(159 85))
                (sewer:status(3))
                (send (ScriptID(702 2)):
                    setScript(ScriptID(702 4))
                    moveSpeed(0)
                )
                (self:dispose())
            )
        )
    )

)
(instance daDripScript of Script
    (properties)

    (method (changeState newState)
        (var temp0[2])
        (switch (= state newState)
            (case 0
                (send (ScriptID(702 5)):setCycle(End self))
            )
            (case 1
                = cycles Random(5 20)
            )
            (case 2
                (self:init())
            )
        )
    )

)
(instance slimeLeaving of Script
    (properties)

    (method (changeState newState)
        (var temp0[2])
        (switch (= state newState)
            (case 0
                (send (ScriptID(702 2)):setMotion(MoveTo 158 210 self))
            )
            (case 1
                (send (ScriptID(702 2)):
                    posn(1000 1000)
                    dispose()
                )
                (sewer:
                    location(95)
                    status(6)
                    rmTimer(0)
                )
                (self:dispose())
            )
        )
    )

)
(instance enterRight of Script
    (properties)

    (method (changeState newState)
        (var temp0[2])
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gEgo:
                    posn(303 99)
                    setMotion(MoveTo 294 99 self)
                )
            )
            (case 1
                proc0_3()
                proc0_1()
                (self:dispose())
            )
        )
    )

)
