(include "sci.sh")
(use "Main")
(use "Class_255_0")
(use "mall")
(use "BeltWay")
(use "SQRoom")
(use "RandCycle")
(use "MCyc")
(use "Polygon")
(use "Class_950_0")
(use "Sound")
(use "Cycle")
(use "PicView")
(use "Obj")
(script 385)


(local
    local0[53] = (0 0 164 69 0 0 165 75 0 1 167 82 0 1 168 90 0 2 169 99 0 2 170 108 0 3 171 115 0 3 173 125 0 4 174 129 0 4 176 128 0 5 177 122 0 5 178 127 0 6 178 129 32768 )
    local53[53] = (1 0 164 69 1 0 165 75 1 0 167 82 1 1 168 90 1 1 169 99 1 2 170 108 1 2 171 115 1 3 173 125 1 3 174 129 1 4 176 128 1 4 177 122 1 5 178 127 1 5 178 129 32768 )
    local106[29] = (5 3 180 93 5 4 177 103 5 5 171 99 5 6 165 94 5 0 161 105 5 1 156 123 5 2 156 140 32768 )
    local135
    local136
    local137
    local138
    local139
    local140
    local141 = 175

)
(instance public rm385 of SQRoom
    (properties
        picture 385
        style 30
        east 390
        west 380
    )

    (method (init)
        (var temp0, temp1)
        proc0_2()
        (if ((<> gWest 386) and not Btest(11))
            (groundCigarSFX:init())
            (tossedSFX:init())
            (egoLandsSFX:init())
            (send gLongSong2:
                number(4)
                loop(-1)
                vol(10)
                flags(1)
                playBed()
            )
        )(else
            (if (Btest(11))
                (send gLongSong2:
                    number(0)
                    vol(0)
                    stop()
                )
            )
        )
        (switch (gWest)
            (case west
                (if (== (send (ScriptID(700 0)):whichBelt) 1)
                    = temp0 65524
                    = temp1 139
                )(else
                    = temp0 65524
                    = temp1 99
                )
                (send gEgo:
                    x(temp0)
                    y(temp1)
                    setLoop(gStopGroop)
                )
                (self:setScript(ScriptID(700 1) 0 egoBwGreen))
            )
            (case east
                (if (== (send (ScriptID(700 0)):whichBelt) 1)
                    = temp0 334
                    = temp1 149
                )(else
                    = temp0 334
                    = temp1 119
                )
                (send gEgo:
                    x(temp0)
                    y(temp1)
                    setLoop(gStopGroop)
                )
                (self:setScript(ScriptID(700 1) 0 egoBwBlue))
            )
            (case 387
                (send gLongSong:
                    number(405)
                    loop(-1)
                    flags(1)
                    play()
                )
                (send gEgo:
                    x(65436)
                    y(65436)
                )
                (self:setScript(egoTossedOut 0 0))
            )
            (default 
                (send gLongSong:
                    number(405)
                    loop(-1)
                    vol(95)
                    flags(1)
                    play()
                )
                (send gEgo:
                    x(65436)
                    y(65436)
                )
                (if (proc700_3(ScriptID(700 0) 512 1))
                    (self:setScript(egoTossedOut 0))
                    (mall:rFlag4((& (mall:rFlag4) $fffe)))
                )(else
                    (self:setScript(fromStoreScript))
                )
            )
        )
        (super:init())
        (if (Btest(11))
            (send gAddToPics:
                add(door)
                eachElementDo(102)
                doit()
            )
            (self:addObstacle((send ((Polygon:new())):
                    type(2)
                    init(319 108 191 101 185 93 136 92 134 98 0 91 0 0 319 0)
                    yourself()
                )
))
        )(else
            (self:addObstacle((send ((Polygon:new())):
                    type(2)
                    init(153 65 152 75 138 97 0 91 0 55)
                    yourself()
                )
 (send ((Polygon:new())):
                    type(2)
                    init(170 65 319 66 319 108 183 100)
                    yourself()
                )
))
        )
        (self:addObstacle((send ((Polygon:new())):
                type(2)
                init(319 165 319 189 0 189 0 149)
                yourself()
            )
 (send ((Polygon:new())):
                type(2)
                init(0 105 124 110 139 114 130 133 0 128)
                yourself()
            )
 (send ((Polygon:new())):
                type(2)
                init(319 122 319 144 189 136 181 116 190 114)
                yourself()
            )
))
        (if (Btest(23) and not Btest(22))
            Load(rsSOUND 105)
            (send (ScriptID(700 7)):
                posn(168 118)
                view(13)
                setLoop(0)
                setCel(0)
                init()
                setScript(shootEgo)
            )
        )
        (send gEgo:
            init()
            setPri(-1)
        )
        (self:setRegions(700))
        (send gFeatures:
            addToFront(store bush1 bush2)
            eachElementDo(102)
            doit()
        )
    )


    (method (doit)
        (var temp0)
        = temp0 GetDistance((send gEgo:x) (send gEgo:y) local141 0)
        (if (< temp0 0)
            = temp0 0
        )(else
            (if (> temp0 300)
                = temp0 300
            )
        )
        (send gLongSong2:
            vol(- 127 (/ temp0 3))
            changeState()
        )
        (if (script)
            0
        )(else
            (if (== (send gEgo:edgeHit) 2)
                proc0_2()
                (send (ScriptID(700 0)):enterBelt(egoBwGreen))
                (self:setScript(ScriptID(700 2) 0 east))
            )(else
                (if (== (send gEgo:edgeHit) 4)
                    proc0_2()
                    (send (ScriptID(700 0)):enterBelt(egoBwBlue))
                    (self:setScript(ScriptID(700 2) 0 west))
                )(else
                    (if (proc0_5(gEgo 8))
                        (if (== (send gEgo:view) 402)
                            (self:setScript(egoTossedOut 0 1))
                        )(else
                            (send global2:newRoom(386))
                        )
                    )(else
                        (if (proc0_5(gEgo 4))
                            (egoBwGreen:
                                who(gEgo)
                                doit()
                            )
                            (send (ScriptID(700 0)):whichBelt(1))
                            proc700_5(0)
                            (send gLongSong:fade(127 10 5 0))
                        )(else
                            (if (proc0_5(gEgo 2))
                                (egoBwBlue:
                                    who(gEgo)
                                    doit()
                                )
                                (send (ScriptID(700 0)):whichBelt(2))
                                proc700_5(0)
                                (send gLongSong:fade(95 10 5 0))
                            )(else
                                (if ((egoBwGreen:onCon) or (egoBwBlue:onCon))
                                    (egoBwGreen:onCon(0))
                                    (egoBwBlue:onCon(0))
                                    (send gEgo:
                                        xStep(3)
                                        yStep(2)
                                    )
                                    proc700_5(1)
                                )
                            )
                        )
                    )
                )
            )
        )
        (super:doit())
    )


    (method (dispose)
        DisposeScript(804)
        (super:dispose())
    )

)
(instance fromStoreScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send gEgo:
                    x(167)
                    y(74)
                    setMotion(MoveTo 167 96 self)
                )
            )
            (case 1
                proc700_5(1)
                proc0_3()
                (self:dispose())
            )
        )
    )

)
(instance sDS of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                = cycles 10
            )
            (case 1
                (if ((< 130 (send (ScriptID(700 9)):x)) and (< (send (ScriptID(700 9)):x) 220))
                    (self:init())
                )(else
                    (self:dispose())
                )
            )
        )
    )

)
(instance egoTossedOut of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                Load(rsVIEW 392)
                proc0_2()
                (if (== register 1)
                    (send gEgo:
                        illegalBits(0)
                        setMotion(MoveTo 160 42 self)
                    )
                )(else
                    = cycles 1
                )
            )
            (case 1
                (if ((< 130 (send (ScriptID(700 9)):x)) and (< (send (ScriptID(700 9)):x) 220))
                    (self:setScript(sDS self))
                )(else
                    = cycles 1
                )
            )
            (case 2
                (send gEgo:
                    view(392)
                    setLoop(register)
                )
                (if (== register 1)
                    (tossedSFX:play())
                    (send gEgo:setCycle(MCyc @local53))
                    = cycles 10
                )(else
                    (tossedSFX:play())
                    (send gEgo:setCycle(MCyc @local0))
                    = cycles 10
                )
            )
            (case 3
                (egoLandsSFX:play())
                (boss:
                    init()
                    setLoop(0)
                    illegalBits(0)
                    setCycle(Walk)
                    setMotion(MoveTo 155 95 self)
                )
            )
            (case 4
                (boss:loop(4))
                (pighead:
                    init()
                    ignoreActors(1)
                    illegalBits(0)
                    setPri(7)
                    x(+ (boss:x) 2)
                    y(- (boss:y) 48)
                    z(0)
                    setCycle(RandCycle 30 self)
                )
                (if (== register 1)
                    = local140 proc0_12("No shirt, no shoes, no service!!" 67 70 20 28 global135 29 gColor)
                )(else
                    = local140 proc0_12("\"You're FIRED! My JANITOR could do a better job than you could!\"" 70 310 67 10 10 28 global135 29 gColor 30 1)
                    Bset(70)
                )
            )
            (case 5
                proc0_12(local140)
                (if (((== register 0) and not (send ((send gInv:at(12))):ownedBy(400))) and not (send gEgo:has(12)))
                    (boss:
                        loop(2)
                        cel(0)
                        setCycle(CT 3 1 self)
                    )
                    (send ((send gInv:at(12))):owner(400))
                    = register 2
                )(else
                    = cycles 1
                )
                (pighead:dispose())
            )
            (case 6
                (if (== register 2)
                    (boss:cel(4))
                    (cigar:
                        init()
                        z(0)
                        illegalBits(0)
                        ignoreActors(1)
                        setCycle(MCyc @local106 self)
                    )
                    (headCigarSFX:
                        init()
                        play()
                    )
                )(else
                    = cycles 1
                )
            )
            (case 7
                (if (== register 2)
                    (groundCigarSFX:play())
                    (cigar:
                        setLoop(5)
                        setMotion(MoveTo 321 148 self)
                    )
                )(else
                    = cycles 1
                )
                (boss:
                    loop(1)
                    cel(0)
                    setCycle(Walk)
                    setMotion(MoveTo 160 42 self)
                )
            )
            (case 8
                0
            )
            (case 9
                (boss:dispose())
                (if (== register 2)
                    (cigar:dispose())
                )
                = cycles 1
            )
            (case 10
                (send gEgo:setCycle(End self))
            )
            (case 11
                proc0_1(2 
                    (if (== (send gEgo:loop) 1)
                        402
                    )(else
                        0
                    )
 
                    (if (== (send gEgo:loop) 1)
                        14
                    )(else
                        4
                    )
)
                = cycles 1
            )
            (case 12
                proc0_3()
                proc700_5(1)
                (self:dispose())
            )
        )
    )

)
(instance shootEgo of Script
    (properties)

    (method (doit param1)
        (if (not state and not (send global2:script))
            (self:cue())
        )
        (super:doit(rest param1))
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                0
            )
            (case 1
                proc0_2()
                (send (ScriptID(700 7)):setCycle(CT 1 1 self))
            )
            (case 2
                = local136 89
                = local135 local136
                = local138 (- (send gEgo:x) 3)
                = local137 194
                = local139 Graph(7 (- local135 1) (- local137 1) (+ local136 1) (+ local138 1) 1)
                Graph(4 local136 local137 local135 local138 proc0_18(global133 global143) - (send gEgo:priority) 1 -1)
                Graph(13 - local135 1 - local137 1 + local136 1 + local138 1)
                (aSound:
                    number(105)
                    loop(1)
                    vol(127)
                    play()
                )
                = cycles 1
            )
            (case 3
                (blast:
                    init()
                    cel(0)
                    posn(local138 local135)
                    setPri(+ (send gEgo:priority) 1)
                    setCycle(End)
                )
                (send gEgo:
                    view(26)
                    cel(0)
                    cycleSpeed(1)
                    setCycle(End self)
                )
                Graph(8 local139)
                Graph(13 - local135 1 - local137 1 + local136 1 + local138 1)
            )
            (case 4
                proc0_10(8 24)
            )
        )
    )

)
(instance egoBwGreen of BeltWay
    (properties
        xStep 2
        xOff 8
        yOff 1
        xTweak 2
        key 270
        head 90
        xDir 1
        yDir 1
    )
)
(instance egoBwBlue of BeltWay
    (properties
        xStep 2
        xOff 8
        yOff -1
        xTweak 2
        key 90
        head 270
        xDir -1
        yDir 1
    )
)
(instance tossedSFX of Sound
    (properties
        number 836
    )
)
(instance headCigarSFX of Sound
    (properties
        number 873
    )
)
(instance groundCigarSFX of Sound
    (properties
        number 874
    )
)
(instance egoLandsSFX of Sound
    (properties
        number 134
    )
)
(instance door of PicView
    (properties
        x 168
        y 91
        description "door"
        sightAngle 90
        lookStr "This store seems to be closed. A security door blocks its entrance."
        view 385
        loop 6
        priority 1
        signal 16400
    )

    (method (doVerb param1 param2)
        (switch (param1)
            (case 2
                Print("It's locked down tight. You can't open it.")
            )
            (case 11
                Print("You smell that famous but unidentifiable Monolith Burger Secret Smell(tm).")
            )
            (case 10
                Print("It tastes like it smells.")
            )
            (default 
                (super:doVerb(param1 rest param2))
            )
        )
    )

)
(instance boss of Actor
    (properties
        x 160
        y 42
        sightAngle 90
        lookStr "It's your pachyderm of an ex-boss."
        view 385
    )

    (method (doVerb param1 param2)
        (switch (param1)
            (case 11
                Print("He doesn't smell spring fresh, that's for sure.")
            )
            (case 10
                Print("Not with your taste buds!")
            )
            (default 
                (super:doVerb(param1 rest param2))
            )
        )
    )

)
(instance pighead of Actor
    (properties
        z 1000
        view 385
        loop 3
    )
)
(instance cigar of Actor
    (properties
        z 1000
        description "cigar"
        sightAngle 90
        lookStr "It's a cigar butt."
        yStep 1
        view 385
        loop 5
        xStep 2
    )

    (method (doVerb param1 param2)
        (switch (param1)
            (case 11
                Print("If you had it in your possesion that might be possible.")
            )
            (case 10
                Print("If you had it in your possesion that might be possible.")
            )
            (default 
                (super:doVerb(param1 rest param2))
            )
        )
    )

)
(instance blast of Prop
    (properties
        view 28
    )
)
(instance store of Feature
    (properties
        description "Monolith Burger"
        sightAngle 90
        lookStr "This is Monolith Burger - the only fast-food chain to survive the infamous \"Food Wars\"."
    )

    (method (doVerb param1 param2)
        (switch (param1)
            (case 11
                Print("Wow, it smells just like a giant, juicy, delicious Monolith Slugburger Combo!")
            )
            (case 10
                Print("Wow, it tastes just like a giant, delicious Monolith Slugburger Combo, coated with a heavy duoplasticizer and shellacked to look extra juicy!")
            )
            (case 2
                Print("It feels like a real burger place!")
            )
            (default 
                (super:doVerb(param1 rest param2))
            )
        )
    )


    (method (onMe param1)
        return >= 5 (/ (* 100 (- (send param1:y) 88)) proc999_3(1 (send param1:x)))
    )

)
(instance bush1 of Feature
    (properties
        x 55
        y 90
        nsTop 81
        nsLeft 44
        nsBottom 106
        nsRight 63
        description "fabricated flora"
        lookStr "This is a fine example of the wonders of fabricated flora."
    )

    (method (doVerb param1 param2)
        (switch (param1)
            (case 11
                Print("It smells a little like Julanar, the enchanted plant woman from QUEST FOR GLORY II.")
            )
            (case 10
                Print("It tastes like another cheap plug for another Sierra product.")
            )
            (case 2
                Print("Hey! They had to be bolted to the super-structure because of people like you.")
            )
            (default 
                (super:doVerb(param1 rest param2))
            )
        )
    )

)
(instance bush2 of Feature
    (properties
        x 262
        y 110
        nsTop 93
        nsLeft 256
        nsBottom 118
        nsRight 274
        description "fabricated flora"
        lookStr "This is a fine example of the wonders of fabricated flora."
    )

    (method (doVerb param1 param2)
        (switch (param1)
            (case 11
                Print("It smells a little like Julanar, the enchanted plant woman from QUEST FOR GLORY II.")
            )
            (case 10
                Print("It tastes like another cheap plug for another Sierra product.")
            )
            (case 2
                Print("Hey! They had to be bolted to the super-structure because of people like you.")
            )
            (default 
                (super:doVerb(param1 rest param2))
            )
        )
    )

)
(instance aSound of Sound
    (properties)
)
