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


(local
    local0[24] = (18 0 160 85 161 105 141 164 173 169 199 148 181 99 182 81 224 0 184 0 167 51 123 )
    local24[20] = (78 38 15 0 0 0 0 189 23 189 54 167 51 144 63 144 87 128 74 50 )
    local44[16] = (82 86 108 80 127 81 159 98 158 107 150 130 112 139 86 118 )
    local60[8] = (158 115 144 123 139 120 149 109 )
    local68[18] = (74 77 79 73 162 83 161 99 138 84 114 79 107 79 96 84 81 86 )
    local86[26] = (181 189 214 158 215 148 207 142 198 140 185 99 180 98 181 85 253 94 272 93 294 86 319 68 319 189 )
    local112[64] = (26 189 55 167 52 144 61 144 87 129 86 119 127 151 150 136 139 164 174 169 200 148 198 140 210 144 215 148 214 157 180 189 152 81 110 76 95 64 106 54 155 38 171 38 167 52 241 40 297 0 319 0 319 68 292 87 273 92 255 94 181 84 205 40 )

)
(procedure (localproc_10e6 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 rm040 of SQRoom
    (properties
        picture 40
        style 30
        horizon 48
        north 25
        east 45
        south 55
        vanishingX 319
        vanishingY 65501
    )

    (method (init)
        Load(rsVIEW 40)
        (send global2:addObstacle((send ((Polygon:new())):
                type(2)
                init(298 0 251 49 102 49 97 60 102 66 45 97 33 152 68 163 41 189 0 189 0 0)
                yourself()
            )
 (send ((Polygon:new())):
                type(2)
                init(103 79 181 120 142 144 113 143 60 100 75 85)
                yourself()
            )
 (send ((Polygon:new())):
                type(2)
                init(215 148 179 179 123 169 169 137)
                yourself()
            )
))
        (if (proc0_6(0))
            proc958_0(128 7 13)
            (cop1:init())
        )
        (switch (global12)
            (case north
                proc0_2()
                (self:setScript(enterScript))
            )
            (case south
                (send gEgo:x(89))
            )
            (case east
            )
            (default 
                proc0_7(0)
                proc0_1(0 0)
                (send gEgo:posn(64 81))
                (self:setScript(enterScript))
                (send gLongSong:
                    number(802)
                    loop(-1)
                    vol(127)
                    flags(1)
                    playBed()
                )
                (cop1:init())
            )
        )
        (send gEgo:init())
        (theTank:init())
        (theSupport:init())
        (thePurpleBldg:init())
        (theLeftBldg:init())
        (theHole:init())
        (street1:init())
        (street2:init())
        (sidewalk1:init())
        (sidewalk2:init())
        (sidewalk3:init())
        (sidewalk4:init())
        (theArea:init())
        (self:setRegions(701))
        (super:init())
        (self:setRegions(705))
        (supportPoly:
            points(@local0)
            size(12)
        )
        (buildingPoly:
            points(@local24)
            size(10)
        )
        (tankPoly:
            points(@local44)
            size(8)
        )
        (holePoly:
            points(@local60)
            size(4)
        )
        (street1Poly:
            points(@local68)
            size(9)
        )
        (street2Poly:
            points(@local86)
            size(13)
        )
        (sidewalk1Poly:
            points(@local112)
            size(16)
        )
        (sidewalk2Poly:
            points(@local65424)
            size(4)
        )
        (sidewalk3Poly:
            points(@local65432)
            size(3)
        )
        (sidewalk4Poly:
            points(@local65438)
            size(9)
        )
    )


    (method (newRoom param1)
        (if ((((== (send gEgo:edgeHit) 1) and (<> script exitScript)) and (<> script ScriptID(701 3))) and (<> (send (ScriptID(701 1)):script) ScriptID(701 4)))
            proc0_2()
            (self:setScript(exitScript 0 1))
        )(else
            (if ((== (send gEgo:edgeHit) 1) and not (send script:register))
                (super:newRoom(param1))
            )(else
                (if (((((== (send gEgo:edgeHit) 3) and (> (send gEgo:x) 199)) and not proc0_6(0)) and (<> (send global2:script) ScriptID(701 3))) and (<> (send (ScriptID(701 1)):script) ScriptID(701 4)))
                    (super:newRoom(60))
                )(else
                    (super:newRoom(param1))
                )
            )
        )
    )

)
(instance enterScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (if (== global12 72)
                    (send gEgo:setMotion(MoveTo (+ (send gEgo:x) 15) (send gEgo:y) self))
                )(else
                    (send gEgo:
                        posn(333 1)
                        setLoop(5)
                        setMotion(MoveTo 272 49 self)
                    )
                )
            )
            (case 1
                proc0_1()
                proc0_3()
                (self:dispose())
            )
        )
    )

)
(instance exitScript of Script
    (properties)

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

)
(instance theTank of Feature
    (properties
        x 125
        y 110
        description "tank"
        sightAngle 45
        lookStr "A corroding battle machine vividly reveals why it no longer serves. The structural warpage, not to mention the gaping hole in it, indicates a violent end."
    )

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


    (method (doVerb param1 param2)
        (switch (param1)
            (case 2
                (if ((send global2:script) or (send global5:contains(closeup)))
                    0
                )(else
                    proc0_2()
                    (send global2:setScript(tankScript))
                )
            )
            (case 3
                (switch (param2)
                    (case 2
                        proc0_2()
                        (send global2:setScript(bombScript))
                    )
                    (default 
                        (super:doVerb(param1))
                    )
                )
            )
            (case 11
                Print("It smells exactly like the hull of a useless, burnt out battle vehicle.")
            )
            (case 10
                Print("It needs salt.")
            )
            (default 
                (super:doVerb(param1))
            )
        )
    )

)
(instance tankPoly of Polygon
    (properties)
)
(instance tankScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send gEgo:setMotion(PolyPath 154 137 self))
            )
            (case 1
                (send gEgo:setHeading(315 self))
            )
            (case 2
                (if (== (send ((send global9:at(2))):owner) 40)
                    (theBomb:init())
                )
                (closeup:
                    init()
                    stopUpd()
                )
                = cycles 1
            )
            (case 3
                proc0_3()
                (send client:setScript(0))
            )
        )
    )

)
(instance bombScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send gEgo:setMotion(PolyPath 154 137 self))
            )
            (case 1
                (send gEgo:setHeading(315 self))
                (send gEgo:put(2 40))
                proc0_11(44 65516)
            )
            (case 2
                Print("A very wise choice! Carefully placing the unstable ordnance back inside the tank, you decide some things are better left alone.")
                proc0_3()
                (send client:setScript(0))
            )
        )
    )

)
(instance theSupport of Feature
    (properties
        x 172
        y 154
        description "supports"
        sightAngle 45
        lookStr "The huge building supports miraculously still stand."
    )

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


    (method (doVerb param1)
        (switch (param1)
            (case 11
                Print("You inhale the smell of the column and file it away in your brain under \"Useful Information.\"")
            )
            (case 10
                Print("Good thing it's not below freezing, or you'd end up spending the whole game with your tongue stuck to the frozen metal.")
            )
            (default 
                (super:doVerb(param1))
            )
        )
    )

)
(instance supportPoly of Polygon
    (properties)
)
(instance thePurpleBldg of Feature
    (properties
        x 198
        y 15
        nsBottom 200
        nsRight 320
        description "purple building"
        sightAngle 45
        onMeCheck 8192
        lookStr "A battered and boarded purple building stands silently now."
    )

    (method (doVerb param1)
        (theLeftBldg:doVerb(param1))
    )

)
(instance theLeftBldg of Feature
    (properties
        x 43
        y 123
        description "left building"
        sightAngle 45
        lookStr "Another of Xenon's ruined structures awaits the the final, slow assault of nature."
    )

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


    (method (doVerb param1)
        (switch (param1)
            (case 2
                Print("The building is inaccessible.")
            )
            (case 11
                Print("It smells like hundreds of sweaty public servants once populated this building.")
            )
            (case 10
                Print("It tastes about like you'd expect it to taste, given how it smells.")
            )
            (default 
                (super:doVerb(param1))
            )
        )
    )

)
(instance buildingPoly of Polygon
    (properties)
)
(instance street1 of Feature
    (properties
        description "street"
    )

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


    (method (doVerb param1 param2)
        (switch (param1)
            (case 1
                Print("It's a safe bet that tank had something to do with the end of traffic on this thoroughfare.")
            )
            (case 11
                Print("The pavement has lost that wonderful wet-tar smell you loved so much as a kid.")
            )
            (case 10
                Print("Okay, you scrape some taste buds off onto the street.")
            )
            (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("One thing THIS society can say is that no citizen of THEIRS lives in the streets. In fact, nothing seems to live anywhere. This place is definitely DOA.")
            )
            (case 11
                Print("The smell of devastation is everywhere.")
            )
            (case 10
                Print("The taste of devastation is everywhere.")
            )
            (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 sidewalk4 of Feature
    (properties
        description "sidewalk"
    )

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


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

)
(instance sidewalk4Poly of Polygon
    (properties)
)
(instance theArea of Feature
    (properties
        nsBottom 200
        nsRight 320
        description "area"
        lookStr "You are at the left edge of this area. More debris chokes off the west. A devastated tank stands a blind guard."
    )

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

)
(instance closeup of View
    (properties
        x 132
        y 155
        z 77
        description "tank interior"
        sightAngle 90
        view 40
        priority 13
        signal 16400
    )

    (method (doit)
        (super:doit())
        (if ((send gEgo:mover) or (<> (send gEgo:loop) 7))
            (self:
                hide()
                dispose()
            )
        )
        (if (== (send global2:curPic) 31)
            (self:z(1000))
        )(else
            (self:z(77))
        )
    )


    (method (doVerb param1 param2)
        (switch (param1)
            (case 1
                (if (== (send ((send global9:at(2))):owner) 40)
                    Print("This is the interior of a battle-scarred tank. Although somewhat intact, the operators must have lost their lives. A piece of unstable ordnance rests in the corner.")
                )(else
                    Print("This is the interior of a battle-scarred tank. Although somewhat intact, the operators must have lost their lives.")
                )
            )
            (case 3
                (theTank:doVerb(3 param2))
            )
            (default 
                (super:doVerb(param1))
            )
        )
    )

)
(instance theBomb of Prop
    (properties
        x 134
        y 156
        z 97
        description "explosive ordnance"
        sightAngle 90
        view 40
        cel 1
        priority 14
        signal 16400
    )

    (method (doit)
        (super:doit())
        (if ((send gEgo:mover) or (<> (send gEgo:loop) 7))
            (self:
                hide()
                dispose()
            )
        )
        (if (== (send global2:curPic) 31)
            (self:z(1000))
        )(else
            (self:z(97))
        )
    )


    (method (doVerb param1)
        (switch (param1)
            (case 1
                Print("Surprisingly, no one has taken this small, innocuous-looking piece of unstable ordnance.")
            )
            (case 2
                (theBomb:dispose())
                (send gEgo:get(2))
                proc0_11(69 25)
                (if (proc0_6(0) and (== (shootEgo:state) 0))
                    (shootEgo:register(10))
                )
                Animate((send global5:elements) 0)
                Print("Okay. You now have the unstable ordnance. Remember, it was your idea. Good luck.")
            )
            (default 
                (super:doVerb(param1))
            )
        )
    )

)
(instance theHole of Feature
    (properties
        x 149
        y 115
        description "hole"
        sightAngle 45
    )

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


    (method (doVerb param1 param2)
        (if ((== param1 1) or (== param1 2))
            (theTank:doVerb(2 param2))
        )(else
            (if (== param1 3)
                (theTank:doVerb(3 param2))
            )(else
                (super:doVerb(param1))
            )
        )
    )

)
(instance holePoly of Polygon
    (properties)
)
(instance cop1 of Actor
    (properties
        x 329
        y 165
        lookStr "Oh No! Sequel Police!"
        view 7
        loop 2
    )

    (method (init)
        (cop2:init())
        (shootEgo:register(500))
        (self:setScript(shootEgo))
        (super:init())
    )

)
(instance cop2 of Actor
    (properties
        x 340
        y 145
        lookStr "Oh No! Sequel Police!"
        view 7
    )
)
(instance shootEgo of Script
    (properties)

    (method (doit param1)
        (super:doit(rest param1))
        (if (register)
            --register
        )(else
            (if (not state)
                (self:cue())
            )
        )
        (if ((== state 1) and (> (send gEgo:x) 205))
            (self:cue())
        )
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                0
            )
            (case 1
                0
            )
            (case 2
                (if (> (send gEgo:y) 100)
                    (cop1:y(65))
                    (cop2:y(45))
                )
                (cop1:
                    setCycle(Walk)
                    setMotion(MoveTo 275 (cop1:y) self)
                )
                (cop2:
                    setCycle(Walk)
                    setMotion(MoveTo 0 (cop2:y))
                )
            )
            (case 3
                proc0_13(cop1 gEgo)
                = cycles 4
            )
            (case 4
                (cop2:setMotion(0))
                proc0_13(cop2 gEgo)
                (cop1:
                    view(13)
                    cel(0)
                    setMotion(0)
                    setCycle(CT 2 1 self)
                )
            )
            (case 5
                proc0_2()
                (cop1:setCycle(End self))
                (if (< (cop1:x) (send gEgo:x))
                    localproc_10e6(- (cop1:y) 27 (cop1:x) - (send gEgo:y) 32 (send gEgo:x))
                )(else
                    localproc_10e6(- (send gEgo:y) 32 (send gEgo:x) - (cop1:y) 27 (cop1:x))
                )
            )
            (case 6
                256
                (send gEgo:
                    superClass
                    view(26)
                    loop(
                        (switch ((send gEgo:loop))
                            (case 4
                                0
                            )
                            (case 5
                                1
                            )
                            (case 6
                                0
                            )
                            (case 7
                                1
                            )
                            (default 
                                (send gEgo:loop)
                            )
                        )
)
                    cel(0)
                    cycleSpeed(0)
                    setCycle(CT 2 1 self)
                )
            )
            (case 7
                (send gEgo:
                    setMotion(0)
                    setCycle(CT 1 -1 self)
                )
            )
            (case 8
                (send gEgo:
                    setMotion(0)
                    setCycle(End self)
                )
            )
            (case 9
                = seconds 4
                proc0_10(8)
            )
        )
    )

)
