(include "sci.sh")
(use "Main")
(use "Class_255_0")
(use "sewer")
(use "SQRoom")
(use "PolyPath")
(use "Polygon")
(use "Class_950_0")
(use "Rev")
(use "Cycle")
(use "Obj")
(script 90)



(instance public rm090 of SQRoom
    (properties
        picture 90
        horizon 47
        north 75
        east 95
        south 105
        west 105
        picAngle 70
        vanishingX 319
        vanishingY 65486
    )

    (method (init)
        (sewer:roomVer(22691))
        proc0_2()
        Load(rsVIEW 80)
        Load(rsVIEW 0)
        Load(rsVIEW 100)
        (switch (gWest)
            (case 72
                (self:setScript(climbDOWNscript))
            )
            (case 95
                (send gEgo:posn(309 96))
                (if ((== (sewer:status) 3) and (== (sewer:location) 90))
                    (if (> (sewer:oldDistance) 87)
                        (sewer:oldDistance(87))
                    )
                    (send (ScriptID(702 2)):posn((- 271 (sewer:oldDistance)) 89))
                    (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)
                    )
                )
                (self:
                    style(40)
                    setScript(enterRight)
                )
            )
            (case 105
                (if ((== (sewer:status) 1) or (== (sewer:status) 2))
                    (sewer:
                        status(0)
                        location(0)
                    )
                )
                (if ((== (sewer:location) 90) and (== (sewer:status) 6))
                    (sewer:
                        status(3)
                        prevDistance(20)
                    )
                )
                (if (((== (sewer:status) 3) and (== (sewer:location) 105)) and (== (send (ScriptID(702 2)):loop) 2))
                    (if (> (send (ScriptID(702 2)):x) 180)
                        (sewer:
                            status(0)
                            location(0)
                        )
                    )(else
                        (sewer:
                            status(6)
                            rmTimer(0)
                        )
                    )
                    (send gLongSong2:
                        vol(0)
                        fade(0 10 10 0)
                    )
                    (send gLongSong:
                        vol(127)
                        playBed()
                    )
                )
                (self:
                    setScript(enterSouth)
                    style(30)
                )
            )
            (case north
                (if ((== (sewer:status) 3) and (== (sewer:location) 75))
                    (if (> (sewer:prevDistance) 70)
                        (send (ScriptID(702 2)):posn(305 65504))
                    )(else
                        (if (> (sewer:prevDistance) 50)
                            (send (ScriptID(702 2)):posn(300 65512))
                        )(else
                            (if (> (sewer:prevDistance) 20)
                                (send (ScriptID(702 2)):posn(280 65526))
                            )(else
                                (send (ScriptID(702 2)):posn(274 65528))
                            )
                        )
                    )
                    (send (ScriptID(702 2)):
                        init()
                        hide()
                        setLoop(0)
                        setCycle(Fwd)
                        cycleSpeed(0)
                        setScript(ScriptID(702 4))
                    )
                    (send gEgo:
                        init()
                        hide()
                        posn(244 29)
                    )
                    (sewer:location(90))
                )(else
                    (send gEgo:
                        init()
                        hide()
                        posn(283 65528)
                    )
                )
                (self:
                    setScript(enterNorth)
                    style(30)
                )
            )
            (default 
                (send gLongSong:
                    number(805)
                    vol(127)
                    loop(-1)
                    playBed()
                )
                (send gEgo:
                    init()
                    hide()
                    posn(283 65528)
                )
                (self:
                    setScript(enterNorth)
                    style(30)
                )
            )
        )
        (super:init())
        (send (ScriptID(702 5)):
            init()
            setLoop(6)
            posn(229 44)
            setPri(5)
            ignoreActors(1)
            cycleSpeed(1)
            setCycle(Fwd)
        )
        (send (ScriptID(702 6)):
            init()
            setLoop(7)
            posn(27 130)
            setScript(daDripScript)
        )
        (send gEgo:show())
        (send (ScriptID(702 2)):show())
        (self:
            setFeatures(theLadder)
            setRegions(702)
            addObstacle((send ((Polygon:new())):
                    type(2)
                    init(0 189 0 0 263 0 38 189)
                    yourself()
                )
 (send ((Polygon:new())):
                    type(2)
                    init(48 189 150 105 163 101 319 101 319 189)
                    yourself()
                )
 (send ((Polygon:new())):
                    type(2)
                    init(319 0 319 94 179 94 170 88 181 78 275 0)
                    yourself()
                )
)
        )
    )


    (method (doit param1)
        (if (script)
            0
        )(else
            (if (== (send gEgo:edgeHit) 2)
                (if (== (sewer:location) 105)
                    (sewer:
                        status(0)
                        location(0)
                    )
                )
                (if (((== (sewer:location) 90) and (== (sewer:status) 3)) and (> (send (ScriptID(702 2)):y) 135))
                    (sewer:status(8))
                )
                (if (> (sewer:distance) 30)
                    (send gLongSong2:
                        vol(0)
                        fade(0 10 10 0)
                    )
                    (send gLongSong:
                        vol(127)
                        playBed()
                    )
                )
            )(else
                (if (== (send gEgo:edgeHit) 1)
                    proc0_2()
                    (self:setScript(exitUp))
                )(else
                    (if (== (send gEgo:edgeHit) 3)
                        proc0_2()
                        (self:setScript(exitDown))
                    )(else
                        (if (((== (sewer:status) 6) and (== (sewer:location) 105)) and ((< (send gEgo:y) 143) or (> (sewer:rmTimer) 7)))
                            (sewer:
                                location(0)
                                status(0)
                            )
                        )
                    )
                )
            )
        )
        (if ((& (send gEgo:onControl(1)) $0002) and (== (send (ScriptID(702 2)):loop) 0))
            (sewer:cantDie(1))
        )(else
            (sewer:cantDie(0))
        )
        (if (< (send gEgo:y) 50)
            (send gEgo:setPri(4))
        )(else
            (send gEgo:setPri(-1))
        )
        (super:doit(rest param1))
    )

)
(instance exitUp of Script
    (properties)

    (method (changeState newState)
        (var temp0[2])
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gEgo:
                    illegalBits(0)
                    ignoreActors(1)
                    setLoop(6)
                    setMotion(PolyPath 283 65528 self)
                )
            )
            (case 1
                (if (== (sewer:location) 105)
                    (sewer:
                        status(0)
                        location(0)
                    )
                )
                (if ((== (sewer:location) 90) and (== (sewer:status) 3))
                    (sewer:status(6))
                    (send gLongSong2:
                        vol(0)
                        fade(0 10 10 0)
                    )
                    (send gLongSong:
                        vol(127)
                        playBed()
                    )
                )
                (send global2:newRoom(75))
            )
        )
    )

)
(instance theLadder of Feature
    (properties
        x 75
        y 107
        nsTop 18
        nsLeft 73
        nsBottom 121
        nsRight 100
        description "ladder"
        sightAngle 45
        lookStr "A sturdy metal ladder is attached to the wall here. At the top of the ladder there appears to be something resembling the underside of a manhole cover."
    )

    (method (doVerb param1 param2 param3)
        (switch (param1)
            (case 2
                proc0_2()
                (if (<> (sewer:status) 4)
                    (send global2:setScript(climbUPscript))
                )(else
                    (if (<> (send (ScriptID(702 2)):loop) 2)
                        (send gEgo:setHeading(270))
                        Print("You should not have tried that!")
                    )(else
                        (send global2:setScript(climbUPscript))
                    )
                )
            )
            (default 
                (super:doVerb(param1 rest param3))
            )
        )
    )

)
(instance climbUPscript of Script
    (properties)

    (method (changeState newState)
        (var temp0[2])
        (switch (= state newState)
            (case 0
                (send gEgo:setMotion(PolyPath 98 129 self))
            )
            (case 1
                (send gEgo:
                    posn(98 129)
                    view(100)
                    setLoop(1)
                    setCel(0)
                    cycleSpeed(0)
                    ignoreActors(1)
                    setCycle(Fwd)
                    setMotion(MoveTo 98 72 self)
                )
                (send gLongSong:fade())
                (send gLongSong2:fade())
            )
            (case 2
                (send gLongSong:number(0))
                (send gLongSong2:number(0))
                (send gEgo:
                    setCel(255)
                    ignoreActors(0)
                )
                (send global2:newRoom(72))
            )
        )
    )

)
(instance climbDOWNscript of Script
    (properties)

    (method (changeState newState)
        (var temp0[2])
        (switch (= state newState)
            (case 0
                (send gLongSong:
                    vol(127)
                    number(805)
                    loop(-1)
                    playBed()
                )
                (send gEgo:
                    init()
                    view(100)
                    posn(98 69)
                    illegalBits(0)
                    ignoreActors(1)
                    setCel(255)
                    setLoop(1)
                    cycleSpeed(0)
                )
                = cycles 1
            )
            (case 1
                (send gEgo:
                    setCycle(Rev)
                    setMotion(MoveTo 98 129 self)
                )
            )
            (case 2
                (send gEgo:view(0))
                proc0_1()
                = cycles 1
            )
            (case 3
                (send gEgo:
                    setLoop(-1)
                    setHeading(90 self)
                )
            )
            (case 4
                (send gEgo:setMotion(MoveTo (+ (send gEgo:x) 15) (send gEgo:y) self))
            )
            (case 5
                proc0_3()
                (self:dispose())
            )
        )
    )

)
(instance enterRight of Script
    (properties)

    (method (changeState newState)
        (var temp0[2])
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gEgo:
                    init()
                    hide()
                    setMotion(MoveTo 290 96 self)
                )
                (if (((== (sewer:status) 3) and (== (sewer:location) 95)) and (< (sewer:prevDistance) 30))
                    (send (ScriptID(702 2)):
                        init()
                        hide()
                        posn(357 89)
                        setLoop(2)
                        moveSpeed(0)
                        setScript(ScriptID(702 4))
                    )
                    (send gLongSong2:
                        vol(127)
                        loop(-1)
                        playBed()
                    )
                    (send gLongSong:
                        vol(0)
                        fade(0 10 10 0)
                    )
                    (sewer:location(90))
                )
                (if ((== (sewer:location) 90) and (== (sewer:status) 8))
                    (send (ScriptID(702 2)):
                        init()
                        hide()
                        posn(53 173)
                        setLoop(0)
                        moveSpeed(0)
                        setScript(slimeLeaving)
                    )
                )
            )
            (case 1
                proc0_1()
                proc0_3()
                (self:dispose())
            )
        )
    )

)
(instance enterSouth of Script
    (properties)

    (method (changeState newState)
        (var temp0[2])
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gEgo:
                    init()
                    hide()
                    posn(65527 246)
                    setLoop(6)
                    setMotion(PolyPath 53 180 self)
                )
                (if ((== (sewer:status) 3) and (== (sewer:location) 90))
                    (send (ScriptID(702 2)):posn(75 156))
                    (if (> (sewer:prevDistance) 30)
                        (send (ScriptID(702 2)):posn(90 144))
                    )
                    (if (> (sewer:prevDistance) 50)
                        (send (ScriptID(702 2)):posn(107 128))
                    )
                    (if (> (sewer:prevDistance) 70)
                        (send (ScriptID(702 2)):posn(140 100))
                    )
                    (if (> (sewer:prevDistance) 90)
                        (send (ScriptID(702 2)):posn(176 72))
                    )
                    (if (> (sewer:prevDistance) 110)
                        (send (ScriptID(702 2)):posn(239 21))
                    )
                    (send (ScriptID(702 2)):
                        init()
                        hide()
                        setLoop(0)
                        moveSpeed(2)
                        setScript(ScriptID(702 4))
                    )
                    (sewer:status(4))
                    (send gLongSong2:
                        vol(127)
                        playBed()
                    )
                    (send gLongSong:
                        vol(0)
                        fade(0 10 10 0)
                    )
                )
            )
            (case 1
                (if ((== (sewer:location) 105) and (<> (send (ScriptID(702 2)):loop) 2))
                    (send (ScriptID(702 2)):
                        init()
                        posn(22 199)
                        setLoop(0)
                        setScript(ScriptID(702 4))
                    )
                    (sewer:location(90))
                )
                (if (((== (sewer:location) 90) and (== (sewer:status) 3)) and (== (send (ScriptID(702 2)):loop) 0))
                    (send (ScriptID(702 2)):moveSpeed(1))
                )
                proc0_1()
                proc0_3()
                (self:dispose())
            )
        )
    )

)
(instance enterNorth of Script
    (properties)

    (method (changeState newState)
        (var temp0[2])
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gEgo:
                    setLoop(5)
                    setMotion(PolyPath 208 56 self)
                )
                (if ((== (sewer:status) 6) and (== (sewer:location) 90))
                    (send (ScriptID(702 2)):
                        init()
                        hide()
                        posn(171 79)
                        setLoop(0)
                        setCycle(Fwd)
                        cycleSpeed(0)
                        setScript(ScriptID(702 4))
                    )
                    (sewer:status(4))
                )
            )
            (case 1
                proc0_1()
                proc0_3()
                (self:dispose())
            )
        )
    )

)
(instance exitDown of Script
    (properties)

    (method (changeState newState)
        (var temp0[2])
        (switch (= state newState)
            (case 0
                (send gEgo:
                    setHeading(225 self)
                    setMotion(0)
                )
            )
            (case 1
                (send gEgo:
                    setLoop(5)
                    setMotion(PolyPath 65527 246 self)
                )
            )
            (case 2
                (if (< (send (ScriptID(702 2)):y) 105)
                    (sewer:
                        location(0)
                        status(0)
                    )
                    (send gLongSong2:
                        vol(0)
                        fade(0 10 10 0)
                    )
                    (send gLongSong:
                        vol(127)
                        playBed()
                    )
                )
                (send global2:newRoom(105))
            )
        )
    )

)
(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)):
                    setCycle(Fwd)
                    setMotion(MoveTo 19 207 self)
                )
            )
            (case 1
                (sewer:
                    location(105)
                    status(3)
                )
                (send (ScriptID(702 2)):
                    posn(1000 1000)
                    dispose()
                )
                (self:dispose())
            )
        )
    )

)
