(include "sci.sh")
(use "Main")
(use "Class_255_0")
(use "mall")
(use "BeltWay")
(use "SQRoom")
(use "Polygon")
(use "Class_950_0")
(use "MoveFwd")
(use "Cycle")
(use "PicView")
(use "Obj")
(script 375)


(local
    local0[10] = (0 0 206 0 183 28 85 76 0 82 )
    local10 = 65

)
(instance public rm375 of SQRoom
    (properties
        picture 375
        style 30
        east 380
        south 370
        west 370
    )

    (method (init)
        (var temp0, temp1)
        proc0_2()
        (if ((<> gWest 376) and not Btest(9))
            (send gLongSong2:
                number(19)
                loop(-1)
                flags(1)
                playBed()
            )
        )(else
            (if (Btest(9))
                (send gLongSong2:
                    number(0)
                    vol(0)
                    stop()
                )
            )
        )
        (switch (gWest)
            (case west
                (if (== (send (ScriptID(700 0)):whichBelt) 1)
                    = temp0 49
                    = temp1 237
                )(else
                    = temp0 65520
                    = temp1 181
                )
                (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 333
                    = temp1 78
                )(else
                    = temp0 327
                    = temp1 65528
                )
                (send gEgo:
                    x(temp0)
                    y(temp1)
                    setLoop(gStopGroop)
                )
                (self:setScript(ScriptID(700 1) 0 egoBwBlue))
            )
            (default 
                (send gLongSong:
                    number(405)
                    loop(-1)
                    vol(95)
                    flags(1)
                    play()
                )
                (self:setScript(fromStoreScript 0 (> (send gEgo:x) 160)))
            )
        )
        (light1:
            init()
            setCycle(Fwd)
        )
        (light2:
            init()
            setCycle(Fwd)
        )
        (super:init())
        (self:addObstacle((send ((Polygon:new())):
                type(2)
                init(0 149 0 63 51 114 47 125 44 128)
                yourself()
            )
 (send ((Polygon:new())):
                type(2)
                init(298 0 224 39 216 39 208 38 106 0)
                yourself()
            )
 (send ((Polygon:new())):
                type(2)
                init(123 28 150 74 118 91 84 49)
                yourself()
            )
))
        (signPoly:
            points(@local0)
            size(5)
        )
        (send gEgo:
            init()
            setPri(-1)
        )
        (self:addObstacle((send ((Polygon:new())):
                type(2)
                init(319 121 319 189 185 189)
                yourself()
            )
 (send ((Polygon:new())):
                type(2)
                init(319 21 319 66 215 117 174 95)
                yourself()
            )
 (send ((Polygon:new())):
                type(2)
                init(0 189 0 185 132 116 170 140 72 189)
                yourself()
            )
))
        (self:setRegions(700))
        (send gFeatures:
            addToFront(store bush1 bush2)
            eachElementDo(102)
            doit()
        )
    )


    (method (doit)
        (var temp0)
        = temp0 GetDistance((send gEgo:x) (send gEgo:y) local10 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) or (== (send gEgo:edgeHit) 3))
                    (if (proc0_5(gEgo 4))
                        (send gEgo:
                            edgeHit(0)
                            setMotion(0)
                            posn(+ (send gEgo:x) 3 - (send gEgo:y) 4)
                        )
                    )(else
                        proc0_2()
                        (send (ScriptID(700 0)):enterBelt(egoBwBlue))
                        (self:setScript(ScriptID(700 2) 0 west))
                    )
                )(else
                    (if (proc0_5(gEgo 8))
                        (send global2:newRoom(376))
                    )(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(
                        (if (register)
                            149
                        )(else
                            70
                        )
)
                    y(
                        (if (register)
                            43
                        )(else
                            82
                        )
)
                    setHeading(180)
                    setMotion(MoveFwd 20 self)
                )
            )
            (case 1
                proc700_5(1)
                proc0_3()
                (self:dispose())
            )
        )
    )

)
(instance egoBwGreen of BeltWay
    (properties
        xStep 2
        yStep 1
        xOff 3
        yOff 1
        xTweak 1
        yTweak 1
        key 225
        head 63
        xDir 1
        yDir -1
    )
)
(instance egoBwBlue of BeltWay
    (properties
        xStep 2
        yStep 1
        xOff 1
        yOff 1
        xTweak 1
        yTweak 1
        key 45
        head 242
        xDir -1
        yDir 1
    )
)
(instance door of PicView
    (properties
        x 21
        y 82
        description "door"
        sightAngle 90
        lookStr "This store seems to be closed. A security door blocks its entrance."
        view 375
        loop 2
        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("It smells like the kind of place where unwashed teenagers stand around smoking, sweating and performing other unmentionable teenage acts.")
            )
            (case 10
                Print("It tastes like it smells.")
            )
            (default 
                (super:doVerb(param1 rest param2))
            )
        )
    )

)
(instance light1 of Prop
    (properties
        x 30
        y 110
        description "sign"
        lookStr "It's \"Buckazoid Bill's Arcade and Sushi Bar.\""
        view 375
        signal 16384
    )

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


    (method (doVerb param1 param2)
        (switch (param1)
            (case 11
                Print("It smells like the kind of place where unwashed teenagers stand around smoking, sweating and performing other unmentionable teenage acts.")
            )
            (default 
                (super:doVerb(param1 rest param2))
            )
        )
    )

)
(instance signPoly of Polygon
    (properties)
)
(instance light2 of Prop
    (properties
        x 214
        y 20
        lookStr "It's \"Buckazoid Bill's Arcade and Sushi Bar.\""
        view 375
        loop 1
        signal 16384
    )

    (method (doVerb param1 param2)
        (switch (param1)
            (case 11
                Print("It smells like the kind of place where unwashed teenagers stand around smoking, sweating and performing other unmentionable teenage acts.")
            )
            (case 10
                Print("It tastes like it smells.")
            )
            (default 
                (super:doVerb(param1 rest param2))
            )
        )
    )

)
(instance store of Feature
    (properties
        description "Arcade"
        lookStr "Ah! An arcade!. It's \"Buckazoid Bill's Arcade and Sushi Bar.\""
    )

    (method (doVerb param1 param2)
        (switch (param1)
            (case 11
                Print("It smells like the kind of place where unwashed teenagers stand around smoking, sweating and performing other unmentionable teenage acts.")
            )
            (case 10
                Print("It tastes like it smells.")
            )
            (default 
                (super:doVerb(param1 rest param2))
            )
        )
    )


    (method (onMe param1)
        return <= 49 (/ (* 100 (- 145 (send param1:y))) proc999_3(1 (send param1:x)))
    )

)
(instance bush1 of Feature
    (properties
        x 68
        y 145
        nsTop 129
        nsLeft 62
        nsBottom 153
        nsRight 84
        description "fabricated flora"
        lookStr "This is a fine example of the wonders of fabricated flora."
    )

    (method (doVerb param1 param2)
        (switch (param1)
            (case 11
                Print("There's a fresh woodsy scent coming from the plants.")
            )
            (case 10
                Print("Urp...somebody's dumped their potpourri on these plants.")
            )
            (case 2
                Print("Get some taste! These are phoney mall plants!")
            )
            (default 
                (super:doVerb(param1 rest param2))
            )
        )
    )

)
(instance bush2 of Feature
    (properties
        x 260
        y 45
        nsTop 31
        nsLeft 254
        nsBottom 57
        nsRight 276
        description "fabricated flora"
        lookStr "This is a fine example of the wonders of fabricated flora."
    )

    (method (doVerb param1 param2)
        (switch (param1)
            (case 11
                Print("There's a fresh woodsy scent coming from the plants.")
            )
            (case 10
                Print("Urp...somebody's dumped their potpourri on these plants.")
            )
            (case 2
                Print("Get some taste! These are phoney mall plants!")
            )
            (default 
                (super:doVerb(param1 rest param2))
            )
        )
    )

)
