(include "sci.sh")
(use "Main")
(use "Class_255_0")
(use "SQRoom")
(use "PolyPath")
(use "Polygon")
(use "Class_950_0")
(use "n958")
(use "Sound")
(use "Jump")
(use "Cycle")
(use "PicView")
(use "Obj")
(script 50)


(local
    local0[26] = (108 0 140 69 139 88 121 145 147 170 182 164 161 98 160 76 271 0 190 0 158 40 153 37 145 )
    local26[30] = (0 42 45 38 32 11 41 0 72 0 115 30 122 31 136 62 136 66 140 69 140 73 69 84 55 84 32 78 0 51 )
    local56[6] = (251 59 170 70 229 29 )
    local62[38] = (141 189 109 157 109 143 122 137 120 145 147 170 183 165 172 129 238 118 240 120 226 126 244 137 244 144 255 153 272 157 293 154 288 173 295 185 304 189 )
    local100[26] = (0 51 31 78 55 83 72 84 139 73 140 87 123 136 111 141 104 150 94 157 94 165 117 189 0 189 )
    local126[26] = (249 60 223 85 252 92 236 118 173 128 162 98 161 78 170 70 0 56 5 56 21 70 9 71 0 62 )

)
(instance public rm050 of SQRoom
    (properties
        picture 50
        style 30
        horizon 37
        north 35
        south 65
        west 45
        vanishingX 2
        vanishingY 65511
    )

    (method (init)
        proc958_0(128 50)
        proc958_0(132 131 808 809 103 123 147)
        (if ((send gEgo:has(2)))
            Load(rsVIEW 66)
            Load(rsSCRIPT 991)
        )
        (send global2:addObstacle((send ((Polygon:new())):
                type(2)
                init(106 140 166 140 200 165 140 176)
                yourself()
            )
 (send ((Polygon:new())):
                type(2)
                init(0 25 60 25 72 40 0 49)
                yourself()
            )
 (send ((Polygon:new())):
                type(2)
                init(319 0 319 40 111 40 67 0)
                yourself()
            )
 (send ((Polygon:new())):
                type(2)
                init(319 91 319 189 291 189 284 185 278 170 286 164 286 159 250 158 233 146 232 136 248 136 255 106)
                yourself()
            )
))
        (switch (gWest)
            (case north
                proc0_2()
                (self:setScript(enterScript))
            )
            (case south
                (send gEgo:x(255))
            )
            (default 
                (send gEgo:
                    x(100)
                    y(160)
                )
            )
        )
        (send gEgo:init())
        (theGrate:init())
        (otherGrate:init())
        (grateSnd:init())
        (supportPoly:
            points(@local0)
            size(13)
        )
        (sidewalk1Poly:
            points(@local26)
            size(15)
        )
        (sidewalk2Poly:
            points(@local56)
            size(3)
        )
        (sidewalk3Poly:
            points(@local62)
            size(19)
        )
        (street1Poly:
            points(@local100)
            size(13)
        )
        (street2Poly:
            points(@local126)
            size(8)
        )
        (otherGratePoly:
            points(@local65422)
            size(4)
        )
        (self:setRegions(701))
        (super:init())
        (self:setRegions(705))
        (theHole:init())
        (theLiquid:init())
        (theSupports:init())
        (theSmallSupports:init())
        (theRedBldg:init())
        (street1:init())
        (street2:init())
        (sidewalk1:init())
        (sidewalk2:init())
        (sidewalk3:init())
        (theArea:init())
    )


    (method (doit)
        (var temp0)
        = temp0 (send gEgo:onControl(1))
        (if ((send global2:script))
            0
        )(else
            (if (((((& temp0 $0004) or (& temp0 $0008)) or (& temp0 $0010)) or (& temp0 $0002)) or (& temp0 $4000))
                proc0_2()
                (self:setScript(fallScript 0 temp0))
            )(else
                (if (== (send gEgo:edgeHit) 1)
                    proc0_2()
                    (self:setScript(exitScript 0 1))
                )
            )
        )
        (super:doit())
    )


    (method (dispose)
        DisposeScript(991)
        (super:dispose())
    )


    (method (newRoom param1)
        (if ((((== (send gEgo:edgeHit) 3) and (< (send gEgo:x) 133)) and (<> (send global2:script) ScriptID(701 3))) and (<> (send (ScriptID(701 1)):script) ScriptID(701 4)))
            (super:newRoom(60))
        )(else
            (if (== param1 70)
                (send gLongSong:fade(0 10 10 1))
            )
            (super:newRoom(param1))
        )
    )

)
(instance enterScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send gEgo:
                    posn(50 -1)
                    setMotion(MoveTo 85 47 self)
                )
            )
            (case 1
                proc0_3()
                (self:dispose())
            )
        )
    )

)
(instance exitScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send gEgo:setMotion(MoveTo 15 65526 self))
            )
            (case 1
                = register 0
                (send global2:newRoom((send global2:north)))
            )
        )
    )

)
(instance public grateScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send gEgo:setMotion(PolyPath 68 85 self))
            )
            (case 1
                (send gEgo:setMotion(MoveTo 68 87 self))
            )
            (case 2
                (if (not (send gEgo:has(2)))
                    proc0_11(42 5)
                )
                (send gEgo:
                    view(50)
                    normal(0)
                    loop(0)
                    cel(0)
                    cycleSpeed(1)
                )
                = cycles 5
            )
            (case 3
                (send gEgo:setCycle(CT 3 1 self))
            )
            (case 4
                = cycles 3
            )
            (case 5
                (grateSnd:
                    number(809)
                    loop(1)
                    vol(25)
                    play()
                )
                = cycles 2
            )
            (case 6
                (send gEgo:setCycle(CT 5 1 self))
                (theGrate:hide())
                = cycles 7
            )
            (case 7
                (grateSnd:play())
                (send gEgo:setCycle(CT 4 -1))
                = cycles 3
            )
            (case 8
                (grateSnd:
                    number(808)
                    loop(1)
                    vol(127)
                    play()
                )
                (send gEgo:setCycle(End self))
            )
            (case 9
                (send gEgo:
                    loop(1)
                    cel(0)
                    x(+ (send gEgo:x) 35)
                    y(- (send gEgo:y) 1)
                    setCycle(CT 5 1 self)
                )
            )
            (case 10
                (send gEgo:setCycle(End self))
            )
            (case 11
                (grateSnd:
                    number(809)
                    play()
                )
                (send gEgo:x(500))
                (theGrate:show())
                = cycles 5
            )
            (case 12
                (if ((send gEgo:has(2)))
                    = seconds 2
                )(else
                    (send global2:newRoom(70))
                )
            )
            (case 13
                (send gLongSong:
                    number(103)
                    vol(127)
                    loop(1)
                    playBed()
                )
                (theGrate:
                    yStep(20)
                    setMotion(MoveTo - (theGrate:x) 40 65436)
                )
                (explosion:
                    init()
                    x(83)
                    y(89)
                    view(66)
                    loop(0)
                    cel(0)
                    setCycle(End)
                    ignoreActors(1)
                )
                (armBit:
                    init()
                    setMotion(JumpTo - (armBit:x) 15 + (armBit:y) 30)
                )
                (legBit:
                    init()
                    setMotion(JumpTo - (armBit:x) 15 - (armBit:y) 30)
                )
                (headBit:
                    init()
                    setMotion(JumpTo + (armBit:x) 30 + (armBit:y) 10)
                )
                = seconds 5
            )
            (case 14
                (theGrate:
                    yStep(20)
                    setMotion(MoveTo - (theGrate:x) 10 101 self)
                )
            )
            (case 15
                (grateSnd:
                    number(809)
                    loop(1)
                    play()
                )
                (theGrate:setMotion(JumpTo (- (theGrate:x) 20) 111 self))
            )
            (case 16
                (grateSnd:
                    number(123)
                    play()
                )
                (theGrate:setMotion(JumpTo (- (theGrate:x) 5) 113 self))
            )
            (case 17
                (grateSnd:play())
                = seconds 3
            )
            (case 18
                Print("Given another opportunity in this thing we loosely refer to as life, I think UNSTABLE ORDNANCE would be low on your list of fun things to carry.")
                proc0_10(6 4)
            )
        )
    )

)
(instance fallScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (if (& register $0008)
                    (send gEgo:setPri(0))
                )(else
                    (if (& register $0010)
                        (send gEgo:setPri(1))
                    )(else
                        (if (& register $0004)
                            (send gEgo:setPri(2))
                        )(else
                            (if (& register $0002)
                                (send gEgo:setPri(3))
                            )(else
                                (if (& register $4000)
                                    (send gEgo:setPri(4))
                                )
                            )
                        )
                    )
                )
                (send gEgo:
                    x(+ (send gEgo:x) 8)
                    y(+ (send gEgo:y) 12)
                    setLoop((send gEgo:loop))
                )
                (send gLongSong:
                    number(131)
                    loop(1)
                    vol(127)
                    play()
                )
                = cycles 1
            )
            (case 1
                (send gEgo:
                    yStep(20)
                    setMotion(MoveTo (send gEgo:x) + (send gEgo:y) 250 self)
                )
            )
            (case 2
                = seconds 2
            )
            (case 3
                (send gLongSong:fade(0 1 2 1))
                = seconds 1
            )
            (case 4
                (send gLongSong:
                    number(147)
                    loop(1)
                    vol(127)
                    play()
                )
                Print("Serious damage to important body parts, particularly those vital organs normally well-protected by the skeletal structure of the chest, pretty much screws up any future plans you might have had for living. Bummer, eh?")
                proc0_10(0 8)
            )
        )
    )

)
(instance theGrate of Actor
    (properties
        x 84
        y 91
        heading 170
        description "grate"
        sightAngle 40
        lookStr "This grate has a fair amount of crud, gunk, and sludge built up around the edges. You can see through the grate but can't make anything out."
        view 50
        loop 2
        signal 30736
    )

    (method (doit)
        (super:doit())
        (if (== (send global2:curPic) 31)
            (self:z(1000))
        )(else
            (self:z(0))
        )
    )


    (method (doVerb param1)
        (switch (param1)
            (case 2
                (if ((send global2:script))
                    0
                )(else
                    proc0_2()
                    (send global2:setScript(grateScript))
                )
            )
            (case 11
                Print("The cool, rank smell of a sewer wafts up from underground.")
            )
            (case 10
                Print("Okay, you taste grate and find it less filling.")
            )
            (default 
                (super:doVerb(param1))
            )
        )
    )

)
(instance otherGrate of Feature
    (properties
        x 10
        y 66
        nsBottom 200
        nsRight 320
        description "grate"
        sightAngle 40
        lookStr "The grate is anchored securely by bolts with mildly corroded heads."
    )

    (method (init)
        (super:init())
        (self:onMeCheck(otherGratePoly))
    )


    (method (doVerb param1)
        (switch (param1)
            (case 2
                Print("The bolted down grate won't budge.")
            )
            (case 11
                Print("The cool, rank smell of a sewer wafts up from underground.")
            )
            (case 10
                Print("Okay, you taste grate and find it less filling.")
            )
            (default 
                (super:doVerb(param1))
            )
        )
    )

)
(instance otherGratePoly of Polygon
    (properties)
)
(instance theRedBldg of Feature
    (properties
        x 294
        y 143
        nsBottom 200
        nsRight 320
        description "red building"
        sightAngle 45
        onMeCheck 1024
        lookStr "A battered and boarded storefront shows the wear and tear a little war can inflict."
    )

    (method (doVerb param1)
        (switch (param1)
            (case 2
                Print("The building is closed up with welded metal panels enhancing non-access.")
            )
            (default 
                (super:doVerb(param1))
            )
        )
    )

)
(instance theHole of Feature
    (properties
        x 249
        y 76
        nsBottom 200
        nsRight 320
        description "hole"
        sightAngle 45
        onMeCheck 28
        lookStr "A large void indicates the absence of any dense matter."
    )

    (method (doVerb param1)
        (switch (param1)
            (case 11
                Print("As is so often the case with voids there is nothing to smell.")
            )
            (case 10
                Print("As is so often the case with voids there is nothing to taste.")
            )
            (default 
                (super:doVerb(param1))
            )
        )
    )

)
(instance theLiquid of Feature
    (properties
        x 116
        y 174
        nsBottom 200
        nsRight 320
        description "crystalized liquid"
        sightAngle 45
        onMeCheck 64
        lookStr "A fluid-looking mass lying in the gutter is actually crystalized toxic run-off."
    )

    (method (doVerb param1)
        (switch (param1)
            (case 2
                Print("It would serve no purpose.")
            )
            (case 11
                Print("It's probably the most nauseating thing to smell in the whole non-liquid liquid family of smells.")
            )
            (case 10
                Print("It's definitely the most nauseating thing to taste in the whole non-liquid liquid family of tastes.")
            )
            (default 
                (super:doVerb(param1))
            )
        )
    )

)
(instance theSupports of Feature
    (properties
        x 154
        y 149
        description "supports"
        sightAngle 45
        lookStr "Huge supports miraculously still do just that to these buildings."
    )

    (method (init)
        (super:init())
        (self:onMeCheck(supportPoly))
    )


    (method (doVerb param1)
        (asm
            lsp     param1
            pushi   #doVerb
            pushi   1
            lsp     param1
            super   Feature, 6
            toss    
            ret     
        )
    )

)
(instance supportPoly of Polygon
    (properties)
)
(instance theSmallSupports of Feature
    (properties
        x 10
        y 10
        nsBottom 200
        nsRight 320
        description "supports"
        sightAngle 45
        onMeCheck 8192
        lookStr "Huge supports miraculously still do just that to these buildings."
    )
)
(instance street1 of Feature
    (properties
        description "street"
        sightAngle 40
    )

    (method (init)
        (super:init())
        (self:onMeCheck(street1Poly))
    )


    (method (doVerb param1 param2)
        (switch (param1)
            (case 1
                Print("I'll bet you're getting bored with these street descriptions so, in an effort to decrease the message tedium to some degree, I won't go into some long description about the grates or the sizeable void to the east. Happy adventuring!")
            )
            (case 11
                Print("After being away for so long, you'd forgotten how rancid the streets of Xenon smell.")
            )
            (case 10
                Print("The artificial taste of the Xenon road makes you long for the all-natural flavor of unpaved country lanes.")
            )
            (case 3
                (send (ScriptID(705 4)):doVerb(param1 param2))
            )
            (default 
                (super:doVerb(param1))
            )
        )
    )

)
(instance street1Poly of Polygon
    (properties)
)
(instance street2 of Feature
    (properties
        description "street"
    )

    (method (init)
        (super:init())
        (self:onMeCheck(street2Poly))
    )


    (method (doVerb param1 param2)
        (street1:doVerb(param1 param2))
    )

)
(instance street2Poly of Polygon
    (properties)
)
(instance sidewalk1 of Feature
    (properties
        description "sidewalk"
    )

    (method (init)
        (super:init())
        (self:onMeCheck(sidewalk1Poly))
    )


    (method (doVerb param1 param2)
        (switch (param1)
            (case 1
                Print("You are at the eastern boundary of a clearing in this ruined city. Passage to the east is stopped by a great void in the landscape.")
            )
            (case 11
                Print("You smell the sidewalk, and it smells back.")
            )
            (case 10
                Print("You give the sidewalk a lick and accidentally step on a crack. Somewhere, your mother screams out in agony, her spinal cord snapped cleanly in half. Of course, she probably deserved it for the way she spazzed-out and threw away those magazines she found in your room that time back in junior high. Those things cost you a lot of good lunch money!")
            )
            (case 3
                (send (ScriptID(705 4)):doVerb(param1 param2))
            )
            (default 
                (super:doVerb(param1))
            )
        )
    )

)
(instance sidewalk1Poly of Polygon
    (properties)
)
(instance sidewalk2 of Feature
    (properties
        description "sidewalk"
    )

    (method (init)
        (super:init())
        (self:onMeCheck(sidewalk2Poly))
    )


    (method (doVerb param1 param2)
        (sidewalk1:doVerb(param1 param2))
    )

)
(instance sidewalk2Poly of Polygon
    (properties)
)
(instance sidewalk3 of Feature
    (properties
        description "sidewalk"
    )

    (method (init)
        (super:init())
        (self:onMeCheck(sidewalk3Poly))
    )


    (method (doVerb param1 param2)
        (sidewalk1:doVerb(param1 param2))
    )

)
(instance sidewalk3Poly of Polygon
    (properties)
)
(instance theArea of Feature
    (properties
        nsBottom 200
        nsRight 320
        description "area"
        lookStr "You are at the eastern boundary of a clearing in this ruined city. Passage to the east is stopped by a great void in the landscape."
    )

    (method (doVerb param1 param2)
        (switch (param1)
            (case 3
                (send (ScriptID(705 4)):doVerb(param1 param2))
            )
            (default 
                (super:doVerb(param1))
            )
        )
    )

)
(instance explosion of Prop
    (properties)
)
(instance armBit of Actor
    (properties
        x 83
        y 89
        view 66
        loop 1
        signal 30720
    )
)
(instance legBit of Actor
    (properties
        x 83
        y 89
        view 66
        loop 1
        cel 1
        signal 30720
    )
)
(instance headBit of Actor
    (properties
        x 83
        y 89
        view 66
        loop 1
        cel 2
        signal 30720
    )
)
(instance grateSnd of Sound
    (properties
        number 808
        priority 15
    )
)
