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


(local
    local0[18] = (181 5 187 8 197 14 211 16 225 20 235 31 250 36 263 41 274 45 )
    local18
    local19
    gEgoX_2
    gEgoX
    local22

)
(instance public rm390 of SQRoom
    (properties
        picture 390
        style 30
        north 385
        east 395
        south 395
        west 385
    )

    (method (init)
        (var temp0, temp1)
        proc0_2()
        (switch (gWest)
            (case west
                (if (== (send (ScriptID(700 0)):whichBelt) 1)
                    = temp0 65524
                    = temp1 81
                )(else
                    = temp0 65527
                    = temp1 65530
                )
                (send gEgo:
                    x(temp0)
                    y(temp1)
                    setLoop(gStopGroop)
                )
                (self:setScript(ScriptID(700 1) 0 egoBwGreen))
                (send gLongSong2:stop())
            )
            (case east
                (if (== (send (ScriptID(700 0)):whichBelt) 1)
                    = temp0 256
                    = temp1 249
                )(else
                    = temp0 331
                    = temp1 173
                )
                (send gEgo:
                    x(temp0)
                    y(temp1)
                    setLoop(gStopGroop)
                )
                (self:setScript(ScriptID(700 1) 0 egoBwBlue))
                (send gLongSong2:stop())
            )
            (case 410
                (send gLongSong2:stop())
                (send gLongSong:
                    number(405)
                    loop(-1)
                    play()
                )
                (self:setScript(fromElsewhereScript 0 0))
            )
            (default 
                (send gLongSong2:stop())
                (send gLongSong:
                    number(405)
                    play()
                )
                (self:setScript(fromElsewhereScript 0 1))
            )
        )
        (send gLongSong:
            vol(127)
            loop(-1)
            priority(7)
            changeState()
        )
        (super:init())
        (zap:
            init()
            setScript(zapScript)
        )
        (send gEgo:
            init()
            setPri(-1)
        )
        (self:addObstacle((send ((Polygon:new())):
                type(2)
                init(0 113 65 145 64 157 44 170 40 179 13 189 0 189)
                yourself()
            )
 (send ((Polygon:new())):
                type(2)
                init(0 23 147 99 110 123 0 65)
                yourself()
            )
 (send ((Polygon:new())):
                type(2)
                init(235 189 149 144 189 120 319 187 319 189)
                yourself()
            )
 (send ((Polygon:new())):
                type(2)
                init(150 189 95 189 117 171)
                yourself()
            )
))
        (if (Btest(23) and not Btest(22))
            Load(rsSOUND 105)
            (send (ScriptID(700 7)):
                illegalBits(0)
                ignoreActors()
                init()
                posn(65522 79)
                setScript(sp2Squeeze)
            )
            (send (ScriptID(700 6)):
                illegalBits(0)
                ignoreActors()
            )
        )
        (self:setRegions(700))
        (send gFeatures:
            addToFront(store bush1 bush2 steps)
            eachElementDo(102)
            doit()
        )
        (if (Btest(12))
            (send gAddToPics:
                add(door)
                eachElementDo(102)
                doit()
            )
            (self:addObstacle((send ((Polygon:new())):
                    type(2)
                    init(21 0 319 0 319 150 224 101 235 82 181 53 156 69)
                    yourself()
                )
))
        )(else
            (self:addObstacle((send ((Polygon:new())):
                    type(2)
                    init(316 0 163 73 21 0)
                    yourself()
                )
 (send ((Polygon:new())):
                    type(2)
                    init(319 152 226 105 319 51)
                    yourself()
                )
))
        )
    )


    (method (doit)
        (var temp0)
        (if (script)
            0
        )(else
            (if (proc999_5((send gEgo:edgeHit) 3 2))
                proc0_2()
                (send (ScriptID(700 0)):enterBelt(egoBwGreen))
                (self:setScript(ScriptID(700 2) 0 east))
            )(else
                (if (proc999_5((send gEgo:edgeHit) 1 4))
                    proc0_2()
                    (send (ScriptID(700 0)):enterBelt(egoBwBlue))
                    (self:setScript(ScriptID(700 2) 0 west))
                )(else
                    (if (proc0_5(gEgo 16))
                        proc0_2()
                        (self:setScript(goToRamaScript))
                    )(else
                        (if (proc0_5(gEgo 8))
                            (send global2:newRoom(391))
                        )(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)
                                            setPri(-1)
                                        )
                                        proc700_5(1)
                                    )
                                )
                            )
                        )
                    )
                )
            )
        )
        (super:doit())
    )


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


    (method (newRoom param1)
        (if (== param1 391)
            (send gLongSong:fade(40 10 10 0))
        )
        (if (proc999_5(param1 391 410 900))
            (super:newRoom(param1))
        )(else
            (if (<> script ScriptID(700 2))
                proc0_2()
                (self:setScript(ScriptID(700 2) 0 1))
            )(else
                (if (script and not (send script:register))
                    (super:newRoom(param1))
                )(else
                    (super:newRoom(param1))
                )
            )
        )
    )

)
(instance fromElsewhereScript of Script
    (properties)

    (method (changeState newState)
        (var temp0, temp1, temp2, temp3)
        (switch (= state newState)
            (case 0
                (if (register)
                    = temp0 224
                    = temp1 54
                    = temp2 196
                    = temp3 82
                )(else
                    = temp0 65533
                    = temp1 244
                    = temp2 71
                    = temp3 170
                )
                (send gEgo:
                    x(temp0)
                    y(temp1)
                    setMotion(MoveTo temp2 temp3 self)
                )
            )
            (case 1
                proc700_5(1)
                proc0_3()
                (self:dispose())
            )
        )
    )

)
(instance goToRamaScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send gEgo:
                    setHeading(225)
                    setMotion(MoveFwd 80 self)
                )
            )
            (case 1
                (send global2:newRoom(410))
            )
        )
    )

)
(instance zapScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send client:
                    x(local0[register])
                    y(local0[+ register 1])
                    cel(/ register 2)
                )
                (if ((< register 3) and (> global106 1))
                    (signSound:
                        priority(1)
                        changeState()
                        play()
                    )
                )
                = cycles 1
            )
            (case 1
                (if (> (= register (+ register 2)) 16)
                    = register 0
                )
                (self:init())
            )
        )
    )

)
(instance zap of Prop
    (properties
        x 181
        y 5
        lookStr "It's the Radio Shock sign. It seems to be designed after some ancient electronic experiments."
        view 390
        priority 15
        signal 16
    )
)
(instance egoBwGreen of BeltWay
    (properties
        xStep 2
        yStep -1
        xOff 1
        yOff -1
        xTweak 1
        yTweak -1
        key 315
        head 119
        xDir 1
        yDir -1
    )
)
(instance egoBwBlue of BeltWay
    (properties
        xStep 2
        yStep -1
        xOff 1
        yOff -1
        xTweak 1
        yTweak -1
        key 135
        head 301
        xDir -1
        yDir 1
    )
)
(instance door of PicView
    (properties
        x 181
        y 28
        description "security door"
        lookStr "This store seems to be closed. A security door blocks its entrance."
        view 390
        loop 1
        priority 3
        signal 16400
    )
)
(instance sp2Squeeze of Script
    (properties)

    (method (doit param1)
        (super:doit(rest param1))
        (if (not state and ((< (send gEgo:x) 219) or proc0_5(gEgo 8192)))
            (self:cue())
        )(else
            (if ((send global2:script))
            )(else
                (if ((< (send gEgo:y) (- (send (ScriptID(700 7)):y) 12)) and not proc0_5(gEgo 8192))
                    (send client:setScript(sp2ShootEgo))
                )(else
                    (if (proc0_5(gEgo 1))
                        (send client:setScript(sp2ShootDown))
                    )(else
                        (if (proc0_5(gEgo 8192))
                            (send global2:setScript(hideEgoInStore))
                        )
                    )
                )
            )
        )
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                0
            )
            (case 1
                (send (ScriptID(700 7)):
                    view(7)
                    setLoop(2)
                    setCel(5)
                    setStep(2 2)
                    setMotion(MoveTo 89 133 self)
                )
            )
            (case 2
                (send (ScriptID(700 6)):
                    init()
                    setScript(sp1Squeeze)
                )
                (send (ScriptID(700 7)):
                    setStep(3 2)
                    setCycle(Walk)
                    setLoop(-1)
                    setCel(-1)
                    setMotion(MoveTo 134 122 self)
                )
            )
            (case 3
                (send (ScriptID(700 7)):
                    view(13)
                    loop(3)
                    cel(0)
                    stopUpd()
                )
                (self:dispose())
            )
        )
    )

)
(instance sp1Squeeze of rmnScript
    (properties)

    (method (doit param1)
        (super:doit(rest param1))
        (if ((send global2:script))
        )(else
            (if ((< (send (ScriptID(700 6)):x) 310) and not (& (send gEgo:onControl(1)) $2000))
                (send client:setScript(sp1ShootEgo))
            )
        )
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send (ScriptID(700 6)):
                    setStep(2 2)
                    posn(330 182)
                    view(13)
                    setLoop(1)
                    setCel(0)
                    init()
                    setMotion(MoveTo 199 112 self)
                )
            )
            (case 1
                (send (ScriptID(700 6)):
                    setStep(3 2)
                    view(7)
                    setCycle(Walk)
                    setLoop(-1)
                    setCel(-1)
                    setMotion(MoveTo 159 116 self)
                )
            )
            (case 2
                (send (ScriptID(700 6)):
                    view(13)
                    loop(1)
                    cel(0)
                    stopUpd()
                )
                = seconds 3
            )
            (case 3
                (self:save1(proc0_12("I am in pursuit of Wilco." 67 175 80)))
                = seconds 5
            )
            (case 4
                (self:restore())
                (self:save1(proc0_12("How did he get past me?" 67 25 127 28 global132)))
                = seconds 4
            )
            (case 5
                (self:restore())
                (self:save1(proc0_12("He is must be\nhiding in a store." 67 175 70)))
                = seconds 4
            )
            (case 6
                (self:restore())
                (self:save1(proc0_12("We must search each one carefully." 67 20 127 28 global132)))
                = seconds 5
            )
            (case 7
                (self:restore())
                (self:save1(proc0_12("I will first search\nMonolith Burger." 67 145 38)))
                = seconds 6
            )
            (case 8
                (self:restore())
                (self:save1(proc0_12("Good. I will cover the\nthe opposite direction." 67 30 130 28 global132)))
                = seconds 6
            )
            (case 9
                (self:restore())
                (self:save1(proc0_12("Long May Vohaul \nRule Supreme!" 67 145 38)))
                = seconds 5
            )
            (case 10
                (self:restore())
                (self:save1(proc0_12("Yeah... yeah... right." 67 60 130 28 global132)))
                = seconds 3
            )
            (case 11
                (self:restore())
                (send (ScriptID(700 6)):
                    view(7)
                    setMotion(MoveTo 148 85 self)
                )
            )
            (case 12
                (send (ScriptID(700 6)):
                    view(13)
                    setLoop(1)
                    setCel(0)
                    setStep(2 2)
                    setMotion(MoveTo 1 1)
                )
                = cycles 10
            )
            (case 13
                (send (ScriptID(700 7)):
                    view(7)
                    setMotion(MoveTo 143 156 self)
                )
            )
            (case 14
                (send (ScriptID(700 7)):
                    view(13)
                    setLoop(0)
                    setCel(0)
                    setStep(2 2)
                    setMotion(MoveTo 267 236 self)
                )
            )
            (case 15
                (hideEgoInStore:cue())
                (self:dispose())
            )
        )
    )

)
(instance sp1ShootEgo of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send (ScriptID(700 6)):
                    setLoop(3)
                    cel(0)
                    setCycle(End self)
                )
            )
            (case 1
                = local18 (- (send gEgo:y) 33)
                = local19 (- (send (ScriptID(700 6)):y) 34)
                = gEgoX (send gEgo:x)
                = gEgoX_2 (- (send (ScriptID(700 6)):x) 8)
                = local22 Graph(7 (- local18 1) (- gEgoX 1) (+ local19 1) (+ gEgoX_2 1) 1)
                Graph(4 local19 gEgoX_2 local18 gEgoX proc0_18(global133 global143) - (send gEgo:priority) 1 -1)
                Graph(13 - local18 1 - gEgoX 1 + local19 1 + gEgoX_2 1)
                (aSound:
                    number(105)
                    loop(1)
                    vol(127)
                    play()
                )
                = cycles 1
            )
            (case 2
                Graph(8 local22)
                Graph(13 - local18 1 - gEgoX 1 + local19 1 + gEgoX_2 1)
                (blast:
                    init()
                    cel(0)
                    posn(gEgoX local18)
                    setPri(+ (send gEgo:priority) 1)
                    setCycle(End)
                )
                (send gEgo:
                    view(26)
                    cel(0)
                    cycleSpeed(1)
                    ignoreActors()
                    setCycle(End self)
                )
            )
            (case 3
                proc0_10(8 3)
            )
        )
    )

)
(instance sp2ShootDown of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send (ScriptID(700 7)):
                    view(13)
                    setLoop(4)
                    setCel(0)
                    setPri((send gEgo:priority))
                )
                = cycles 4
            )
            (case 1
                (send (ScriptID(700 7)):setCycle(CT 1 1 self))
            )
            (case 2
                = local19 (- (send gEgo:y) 33)
                = local18 (- (send (ScriptID(700 7)):y) 20)
                = gEgoX_2 (send gEgo:x)
                = gEgoX (+ (send (ScriptID(700 7)):x) 11)
                = local22 Graph(7 (- local18 1) (- gEgoX 1) (+ local19 1) (+ gEgoX_2 1) 1)
                Graph(4 local18 gEgoX local19 gEgoX_2 proc0_18(global133 global143) - (send gEgo:priority) 1 -1)
                Graph(13 - local18 1 - gEgoX 1 + local19 1 + gEgoX_2 1)
                (aSound:
                    number(105)
                    loop(1)
                    vol(127)
                    play()
                )
                = cycles 1
            )
            (case 3
                (send (ScriptID(700 7)):setCel(0))
                Graph(8 local22)
                Graph(13 - local18 1 - gEgoX 1 + local19 1 + gEgoX_2 1)
                (blast:
                    init()
                    cel(0)
                    posn(gEgoX_2 local19)
                    setPri(+ (send gEgo:priority) 1)
                    setCycle(End)
                )
                (send gEgo:
                    view(26)
                    cel(0)
                    cycleSpeed(1)
                    ignoreActors()
                    setCycle(End self)
                )
            )
            (case 4
                proc0_10(8 3)
            )
        )
    )

)
(instance sp2ShootEgo of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send (ScriptID(700 7)):
                    view(13)
                    setLoop(0)
                    setCel(0)
                )
                = cycles 2
            )
            (case 1
                (send (ScriptID(700 7)):setCycle(CT 1 1 self))
            )
            (case 2
                = local18 (- (send gEgo:y) 33)
                = local19 (- (send (ScriptID(700 7)):y) 28)
                = gEgoX_2 (send gEgo:x)
                = gEgoX (+ (send (ScriptID(700 7)):x) 16)
                = local22 Graph(7 (- local18 1) (- gEgoX 1) (+ local19 1) (+ gEgoX_2 1) 1)
                Graph(4 local19 gEgoX local18 gEgoX_2 proc0_18(global133 global143) - (send gEgo:priority) 1 -1)
                Graph(13 - local18 1 - gEgoX 1 + local19 1 + gEgoX_2 1)
                (send (ScriptID(700 7)):setCycle(End))
                (aSound:
                    number(105)
                    loop(1)
                    vol(127)
                    play()
                )
                = cycles 1
            )
            (case 3
                Graph(8 local22)
                Graph(13 - local18 1 - gEgoX 1 + local19 1 + gEgoX_2 1)
                (blast:
                    init()
                    cel(0)
                    posn(gEgoX_2 local18)
                    setPri(+ (send gEgo:priority) 1)
                    setCycle(End)
                )
                (send gEgo:
                    view(26)
                    cel(0)
                    cycleSpeed(1)
                    ignoreActors()
                    setCycle(End self)
                )
            )
            (case 4
                proc0_10(8 3)
            )
        )
    )

)
(instance hideEgoInStore of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gEgo:
                    illegalBits(0)
                    setMotion(MoveTo 192 49 self)
                )
            )
            (case 1
                (send gEgo:
                    setPri(1)
                    setMotion(MoveTo 171 47)
                )
            )
            (case 2
                (send gEgo:setMotion(MoveTo 192 49 self))
            )
            (case 3
                (send gEgo:
                    setPri(-1)
                    setMotion(MoveTo 199 86 self)
                )
            )
            (case 4
                = cycles 4
            )
            (case 5
                Print("These guys mean bussiness, alright.  But they sure aren't Harvard graduates.")
                proc0_3()
                (send gEgo:illegalBits(32768))
                (self:dispose())
            )
        )
    )

)
(instance blast of Prop
    (properties
        view 28
        signal 16384
    )
)
(instance signSound of Sound
    (properties
        number 391
        priority 1
    )
)
(instance store of Feature
    (properties
        x 280
        y 30
        description "Radio Shock"
        lookStr "Radio Shock - a Dandy store."
    )

    (method (doVerb param1 param2)
        (switch (param1)
            (case 2
                Print("It feels just like a wall with hot dogs and pickles stuck to it.")
            )
            (case 11
                Print("It smells like all the other 15,000,000,000 Radio Shocks all throughout the Greater Crab Nebula Metro Area.")
            )
            (case 10
                Print("It's like licking a battery.")
            )
            (default 
                (super:doVerb(param1 rest param2))
            )
        )
    )


    (method (onMe param1)
        return >= -51 (/ (* 100 (- 151 (send param1:y))) (- (send param1:x) 320))
    )

)
(instance steps of Feature
    (properties
        y 185
        description "steps"
        lookStr "These steps lead down to the Skate-O-Rama."
    )

    (method (doVerb param1 param2)
        (switch (param1)
            (case 11
                Print("They smell like used foot powder, ground sole dust, and an interesting potpourri of granules from the various items that hitched free rides on said shoes.")
            )
            (case 10
                Print("Oh, this doesn't taste good! YUCK!")
            )
            (default 
                (super:doVerb(param1 rest param2))
            )
        )
    )


    (method (onMe param1)
        return == OnControl(4 (send param1:x) (send param1:y)) 2048
    )

)
(instance bush1 of Feature
    (properties
        x 60
        y 45
        nsTop 32
        nsLeft 49
        nsBottom 62
        nsRight 70
        description "fabricated flora"
        lookStr "Why, they're those incredibly decorative PermaShrubs from Polyflora Permutations, Inc! (As seen on TV!)"
    )

    (method (doVerb param1 param2)
        (switch (param1)
            (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.")
            )
            (case 2
                Print("They're bolted down. Maybe you're not the first one to try stealing these decorative PermaShrubs.")
            )
            (default 
                (super:doVerb(param1 rest param2))
            )
        )
    )

)
(instance bush2 of Feature
    (properties
        x 245
        y 140
        nsTop 129
        nsLeft 239
        nsBottom 157
        nsRight 261
        description "fabricated flora"
        lookStr "Why, they're those incredibly decorative and disturbingly durable Polyflora PermaShrubs from the wonderful beings at Permutronics Synthefacturing. (As seen on TV!)"
    )

    (method (doVerb param1 param2)
        (switch (param1)
            (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.")
            )
            (case 2
                Print("They're bolted down. Maybe you're not the first one to try stealing these decorative PermaShrubs.")
            )
            (default 
                (super:doVerb(param1 rest param2))
            )
        )
    )

)
(instance aSound of Sound
    (properties)
)
