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


(local
    local0

)
(instance public rm110 of SQRoom
    (properties
        picture 110
        horizon 50
        east 115
        west 105
        picAngle 70
    )

    (method (init)
        (var temp0)
        (sewer:roomVer(22691))
        Load(rsVIEW 80)
        (switch (gWest)
            (case 95
                (self:setScript(enterNorth))
                = temp0 42
            )
            (case east
                = temp0 40
                proc0_2()
                (self:setScript(enterRight))
            )
            (case west
                (if (== (sewer:location) 90)
                    (sewer:
                        status(0)
                        location(0)
                    )
                )
                = temp0 41
                proc0_2()
                (self:setScript(enterLeft))
            )
            (default 
                (send gLongSong:
                    number(805)
                    vol(127)
                    loop(-1)
                    playBed()
                )
                (send gEgo:
                    init()
                    hide()
                    posn(20 133)
                )
                proc0_1()
            )
        )
        (self:style(temp0))
        (send (ScriptID(702 5)):
            init()
            setLoop(13)
            posn(250 114)
            setScript(daDripScript)
        )
        (super:init())
        (send (ScriptID(702 2)):show())
        (send gEgo:show())
        (self:
            setRegions(702)
            addObstacle((send ((Polygon:new())):
                    type(2)
                    init(0 0 146 0 146 120 139 130 0 130)
                    yourself()
                )
 (send ((Polygon:new())):
                    type(2)
                    init(164 0 319 0 319 130 168 130 164 120)
                    yourself()
                )
 (send ((Polygon:new())):
                    type(2)
                    init(0 136 319 136 319 189 0 189)
                    yourself()
                )
)
        )
    )


    (method (doit param1)
        (if (script)
            0
        )(else
            (if (== (send gEgo:edgeHit) 1)
                proc0_2()
                (self:setScript(exitScript))
            )(else
                (if ((== (send gEgo:edgeHit) 4) or (== (send gEgo:edgeHit) 2))
                    (if (== (sewer:location) 95)
                        (sewer:
                            status(0)
                            location(0)
                        )
                    )
                    (if ((== (sewer:status) 3) and ((== (send (ScriptID(702 2)):y) 1000) or (< (send (ScriptID(702 2)):y) 50)))
                        (sewer:
                            status(0)
                            location(0)
                        )
                    )
                )(else
                    (if (((== (sewer:status) 3) and (> (sewer:rmTimer) 11)) and (<> (sewer:location) 110))
                        (sewer:
                            location(0)
                            status(0)
                        )
                    )(else
                        (if ((== (sewer:location) 95) and (> (sewer:rmTimer) 6))
                            (sewer:
                                status(0)
                                location(0)
                            )
                        )
                    )
                )
            )
        )
        (super:doit(rest param1))
        (if ((((== (sewer:status) 3) and (== (sewer:location) 115)) and (< (send gEgo:x) 245)) and (< (sewer:rmTimer) 12))
            (sewer:location(110))
            (send (ScriptID(702 2)):
                init()
                setLoop(2)
                moveSpeed(0)
                posn(346 125)
                setCycle(Fwd)
                cycleSpeed(0)
                setScript(ScriptID(702 4))
            )
            (send gLongSong2:
                vol(127)
                playBed()
            )
            (send gLongSong:
                vol(0)
                fade(0 10 10 0)
            )
        )
        (if (((> (send gEgo:x) 85) and (== (sewer:status) 3)) and (== (sewer:location) 105))
            (sewer:location(110))
            (send (ScriptID(702 2)):
                init()
                setLoop(2)
                moveSpeed(0)
                posn(65497 125)
                setCycle(Fwd)
                cycleSpeed(0)
                setScript(ScriptID(702 4))
            )
            (send gLongSong2:
                vol(127)
                playBed()
            )
            (send gLongSong:
                vol(0)
                fade(0 10 10 0)
            )
        )
        (if (< (send gEgo:y) 63)
            (send gEgo:setPri(4))
        )(else
            (send gEgo:setPri(-1))
        )
    )

)
(instance exitScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (if ((== (send (ScriptID(702 2)):loop) 3) and (> (sewer:distance) 29))
                    (send (ScriptID(702 2)):
                        setScript(0)
                        posn(1000 1000)
                    )
                    (sewer:location(95))
                )
                (send gEgo:
                    ignoreHorizon(1)
                    setMotion(MoveTo (send gEgo:x) 65510 self)
                )
            )
            (case 1
                (if (== (send (ScriptID(702 2)):loop) 3)
                    (send (ScriptID(702 2)):hide())
                )
                (if (== (sewer:location) 110)
                    (send gLongSong2:
                        vol(0)
                        fade(0 10 10 0)
                    )
                    (send gLongSong:
                        vol(127)
                        playBed()
                    )
                    (if (((< (send (ScriptID(702 2)):x) 90) or (> (send (ScriptID(702 2)):x) 240)) and (== (send (ScriptID(702 2)):loop) 2))
                        (sewer:
                            location(0)
                            status(0)
                        )
                    )
                )
                (if (== (sewer:location) 115)
                    (sewer:
                        status(0)
                        location(0)
                    )
                )
                (send global2:newRoom(95))
            )
        )
    )

)
(instance enterLeft of Script
    (properties)

    (method (changeState newState)
        (var temp0[2])
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gEgo:
                    init()
                    hide()
                    posn(10 133)
                    setMotion(MoveTo 25 133 self)
                )
                (if ((== (sewer:status) 6) and (== (sewer:location) 110))
                    (send gLongSong2:
                        vol(127)
                        playBed()
                    )
                    (send gLongSong:
                        vol(0)
                        fade(0 10 10 0)
                    )
                    (send (ScriptID(702 2)):
                        init()
                        hide()
                        posn(57 127)
                        moveSpeed(0)
                        setLoop(2)
                        setScript(ScriptID(702 4))
                    )
                    (sewer:status(4))
                )(else
                    (if ((== (sewer:status) 3) and (== (sewer:location) 110))
                        (send gLongSong2:
                            vol(127)
                            playBed()
                        )
                        (send gLongSong:
                            vol(0)
                            fade(0 10 10 0)
                        )
                        (if (> (sewer:oldDistance) 109)
                            (sewer:oldDistance(109))
                        )
                        (send (ScriptID(702 2)):
                            init()
                            hide()
                            moveSpeed(0)
                            setLoop(2)
                        )
                        (sewer:status(4))
                        (if (not Random(0 2))
                            (send (ScriptID(702 2)):
                                posn((sewer:oldDistance) 127)
                                setScript(ScriptID(702 4))
                            )
                        )(else
                            (send (ScriptID(702 2)):
                                posn(Random(310 334) 127)
                                setScript(slimeLeavingR)
                            )
                        )
                    )(else
                        (if (((== (sewer:status) 3) and (== (sewer:location) 105)) and (< (sewer:prevDistance) 40))
                            (send gLongSong2:
                                vol(127)
                                playBed()
                            )
                            (send gLongSong:
                                vol(0)
                                fade(0 10 10 0)
                            )
                            (send (ScriptID(702 2)):
                                init()
                                hide()
                                posn(65497 125)
                                setLoop(2)
                                moveSpeed(0)
                                setScript(ScriptID(702 4))
                            )
                            (sewer:location(110))
                        )
                    )
                )
            )
            (case 1
                proc0_3()
                proc0_1()
                (self:dispose())
            )
        )
    )

)
(instance enterRight of Script
    (properties)

    (method (changeState newState)
        (var temp0[2])
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gEgo:
                    init()
                    hide()
                    posn(309 134)
                    setMotion(MoveTo 297 134 self)
                )
                (if ((== (sewer:status) 3) and (== (sewer:location) 110))
                    (send gLongSong2:
                        vol(127)
                        playBed()
                    )
                    (send gLongSong:
                        vol(0)
                        fade(0 10 10 0)
                    )
                    (send (ScriptID(702 2)):
                        init()
                        hide()
                        moveSpeed(0)
                        setLoop(2)
                        setScript(ScriptID(702 4))
                    )
                    (sewer:status(4))
                    (if (not Random(0 2))
                        (send (ScriptID(702 2)):
                            posn(- 320 (sewer:oldDistance) 125)
                            setScript(ScriptID(702 4))
                        )
                    )(else
                        (send (ScriptID(702 2)):
                            posn(Random(65515 12) 127)
                            setScript(slimeLeavingL)
                        )
                    )
                )
                (if (((== (sewer:status) 3) and (== (sewer:location) 115)) and (< (sewer:prevDistance) 40))
                    (send (ScriptID(702 2)):
                        init()
                        hide()
                        posn(359 125)
                        setLoop(2)
                        moveSpeed(0)
                        setScript(ScriptID(702 4))
                    )
                    (sewer:location(110))
                )
            )
            (case 1
                proc0_3()
                proc0_1()
                (self:dispose())
            )
        )
    )

)
(instance enterNorth of Script
    (properties)

    (method (changeState newState)
        (var temp0[2])
        (switch (= state newState)
            (case 0
                proc0_2()
                (sewer:rmTimer(0))
                (send gEgo:
                    init()
                    posn(161 76)
                )
                (if (== (sewer:status) 3)
                    (switch ((sewer:location))
                        (case 95
                            (if (< (sewer:prevDistance) 60)
                                (sewer:prevDistance(60))
                            )
                            (send (ScriptID(702 2)):posn(158 (- 30 (sewer:prevDistance))))
                            (send (ScriptID(702 2)):
                                init()
                                hide()
                                setLoop(3)
                                setCycle(Fwd)
                                setScript(ScriptID(702 4))
                            )
                            (sewer:
                                cantDie(1)
                                location(110)
                            )
                        )
                        (case 110
                            (send (ScriptID(702 2)):
                                init()
                                hide()
                                posn(157 108)
                                setLoop(3)
                                setCycle(Fwd)
                                setScript(ScriptID(702 4))
                            )
                            (sewer:status(4))
                        )
                    )
                )
                = seconds 2
            )
            (case 1
                proc0_3()
                proc0_1()
                (sewer:rmTimer(0))
                (self:dispose())
            )
        )
    )

)
(instance slimeLeavingR of Script
    (properties)

    (method (changeState newState)
        (var temp0[2])
        (switch (= state newState)
            (case 0
                (sewer:status(8))
                (send (ScriptID(702 2)):
                    setCycle(Fwd)
                    setMotion(MoveTo 370 127 self)
                )
            )
            (case 1
                (send (ScriptID(702 2)):dispose())
                (sewer:
                    location(115)
                    status(6)
                )
            )
        )
    )

)
(instance slimeLeavingL of Script
    (properties)

    (method (changeState newState)
        (var temp0[2])
        (switch (= state newState)
            (case 0
                (sewer:status(8))
                (send (ScriptID(702 2)):
                    setCycle(Fwd)
                    setMotion(MoveTo 65491 127 self)
                )
            )
            (case 1
                (send (ScriptID(702 2)):dispose())
                (sewer:
                    location(105)
                    status(6)
                )
            )
        )
    )

)
(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())
            )
        )
    )

)
