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



(instance public rm100 of SQRoom
    (properties
        picture 100
        horizon 48
        north 85
        south 115
        west 95
        picAngle 70
        vanishingX 0
        vanishingY 65486
    )

    (method (init)
        (sewer:roomVer(22891))
        Load(rsVIEW 80)
        (switch (global12)
            (case 95
                proc0_3()
                (if (== (sewer:location) 100)
                    (if (> (sewer:oldDistance) 68)
                        (send (ScriptID(702 2)):posn(121 91))
                    )(else
                        (if (> (sewer:oldDistance) 40)
                            (send (ScriptID(702 2)):posn(68 91))
                        )(else
                            (send (ScriptID(702 2)):posn(37 91))
                            (sewer:status(4))
                        )
                    )
                    (send gLongSong2:
                        number(819)
                        vol(127)
                        playBed()
                    )
                    (send gLongSong:
                        vol(0)
                        fade(0 10 10 0)
                    )
                    (send (ScriptID(702 2)):
                        init()
                        hide()
                        setLoop(2)
                        moveSpeed(0)
                        setScript(ScriptID(702 4))
                    )
                )
                (self:
                    style(41)
                    setScript(enterLeft)
                )
            )
            (case 85
                (self:
                    setScript(enterNorth)
                    style(30)
                )
            )
            (case 115
                (if ((== (sewer:status) 1) or (== (sewer:status) 2))
                    (sewer:
                        status(0)
                        location(0)
                    )
                )
                (if ((== (sewer:location) 100) and (== (sewer:status) 8))
                    (if (> Random(0 100) 50)
                        (send (ScriptID(702 2)):
                            init()
                            hide()
                            setCycle(Fwd)
                            setLoop(2)
                            posn(11 93)
                            setScript(slimeLeavingL)
                        )
                    )(else
                        (send (ScriptID(702 2)):
                            init()
                            hide()
                            setCycle(Fwd)
                            setLoop(1)
                            posn(72 16)
                            setScript(slimeLeavingUp)
                        )
                    )
                )
                (self:
                    setScript(enterSouth)
                    style(30)
                )
            )
            (default 
                (send gLongSong:
                    number(805)
                    vol(127)
                    loop(-1)
                    playBed()
                )
                (self:
                    setScript(enterSouth)
                    style(30)
                )
            )
        )
        (send (ScriptID(702 5)):
            init()
            setLoop(10)
            posn(90 44)
            setPri(5)
            cycleSpeed(1)
            setCycle(Fwd)
        )
        (send (ScriptID(702 6)):
            init()
            setLoop(11)
            posn(292 130)
            setScript(daDripScript)
        )
        (super:init())
        (send gEgo:show())
        (send (ScriptID(702 2)):show())
        (self:
            setRegions(702)
            addObstacle((send ((Polygon:new())):
                    type(2)
                    init(58 0 319 0 319 189 284 189)
                    yourself()
                )
 (send ((Polygon:new())):
                    type(2)
                    init(46 0 150 87 149 94 0 94 0 0)
                    yourself()
                )
 (send ((Polygon:new())):
                    type(2)
                    init(0 99 159 99 270 189 0 189)
                    yourself()
                )
)
        )
    )


    (method (doit param1)
        (if (script)
            0
        )(else
            (if (== (send gEgo:edgeHit) 4)
                (if (proc999_5((sewer:location) 115 85))
                    (sewer:
                        status(0)
                        location(0)
                    )
                )
                (if (((== (sewer:location) 100) and (== (sewer:status) 3)) and (> (send (ScriptID(702 2)):y) 135))
                    (sewer:status(8))
                )
            )(else
                (if (== (send gEgo:edgeHit) 1)
                    proc0_2()
                    (self:setScript(exitNorth))
                )(else
                    (if (== (send gEgo:edgeHit) 3)
                        proc0_2()
                        (self:setScript(exitSouth))
                    )(else
                        (if (((> (sewer:rmTimer) 5) and (== (sewer:location) 95)) and (> (send gEgo:x) 146))
                            (sewer:
                                status(0)
                                location(0)
                            )
                        )
                    )
                )
            )
        )
        (if (((> (sewer:rmTimer) 15) and (== (sewer:location) 85)) and (== (sewer:status) 8))
            (sewer:
                status(0)
                location(0)
            )
        )
        (super:doit(rest param1))
        (if (< (send gEgo:y) 50)
            (send gEgo:setPri(4))
        )(else
            (send gEgo:setPri(-1))
        )
        (if ((& (send gEgo:onControl(1)) $0002) and (== (send (ScriptID(702 2)):loop) 1))
            (sewer:cantDie(1))
        )(else
            (sewer:cantDie(0))
        )
    )

)
(instance exitSouth of Script
    (properties)

    (method (changeState newState)
        (var temp0[2])
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gEgo:
                    setLoop(-1)
                    setHeading(132 self)
                )
            )
            (case 1
                (send gEgo:
                    setLoop(4)
                    setMotion(MoveTo 325 239 self)
                )
            )
            (case 2
                (if (proc999_5((sewer:location) 95 85))
                    (sewer:
                        location(0)
                        status(0)
                    )
                )
                (if ((== (sewer:location) 100) and (< (send (ScriptID(702 2)):y) 120))
                    (sewer:status(8))
                    (send gLongSong2:
                        vol(0)
                        fade(0 10 10 0)
                    )
                )
                (send global2:newRoom(115))
            )
        )
    )

)
(instance enterNorth of Script
    (properties)

    (method (changeState newState)
        (var temp0[2])
        (switch (= state newState)
            (case 0
                proc0_2()
                (if ((== (sewer:status) 2) and (== (sewer:location) 85))
                    (if (> Random(0 100) 50)
                        (send gLongSong:
                            vol(127)
                            playBed()
                        )
                        (send gLongSong2:
                            vol(0)
                            fade(0 10 10 0)
                        )
                        (sewer:status(6))
                    )(else
                        (sewer:status(3))
                    )
                )
                (send gEgo:
                    init()
                    setLoop(4)
                    illegalBits(0)
                    ignoreActors(1)
                    posn(38 65530)
                    setMotion(MoveTo 80 27 self)
                )
            )
            (case 1
                (if ((== (sewer:location) 85) and (== (sewer:status) 3))
                    (send (ScriptID(702 2)):
                        init()
                        hide()
                        posn(20 65509)
                        setLoop(1)
                        setCycle(Fwd)
                        cycleSpeed(0)
                        setScript(bringInSlime)
                    )
                    (sewer:location(100))
                )
                (send gEgo:setMotion(MoveTo 111 51 self))
            )
            (case 2
                proc0_1()
                proc0_3()
                (self:dispose())
            )
        )
    )

)
(instance exitNorth of Script
    (properties)

    (method (changeState newState)
        (var temp0[2])
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gEgo:
                    setLoop(-1)
                    illegalBits(0)
                    ignoreActors(1)
                    setHeading(311 self)
                )
            )
            (case 1
                (send gEgo:
                    setLoop(7)
                    setMotion(MoveTo 38 65530 self)
                )
            )
            (case 2
                (if ((== (sewer:location) 100) and (== (sewer:status) 3))
                    (send gLongSong:
                        vol(127)
                        playBed()
                    )
                    (send gLongSong2:
                        vol(0)
                        fade(0 10 10 0)
                    )
                )
                (if (== (sewer:location) 95)
                    (sewer:
                        location(0)
                        status(0)
                    )
                )
                (send global2:newRoom(85))
            )
        )
    )

)
(instance enterSouth of Script
    (properties)

    (method (changeState newState)
        (var temp0[2])
        (switch (= state newState)
            (case 0
                proc0_2()
                (if (== (sewer:status) 6)
                    (send gEgo:
                        init()
                        hide()
                        view(76)
                        normal(0)
                        setLoop(0)
                        posn(284 189)
                    )
                    (send (ScriptID(702 2)):
                        init()
                        hide()
                        setLoop(1)
                        posn(284 182)
                        setCycle(Fwd)
                        cycleSpeed(0)
                        setScript(ScriptID(702 1))
                    )
                )(else
                    (send gEgo:
                        init()
                        setLoop(7)
                        illegalBits(0)
                        ignoreActors(1)
                        posn(336 249)
                        setMotion(MoveTo 274 187 self)
                    )
                    (if ((== (sewer:location) 100) and (== (sewer:status) 3))
                        (switch ((sewer:oldDistance))
                            (case 4
                                (send (ScriptID(702 2)):posn(159 85))
                            )
                            (case 3
                                (send (ScriptID(702 2)):posn(175 98))
                            )
                            (case 2
                                (send (ScriptID(702 2)):posn(218 127))
                            )
                            (case 1
                                (send (ScriptID(702 2)):posn(225 138))
                            )
                        )
                        (send (ScriptID(702 2)):
                            init()
                            hide()
                            setLoop(1)
                            setScript(ScriptID(702 4))
                        )
                        (send gLongSong2:
                            vol(127)
                            playBed()
                        )
                        (send gLongSong:
                            vol(0)
                            fade(0 10 10 0)
                        )
                    )
                )
            )
            (case 1
                (if ((== (sewer:location) 115) and (== (sewer:status) 3))
                    (send (ScriptID(702 2)):
                        posn(300 198)
                        init()
                        setScript(ScriptID(702 4))
                    )
                    (sewer:status(4))
                )
                proc0_1()
                proc0_3()
                (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(12 98)
                    setMotion(MoveTo 31 97 self)
                )
                (if ((== (sewer:location) 100) and (== (sewer:status) 8))
                    (send (ScriptID(702 2)):
                        init()
                        hide()
                        posn(270 174)
                        setLoop(1)
                        moveSpeed(0)
                        setScript(slimeLeavingDown)
                    )
                )
                (if ((((== (sewer:location) 95) and (== (sewer:status) 3)) and (== (send (ScriptID(702 2)):loop) 2)) and (< (sewer:prevDistance) 35))
                    (send (ScriptID(702 2)):
                        init()
                        hide()
                        posn(65503 89)
                        setLoop(2)
                        moveSpeed(0)
                        setScript(ScriptID(702 4))
                    )
                    (sewer:location(100))
                    (send gLongSong2:
                        vol(127)
                        playBed()
                    )
                    (send gLongSong:
                        vol(0)
                        fade(0 10 10 0)
                    )
                )
            )
            (case 1
                proc0_3()
                proc0_1()
                (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 slimeLeavingDown of Script
    (properties)

    (method (changeState newState)
        (var temp0[2])
        (switch (= state newState)
            (case 0
                (send (ScriptID(702 2)):
                    setCycle(Fwd)
                    setMotion(MoveTo 302 208 self)
                )
            )
            (case 1
                (sewer:
                    location(115)
                    status(3)
                )
                (send (ScriptID(702 2)):
                    posn(1000 1000)
                    dispose()
                )
                (self:dispose())
            )
        )
    )

)
(instance slimeLeavingUp of Script
    (properties)

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

)
(instance slimeLeavingL of Script
    (properties)

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

)
(instance bringInSlime of Script
    (properties)

    (method (changeState newState)
        (var temp0[2])
        (switch (= state newState)
            (case 0
                = cycles 7
                (if (> (sewer:prevDistance) 50)
                    = cycles 15
                )
                (if (> (sewer:prevDistance) 100)
                    = cycles 25
                )
            )
            (case 1
                (if (<> (send gLongSong2:number) 819)
                    (send gLongSong2:
                        number(819)
                        vol(127)
                        playBed()
                    )
                )
                (send (ScriptID(702 2)):
                    show()
                    setScript(ScriptID(702 4))
                )
                (self:dispose())
            )
        )
    )

)
