(include "sci.sh")
(use "Main")
(use "Class_255_0")
(use "SQRoom")
(use "Polygon")
(use "Class_950_0")
(use "n958")
(use "DPath")
(use "Cycle")
(use "PicView")
(use "Obj")
(script 25)


(local
    local0[30] = (32 189 54 172 72 168 91 154 99 141 101 101 106 97 147 100 170 83 189 75 201 67 212 49 211 0 0 0 0 189 )
    local30[14] = (319 87 289 88 244 74 199 69 212 51 212 0 319 )
    local44[38] = (33 189 55 172 71 168 82 162 94 151 99 143 102 128 102 115 100 102 105 97 148 100 171 82 185 78 199 71 258 78 267 82 280 82 287 88 182 189 )
    local82[8] = (181 189 285 89 319 92 319 189 )

)
(procedure (localproc_059c param1 param2 param3 param4)
    (var temp0, temp1, temp2)
    (send gLongSong2:
        number(105)
        vol(127)
        loop(1)
        play()
    )
    (if (< param1 param3)
        = temp0 (- param1 1)
        = temp1 (+ param3 1)
    )(else
        = temp0 (- param3 1)
        = temp1 (+ param1 1)
    )
    = temp2 Graph(7 temp0 (- param2 1) temp1 (+ param4 1) 1)
    Graph(4 param1 param2 param3 param4 global143 -1 -1)
    Graph(13 temp0 - param2 1 temp1 + param4 1)
    Wait(1)
    Wait(4)
    Graph(8 temp2)
    Graph(13 temp0 - param2 1 temp1 + param4 1)
)


