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



(instance public rm115 of SQRoom
    (properties
        picture 115
        horizon 50
        west 110
        picAngle 70
        vanishingX 0
        vanishingY 65471
    )

    (method (init)
        (sewer:roomVer(22291))
        Load(rsVIEW 80)
        (switch (global12)
            (case 100
                (send gEgo:posn(88 -1))
                (self:
                    setScript(enterNorth)
                    style(30)
                )
                (if (not proc999_5((sewer:location) 100 115))
                    (sewer:status(1))
                )(else
                    (if ((== (sewer:status) 3) and (== (sewer:location) 115))
                        (send (ScriptID(702 2)):
                            init()
                            posn(189 75)
                            setLoop(1)
                            setCycle(Fwd)
                            cycleSpeed(0)
                            setScript(ScriptID(702 4))
                        )
                        (sewer:status(4))
                    )
                )
            )
            (case west
                (if ((== (sewer:location) 115) and (== (sewer:status) 6))
                    (sewer:status(4))
                    (send (ScriptID(702 2)):
                        init()
                        posn(61 127)
                        hide()
                        setCycle(Fwd)
                    )
                )
                (self:
                    style(41)
                    setScript(enterLeft)
                )
            )
            (default 
                (send gLongSong:
                    number(805)
                    vol(127)
                    loop(-1)
                    playBed()
                )
                (send gEgo:
                    init()
                    posn(18 128)
                )
                proc0_1()
            )
        )
        (send (ScriptID(702 5)):
            init()
            setLoop(14)
            posn(85 80)
            cycleSpeed(1)
            setCycle(Fwd)
        )
        (send (ScriptID(702 6)):
            init()
            setLoop(15)
            posn(232 78)
            cycleSpeed(1)
            setCycle(Fwd)
        )
        (super:init())
        (send gEgo:
            init()
            show()
        )
        (send (ScriptID(702 2)):show())
        (self:
            setRegions(702)
            addObstacle((send ((Polygon:new())):
                    type(2)
                    init(0 0 81 0 233 121 227 129 0 129)
                    yourself()
                )
 (send ((Polygon:new())):
                    type(2)
                    init(319 0 319 189 0 189 0 136 241 136 248 129 243 118 95 0)
                    yourself()
                )
)
        )
    )


    (method (doit param1)
        (if (script)
            0
        )(else
            (if (== (send gEgo:edgeHit) 1)
                proc0_2()
                (send (ScriptID(702 2)):setScript(0))
                (self:setScript(exitNorth))
            )(else
                (if (== (send gEgo:edgeHit) 4)
                    (if (> (sewer:distance) 39)
                        (send gLongSong2:
                            vol(0)
                            fade(0 10 10 0)
                        )
                    )
                    (if ((< (send (ScriptID(702 2)):y) 80) or (== (sewer:location) 100))
                        (send gLongSong2:
                            vol(0)
                            fade(0 10 10 0)
                        )
                        (sewer:
                            location(0)
                            status(0)
                        )
                    )
                )
            )
        )
        (super:doit(rest param1))
        (if (((== (dripScript:state) -1) and (<> global12 110)) and (== (sewer:status) 1))
            (send (ScriptID(702 3)):
                init()
                hide()
                setScript(dripScript)
            )
        )
        (if ((((== (sewer:location) 110) and (> (send gEgo:x) 121)) and (> (sewer:prevDistance) 90)) and (> (sewer:rmTimer) 5))
            (sewer:
                location(0)
                status(0)
            )
        )
        (if (< (send gEgo:y) 60)
            (send gEgo:setPri(4))
        )(else
            (send gEgo:setPri(-1))
        )
    )

)
(instance exitNorth of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gEgo:
                    setPri(4)
                    illegalBits(0)
                    ignoreActors(1)
                    setLoop(7)
                    setMotion(MoveTo 89 0 self)
                )
            )
            (case 1
                (if ((== (sewer:location) 100) and (> (sewer:rmTimer) 30))
                    (sewer:
                        location(0)
                        status(0)
                    )
                )
                (if ((== (send (ScriptID(702 2)):loop) 2) or (== (sewer:location) 110))
                    (sewer:
                        location(0)
                        status(0)
                    )
                )
                (send (ScriptID(702 2)):posn(1000 1000))
                (send global2:newRoom(100))
            )
        )
    )

)
(instance dripScript of Script
    (properties)

    (method (changeState newState)
        (var temp0[2])
        (switch (= state newState)
            (case 0
                = seconds Random(3 8)
            )
            (case 1
                (if (< (send gEgo:y) 105)
                    (self:init())
                )(else
                    (self:cue())
                )
            )
            (case 2
                (sewer:
                    status(2)
                    location(115)
                )
                (send gLongSong:
                    vol(0)
                    fade(0 10 10 0)
                )
                (send gLongSong2:
                    vol(127)
                    number(806)
                    loop(1)
                    play()
                )
                (send (ScriptID(702 3)):
                    show()
                    setLoop(6)
                    posn(186 14)
                    cel(0)
                    cycleSpeed(2)
                    setCycle(CT 9 1 self)
                )
            )
            (case 3
                (send (ScriptID(702 3)):
                    cycleSpeed(1)
                    setCycle(End)
                )
                (send (ScriptID(702 2)):
                    init()
                    setLoop(8)
                    cycleSpeed(1)
                    setCycle(End self)
                    posn(161 48)
                )
            )
            (case 4
                (send gLongSong2:
                    vol(127)
                    number(819)
                    loop(-1)
                    playBed()
                )
                (sewer:status(3))
                (send (ScriptID(702 2)):
                    setLoop(1)
                    setCycle(Fwd)
                    cycleSpeed(0)
                    setScript(ScriptID(702 4))
                )
                (self:dispose())
            )
        )
    )

)
(instance enterNorth of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gEgo:
                    ignoreHorizon(1)
                    setLoop(4)
                    setMotion(MoveTo 123 29 self)
                )
            )
            (case 1
                (if ((== (sewer:location) 115) and (== (sewer:status) 3))
                    (send (ScriptID(702 2)):setScript(ScriptID(702 4)))
                )
                (if ((== (sewer:status) 3) and (== (sewer:location) 100))
                    (if (< (sewer:prevDistance) 60)
                        (send (ScriptID(702 2)):posn(79 65520))
                    )(else
                        (send (ScriptID(702 2)):posn(73 65514))
                    )
                    (send (ScriptID(702 2)):
                        init()
                        setLoop(1)
                        setCycle(Fwd)
                        cycleSpeed(0)
                        setScript(ScriptID(702 4))
                    )
                    (sewer:location(115))
                )
                (send gEgo:setMotion(MoveTo 159 59 self))
            )
            (case 2
                proc0_3()
                proc0_1()
                (self:dispose())
            )
        )
    )

)
(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 30 133 self)
                )
                (if ((== (sewer:status) 3) and (== (sewer:location) 110))
                    (if (< (sewer:prevDistance) 50)
                        (send (ScriptID(702 2)):
                            init()
                            hide()
                            posn(65504 125)
                            setLoop(2)
                            moveSpeed(0)
                            setScript(ScriptID(702 4))
                        )
                        (sewer:location(115))
                    )(else
                        (send gLongSong:
                            vol(127)
                            playBed()
                        )
                        (send gLongSong2:
                            vol(0)
                            fade(0 10 10 0)
                        )
                    )
                )(else
                    (if ((== (sewer:status) 3) and (== (sewer:location) 115))
                        (if (> (sewer:oldDistance) 140)
                            (send (ScriptID(702 2)):posn(203 127))
                        )(else
                            (send (ScriptID(702 2)):posn((sewer:oldDistance) 127))
                        )
                        (sewer:status(4))
                        (send (ScriptID(702 2)):
                            init()
                            hide()
                            setLoop(2)
                            moveSpeed(0)
                            setScript(ScriptID(702 4))
                        )
                        (send gLongSong2:
                            vol(127)
                            loop(-1)
                            playBed()
                        )
                        (send gLongSong:
                            vol(0)
                            fade(0 10 10 0)
                        )
                    )
                )
            )
            (case 1
                proc0_3()
                proc0_1()
                (self:dispose())
            )
        )
    )

)
