(include "sci.sh")
(use "Main")
(use "Class_255_0")
(use "RegionPath")
(use "Inertia")
(use "PolyPath")
(use "Class_950_0")
(use "StopWalk")
(use "Cycle")
(use "Game")
(use "User")
(use "PicView")
(use "Obj")
(script 700)


(local
    local0[43] = (32767 400 324 90 65531 90 32767 370 78 231 324 87 32767 375 78 233 324 87 32767 380 65531 142 324 127 32767 385 65531 142 324 158 32767 390 65531 89 239 233 32767 395 65531 88 230 238 32768 )
    local43[43] = (32767 400 65531 145 324 145 32767 395 324 179 65531 3 32767 390 324 173 65531 0 32767 385 324 116 65531 100 32767 380 324 87 65531 101 32767 375 324 65533 65531 169 32767 370 324 65533 65531 169 32768 )
    theLoop[8] = (3 6 0 4 2 5 1 7 )

)
(procedure public (proc700_3 param1 param2 param3)
    return 
        (if (& (send param1:param2) param3)
            return 1
        )(else
            return 0
        )
)


(procedure public (proc700_5 param1)
    (if (param1)
        = global87 1
        (send gEgo:illegalBits(0))
        (if (IsObject((send gEgo:mover)))
            (send gEgo:setMotion(PolyPath (send ((send gEgo:mover)):x) (send ((send gEgo:mover)):y)))
        )
    )(else
        = global87 0
        (send gEgo:illegalBits(32768))
    )
)


(procedure (localproc_06f0 param1)
    (if ((((send gEgo:mover) and not (send param1:z)) and (& (send param1:signal) $0400)) and (< (send gEgo:distanceTo(param1)) 35))
        (send gEgo:setMotion(0))
    )
)


