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


(local
    local0
    local1[24] = (0 0 0 0 138 40 1 151 43 2 155 51 3 157 57 4 158 59 5 159 63 65535 65535 65535 )
    local25 = 151

)
(instance public rm380 of SQRoom
    (properties
        picture 380
        style 30
        east 385
        west 375
    )

    (method (init)
        (var temp0, temp1)
        Load(rsVIEW 380)
        (if ((<> gWest 381) and not Btest(10))
            (send gLongSong2:
                number(381)
                loop(-1)
                playBed()
            )
        )(else
            (if (Btest(10))
                (send gLongSong2:
                    number(0)
                    vol(0)
                    stop()
                )
            )
        )
        proc0_2()
        (switch (gWest)
            (case west
                (if (== (send (ScriptID(700 0)):whichBelt) 1)
                    = temp0 65496
                    = temp1 135
                )(else
                    = temp0 65524
                    = temp1 105
                )
                (send gEgo:
                    x(temp0)
                    y(temp1)
                    setLoop(gStopGroop)
                )
                (if (Btest(6) or Btest(10))
                    (self:setScript(ScriptID(700 1) 0 egoBwGreen))
                )(else
                    (tallGuy:
                        init()
                        x(64536)
                        y(64536)
                        setScript(tallGuyScript 0 egoBwGreen)
                    )
                )
            )
            (case east
                (if (== (send (ScriptID(700 0)):whichBelt) 1)
                    = temp0 340
                    = temp1 123
                )(else
                    = temp0 339
                    = temp1 84
                )
                (send gEgo:
                    x(temp0)
                    y(temp1)
                    setLoop(gStopGroop)
                )
                (if (Btest(6) or Btest(10))
                    (self:setScript(ScriptID(700 1) 0 egoBwBlue))
                )(else
                    (tallGuy:
                        init()
                        x(64536)
                        y(64536)
                        setScript(tallGuyScript 0 egoBwBlue)
                    )
                )
            )
            (default 
                (send gLongSong:
                    number(405)
                    loop(-1)
                    vol(95)
                    play()
                )
                (send gEgo:posn(65526 65526))
                (self:setScript(
                    (if (proc700_3(ScriptID(700 0) 509 128))
                        tossScript
                    )(else
                        fromStoreScript
                    )
))
            )
        )
        (tallSign:
            init()
            cel(
                (if (Btest(6))
                    4
                )(else
                    0
                )
)
            stopUpd()
        )
        (send gEgo:
            init()
            setPri(-1)
        )
        (super:init())
        (if (Btest(10))
            (send gAddToPics:
                add(door)
                eachElementDo(102)
                doit()
            )
            (self:addObstacle((send ((Polygon:new())):
                    type(2)
                    init(319 78 209 83 193 64 114 69 105 88 0 92 0 0 319 0)
                    yourself()
                )
))
        )(else
            (self:addObstacle((send ((Polygon:new())):
                    type(2)
                    init(151 0 110 89 0 94 0 0)
                    yourself()
                )
 (send ((Polygon:new())):
                    type(2)
                    init(319 0 319 78 203 84 178 41 175 0)
                    yourself()
                )
))
        )
        (self:addObstacle((send ((Polygon:new())):
                type(2)
                init(319 138 319 189 0 189 0 152)
                yourself()
            )
 (send ((Polygon:new())):
                type(2)
                init(0 111 133 103 131 123 120 127 0 133)
                yourself()
            )
 (send ((Polygon:new())):
                type(2)
                init(319 95 319 116 187 123 179 101)
                yourself()
            )
))
        (self:setRegions(700))
        (send gFeatures:
            addToFront(bush bush1 BigTallSign store OutsideTheShop)
            eachElementDo(102)
            doit()
        )
    )


    (method (doit)
        (var temp0)
        = temp0 GetDistance((send gEgo:x) (send gEgo:y) local25 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))
                    (send gLongSong2:stop())
                    (self:setScript(ScriptID(700 2) 0 west))
                )(else
                    (if (proc0_5(gEgo 16))
                        (send gEgo:setPri(1))
                    )(else
                        (if (proc0_5(gEgo 4))
                            (egoBwGreen:
                                who(gEgo)
                                doit()
                            )
                            (send (ScriptID(700 0)):whichBelt(1))
                            (send gEgo:setPri(-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))
                                    proc700_5(1)
                                )(else
                                    (if (proc0_5(gEgo 8))
                                        (send global2:newRoom(381))
                                    )
                                )
                            )
                        )
                    )
                )
            )
        )
        (super:doit())
    )


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

)
(instance fromStoreScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                = cycles 1
            )
            (case 1
                (send gEgo:
                    x(151)
                    y(56)
                    illegalBits(0)
                    heading(180)
                    setMotion(MoveTo 151 80 self)
                )
            )
            (case 2
                proc700_5(1)
                proc0_3()
                (send gEgo:illegalBits(32768))
                (self:dispose())
            )
        )
    )

)
(instance tossScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                = local0 0
                = seconds 5
            )
            (case 1
                = local0 (+ local0 3)
                (if (<> local1[local0] -1)
                    (send gEgo:
                        view(392)
                        illegalBits(0)
                        setLoop(1)
                        cel(local1[local0])
                        posn(local1[+ --state 1] local1[+ local0 2])
                    )
                    = cycles 1
                )(else
                    (self:cue())
                )
            )
            (case 2
                proc0_3()
                proc0_1(2 402 14)
                proc700_5(1)
                (send (ScriptID(700 0)):rFlag1((& (send (ScriptID(700 0)):rFlag1) $ff7f)))
                (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) 240))
                    (self:init())
                )(else
                    (self:dispose())
                )
            )
        )
    )

)
(instance tallGuyScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (if ((< 130 (send (ScriptID(700 9)):x)) and (< (send (ScriptID(700 9)):x) 240))
                    (self:setScript(sDS self))
                )(else
                    = cycles 1
                )
            )
            (case 1
                (tallGuy:
                    setCycle(Walk)
                    setPri(1)
                    setStep(3 2)
                    posn(148 65478)
                    setMotion(MoveTo 148 65530 self)
                )
            )
            (case 2
                (soundFX:
                    number(145)
                    vol(127)
                    loop(1)
                    play()
                )
                (tallSign:setCycle(CT 2 1 self))
            )
            (case 3
                (tallSign:setCycle(End))
                (tallGuy:setMotion(MoveTo 148 14 self))
            )
            (case 4
                Bset(6)
                (send global2:setScript(ScriptID(700 1) 0 register))
                (tallGuy:
                    setLoop(1)
                    setPri(6)
                    setMotion(MoveTo - (tallGuy:x) 40 20 self)
                )
            )
            (case 5
                (tallGuy:setMotion(MoveTo 65518 20 self))
            )
            (case 6
                proc700_5(1)
                proc0_3()
                (self:dispose())
            )
        )
    )

)
(instance egoBwGreen of BeltWay
    (properties
        xStep 2
        xOff 8
        yOff 1
        xTweak 2
        key 270
        head 86
        xDir 1
        yDir -1
    )
)
(instance egoBwBlue of BeltWay
    (properties
        xStep 2
        xOff 8
        yOff 1
        xTweak 2
        key 90
        head 265
        xDir -1
        yDir 1
    )
)
(instance door of PicView
    (properties
        x 110
        y 27
        description "security door"
        lookStr "This store seems to be closed.  A security door blocks its entrance."
        view 380
        loop 3
        priority 1
        signal 16400
    )
)
(instance tallGuy of Actor
    (properties
        x 148
        y 65478
        description "tall alien"
        lookStr "Geez! This guy could be a whole basketball team!"
        view 380
        priority 3
        signal 26640
        illegalBits 0
    )

    (method (doVerb param1 param2)
        (switch (param1)
            (case 11
                Print("He smells a little like vermicelli.")
            )
            (case 10
                Print("What, and moisten his new Size 15 Extra Tall Jumpsuit??")
            )
            (case 4
                Print("After thinking hard, you remember an off-color tall joke. But, just as you begin to open your mouth, your strong will to live overcomes your juvenile impulse (ie. you keep your trap shut).")
            )
            (default 
                (super:doVerb(param1 rest param2))
            )
        )
    )

)
(instance tallSign of Prop
    (properties
        x 149
        y 27
        view 380
        loop 2
        priority 5
        signal 16
        cycleSpeed 1
    )
)
(instance bush of Feature
    (properties
        x 51
        y 121
        z 32
        nsTop 81
        nsLeft 40
        nsBottom 106
        nsRight 63
        description "fabricated flora"
        sightAngle 90
        lookStr "This is a fine example of the wonders of fabricated flora."
    )

    (method (doVerb param1 param2)
        (switch (param1)
            (case 2
                Print("Don't bother. The fake plants are bolted down because of people like you.")
            )
            (case 11
                Print("There's a powerful eucalyptus odor coming from the plant.")
            )
            (case 10
                Print("You lick the plant. You don't learn anything, but your sinuses are clearer.")
            )
            (default 
                (super:doVerb(param1 rest param2))
            )
        )
    )

)
(instance bush1 of Feature
    (properties
        x 264
        y 109
        z 31
        nsTop 71
        nsLeft 251
        nsBottom 95
        nsRight 275
        description "fabricated flora"
        sightAngle 90
        lookStr "This is a fine example of the wonders of fabricated flora."
    )

    (method (doVerb param1 param2)
        (switch (param1)
            (case 2
                Print("Don't bother. The fake plants are bolted down because of people like you.")
            )
            (case 11
                Print("There's a powerful eucalyptus odor coming from the plant.")
            )
            (case 10
                Print("You lick the plant. You don't learn anything, but your sinuses are clearer.")
            )
            (default 
                (super:doVerb(param1 rest param2))
            )
        )
    )

)
(instance BigTallSign of Feature
    (properties
        x 152
        y 87
        z 73
        nsTop 1
        nsLeft 60
        nsBottom 27
        nsRight 245
        description "Big and Tall Sign"
        sightAngle 90
        lookStr "The sign reads \"BIG and Tall\"."
    )

    (method (doVerb param1 param2)
        (switch (param1)
            (case 2
                Print("Forget it. You'll only get hurt.")
            )
            (case 11
                Print("It smells like expensive cologne, leather and tobacco.")
            )
            (case 10
                Print("It tastes like sewage, vinyl and tobacco.")
            )
            (default 
                (super:doVerb(param1 rest param2))
            )
        )
    )

)
(instance OutsideTheShop of Feature
    (properties
        nsBottom 200
        nsRight 320
        description "Big and Tall Alien Store"
        sightAngle 500
        lookStr "You are outside the Big and Tall Alien store."
    )

    (method (doVerb param1)
        (switch (param1)
            (case 11
                Print("The mall has that high-rent, low-occupancy smell...like any office building in downtown Los Angeles.")
            )
            (case 10
                Print("It's against the Third Law of Mall Security to be caught licking mall components.")
            )
            (case 1
                (super:doVerb(param1))
            )
            (default 
                0
            )
        )
    )

)
(instance soundFX of Sound
    (properties)
)
(instance store of Feature
    (properties
        x 145
        description "Big and Tall"
        lookStr "This place sells body covers for the big, tall, and otherwise bizarre alien."
    )

    (method (doVerb param1 param2)
        (switch (param1)
            (case 11
                Print("It smells like expensive cologne, leather and tobacco.")
            )
            (case 10
                Print("It tastes like sewage, vinyl and tobacco.")
            )
            (default 
                (super:doVerb(param1 rest param2))
            )
        )
    )


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

)
