(include "sci.sh")
(use "Main")
(use "Class_255_0")
(use "rmnScript")
(use "SQRoom")
(use "RandCycle")
(use "PolyPath")
(use "Polygon")
(use "Class_950_0")
(use "Cycle")
(use "PicView")
(use "Obj")
(script 397)


(local
    local0
    local1
    local2[2]
    local4
    local5[2]
    local7
    local8
    local9[300]

)
(instance public rm397 of SQRoom
    (properties)

    (method (init)
        = local7 global34
        = global34 0
        (send global2:addObstacle((send ((Polygon:new())):
                type(2)
                init(0 189 0 0 319 0 319 189 306 189 298 180 197 176 181 145 297 145 269 113 254 113 223 117 93 117 66 112 41 112 31 144 133 144 114 178 17 178 7 189)
                yourself()
            )
))
        (send gLongSong:
            number(0)
            stop()
        )
        (send gLongSong2:
            vol(127)
            changeState()
        )
        proc0_3()
        (clerkHead:
            posn(161 70)
            setPri(8)
            init()
        )
        (clerk:
            posn(160 85)
            init()
        )
        (super:init())
        (self:setRegions(700))
        (birdyFeature:init())
        (displayCase:init())
        (shelf1:init())
        (box:init())
        (shelf2:init())
        (bin1:init())
        (bin2:init())
        (send gEgo:
            x(160)
            y(180)
            init()
        )
        (if (== gWest 398)
            (send gEgo:posn(127 163))
        )
        (if (== gWest 395)
            (send global2:setScript(walkIn))
        )(else
            (send global2:setScript(clerkScript))
        )
    )


    (method (doit)
        (super:doit())
        (if ((((& (send gEgo:onControl(1)) $4000) and (<> gBoxPropBoxID 0)) and (<> local0 1)) and not Btest(31))
            = local0 1
            (send global2:setScript(yell))
        )
        (if ((((& (send gEgo:onControl(1)) $2000) and (<> gBoxPropBoxID 0)) and (<> local1 1)) and not Btest(31))
            = local1 1
            (send global2:setScript(yell))
        )
        (if ((((& (send gEgo:onControl(1)) $0200) and not local4) and (<> gBoxPropBoxID 0)) and not Btest(31))
            = local4 1
            (send global2:setScript(buyBox))
        )
        (if (not (& (send gEgo:onControl(1)) $0200) and (== local4 1))
            = local4 0
        )
    )


    (method (dispose)
        DisposeScript(941)
        = global34 local7
        (super:dispose())
    )


    (method (doVerb param1)
        (switch (param1)
            (case 1
                (super:doVerb(param1))
            )
            (case 11
                proc0_16()
            )
            (case 10
                proc0_16()
            )
            (default 
                (super:doVerb(param1))
            )
        )
    )

)
(instance walkIn of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gEgo:posn(160 200))
                = cycles 1
            )
            (case 1
                (send gEgo:setMotion(MoveTo 160 170 self))
            )
            (case 2
                proc0_3()
                (send client:setScript(clerkScript))
            )
        )
    )

)
(instance buyBox of rmnScript
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (clerk:setScript(talk))
                (self:save1(proc0_12("\"That will be 5 Buckazoids.\"" 67 2 5 30 1 28 global135 29 gColor)))
                = seconds 5
            )
            (case 1
                (clerk:
                    setScript(0)
                    setCycle(0)
                    cel(0)
                )
                (clerkHead:
                    setCycle(0)
                    cel(0)
                )
                (self:restore())
                (clerk:setScript(0))
                proc0_3()
                (self:dispose())
            )
        )
    )

)
(instance yell of rmnScript
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (clerk:setScript(talk))
                (send gEgo:setMotion(0))
                proc0_2()
                (if ((== local0 1) and (== local1 1))
                    (self:save1(proc0_12("\"I wouldn't try that if I was you.\"" 67 2 5 30 1 28 global135 29 gColor)))
                )(else
                    (self:save1(
                        (if (proc999_5((send gEgo:view) 373 374))
                            proc0_12("\"Excuse me, ma'am! Would you like to pay for that?\"" 67 2 5 30 1 28 global135 29 gColor)
                        )(else
                            proc0_12("\"Excuse me, sir! Would you like to pay for that?\"" 67 2 5 30 1 28 global135 29 gColor)
                        )
))
                )
                = seconds 7
            )
            (case 1
                (clerk:
                    setCycle(0)
                    cel(0)
                )
                (clerkHead:
                    setCycle(0)
                    cel(0)
                )
                (self:restore())
                proc0_3()
                (send client:setScript(0))
            )
        )
    )

)
(instance talk2 of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gEgo:setMotion(PolyPath 160 160 self))
            )
            (case 1
                (otherGuy:
                    init()
                    loop(1)
                    illegalBits(0)
                    posn(250 130)
                    setStep(4 2)
                    setCycle(Fwd)
                    setMotion(MoveTo 10 130)
                )
                = cycles 10
            )
            (case 2
                (myGuy:
                    init()
                    loop(2)
                    illegalBits(0)
                    posn(300 115)
                    setCycle(Fwd)
                    setMotion(MoveTo 120 115 self)
                )
            )
            (case 3
                (otherGuy:setCycle(0))
                (myGuy:
                    setMotion(0)
                    view(409)
                    loop(1)
                    setCycle(Fwd)
                )
                = seconds 4
            )
            (case 4
                (myGuy:
                    view(408)
                    loop(1)
                    setMotion(MoveTo 0 115 self)
                    setCycle(Fwd)
                )
            )
            (case 5
                proc0_3()
                (self:dispose())
            )
        )
    )

)
(instance talk of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (clerkHead:
                    cycleSpeed(0)
                    setLoop(1)
                    setCycle(Fwd)
                )
                (clerk:setCycle(Fwd))
            )
        )
    )

)
(instance clerkScript of rmnScript
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (clerk:setScript(talk))
                (if ((not Btest(31) and (<> gBoxPropBoxID 0)) and (== gWest 398))
                    (self:save1(proc0_12("\"Ah, I see you've made a selection\nfrom our box of slop..er, bargain bin.\"" 67 2 5 30 1 28 global135 29 gColor)))
                    = seconds 9
                )(else
                    (if ((== gWest 398) and Btest(31))
                        (self:save1(proc0_12("\"I'm sure you'll be satisfied with your selection.\"" 67 2 5 28 0 30 1 28 global135 29 gColor)))
                        = seconds 9
                    )(else
                        (if (== gWest 398)
                            (self:save1(proc0_12("\"Didn't find anything you liked, eh?\"" 67 2 5 28 0 30 1 28 global135 29 gColor)))
                        )(else
                            (self:save1(proc0_12("\"Sorry, but the crowd completely cleaned out my stock of Sierra software. The only thing that's left is boring home and business applications software along with a few inferior games. But feel free to look around anyway.\"" 67 2 5 70 315 30 1 28 global135 29 gColor)))
                            = seconds 20
                        )
                    )
                )
            )
            (case 1
                (if (<> gWest 398)
                    (self:restore())
                    (self:save1(proc0_12(
                            (switch (Random(0 2))
                                (case 0
                                    "\"So, are ya looking for a good data base? We're got one coming in next week.\""
                                )
                                (case 1
                                    "\"Hey, have you seen the newest time travel simulator? Neither have I. I'm sure we're getting some in soon.\""
                                )
                                (case 3
                                    "\"If you're here to return something, forget it. We have a strict 'No Returns' policy. I'd like to help you out, guy. But you know how corporations are.\""
                                )
                            )
 67 2 5 70 315 30 1 28 global135 29 gColor)))
                    = seconds 30
                )(else
                    (self:cue())
                )
            )
            (case 2
                (clerk:
                    setCycle(0)
                    cel(0)
                )
                (clerkHead:
                    setCycle(0)
                    stopUpd()
                    cel(0)
                )
                (self:restore())
                proc0_3()
                (clerk:setScript(0))
                (self:dispose())
            )
        )
    )

)
(instance birdy of Script
    (properties)

    (method (doit)
        (super:doit())
        (if (<> (send gEgo:loop) 2)
            (clerk:
                loop(0)
                cel(0)
            )
            (clerkHead:
                loop(2)
                setCycle(RandCycle)
                cycleSpeed(20)
            )
            (self:dispose())
        )
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (clerkHead:
                    setCycle(0)
                    loop(3)
                    cel(1)
                )
                (clerk:
                    setCycle(0)
                    loop(3)
                    cel(0)
                )
                = seconds 3
            )
            (case 1
                (clerkHead:
                    loop(4)
                    cycleSpeed(0)
                    setCycle(Fwd)
                )
                (clerk:
                    loop(0)
                    cel(0)
                )
                = cycles Random(20 40)
            )
            (case 2
                (clerkHead:
                    loop(2)
                    setCycle(RandCycle)
                    cycleSpeed(20)
                )
                = seconds 10
            )
            (case 3
                (self:dispose())
            )
        )
    )

)
(instance sayThankYou of rmnScript
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (self:save1(proc0_12("\"Thank You.\"" 67 2 5 30 1 28 global135 29 gColor)))
                = seconds 3
            )
            (case 1
                proc0_3()
                (self:restore())
                (self:dispose())
            )
        )
    )

)
(instance clerk of Prop
    (properties
        description "sales clerk"
        view 397
    )

    (method (doit)
        (super:doit())
        (if ((((not (self:script) and (== (clerkHead:loop) 2)) and (== (send gEgo:loop) 2)) and (== Random(0 100) 1)) and local8)
            (send global2:setScript(birdy))
        )
    )


    (method (doVerb param1 param2 param3)
        (switch (param1)
            (case 4
                (send global2:setScript(clerkScript))
            )
            (case 3
                (switch (param2)
                    (case 0
                        (if (not gBoxPropBoxID)
                            Print("You should pick something out before you give money to the clerk.")
                        )(else
                            (if (Btest(31))
                                Print("You have already paid the clerk.")
                            )(else
                                (if (< global159 5)
                                    (send global2:setScript(buyBox))
                                )(else
                                    (self:setScript(sayThankYou))
                                    = global159 (- global159 5)
                                    (if (< global159 1)
                                        (send gEgo:put(0))
                                    )
                                    proc0_11(85 5)
                                    Bset(31)
                                )
                            )
                        )
                    )
                    (default 
                        (super:doVerb(param1))
                    )
                )
            )
            (case 1
                Print("It looks like the clerk is keeping his eye on you.")
            )
            (case 11
                Print("Ah!  The distinctive aroma of Centauri Moon No. 5.")
            )
            (default 
                (super:doVerb(param1 rest param3))
            )
        )
    )

)
(instance clerkHead of Prop
    (properties
        description "sales clerk"
        view 397
        loop 1
    )

    (method (doit)
        (super:doit())
        (if ((clerk:script) or (send global2:script))
            0
        )(else
            (if (> (send gEgo:y) 168)
                (self:
                    setCycle(0)
                    loop(1)
                    cel(11)
                )
            )(else
                (if (not (& (send gEgo:onControl(1)) $0200) and not cycler)
                    (self:
                        setCycle(RandCycle)
                        loop(2)
                        cycleSpeed(20)
                    )
                )(else
                    (if (& (send gEgo:onControl(1)) $0200)
                        (self:
                            setCycle(0)
                            loop(1)
                            cel(0)
                        )
                    )
                )
            )
        )
    )


    (method (doVerb param1 param2)
        (clerk:doVerb(param1 param2))
    )

)
(instance goBox of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send gEgo:setMotion(PolyPath 135 162 self))
            )
            (case 1
                (send gEgo:loop(5))
                = cycles 5
            )
            (case 2
                (send global2:newRoom(398))
            )
        )
    )

)
(instance displayCase of Feature
    (properties
        x 157
        y 94
        nsTop 80
        nsLeft 45
        nsBottom 109
        nsRight 269
        description "display case"
        sightAngle 90
        lookStr "The clerk was right. Only boring applications software remains."
    )
)
(instance bin1 of Feature
    (properties
        x 89
        y 135
        nsTop 129
        nsLeft 68
        nsBottom 141
        nsRight 111
        description "bargain bin"
        sightAngle 90
        lookStr "A bargain bin containing discount software."
    )

    (method (doVerb param1 param2)
        (switch (param1)
            (case 2
                (send global2:setScript(goBox))
            )
            (default 
                (super:doVerb(param1 rest param2))
            )
        )
    )

)
(instance bin2 of Feature
    (properties
        x 78
        y 144
        nsTop 141
        nsLeft 49
        nsBottom 148
        nsRight 107
        description "bargain bin"
        sightAngle 90
        lookStr "A bargain bin containing discount software."
    )

    (method (doVerb param1 param2)
        (switch (param1)
            (case 2
                (send global2:setScript(goBox))
            )
            (default 
                (super:doVerb(param1 rest param2))
            )
        )
    )

)
(instance shelf1 of Feature
    (properties
        x 161
        y 58
        nsTop 42
        nsLeft 63
        nsBottom 74
        nsRight 260
        description "display shelf"
        sightAngle 90
        lookStr "The clerk was right. Only boring applications software remains."
    )
)
(instance otherGuy of Actor
    (properties
        view 382
    )
)
(instance myGuy of Actor
    (properties
        view 408
    )
)
(instance box of Feature
    (properties
        x 307
        y 35
        nsTop 30
        nsLeft 296
        nsBottom 40
        nsRight 319
        description "wall"
        sightAngle 90
        lookStr ""
    )

    (method (doVerb param1)
        (switch (param1)
            (case 10
                (if (not (send global2:script))
                    (send global2:setScript(talk2))
                )
            )
        )
    )

)
(instance shelf2 of Feature
    (properties
        x 53
        y 63
        nsTop 51
        nsLeft 45
        nsBottom 76
        nsRight 61
        description "display shelf"
        sightAngle 90
        lookStr "The clerk was right. Only boring applications software remains."
    )
)
(instance birdyFeature of Feature
    (properties
        x 9
        y 33
        nsTop 28
        nsBottom 38
        nsRight 19
        description "wall"
        sightAngle 90
        lookStr ""
    )

    (method (doVerb param1)
        (switch (param1)
            (case 11
                (if (not (send global2:script))
                    Print("Ah! Yeaa!")
                    ++local8
                    (self:dispose())
                )
            )
        )
    )

)