(class mall of Rgn
    (properties
        script 0
        number 0
        timer 0
        keep 0
        initialized 0
        lookStr 0
        enterBelt 0
        whichBelt 0
        rFlag1 0
        rFlag2 0
        rFlag3 0
        rFlag4 0
    )

    (method (init param1)
        (var temp0)
        (super:init(rest param1))
        Load(rsVIEW 370)
        Load(rsVIEW 7)
        (if (Btest(22) and not Btest(30))
            (if (<> gNumber 390)
                Bset(30)
                (shopperPath2:
                    x(239)
                    y(233)
                    dx(3)
                    dy(1)
                    {b-moveCnt}(0)
                    {b-i1}(258)
                    {b-i2}(65458)
                    {b-di}(138)
                    {b-xAxis}(1)
                    {b-incr}(1)
                    completed(0)
                    xLast(92)
                    yLast(146)
                    currentRoom(390)
                    value(35)
                    intermediate(0)
                )
                (shopperPath3:
                    x(65531)
                    y(0)
                    dx(65534)
                    dy(-1)
                    {b-moveCnt}(0)
                    {b-i1}(34)
                    {b-i2}(64912)
                    {b-di}(65013)
                    {b-xAxis}(1)
                    {b-incr}(-1)
                    completed(0)
                    xLast(262)
                    yLast(140)
                    currentRoom(390)
                    value(17)
                    intermediate(0)
                )
                (shopper2:
                    x(95)
                    y(148)
                    z(1000)
                    heading(120)
                    xLast(95)
                    yLast(148)
                )
                (shopper3:
                    x(260)
                    y(139)
                    z(1000)
                    heading(298)
                    xLast(260)
                    yLast(139)
                )
            )(else
                (shopper2:z(20000))
                (shopper3:z(20000))
            )
        )
        (if (<> gNumber 387)
            (shopper2:
                view(
                    (if (Btest(30))
                        7
                    )(else
                        384
                    )
)
                setCycle(Walk)
                setStep(4 2)
                init()
                setMotion(shopperPath2)
            )
            (shopper3:
                view(
                    (if (Btest(30))
                        7
                    )(else
                        388
                    )
)
                setCycle(Walk)
                setStep(5 2)
                init()
                setMotion(shopperPath3)
            )
        )
        (if (not proc999_5(gNumber 405 406 410 411))
            = temp0 
                (switch ((send gEgo:view))
                    (case 0
                        4
                    )
                    (case 402
                        14
                    )
                    (case 373
                        374
                    )
                )
            (send gEgo:setCycle(StopWalk temp0))
        )
        (if (proc999_5(gNumber 370 375 380 385 390 395 400))
            (belts:init())
            (restOfMall:init())
            (send gEgo:setScript(nearScript))
        )
    )


    (method (newRoom param1 param2)
        (if (Btest(24))
            ++global110
            (if (Btest(25) and (> global110 2))
                Bclear(25)
            )
        )
        = keep proc999_5(param1 370 371 375 376 380 381 385 386 387 390 391 395 397 398 399 400 405 406 410 411)
        = initialized 0
        (super:newRoom(param1 rest param2))
    )


    (method (offScreen)
        return 
            (if (((< (send gEgo:nsRight) 0) or (> (send gEgo:nsLeft) 319)) or (< (send gEgo:nsBottom) 0))
            )(else
                > (send ((send gEgo:_head)):nsTop) 189
            )
    )

)
(instance public enS of Script
    (properties)

    (method (init param1)
        (send gEgo:illegalBits(0))
        (super:init(rest param1))
    )


    (method (doit param1)
        (super:doit(rest param1))
        (if ((((not (send gEgo:onControl()) or (<= (send gEgo:x) 0)) or (>= (send gEgo:x) 319)) or (<= (send gEgo:y) (send global2:horizon))) or (>= (send gEgo:y) 189))
            0
        )(else
            (send gEgo:illegalBits(32768))
            (self:dispose())
            proc0_3()
        )
        (send register:
            who(gEgo)
            doit()
        )
    )

)
(instance public exS of Script
    (properties)

    (method (doit param1)
        (super:doit(rest param1))
        (send gEgo:setMotion(0))
        (if ((mall:offScreen()))
            (send global2:newRoom(register))
        )(else
            (send ((mall:enterBelt)):
                who(gEgo)
                doit()
            )
        )
    )

)
(instance moveNear of Motion
    (properties)

    (method (doit)
        (var temp0)
        (if ((self:onTarget()))
            (self:moveDone())
        )(else
            (if (<> (send client:heading) GetAngle((send client:x) (send client:y) x y))
                InitBresen(self)
            )
            (super:doit())
        )
    )

)
(instance nearScript of Script
    (properties)

    (method (handleEvent pEvent)
        (if ((send pEvent:claimed))
            return 
        )(else
            (if ((((<> (send gIconBar:curIcon) (send gIconBar:at(0))) or not (User:controls)) or (<> (send pEvent:type) 16384)) or (send pEvent:modifiers))
                (super:handleEvent(pEvent))
            )(else
                (send client:setMotion(
                    (if (global87)
                        PolyPath
                    )(else
                        moveNear
                    )
 (send pEvent:x) (send pEvent:y)))
                (User:prevDir(0))
                (send pEvent:claimed(1))
            )
        )
    )

)
(instance public eSwimCode of Inertia
    (properties
        maxInertia 5
    )
)
(instance spSwimCode of Inertia
    (properties
        maxInertia 4
    )
)
(instance shopper2 of Actor
    (properties
        z 1000
        description "this guy"
        lookStr "This guy (gal?) doesn't look like anybody or anything you've ever seen before. It has very unique head construction (if that's what it's called)."
        view 367
        signal 8192
        illegalBits 0
    )

    (method (doit)
        (super:doit())
        localproc_06f0(self)
        (if (script)
        )(else
            (if (proc0_5(self 1))
                (if (not cycler)
                    (self:
                        view(
                            (if (Btest(30))
                                7
                            )(else
                                384
                            )
)
                        setCycle(Walk)
                        setCel(-1)
                        setStep(4 2)
                    )
                    InitBresen(mover)
                )
            )(else
                (if (cycler)
                    (self:
                        view(
                            (if (Btest(30))
                                13
                            )(else
                                367
                            )
)
                        setCycle(0)
                        setCel(0)
                        setStep(2 2)
                    )
                    InitBresen(mover)
                )
                = loop theLoop[(/ proc999_1((+ heading (/ 180 NumLoops(self))) 360) (/ 360 NumLoops(self)))]
            )
        )
    )


    (method (doVerb param1 param2)
        (switch (param1)
            (case 1
                (if (Btest(30))
                    Print((sp1:lookStr))
                )(else
                    Print(lookStr)
                )
            )
            (case 2
                Print("These guys are scary looking. It wouldn't be a good idea to mess with them.")
            )
            (case 4
                Print("\"Help me fertilize my mother's cat\", the being believes it hears you say! Embarrassed by your presence, it acts as though it doesn't see you.")
            )
            (case 11
                Print("Taking in a whiff of air, you instantly notice its three feet. You thought you smelled a Dr. Scholl's product!")
            )
            (case 10
                Print("As much as we enjoy seeing you get in trouble, we must warn you that this type of behavior is universally considered either rude or amorous, which could get you either killed or married (with the former being preferable in many cases).")
            )
            (default 
                (super:doVerb(param1 rest param2))
            )
        )
    )

)
(instance public shopper3 of Actor
    (properties
        z 1000
        description "this guy"
        lookStr "This guy looks like The Living Torso. Must work for an intergalactic freak show."
        view 368
        signal 8192
        illegalBits 0
    )

    (method (doit)
        (super:doit())
        localproc_06f0(self)
        (if (script)
        )(else
            (if (proc0_5(self 1))
                (if (not cycler)
                    (self:
                        view(
                            (if (Btest(30))
                                7
                            )(else
                                388
                            )
)
                        setCycle(Walk)
                        setCel(-1)
                        setStep(5 2)
                    )
                    InitBresen(mover)
                )
            )(else
                (if (cycler)
                    (self:
                        view(
                            (if (Btest(30))
                                13
                            )(else
                                368
                            )
)
                        setCycle(0)
                        setCel(0)
                        setStep(2 2)
                    )
                    InitBresen(mover)
                )
                = loop theLoop[(/ proc999_1((+ heading (/ 180 NumLoops(self))) 360) (/ 360 NumLoops(self)))]
            )
        )
    )


    (method (doVerb param1 param2)
        (switch (param1)
            (case 1
                (if (Btest(30))
                    Print((sp1:lookStr))
                )(else
                    Print(lookStr)
                )
            )
            (case 2
                Print("These guys are scary looking. It wouldn't be a good idea to mess with them.")
            )
            (case 4
                Print(
                    (switch (Random(1 20))
                        (case 19
                            "\"Mr. Carlos sent me. I want to know about the sheep.\""
                        )
                        (default 
                            "It doesn't have the slightest notion as to what you might be saying."
                        )
                    )
)
            )
            (case 11
                Print("Uhmm! Sulfur! This shopper smells as though it comes from a planet where the only showers are volcanic.")
            )
            (case 10
                Print("As much as we enjoy seeing you get in trouble, we must warn you that this type of behavior is universally considered either rude or amorous, which could get you either killed or married (with the former being preferable in many cases).")
            )
            (default 
                (super:doVerb(param1 rest param2))
            )
        )
    )

)
(instance public sp1 of Actor
    (properties
        description "Sequel Policeman"
        lookStr "It's one of Vohaul's Sequel Policemen!"
        view 7
        signal 24576
    )

    (method (doVerb param1 param2 param3)
        (switch (param1)
            (case 4
                Print("That would be most unwise!")
            )
            (case 11
                Print("Seeing as how these guys are trying to kill you, your best line of defense would be a straight one out of here.")
            )
            (case 10
                Print("You'd best stay out of sight of this guy!")
            )
            (case 2
                Print("Seeing as how these guys are trying to kill you, your best line of defense would be a straight one out of here.")
            )
            (case 3
                Print(
                    (switch (param2)
                        (case 0
                            Print("The Sequel Police are closely monitored by Vohaul. Bribing them would be out of the question.")
                        )
                        (case 1
                            Print("Even if you were to lasso a Sequel Policeman, what would you do with him?")
                        )
                        (case 3
                            Print("Ooooo! Don't throw the bunny at Sequel Policeman! He may have a hare trigger. (Sorry!)")
                        )
                        (case 4
                            Print("No way! That would be assualt with intent to emit battery!")
                        )
                        (case 6
                            Print("Try as you might, the gum just gets stuck to your fingers.")
                        )
                        (case 9
                            Print("He's gonna SHOOT you, not write you a ticket!")
                        )
                        (case 10
                            Print("The Sequel Police are closely monitored by Vohaul. Bribing them would be out of the question.")
                        )
                        (default 
                            Print("You'd better not. You might need that later.")
                        )
                    )
)
            )
            (default 
                (super:doVerb(param1 param2 rest param3))
            )
        )
    )

)
(instance public sp2 of Actor
    (properties
        description "Sequel Policeman"
        lookStr "It's one of Vohaul's Sequel Policemen!"
        view 7
        signal 24576
    )

    (method (doVerb param1)
        (sp1:doVerb(rest param1))
    )

)
(instance shopperPath2 of RegionPath
    (properties
        value 17
        theRegion 700
    )

    (method (doit param1)
        (super:doit(rest param1))
        (if ((((== currentRoom gNumber) and (<> (send client:script) spOnBelt)) and not (spOnBelt:client)) and Btest(30))
            (send client:setScript(spOnBelt))
        )
    )


    (method (at param1)
        return local0[param1]
    )

)
(instance shopperPath3 of RegionPath
    (properties
        value 17
        theRegion 700
    )

    (method (doit param1)
        (super:doit(rest param1))
        (if ((((== currentRoom gNumber) and (<> (send client:script) spOnBelt)) and not (spOnBelt:client)) and Btest(30))
            (send client:setScript(spOnBelt))
        )
    )


    (method (at param1)
        return local43[param1]
    )

)
(instance egoBumpScript of Script
    (properties)

    (method (changeState newState)
        (var temp0, temp1)
        (switch (= state newState)
            (case 0
                proc0_2()
                = temp1 GetAngle((send register:x) (send register:y) (send gEgo:x) (send gEgo:y))
                = temp1 proc999_1((+ temp1 45) 360)
                (send gEgo:
                    view(370)
                    cel(0)
                    setMotion(0)
                    x(temp0)
                    setCycle(End self)
                )
            )
            (case 1
                (User:canInput(1))
                (self:dispose())
            )
        )
    )

)
(instance egoStandScript of Script
    (properties)

    (method (changeState newState)
        (var temp0)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gEgo:setCycle(Beg self))
            )
            (case 1
                (send gEgo:
                    view(0)
                    setCycle(Walk)
                )
                (self:dispose())
                proc0_3()
            )
        )
    )

)
(instance spOnBelt of Script
    (properties)

    (method (init param1)
        (super:init(rest param1))
        Bset(3)
    )


    (method (doit param1)
        (if ((send global2:script))
            (send client:setCel(0))
            proc0_13(client gEgo)
        )(else
            (if ((((((== state 0) and (< 40 (send client:y))) and (< (send client:y) 170)) and (< 20 (send client:x))) and (< (send client:x) 300)) and not (send global2:script))
                (self:cue())
            )(else
                (if (<> gNumber (send ((send client:mover)):currentRoom))
                    proc0_3()
                    (self:dispose())
                )
            )
        )
        (super:doit(rest param1))
    )


    (method (changeState newState)
        (var temp0[4])
        (switch (= state newState)
            (case 0
                0
            )
            (case 1
                proc0_2()
                Bclear(30)
                proc0_13(client gEgo self)
            )
            (case 2
                (send client:
                    setCel(0)
                    view(13)
                    setCycle(End)
                )
                (send gEgo:
                    view(26)
                    cel(0)
                    setCycle(End self)
                )
            )
            (case 3
                proc0_10(8 17)
            )
        )
    )

)
(instance belts of Feature
    (properties
        description "people mover belt way"
        sightAngle 180
        lookStr "This belt way is great! No more tired, aching feet. No more walking just for the sake of going somewhere."
    )

    (method (doVerb param1 param2)
        (switch (param1)
            (case 2
                Print("Your index digit scrapes the interesting coating that now resides on the surface of the belt. Just think, there's probably toe jam from all corners of the universe wedged up under your fingernail!")
            )
            (case 11
                Print("You attempt to smell the moving walkway and end up filing down your nose slightly.")
            )
            (case 10
                Print("Very well, you give the moving walkway a warm kiss. Now you both feel special.")
            )
            (default 
                (super:doVerb(param1 rest param2))
            )
        )
    )


    (method (onMe param1)
        return & OnControl(4 (send param1:x) (send param1:y)) $0006
    )

)
(instance restOfMall of Feature
    (properties
        description "rest of the mall"
        sightAngle 180
        lookStr "It's just another integral, vital part of the Galaxy Galleria Shopping Mall."
    )

    (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.")
            )
            (default 
                (super:doVerb(param1))
            )
        )
    )


    (method (onMe)
        return 1
    )

)
