(version 2)
(include "sci.sh")
(exports
    0 rm29
)
(use "Main")
(use "Class_255_0")
(use "Cycle")
(use "Game")
(use "User")
(use "TheMenuBar")
(use "Feature")
(use "Obj")
(script 29)


(local
    local0
    local1
    local2
    local3
    local4
    local5
    local6
    local7

)
(instance public rm29 of Rm
    (properties
        picture 29
        east 28
    )

    (method (init)
        (var temp0[50])
        (User:
            canInput(1)
            canControl(1)
        )
        Load(128 56)
        Load(128 57)
        Load(128 59)
        Load(128 85)
        (super:init())
        (door:
            init()
            stopUpd()
        )
        (clerk:
            init()
            stopUpd()
        )
        (send gEgo:init())
        (bully:
            init()
            stopUpd()
        )
        (if (> global124 0)
            (al3:
                init()
                stopUpd()
                setScript(al3Script)
            )
            (al1Head:
                init()
                stopUpd()
                setScript((al1Script:new()))
            )
            (al2Head:
                init()
                stopUpd()
                setScript((al1Script:new()))
            )
        )(else
            (al3:
                init()
                addToPic()
            )
            (al1Head:
                init()
                addToPic()
            )
            (al2Head:
                init()
                addToPic()
            )
        )
        (send global10:add(al1 al2 machine))
        (send global10:doit())
        = local0 2
        = local4 0
        = local6 1
        = local7 1
        (switch (global12)
            (case 25
                proc0_3()
                (send gEgo:
                    init()
                    loop(3)
                    cel(0)
                    posn(286 130)
                )
                (if (global247 and global248)
                    proc0_2()
                    = global248 0
                    (send global2:setScript(makeBurger))
                )
                = local1 1
                (send gLongSong:
                    number(16)
                    loop(-1)
                    play()
                )
            )
            (case 28
                proc0_3()
                (send gEgo:init())
                (if (< (send gEgo:y) 110)
                    (send gEgo:posn(200 100))
                )
            )
            (case 280
                proc0_3()
                (send gEgo:
                    init()
                    posn(gGEgoX gGEgoY)
                )
                (send gLongSong:
                    number(16)
                    loop(-1)
                    play()
                )
            )
            (case 290
                (TheMenuBar:draw())
                (SL:enable())
                proc0_3()
                proc0_1(0 0)
                (send gEgo:posn(172 111))
                (send gLongSong:
                    number(16)
                    loop(-1)
                    play()
                )
            )
            (default 
                (send gEgo:
                    init()
                    posn(172 111)
                )
            )
        )
    )


    (method (doit)
        (super:doit())
        (if ((== (send gEgo:onControl(0)) 4) or (== (send gEgo:onControl(0)) 5))
            (send global2:newRoom(28))
        )
        (if (((== (send gEgo:onControl(0)) 16) or (== (send gEgo:onControl(0)) 17)) and not script)
            (send global2:setScript(SitDown))
        )
        (if ((send gEgo:inRect(282 125 319 135)))
            (if (global247)
                (if ((not local1 and not global248) and not (send gEgo:has(17)))
                    (send global2:newRoom(25))
                )
            )(else
                (if (not local2 and not local1)
                    proc255_0(29 0)
                    = local2 1
                )
            )
        )(else
            = local1 0
            = local2 0
        )
        (if ((== (send gEgo:onControl(1)) 8) and not script)
            (send global2:setScript(Bully))
        )
    )


    (method (handleEvent pEvent)
        (var temp0[50])
        (if ((send pEvent:claimed))
            return 
        )
        (switch ((send pEvent:type))
            (case 128
                (if (Said('look>'))
                    (if (Said('/pane') or Said('<out'))
                        proc255_0(29 1)
                    )(else
                        (if (Said('/deck,ceiling') or Said('<up,down'))
                            proc255_0(29 2)
                        )(else
                            (if (Said('/partition'))
                                proc255_0(29 3)
                            )(else
                                (if (Said('/clerk'))
                                    proc255_0(29 4)
                                )(else
                                    (if (Said('/alien,being,man,bystander,folk,animal,customer'))
                                        proc255_0(29 5)
                                    )(else
                                        (if (Said('/craft'))
                                            proc255_0(29 6)
                                        )(else
                                            (if (Said('/counter'))
                                                proc255_0(29 7)
                                            )(else
                                                (if (Said('/door'))
                                                    proc255_0(29 8)
                                                )(else
                                                    (if (Said('/menace'))
                                                        proc255_0(29 9)
                                                    )(else
                                                        (if (Said('/dinner,bag,drink'))
                                                            (if ((send gEgo:has(17)))
                                                                (send pEvent:claimed(0))
                                                            )(else
                                                                (if (== local7 0)
                                                                    proc255_0(29 10)
                                                                )(else
                                                                    proc255_0(29 11)
                                                                )
                                                            )
                                                        )(else
                                                            (if (Said('/astro,astro,grafitti,game,device,comp[<grafitti]') or Said('/astro<astro'))
                                                                (if ((send gEgo:inRect(158 94 200 124)))
                                                                    (send global2:newRoom(290))
                                                                )(else
                                                                    proc255_0(29 12)
                                                                )
                                                            )(else
                                                                (if (Said('/table,chair,booth'))
                                                                    proc255_0(29 13)
                                                                )(else
                                                                    (if (Said('/menu'))
                                                                        (if (== local6 0)
                                                                            proc255_0(29 14)
                                                                        )(else
                                                                            = gGEgoX (send gEgo:x)
                                                                            = gGEgoY (send gEgo:y)
                                                                            (send global2:newRoom(280))
                                                                        )
                                                                    )(else
                                                                        (if (Said('[<around,at,in][/area,cafe]'))
                                                                            proc255_0(29 15)
                                                                        )
                                                                    )
                                                                )
                                                            )
                                                        )
                                                    )
                                                )
                                            )
                                        )
                                    )
                                )
                            )
                        )
                    )
                )(else
                    (if (Said('open,close/door'))
                        proc255_0(29 16)
                    )(else
                        (if (Said('play/astro,astro,grafitti,game,device[<grafitti]') or Said('play/astro<astro'))
                            (if ((send gEgo:inRect(158 94 200 124)))
                                (send global2:newRoom(290))
                            )(else
                                proc255_0(29 12)
                            )
                        )(else
                            (if (Said('beat,tilt/grafitti,game,device[<grafitti]'))
                                (if ((send gEgo:inRect(158 94 200 124)))
                                    proc255_0(29 17)
                                )(else
                                    proc255_0(29 12)
                                )
                            )(else
                                (if (Said('order,buy,get,ask[/dinner,dinner,burger,drink]') or Said('converse/clerk'))
                                    (if (not (send gEgo:inRect(282 125 319 135)))
                                        proc255_0(29 18)
                                    )(else
                                        (if ((send gEgo:has(17)))
                                            proc255_0(29 19)
                                        )(else
                                            (if (not global248)
                                                (send global2:newRoom(25))
                                            )(else
                                                proc255_0(29 0)
                                            )
                                        )
                                    )
                                )(else
                                    (if (Said('read/menu'))
                                        (if (== local6 0)
                                            proc255_0(29 14)
                                        )(else
                                            = gGEgoX (send gEgo:x)
                                            = gGEgoY (send gEgo:y)
                                            (send global2:newRoom(280))
                                        )
                                    )(else
                                        (if (Said('read/menace'))
                                            proc255_0(29 9)
                                        )(else
                                            (if (Said('ask,converse/alien,being,man,bystander,folk,animal,customer'))
                                                proc255_0(29 20)
                                            )(else
                                                (if (Said('converse'))
                                                    proc255_0(29 21)
                                                )(else
                                                    (if (Said('kiss/alien,being,man,bystander,folk,animal,customer'))
                                                        proc255_0(29 22)
                                                    )(else
                                                        (if (Said('smell[/man,alien,being,him,bystander,animal,customer]'))
                                                            proc255_0(29 23)
                                                        )(else
                                                            (if (Said('down,sit[<down]'))
                                                                (if (== local6 0)
                                                                    proc255_0(29 24)
                                                                )(else
                                                                    (if ((send gEgo:inRect(173 123 232 156)))
                                                                        (send global2:setScript(SitDown))
                                                                    )(else
                                                                        proc255_0(29 25)
                                                                    )
                                                                )
                                                            )(else
                                                                (if (Said('up,(get<up),stand[/up]'))
                                                                    (if (== local6 1)
                                                                        proc255_0(29 26)
                                                                    )(else
                                                                        (send global2:setScript(StandUp))
                                                                    )
                                                                )(else
                                                                    (if (Said('consume[<dinner]'))
                                                                        (if (<> local6 0)
                                                                            proc255_0(29 27)
                                                                        )(else
                                                                            (if ((send gEgo:has(17)))
                                                                                (send global2:setScript(EgoEating))
                                                                            )(else
                                                                                proc255_0(29 28)
                                                                            )
                                                                        )
                                                                    )(else
                                                                        (if (Said('get[<up]/bag'))
                                                                            (if ((send gEgo:has(17)))
                                                                                proc255_0(29 29)
                                                                            )(else
                                                                                (if (== local7 0)
                                                                                    proc255_0(29 30)
                                                                                )(else
                                                                                    proc255_0(29 31)
                                                                                )
                                                                            )
                                                                        )(else
                                                                            (if (Said('cast,get[<up,away]/garbage') or Said('clean/table'))
                                                                                (if ((send gEgo:has(17)))
                                                                                    proc255_0(29 32)
                                                                                )(else
                                                                                    (if (== local7 0)
                                                                                        proc255_0(29 30)
                                                                                    )(else
                                                                                        proc255_0(29 33)
                                                                                    )
                                                                                )
                                                                            )
                                                                        )
                                                                    )
                                                                )
                                                            )
                                                        )
                                                    )
                                                )
                                            )
                                        )
                                    )
                                )
                            )
                        )
                    )
                )
            )
            (case 64
                (if (== local6 0)
                    (switch ((send pEvent:message))
                        (case 1
                            (send global2:setScript(StandUp))
                            (send pEvent:claimed(1))
                        )
                        (case 3
                            (send global2:setScript(StandUp))
                            (send pEvent:claimed(1))
                        )
                        (case 5
                            (send pEvent:claimed(1))
                            return 
                        )
                        (case 8
                            (send pEvent:claimed(1))
                            return 
                        )
                        (case 2
                            (send global2:setScript(StandUp))
                            (send pEvent:claimed(1))
                        )
                        (case 4
                            (send pEvent:claimed(1))
                            return 
                        )
                        (case 6
                            (send pEvent:claimed(1))
                            return 
                        )
                        (case 7
                            (send pEvent:claimed(1))
                            return 
                        )
                        (case 0
                            (send pEvent:claimed(1))
                            return 
                        )
                    )
                )
            )
            (case 1
                (if (== local6 0)
                    (send global2:setScript(StandUp))
                    (send pEvent:claimed(1))
                )
            )
        )
    )


    (method (newRoom newRoomNumber)
        (if (<> newRoomNumber 28)
            (send gLongSong:stop())
        )
        (super:newRoom(newRoomNumber))
    )

)
(instance makeBurger of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (clerk:
                    setLoop(3)
                    setMotion(MoveTo 248 103 self)
                )
            )
            (case 1
                = seconds 2
            )
            (case 2
                (clerk:
                    setLoop(4)
                    setMotion(MoveTo 297 105 self)
                )
            )
            (case 3
                (clerk:setLoop(1))
                = seconds 2
            )
            (case 4
                (clerk:setLoop(0))
                (bag:init())
                (balloon:init())
                = seconds 4
            )
            (case 5
                (balloon:dispose())
                (bag:dispose())
                proc255_0(29 34)
                (send gEgo:get(17))
                proc0_3()
                (send global2:setScript(0))
            )
        )
    )

)
(instance SitDown of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gEgo:
                    illegalBits(0)
                    setMotion(MoveTo 186 141 self)
                )
            )
            (case 1
                (send gEgo:
                    view(85)
                    setLoop(7)
                    setPri(15)
                    setCel(0)
                )
                (if ((send gEgo:has(17)))
                    (send gEgo:setCycle(End self))
                )(else
                    (send gEgo:setCycle(CT 4 1 self))
                )
            )
            (case 2
                proc0_3()
                = local6 0
                (send global2:setScript(0))
            )
        )
    )

)
(instance StandUp of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (if (== local7 0)
                    (bag2:init())
                    (send gEgo:put(17))
                )
                (send gEgo:
                    setLoop(7)
                    setCel(4)
                    setCycle(Beg self)
                )
            )
            (case 1
                (send gEgo:posn(191 139))
                proc0_10()
                proc0_1(2 0)
                = local6 1
                proc0_3()
                (send global2:setScript(0))
            )
        )
    )

)
(instance EgoEating of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                = global159 1
                = local6 2
                = local5 7
                (send gEgo:
                    setLoop(0)
                    setCel(0)
                    setCycle(End self)
                )
            )
            (case 1
                (if (<> --local5 0)
                    (switch (Random(1 2))
                        (case 1
                            (self:changeState(10))
                        )
                        (case 2
                            (self:changeState(20))
                        )
                    )
                )(else
                    (if (global249)
                        (self:changeState(30))
                    )(else
                        (self:changeState(40))
                    )
                )
            )
            (case 10
                (send gEgo:
                    setLoop(1)
                    setCel(0)
                    setCycle(End self)
                )
            )
            (case 11
                (send gEgo:setCycle(Beg self))
            )
            (case 12
                (send gEgo:
                    setLoop(2)
                    setCycle(Fwd)
                )
                = seconds 2
            )
            (case 13
                (send gEgo:
                    setLoop(3)
                    setCycle(End self)
                )
            )
            (case 14
                (send gEgo:
                    setLoop(2)
                    setCel(0)
                )
                = cycles 10
            )
            (case 15
                (self:changeState(1))
            )
            (case 20
                (send gEgo:
                    setLoop(4)
                    setCel(0)
                    setCycle(End self)
                )
            )
            (case 21
                (send gEgo:
                    setLoop(5)
                    setCycle(Fwd)
                )
                = seconds 3
            )
            (case 22
                (send gEgo:
                    setLoop(4)
                    setCel(2)
                    setCycle(Beg self)
                )
            )
            (case 23
                (send gEgo:
                    setLoop(2)
                    setCel(0)
                )
                = cycles 10
            )
            (case 24
                (self:changeState(1))
            )
            (case 30
                (send gEgo:
                    setLoop(1)
                    setCel(0)
                    setCycle(End self)
                )
            )
            (case 31
                (send gEgo:setCycle(Beg self))
            )
            (case 32
                (send gEgo:
                    setLoop(2)
                    setCycle(Fwd)
                )
                = seconds 4
            )
            (case 33
                proc255_0(29 35)
                (send gEgo:get(7))
                (send global1:changeScore(10))
                = seconds 3
            )
            (case 34
                (self:changeState(40))
            )
            (case 40
                proc255_0(29 36)
                (send gEgo:setCycle(0))
                (User:canInput(1))
                = global159 0
                = global249 0
                = global244 0
                (send gEgo:put(17))
                = local7 0
                = local6 0
                (send global2:setScript(0))
            )
        )
    )

)
(instance Bully of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (if (not local4)
                    = local4 1
                    proc0_2()
                    (bBalloon:init())
                    = seconds 3
                )(else
                    proc0_2()
                    (self:changeState(20))
                )
            )
            (case 1
                (bBalloon:dispose())
                ShakeScreen(5)
                (pow:
                    init()
                    setCycle(End)
                )
                (door:setCycle(End self))
            )
            (case 2
                (send gEgo:
                    view(57)
                    setLoop(5)
                    setCel(0)
                    posn(146 89)
                    xStep(5)
                    yStep(3)
                    cycleSpeed(1)
                    setCycle(End)
                    setMotion(MoveTo 169 113 self)
                    ignoreControl(1)
                )
            )
            (case 3
                (stars:
                    init()
                    setCycle(Fwd)
                )
                (pow:
                    setLoop(4)
                    setCel(0)
                    posn((send gEgo:x) + (send gEgo:y) 5)
                    setPri(15)
                    setCycle(Fwd)
                )
                = seconds 2
            )
            (case 4
                (pow:dispose())
                = cycles 2
            )
            (case 5
                (bully:
                    setCycle(Walk)
                    setMotion(MoveTo 146 89 self)
                )
            )
            (case 6
                (bully:setMotion(MoveTo 158 97 self))
            )
            (case 7
                (door:setCycle(Beg))
                (bully:setMotion(MoveTo 209 97 self))
            )
            (case 8
                (bully:stopUpd())
                (stars:dispose())
                (send gEgo:
                    setLoop(6)
                    setCycle(End self)
                )
            )
            (case 9
                proc0_1(1 0)
                proc0_3()
                (send global2:setScript(0))
            )
            (case 20
                (door:setCycle(End))
                (bully:
                    setCycle(Walk)
                    setMotion(MoveTo 158 97 self)
                )
            )
            (case 21
                (bully:setMotion(MoveTo 146 89 self))
            )
            (case 22
                (bully:setMotion(MoveTo 122 89 self))
            )
            (case 23
                (door:setCycle(Beg self))
            )
            (case 24
                (bBalloon:
                    init()
                    setCel(1)
                )
                = seconds 3
            )
            (case 25
                (bBalloon:dispose())
                ShakeScreen(5)
                (pow:
                    init()
                    setLoop(3)
                    setCel(0)
                    posn(145 81)
                    setPri(15)
                    setCycle(End)
                )
                = seconds 2
            )
            (case 26
                proc0_17(0 0 10 12)
            )
        )
    )

)
(instance al1Script of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                = seconds Random(2 10)
            )
            (case 1
                (if ((local3 or (<> (send gEgo:mover) 0)) or (<> (rm29:script) 0))
                    (self:changeState(5))
                )(else
                    = cycles 2
                )
            )
            (case 2
                = local3 1
                (send client:setCycle(Fwd))
                = seconds 3
            )
            (case 3
                (send client:stopUpd())
                = local3 0
                = seconds Random(10 20)
            )
            (case 4
                (self:changeState(1))
            )
            (case 5
                = cycles 2
            )
            (case 6
                (self:changeState(1))
            )
        )
    )

)
(instance al3Script of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                = seconds Random(3 14)
            )
            (case 1
                (if ((local3 or (<> (send gEgo:mover) 0)) or (<> (rm29:script) 0))
                    (self:changeState(6))
                )(else
                    = cycles 2
                )
            )
            (case 2
                = local3 1
                (send client:setCycle(End))
                = seconds 2
            )
            (case 3
                (send client:setCycle(Beg self))
            )
            (case 4
                (send client:stopUpd())
                = local3 0
                = seconds Random(10 20)
            )
            (case 5
                (self:changeState(1))
            )
            (case 6
                = cycles 2
            )
            (case 7
                (self:changeState(1))
            )
        )
    )

)
(instance clerk of Act
    (properties)

    (method (init)
        (super:init())
        (self:
            view(59)
            loop(0)
            posn(297 105)
            ignoreActors(1)
        )
    )

)
(instance bag of View
    (properties)

    (method (init)
        (super:init())
        (self:
            view(59)
            setLoop(2)
            setCel(0)
            posn(295 108)
            setPri(9)
            ignoreActors(1)
        )
    )

)
(instance bag2 of Prop
    (properties)

    (method (init)
        (super:init())
        (self:
            view(85)
            setLoop(6)
            setCel(0)
            posn(177 153)
            setPri(15)
            ignoreActors(1)
        )
    )

)
(instance balloon of View
    (properties)

    (method (init)
        (super:init())
        (self:
            view(59)
            setLoop(5)
            setCel(0)
            posn(297 85)
            ignoreActors(1)
        )
    )

)
(instance bully of Act
    (properties)

    (method (init)
        (super:init())
        (self:
            view(57)
            loop(0)
            posn(122 89)
            ignoreActors(1)
            setStep(3 2)
        )
    )

)
(instance bBalloon of View
    (properties)

    (method (init)
        (super:init())
        (self:
            view(57)
            setLoop(2)
            setCel(0)
            posn(177 88)
            setPri(15)
            ignoreActors(1)
        )
    )

)
(instance pow of Prop
    (properties)

    (method (init)
        (super:init())
        (self:
            view(57)
            setLoop(3)
            setCel(0)
            posn(145 81)
            setPri(15)
        )
    )

)
(instance stars of Prop
    (properties)

    (method (init)
        (super:init())
        (self:
            view(57)
            setLoop(7)
            setCel(0)
            posn(+ (send gEgo:x) 3 - (send gEgo:y) 9)
            setPri(+ (send gEgo:priority) 1)
        )
    )

)
(instance al1 of PV
    (properties
        y 164
        x 237
        view 56
        loop 1
        cel 1
        priority 15
        signal 16384
    )
)
(instance al2 of PV
    (properties
        y 134
        x 140
        view 56
        loop 1
        cel 2
        priority 15
        signal 16384
    )
)
(instance machine of PV
    (properties
        y 111
        x 190
        view 56
        loop 1
    )
)
(instance al3 of Prop
    (properties)

    (method (init)
        (super:init())
        (self:
            view(56)
            setLoop(4)
            setCel(0)
            posn(289 170)
            setPri(15)
        )
    )

)
(instance al1Head of Prop
    (properties)

    (method (init)
        (super:init())
        (self:
            view(56)
            setLoop(2)
            setCel(0)
            posn(141 119)
            setPri(15)
            ignoreActors(1)
        )
    )

)
(instance al2Head of Prop
    (properties)

    (method (init)
        (super:init())
        (self:
            view(56)
            setLoop(3)
            setCel(0)
            posn(226 149)
            setPri(15)
            ignoreActors(1)
        )
    )

)
(instance door of Prop
    (properties)

    (method (init)
        (super:init())
        (self:
            view(56)
            setLoop(0)
            setCel(0)
            posn(156 95)
            setPri(6)
            ignoreActors(1)
        )
    )


    (method (doit)
        (super:doit())
        (if (not (rm29:script))
            (if ((== (send gEgo:onControl(0)) 2) or (== (send gEgo:onControl(0)) 3))
                (if (> local0 1)
                    = local0 1
                    (self:setCycle(End self))
                )
            )(else
                (if (< local0 2)
                    = local0 3
                    (self:setCycle(Beg self))
                )
            )
        )
    )


    (method (cue)
        (door:stopUpd())
        = local0 
            (if (== local0 1)
                0
            )(else
                2
            )
    )

)