(instance public rm025 of SQRoom
    (properties
        picture 25
        style 30
        east 30
        south 40
        vanishingX 319
        vanishingY 65501
    )

    (method (init)
        (switch (global12)
            (case south
                (send gEgo:x(103))
            )
            (case 45
                proc0_2()
                (send gEgo:
                    init()
                    x(272)
                    y(245)
                )
                (self:setScript(enterScript))
            )
            (default 
                proc0_3()
                (send gEgo:
                    view(0)
                    posn(160 160)
                )
            )
        )
        (if (proc0_6(0))
            proc958_0(128 7 13)
            (cop1:init())
            (cop2:init())
        )
        (send gEgo:init())
        (theRubble:init())
        (theGreenBuilding:init())
        (theStreet:init())
        (theSidewalk:init())
        (theArea:init())
        (self:setRegions(701))
        (super:init())
        (self:setRegions(705))
        (send global2:addObstacle((send ((Polygon:new())):
                type(2)
                init(0 189 0 0 319 0 319 89 299 92 266 85 246 79 211 77 195 73 153 104 111 101 62 146 69 169 45 189)
                yourself()
            )
))
        (buildingPoly:
            points(@local0)
            size(15)
        )
        (rubblePoly:
            points(@local30)
            size(7)
        )
        (sidewalkPoly:
            points(@local44)
            size(19)
        )
        (streetPoly:
            points(@local82)
            size(4)
        )
    )


    (method (newRoom param1)
        (if ((((<> (send global2:script) ScriptID(701 3)) and (<> (send (ScriptID(701 1)):script) ScriptID(701 4))) and (== (send gEgo:edgeHit) 3)) and (> (send gEgo:x) 199))
            = param1 45
        )
        (super:newRoom(param1))
    )

)
(instance enterScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send gEgo:
                    setLoop(7)
                    setMotion(MoveTo 242 188 self)
                )
            )
            (case 1
                proc0_1()
                (if (not proc0_6(0))
                    proc0_3()
                )
                (send client:setScript(0))
            )
        )
    )

)
(instance cop1 of Actor
    (properties
        x 241
        y 110
        view 7
        loop 2
    )

    (method (doit param1)
        (super:doit(rest param1))
        (if (not (self:script))
            (self:setScript(shootEgo))
        )
    )

)
(instance cop2 of Actor
    (properties
        x 88
        y 126
        view 7
    )
)
(instance shootEgo of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (cop1:
                    setCycle(Walk)
                    setMotion(MoveTo 200 140 self)
                )
                (cop2:
                    setCycle(Walk)
                    setMotion(DPath 120 126 120 136)
                )
            )
            (case 1
                (cop1:
                    view(13)
                    cel(0)
                    setMotion(0)
                    setCycle(CT 4 1 self)
                )
            )
            (case 2
                proc0_2()
                (cop1:setCycle(End self))
                (if (< (cop1:x) (send gEgo:x))
                    localproc_059c(- (cop1:y) 27 (cop1:x) - (send gEgo:y) 32 (send gEgo:x))
                )(else
                    localproc_059c(- (send gEgo:y) 32 (send gEgo:x) - (cop1:y) 27 (cop1:x))
                )
            )
            (case 3
                5
                (send gEgo:)
            )
            (case 4
                (send gEgo:setCycle(CT 1 -1 self))
            )
            (case 5
                (send gEgo:setCycle(End self))
            )
            (case 6
                = seconds 4
            )
            (case 7
                proc0_10(8)
            )
        )
    )

)
(instance theRubble of Feature
    (properties
        x 270
        y 33
        description "rubble"
        sightAngle 40
        lookStr "A hazardous accumulation of unstructured structures blocks safe passage north."
    )

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


    (method (doVerb param1)
        (switch (param1)
            (case 2
                Print("The rubble is rough and jagged. No sense in risking injury this early in the adventure. We'll get to that later.")
            )
            (case 11
                Print("There's nothing like coating your lungs with rubble dust to get your adventure off to a great start.")
            )
            (case 10
                Print("It tastes okay, but you generally prefer your rubble Extra Chunky.")
            )
            (default 
                (super:doVerb(param1))
            )
        )
    )

)
(instance rubblePoly of Polygon
    (properties)
)
(instance theGreenBuilding of Feature
    (properties
        y 180
        description "green building"
        sightAngle 40
        lookStr "The old Bank of Xenon building held up fairly well. Too bad. (They turned Roger down for a loan once.)"
    )

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


    (method (doVerb param1)
        (switch (param1)
            (case 2
                Print("Forget it! The doors and windows have been sealed with welded steel plating. The building is shut tight and void of tactile enticement.")
            )
            (case 11
                Print("It smells like old money and new rust.")
            )
            (case 10
                Print("Okay, you get your last licks on the bank.")
            )
            (default 
                (super:doVerb(param1))
            )
        )
    )

)
(instance buildingPoly of Polygon
    (properties)
)
(instance theSidewalk of Feature
    (properties
        x 100
        y 150
        description "sidewalk"
        sightAngle 40
        lookStr "It looks like a surface suited for foot travel."
    )

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


    (method (doVerb param1 param2)
        (switch (param1)
            (case 10
                Print("It tastes like all the other sidewalks you've ever tasted, weirdo.")
            )
            (case 11
                Print("It smells mostly of dust and dirt.")
            )
            (case 3
                (send (ScriptID(705 4)):doVerb(param1 param2))
            )
            (default 
                (super:doVerb(param1))
            )
        )
    )

)
(instance sidewalkPoly of Polygon
    (properties)
)
(instance theStreet of Feature
    (properties
        x 300
        y 150
        description "street"
        sightAngle 40
    )

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


    (method (doVerb param1 param2)
        (switch (param1)
            (case 1
                (theArea:doVerb(1))
            )
            (case 3
                (send (ScriptID(705 4)):doVerb(param1 param2))
            )
            (case 11
                Print("The rich aroma of hovercar exhaust fills your sinuses.")
            )
            (case 10
                Print("It tastes like you've just scraped your tongue to shreds on the pavement.")
            )
            (default 
                (super:doVerb(param1))
            )
        )
    )

)
(instance streetPoly of Polygon
    (properties)
)
(instance theArea of Feature
    (properties
        nsBottom 200
        nsRight 320
        description "area"
    )

    (method (doVerb param1 param2)
        (switch (param1)
            (case 1
                Print("You are in the northwest corner of a small clearing on the otherwise rubble-choked streets of Xenon.")
            )
            (case 3
                (send (ScriptID(705 4)):doVerb(param1 param2))
            )
            (default 
                (super:doVerb(param1))
            )
        )
    )

)
