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


(local
    local0
    local1
    local2

)
(instance public rm25 of Rm
    (properties
        picture 25
    )

    (method (init)
        (var temp0[50])
        (User:
            canInput(1)
            canControl(1)
        )
        Load(128 38)
        (eyes:
            init()
            setScript(BoredEyes)
        )
        (mouth:
            init()
            setScript(BoredMouth)
        )
        (super:init())
        (send global10:add(sine))
        (send global10:doit())
        Display(25 0 100 121 183 105 600 106 90 102 0)
        (switch (global12)
            (case 29
                (send global2:setScript(Welcome))
            )
            (case 280
                (if (> global244 0)
                    (send global2:setScript(PayUp))
                )
            )
        )
    )


    (method (doit)
        (super:doit())
    )


    (method (handleEvent pEvent)
        (var temp0[50])
        (if ((send pEvent:claimed))
            return 
        )
        (switch ((send pEvent:type))
            (case 128
                (if (Said('pay[/dinner,alien,man,clerk,him,bill]') or Said('give/bill'))
                    (if ((<> global12 280) or not global244)
                        proc255_0(25 1)
                    )(else
                        (if (>= global154 global244)
                            = global154 (- global154 global244)
                            (if (not global154)
                                (send gEgo:put(8 -1))
                            )
                            = global247 1
                            = global244 0
                            = global248 1
                            (if (global249)
                                (send global1:changeScore(10))
                            )
                            = global193 0
                            (send global2:setScript(LeaveRoom))
                        )(else
                            (send global2:setScript(noMoney))
                        )
                    )
                )(else
                    (if (Said('give,trade/crystal[/dinner]'))
                        proc255_0(25 2)
                    )(else
                        (if (Said('disembark[/area]') or Said('/bye'))
                            = global244 0
                            = global248 0
                            = global193 0
                            = global101 0
                            (send global2:newRoom(29))
                        )(else
                            (if (Said('look[/area]'))
                                proc255_0(25 3)
                            )(else
                                (if (Said('look/up,down,deck,ceiling'))
                                    proc255_0(25 4)
                                )(else
                                    (if (Said('look,read/menace'))
                                        proc255_0(25 5)
                                    )(else
                                        (if (Said('look/attire,cap'))
                                            proc255_0(25 6)
                                        )(else
                                            (if (Said('/bitch,her'))
                                                proc255_0(25 7)
                                            )(else
                                                (if (Said('look/man,clerk,alien,him,bystander,animal'))
                                                    proc255_0(25 8)
                                                )(else
                                                    (if (Said('look/eye'))
                                                        proc255_0(25 9)
                                                    )(else
                                                        (if (Said('look/lip'))
                                                            proc255_0(25 10)
                                                        )(else
                                                            (if (Said('look/cavity'))
                                                                proc255_0(25 11)
                                                            )(else
                                                                (if (Said('converse[/man,clerk,alien,him,bystander,animal]'))
                                                                    proc255_0(25 12)
                                                                )(else
                                                                    (if (Said('kiss/man,clerk,alien,him,bystander,animal'))
                                                                        proc255_0(25 13)
                                                                    )(else
                                                                        (if (Said('smell[/man,clerk,alien,him,bystander,animal]'))
                                                                            proc255_0(25 14)
                                                                        )(else
                                                                            (if (Said('consume'))
                                                                                proc255_0(25 15)
                                                                            )(else
                                                                                (if (((Said('look,read/menu') or Said('order')) or Said('order,buy/dinner')) or Said('converse/clerk'))
                                                                                    (send global2:newRoom(280))
                                                                                )
                                                                            )
                                                                        )
                                                                    )
                                                                )
                                                            )
                                                        )
                                                    )
                                                )
                                            )
                                        )
                                    )
                                )
                            )
                        )
                    )
                )
            )
            (case 4
                (if (== (send pEvent:message) 16384)
                    (send pEvent:claimed(1))
                    = global193 0
                    = global101 0
                    (send global2:setScript(LeaveRoom))
                )
            )
            (case 1
                (if ((((<= 119 (send pEvent:x)) and (<= (send pEvent:x) 202)) and (<= 163 (send pEvent:y))) and (<= (send pEvent:y) 190))
                    (send pEvent:claimed(1))
                    = global193 0
                    = global101 0
                    (send global2:setScript(LeaveRoom))
                )
            )
        )
    )

)
(instance Welcome of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                = global193 1
                (balloon:
                    init()
                    setCel(1)
                    stopUpd()
                )
                (mouth:
                    setLoop(0)
                    setCycle(Fwd)
                )
                = seconds 4
            )
            (case 1
                (balloon:setCel(2))
                = seconds 4
            )
            (case 2
                (mouth:
                    setCel(0)
                    stopUpd()
                )
                (balloon:dispose())
                (send global2:setScript(0))
                = global193 0
            )
        )
    )

)
(instance noMoney of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                = global193 1
                (if (== local0 1)
                    = local0 0
                    (eyes:setMotion(MoveTo 155 74))
                )
                (balloon:
                    init()
                    setCel(4)
                    stopUpd()
                )
                (mouth:
                    setLoop(0)
                    setCycle(Fwd)
                )
                = seconds 7
            )
            (case 1
                = global244 0
                = global247 0
                = global193 0
                = global101 0
                (send global2:newRoom(29))
            )
        )
    )

)
(instance LeaveRoom of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (balloon:dispose())
                = cycles 1
            )
            (case 1
                Display(25 16 108 local1)
                (send global2:newRoom(29))
            )
        )
    )

)
(instance PayUp of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                = global193 1
                (balloon:
                    init()
                    setCel(3)
                    stopUpd()
                )
                = local1 Display(Format(@global402 25 17 global244) 100 207 98 106 30 102 0 103 15 105 600 107)
                (mouth:
                    setLoop(0)
                    setCycle(Fwd)
                )
                = seconds 7
            )
            (case 1
                (mouth:
                    setCel(0)
                    stopUpd()
                )
                (balloon:dispose())
                = cycles 2
            )
            (case 2
                Display(25 16 108 local1)
                = global193 0
                (send global2:setScript(0))
            )
        )
    )

)
(instance BoredMouth of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                = seconds Random(5 15)
            )
            (case 1
                (if (<> (rm25:script) 0)
                    (self:changeState(0))
                )(else
                    (mouth:
                        setLoop(1)
                        setCel(Random(0 2))
                    )
                )
                (self:changeState(0))
            )
        )
    )

)
(instance BoredEyes of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                = seconds Random(3 12)
            )
            (case 1
                (if (<> (rm25:script) 0)
                    (self:changeState(0))
                )(else
                    (if (== local0 0)
                        = local0 1
                        (switch (Random(1 3))
                            (case 1
                                (eyes:setMotion(MoveTo 155 61 self))
                            )
                            (case 2
                                (eyes:setMotion(MoveTo 172 71 self))
                            )
                            (case 3
                                (eyes:setMotion(MoveTo 139 71 self))
                            )
                        )
                    )(else
                        = local0 0
                        (eyes:setMotion(MoveTo 155 71 self))
                    )
                )
            )
            (case 2
                (self:changeState(0))
            )
        )
    )

)
(instance eyes of Act
    (properties)

    (method (init)
        (super:init())
        (self:
            view(38)
            setLoop(2)
            posn(155 71)
            ignoreActors(1)
        )
    )

)
(instance mouth of Act
    (properties)

    (method (init)
        (super:init())
        (self:
            view(38)
            setLoop(1)
            setCel(0)
            posn(155 137)
            ignoreActors(1)
            cycleSpeed(2)
        )
    )

)
(instance balloon of Prop
    (properties)

    (method (init)
        (super:init())
        (self:
            view(38)
            setLoop(3)
            setCel(3)
            posn(206 119)
            setPri(15)
        )
    )

)
(instance sine of PV
    (properties
        y 89
        x 290
        view 38
        loop 3
        priority 15
        signal 16384
    )
)
