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


(local
    local0

)
(instance public rm095 of SQRoom
    (properties
        picture 95
        horizon 40
        north 80
        east 100
        south 110
        west 90
        picAngle 70
    )

    (method (init)
        (var temp0)
        (sewer:roomVer(22791))
        Load(rsVIEW 80)
        (if (((== (send (ScriptID(702 2)):loop) 3) and (== (sewer:status) 8)) and (== (sewer:location) 95))
            (send (ScriptID(702 2)):
                init()
                hide()
                posn(158 187)
                setLoop(3)
                setCycle(Fwd)
                moveSpeed(0)
                setScript(slimeLeaving)
            )
        )
        (switch (gWest)
            (case north
                (if ((== (sewer:status) 3) and (== (sewer:location) 80))
                    (if (> (sewer:prevDistance) 100)
                        (send (ScriptID(702 2)):posn(158 65486))
                    )(else
                        (if (> (sewer:prevDistance) 50)
                            (send (ScriptID(702 2)):posn(158 65496))
                        )(else
                            (send (ScriptID(702 2)):posn(158 65511))
                        )
                    )
                    (send (ScriptID(702 2)):
                        init()
                        hide()
                        setLoop(3)
                        setCycle(Fwd)
                        moveSpeed(1)
                        setScript(ScriptID(702 4))
                    )
                    (sewer:
                        cantDie(1)
                        location(95)
                    )
                )
                (if ((== (sewer:status) 6) and (== (sewer:location) 95))
                    (send (ScriptID(702 2)):
                        init()
                        hide()
                        posn(158 92)
                        setLoop(3)
                        setCycle(Fwd)
                        moveSpeed(0)
                    )
                    (sewer:
                        status(4)
                        location(95)
                    )
                )
                (send gEgo:x(156))
                = temp0 42
            )
            (case south
                (self:setScript(enterSouth))
                = temp0 43
            )
            (case east
                = temp0 40
                (self:setScript(enterRight))
            )
            (case west
                (if (proc999_5((sewer:location) 105 75))
                    (sewer:
                        location(0)
                        status(0)
                    )
                )
                = temp0 41
                (self:setScript(enterLeft))
            )
            (default 
                (send gLongSong:
                    number(805)
                    vol(127)
                    loop(-1)
                    playBed()
                )
                (send gEgo:posn(157 174))
            )
        )
        (self:style(temp0))
        (send (ScriptID(702 5)):
            init()
            setLoop(8)
            posn(69 44)
            cycleSpeed(1)
            setCycle(Fwd)
        )
        (send (ScriptID(702 6)):
            init()
            setLoop(9)
            posn(250 79)
            setScript(daDripScript)
        )
        (send gEgo:init())
        (super:init())
        (send (ScriptID(702 2)):show())
        (send gEgo:show())
        (self:
            setRegions(702)
            addObstacle((send ((Polygon:new())):
                    type(2)
                    init(0 0 145 0 145 83 139 88 128 93 0 93)
                    yourself()
                )
 (send ((Polygon:new())):
                    type(2)
                    init(0 102 130 102 139 106 145 116 145 189 0 189)
                    yourself()
                )
 (send ((Polygon:new())):
                    type(2)
                    init(319 0 319 94 179 94 170 89 165 83 165 0)
                    yourself()
                )
 (send ((Polygon:new())):
                    type(2)
                    init(167 189 167 112 172 105 177 102 319 102 319 189)
                    yourself()
                )
)
        )
        (if (not proc999_5(gWest 100 90))
            proc0_3()
        )
    )


    (method (doit param1)
        (if (script)
            0
        )(else
            (if (== (send gEgo:edgeHit) 1)
                proc0_2()
                (self:setScript(exitNorth))
            )(else
                (if (== (send gEgo:edgeHit) 3)
                    proc0_2()
                    (self:setScript(exitSouth))
                )(else
                    (if (== (send gEgo:edgeHit) 2)
                        (if (== (sewer:location) 95)
                            (if (> (send (ScriptID(702 2)):y) 120)
                                (sewer:status(8))
                            )
                            (if (> (sewer:distance) 35)
                                (send gLongSong2:
                                    vol(0)
                                    fade(0 10 10 0)
                                )
                                (send gLongSong:
                                    vol(127)
                                    playBed()
                                )
                            )
                        )
                    )(else
                        (if (== (send gEgo:edgeHit) 4)
                            (if (== (sewer:location) 95)
                                (if (> (send (ScriptID(702 2)):y) 120)
                                    (sewer:status(8))
                                )
                                (if (> (sewer:distance) 35)
                                    (send gLongSong2:
                                        vol(0)
                                        fade(0 10 10 0)
                                    )
                                    (send gLongSong:
                                        vol(127)
                                        playBed()
                                    )
                                )
                            )
                            (if (proc999_5((sewer:location) 110 100))
                                (sewer:
                                    location(0)
                                    status(0)
                                )
                            )
                        )(else
                            (if (((== gWest 110) and (== (sewer:location) 110)) and (> (sewer:rmTimer) 10))
                                (sewer:
                                    location(0)
                                    status(0)
                                )
                            )(else
                                (if (((== gWest 100) and (== (sewer:location) 100)) and (> (sewer:rmTimer) 10))
                                    (sewer:
                                        location(0)
                                        status(0)
                                    )
                                )
                            )
                        )
                    )
                )
            )
        )
        (super:doit(rest param1))
        (if ((& (send gEgo:onControl(1)) $0002) and (== (send (ScriptID(702 2)):loop) 3))
            (sewer:cantDie(1))
        )(else
            (sewer:cantDie(0))
        )
        (if ((((== (sewer:status) 3) and (== (send (ScriptID(702 2)):loop) 3)) and (> (send (ScriptID(702 2)):y) 160)) and (== (send gEgo:heading) 180))
            (send (ScriptID(702 2)):
                setMotion(0)
                setScript(0)
            )
        )
        (if (< (send gEgo:y) 50)
            (send gEgo:setPri(4))
        )(else
            (send gEgo:setPri(-1))
        )
    )

)
(instance exitNorth of Script
    (properties)

    (method (changeState newState)
        (var temp0[2])
        (switch (= state newState)
            (case 0
                proc0_2()
                (if (< (send (ScriptID(702 2)):y) -22)
                    (sewer:status(6))
                    (send (ScriptID(702 2)):posn(1000 1000))
                )
                (send gEgo:setMotion(MoveTo 156 10 self))
            )
            (case 1
                (send gEgo:setMotion(MoveTo 156 65530 self))
            )
            (case 2
                (if (proc999_5((sewer:location) 110 100))
                    (sewer:
                        location(0)
                        status(0)
                    )
                )
                (if ((== (sewer:location) 95) and (== (sewer:status) 3))
                    (send gLongSong2:
                        vol(0)
                        fade(0 10 10 0)
                    )
                    (send gLongSong:
                        vol(127)
                        playBed()
                    )
                    (if (== (send (ScriptID(702 2)):loop) 2)
                        (send (ScriptID(702 2)):setLoop(3))
                        (sewer:status(6))
                    )
                )
                (send global2:newRoom(80))
            )
        )
    )

)
(instance enterRight of Script
    (properties)

    (method (changeState newState)
        (var temp0[2])
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gEgo:
                    posn(309 99)
                    setMotion(MoveTo 292 99 self)
                )
                (if ((== (sewer:status) 6) and (== (sewer:location) 95))
                    (send (ScriptID(702 2)):
                        init()
                        hide()
                        posn(260 89)
                        setLoop(2)
                        moveSpeed(0)
                        setScript(ScriptID(702 4))
                    )
                    (send gLongSong:
                        vol(0)
                        fade(0 10 10 0)
                    )
                    (send gLongSong2:
                        vol(127)
                        playBed()
                    )
                    (sewer:status(4))
                )(else
                    (if ((== (sewer:status) 3) and (== (sewer:location) 95))
                        (send (ScriptID(702 2)):
                            init()
                            hide()
                            posn(227 89)
                            setLoop(2)
                            moveSpeed(0)
                            setScript(ScriptID(702 4))
                        )
                        (send gLongSong2:
                            vol(127)
                            playBed()
                        )
                        (send gLongSong:
                            vol(0)
                            fade(0 10 10 0)
                        )
                    )(else
                        (if ((== (sewer:status) 3) and (== (sewer:location) 100))
                            (if (< (sewer:prevDistance) 50)
                                (send (ScriptID(702 2)):
                                    init()
                                    hide()
                                    posn(352 89)
                                    setLoop(2)
                                    moveSpeed(0)
                                    setScript(ScriptID(702 4))
                                )
                                (sewer:location(95))
                            )(else
                                (send gLongSong2:
                                    vol(0)
                                    fade(0 10 10 0)
                                )
                                (send gLongSong:
                                    vol(127)
                                    playBed()
                                )
                            )
                        )
                    )
                )
            )
            (case 1
                proc0_3()
                proc0_1()
                (self:dispose())
            )
        )
    )

)
(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 (((== (send (ScriptID(702 2)):loop) 2) and (== (sewer:status) 3)) and (== (sewer:location) 95))
                    (sewer:
                        location(0)
                        status(0)
                    )
                    (send gLongSong2:
                        vol(0)
                        fade(0 10 10 0)
                    )
                    (send gLongSong:
                        vol(127)
                        playBed()
                    )
                )
                (if ((((== (send (ScriptID(702 2)):loop) 3) and (< (send (ScriptID(702 2)):y) 100)) and (== (sewer:status) 3)) and (== (sewer:location) 95))
                    (sewer:status(6))
                    (send gLongSong2:
                        vol(0)
                        fade(0 10 10 0)
                    )
                    (send gLongSong:
                        vol(127)
                        playBed()
                    )
                )
                (send gEgo:setMotion(MoveTo (send gEgo:x) 239 self))
            )
            (case 2
                (if (== (sewer:location) 110)
                    (send gLongSong2:
                        vol(127)
                        playBed()
                    )
                    (send gLongSong:
                        vol(0)
                        fade(0 10 10 0)
                    )
                )
                (if (== (sewer:location) 100)
                    (sewer:
                        status(0)
                        location(0)
                    )
                )
                (send global2:newRoom(110))
            )
        )
    )

)
(instance enterLeft of Script
    (properties)

    (method (changeState newState)
        (var temp0[2])
        (switch (= state newState)
            (case 0
                proc0_2()
                (if (((== (sewer:status) 3) and (== (sewer:location) 90)) and (< (sewer:prevDistance) 40))
                    (send (ScriptID(702 2)):
                        init()
                        hide()
                        posn(65504 89)
                        setLoop(2)
                        moveSpeed(0)
                        setScript(ScriptID(702 4))
                    )
                    (sewer:location(95))
                )(else
                    (if ((== (sewer:status) 3) and (== (sewer:location) 95))
                        (if (> (sewer:oldDistance) 109)
                            (sewer:oldDistance(109))
                        )
                        (send (ScriptID(702 2)):
                            init()
                            hide()
                            posn(+ (sewer:oldDistance) 5 89)
                            setLoop(2)
                            moveSpeed(0)
                            setScript(ScriptID(702 4))
                        )
                        (send gLongSong2:
                            vol(127)
                            playBed()
                        )
                        (send gLongSong:
                            vol(0)
                            fade(0 10 10 0)
                        )
                    )
                )
                (send gEgo:
                    posn(11 98)
                    setMotion(MoveTo 29 98 self)
                )
            )
            (case 1
                proc0_3()
                proc0_1()
                (self:dispose())
            )
        )
    )

)
(instance enterSouth of Script
    (properties)

    (method (changeState newState)
        (var temp0[2])
        (switch (= state newState)
            (case 0
                proc0_2()
                (sewer:rmTimer(0))
                (send gEgo:
                    init()
                    posn(162 185)
                )
                (if ((== (sewer:location) 95) and (< (sewer:prevDistance) 60))
                    (sewer:status(6))
                )
                (if ((== (sewer:status) 3) and (== (sewer:location) 95))
                    (send (ScriptID(702 2)):
                        init()
                        hide()
                        posn(158 - 190 (sewer:prevDistance))
                        setLoop(3)
                        setCycle(Fwd)
                        setScript(ScriptID(702 4))
                    )
                    (send gLongSong:
                        vol(0)
                        fade(0 10 10 0)
                    )
                    (send gLongSong2:
                        vol(127)
                        playBed()
                    )
                )(else
                    (if ((== (sewer:status) 6) and (== (sewer:location) 95))
                        (send (ScriptID(702 2)):
                            init()
                            show()
                            posn(158 144)
                            setLoop(3)
                            setCycle(Fwd)
                            setScript(ScriptID(702 4))
                        )
                        (sewer:status(4))
                        (send gLongSong:
                            vol(0)
                            fade(0 10 10 0)
                        )
                        (send gLongSong2:
                            vol(127)
                            playBed()
                        )
                        = register 1
                    )
                )
                = cycles 5
            )
            (case 1
                (if (== register 1)
                    (send (ScriptID(702 2)):setScript(ScriptID(702 1)))
                )(else
                    proc0_1()
                    proc0_3()
                )
                (self:dispose())
            )
        )
    )

)
(instance daDripScript of Script
    (properties)

    (method (changeState newState)
        (var temp0[2])
        (switch (= state newState)
            (case 0
                (send (ScriptID(702 6)):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 209 self))
            )
            (case 1
                (sewer:
                    status(3)
                    location(110)
                )
                (send (ScriptID(702 2)):
                    posn(1000 1000)
                    dispose()
                )
            )
        )
    )

)
