(include "sci.sh")
(use "Main")
(use "Class_255_0")
(use "ulence")
(use "SQRoom")
(use "PolyPath")
(use "Polygon")
(use "Class_950_0")
(use "Cycle")
(use "PicView")
(use "Obj")
(script 615)


(local
    local0
    local1
    local2
    local3

)
(instance public rm615 of SQRoom
    (properties
        picture 615
    )

    (method (init)
        (ulence:roomVer(22891))
        (switch (gWest)
            (case 610
                (send gEgo:
                    x(65531)
                    y(127)
                )
                (send gLongSong:stop())
                (send gLongSong2:fade(127 10 10 0))
                (self:setScript(climbDOWNstairs))
            )
            (default 
                (send gEgo:
                    x(65531)
                    y(127)
                )
                (send gLongSong2:
                    vol(127)
                    number(804)
                    loop(-1)
                    playBed()
                )
                (self:setScript(climbDOWNstairs))
            )
        )
        (send gEgo:
            init()
            show()
            illegalBits(0)
            ignoreActors(1)
        )
        (theWindow:init())
        (stairs:init())
        (door:init())
        (bar:init())
        (stage:init())
        (barTender:
            init()
            setPri(14)
            posn(Random(104 210) 183)
            setLoop(Random(2 3))
            setScript(barTenderScript)
        )
        (band:
            init()
            setCycle(Fwd)
        )
        (if (not (send gEgo:has(13)))
            (theMatches:init())
        )
        (self:
            setFeatures(daFloor daRoom writing)
            setRegions(706)
        )
        (super:init())
        (if (not proc0_6(75))
            (self:addObstacle((send ((Polygon:new())):
                    type(2)
                    init(0 118 22 161 21 169 74 183 86 168 232 168 242 182 299 160 269 147 259 148 218 128 203 144 161 144 121 144 105 127 77 149 65 144 35 157 0 104 0 0 319 0 319 189 0 189)
                    yourself()
                )
))
            (mono1:init())
            (mono2:init())
            (mono3:init())
        )(else
            (self:addObstacle((send ((Polygon:new())):
                    type(2)
                    init(0 118 22 161 21 169 68 183 248 183 299 160 269 147 259 148 218 128 203 144 161 144 121 144 105 127 77 149 65 144 35 157 0 104 0 0 319 0 319 189 0 189)
                    yourself()
                )
))
        )
        Load(rsVIEW 618)
        Load(rsVIEW 620)
        Load(rsVIEW 619)
    )


    (method (doit param1)
        (if (script)
            0
        )(else
            (if (not proc0_6(75) and (send gEgo:inRect(87 155 210 180)))
                (self:setScript(lookMonoGuys))
            )(else
                (if (& (send gEgo:onControl(1)) $0008)
                    proc0_2()
                    = local2 1
                    (self:setScript(exitScript))
                )
            )
        )
        (super:doit(rest param1))
        (if (> (send gEgo:y) 176)
            (send gEgo:setPri(13))
        )(else
            (send gEgo:setPri(-1))
        )
    )

)
(instance climbDOWNstairs of Script
    (properties)

    (method (changeState newState)
        (var temp0[2])
        (switch (= state newState)
            (case 0
                proc0_2()
                = cycles 1
            )
            (case 1
                (send gEgo:setMotion(MoveTo 27 159 self))
            )
            (case 2
                = seconds 2
            )
            (case 3
                (if (not (ulence:beenInBar))
                    Print("The old bar is still here. The smell of new (and used) Kerona Ale stinks-up the place. Just the aroma leads you to vividly remember your previous drunken visit here. You break out in a cold sweat.")
                    (ulence:beenInBar(1))
                )
                proc0_3()
                (self:dispose())
            )
        )
    )

)
(instance lookMonoGuys of Script
    (properties)

    (method (changeState newState)
        (var temp0[2])
        (switch (= state newState)
            (case 0
                proc0_2()
                (if (local1)
                    = local1 0
                    (self:cue())
                )(else
                    (send gEgo:setMotion(PolyPath 117 159 self))
                )
            )
            (case 1
                (send gEgo:setHeading(135 self))
            )
            (case 2
                (mono1:setCycle(End))
                (mono2:setCycle(End))
                (mono3:setCycle(End))
                = seconds 4
            )
            (case 3
                (send gLongSong2:fade(85 10 10 0))
                (send global2:newRoom(620))
            )
        )
    )

)
(instance exitScript of Script
    (properties)

    (method (changeState newState)
        (var temp0[2])
        (switch (= state newState)
            (case 0
                proc0_2()
                (if (local2)
                    (self:cue())
                )(else
                    (send gEgo:setMotion(PolyPath 34 160 self))
                )
            )
            (case 1
                (send gEgo:setMotion(MoveTo 65531 127 self))
            )
            (case 2
                (send gLongSong2:fade(70 10 10 0))
                (send global2:newRoom(610))
            )
        )
    )

)
(instance barTenderScript of Script
    (properties)

    (method (changeState newState)
        (var temp0[2])
        (switch (= state newState)
            (case 0
                = seconds Random(2 5)
            )
            (case 1
                (barTender:
                    setCycle(Walk)
                    setLoop(-1)
                    setMotion(MoveTo Random(104 210) 183 self)
                )
            )
            (case 2
                (if (> Random(0 100) 80)
                    (self:init())
                )(else
                    = cycles Random(2 6)
                )
            )
            (case 3
                (if (> Random(0 100) 50)
                    (barTender:setLoop(3))
                )(else
                    (barTender:setLoop(2))
                )
                (self:init())
            )
        )
    )

)
(instance getMatches of Script
    (properties)

    (method (changeState newState)
        (var temp0[2])
        (switch (= state newState)
            (case 0
                proc0_2()
                (if (proc0_6(75))
                    (send gEgo:setMotion(PolyPath 89 181 self))
                )(else
                    (send gEgo:setMotion(PolyPath 102 174 self))
                )
            )
            (case 1
                (if (proc0_6(75))
                    (send gEgo:setHeading(180 self))
                )(else
                    = local1 1
                    Print("Your attempt to get the matches failed.")
                    (send global2:setScript(lookMonoGuys))
                    (self:dispose())
                )
            )
            (case 2
                proc0_11(76 5)
                (send gEgo:get(13))
                (theMatches:dispose())
                Print("You pick up the book of matches.")
                proc0_1((send gEgo:loop) 0)
                proc0_3()
                (self:dispose())
            )
        )
    )

)
(instance talkToBartender of Script
    (properties)

    (method (changeState newState)
        (var temp0[2])
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gEgo:setMotion(PolyPath 152 184 self))
            )
            (case 1
                (send gEgo:setLoop(2))
                (barTender:setScript(0))
                (if (< (barTender:x) 147)
                    (barTender:
                        setLoop(0)
                        setCycle(Fwd)
                        moveSpeed(1)
                        cycleSpeed(0)
                        setMotion(MoveTo 152 187 self)
                    )
                )(else
                    (if (> (barTender:x) 169)
                        (barTender:
                            setLoop(1)
                            setCycle(Fwd)
                            moveSpeed(1)
                            cycleSpeed(0)
                            setMotion(MoveTo 152 187 self)
                        )
                    )(else
                        = seconds 1
                    )
                )
            )
            (case 2
                (barTender:
                    setLoop(3)
                    setCycle(0)
                    setMotion(0)
                )
                = seconds 1
            )
            (case 3
                Print("You speak to the bartender. He looks up at you and says \"Hey! Aren't you the guy who broke my slot machine? You owe me some money!\"")
                Print("You explain that you are really very busy and must be going.")
                proc0_1()
                proc0_3()
                (barTender:setScript(barTenderScript))
                (self:dispose())
            )
        )
    )

)
(instance daFloor of Feature
    (properties
        x 159
        y 112
        nsTop 36
        nsBottom 189
        nsRight 319
        description "floor."
        onMeCheck 16
        lookStr "You see the bar's floor."
    )
)
(instance daRoom of Feature
    (properties
        x 159
        y 112
        nsTop 36
        nsBottom 189
        nsRight 319
        description "room."
        onMeCheck 32
        lookStr "This looks like the bar in Space Quest I."
    )
)
(instance writing of Feature
    (properties
        x 30
        y 117
        nsTop 97
        nsLeft 26
        nsBottom 138
        nsRight 34
        description "writing"
        sightAngle 90
    )

    (method (doVerb param1 param2 param3)
        (switch (param1)
            (case 1
                (if (<> ++local3 6)
                    Print("There's some writing on the\nwall above the stairs.\nMaybe it says: Watch Your Step.")
                )(else
                    Print("There's some writing on the\nwall above the stairs.\nIt says...")
                    Print("  Quality Assurance by: \n\n     Mike Harian\n     Dan Scott\n     Tate Deloach\n     Keri Cooper\n     Bill Shockley\n     Neil Matz\n     Gordon Owens\n     Dave Fleming\n     Danny Woolard\n     Chris Carr\n     John Ratcliffe\n     Robin Bradley\n     Joe Perry\n     Mike Pickhinke\n     Sharon Smith\n     Sharon Simmons\n     Kevin Ray\n")
                )
            )
            (default 
                (super:doVerb(param1 rest param3))
            )
        )
    )

)
(instance mono1 of Prop
    (properties
        x 193
        y 180
        z 10
        description "mono1"
        view 620
        loop 1
        priority 14
        signal 16400
    )

    (method (doVerb param1 param2 param3)
        (switch (param1)
            (case 4
                (send global2:setScript(lookMonoGuys))
            )
            (case 2
                (send global2:setScript(lookMonoGuys))
            )
            (case 11
                Print("You try to get closer to do that...")
                (send global2:setScript(lookMonoGuys))
            )
            (case 10
                Print("You try to get closer to do that...")
                (send global2:setScript(lookMonoGuys))
            )
            (case 1
                Print("Some rather drab looking individuals\nhog space at the bar. This guy's really ugly!")
            )
            (default 
                (super:doVerb(param1 rest param3))
            )
        )
    )

)
(instance mono2 of Prop
    (properties
        x 118
        y 180
        z 10
        description "mono2"
        view 620
        loop 2
        priority 14
        signal 16400
    )

    (method (doVerb param1 param2 param3)
        (switch (param1)
            (case 2
                (send global2:setScript(lookMonoGuys))
            )
            (case 4
                (send global2:setScript(lookMonoGuys))
            )
            (case 1
                Print("Some rather drab looking individuals\nhog space at the bar. This guy's too ugly to describe!")
            )
            (default 
                (super:doVerb(param1 rest param3))
            )
        )
    )

)
(instance mono3 of Prop
    (properties
        x 157
        y 182
        z 10
        description "mono3"
        view 620
        loop 3
        priority 14
        signal 16400
    )

    (method (doVerb param1 param2 param3)
        (switch (param1)
            (case 2
                (send global2:setScript(lookMonoGuys))
            )
            (case 4
                (send global2:setScript(lookMonoGuys))
            )
            (case 1
                Print("Some rather drab looking individuals\nhog space at the bar. This guy's the ugliest of all!")
            )
            (default 
                (super:doVerb(param1 rest param3))
            )
        )
    )

)
(instance stage of Feature
    (properties
        x 163
        y 118
        nsTop 99
        nsLeft 117
        nsBottom 138
        nsRight 210
        description "stage"
        sightAngle 180
        onMeCheck 4
        lookStr "There is a stage here with two guys singing."
    )
)
(instance bar of Feature
    (properties
        x 158
        y 176
        nsTop 164
        nsLeft 73
        nsBottom 188
        nsRight 243
        description "bar"
        sightAngle 180
        onMeCheck 2
        lookStr "There's the bar just as you remember it."
    )

    (method (doVerb param1 param2 param3)
        (switch (param1)
            (case 4
                ++local0
                (if (not proc0_6(15))
                    Print("You step over to talk to the bartender. As you do you attract the attention of the crude fellows at the bar.")
                    (send global2:setScript(lookMonoGuys))
                )(else
                    (switch (local0)
                        (case 1
                            (send global2:setScript(talkToBartender))
                        )
                        (default 
                            Print("You don't want to get into that mess again.")
                        )
                    )
                )
            )
            (default 
                (super:doVerb(param1 rest param3))
            )
        )
    )

)
(instance door of Feature
    (properties
        x 29
        y 127
        nsTop 94
        nsLeft 6
        nsBottom 160
        nsRight 53
        description "door"
        sightAngle 180
        onMeCheck 16384
        lookStr "It's an incremental elevation adjustment device."
    )

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

)
(instance theMatches of View
    (properties
        x 90
        y 183
        z 10
        nsTop 170
        nsLeft 87
        nsBottom 176
        nsRight 94
        description "matches"
        view 620
        priority 14
        signal 16400
    )

    (method (doVerb param1 param2 param3)
        (switch (param1)
            (case 1
                Print("You see a book of matches\non the bar counter top.")
            )
            (case 2
                (send global2:setScript(getMatches))
            )
            (default 
                (super:doVerb(param1 rest param3))
            )
        )
    )

)
(instance barTender of Actor
    (properties
        description "bartender"
        lookStr "The bartender is a plain man nearly devoid of features."
        view 618
        signal 16384
        illegalBits 0
    )

    (method (doVerb param1 param2 param3)
        (switch (param1)
            (case 1
                Print("You see a man behind the bar serving drinks.")
            )
            (case 2
                Print("You have no time for a drink.")
            )
            (case 4
                ++local0
                (if (not proc0_6(15))
                    Print("You step over to talk to the bartender. As you do you attract the attention of the crude fellows at the bar.")
                    (send global2:setScript(lookMonoGuys))
                )(else
                    (switch (local0)
                        (case 1
                            (send global2:setScript(talkToBartender))
                        )
                        (default 
                            Print("You don't want to get into that mess again.")
                        )
                    )
                )
            )
            (default 
                (super:doVerb(param1 rest param3))
            )
        )
    )

)
(instance band of Prop
    (properties
        x 160
        y 115
        description "singers"
        lookStr "A truly groovy band cranks out tired old tunes."
        view 619
        signal 24576
    )

    (method (doVerb param1 param2 param3)
        (switch (param1)
            (case 1
                Print("You see two guys singing.")
            )
            (case 2
                Print("The band members have nothing of interest.")
            )
            (case 4
                Print("They don't have time to talk right now.")
            )
            (case 11
                Print("Fortunately, they play much better than they smell.")
            )
            (case 3
                (if (<> param2 0)
                    Print("They are not interested in that.")
                )(else
                    Print("You don't have enough to afford their services.")
                )
            )
            (default 
                (super:doVerb(param1 rest param3))
            )
        )
    )

)
(instance theWindow of Feature
    (properties
        x 164
        y 61
        nsTop 52
        nsLeft 154
        nsBottom 70
        nsRight 175
        description "window"
        sightAngle 180
        lookStr "From your position in the bar, you can only see sky through the window."
    )
)
(instance stairs of Feature
    (properties
        x 26
        y 128
        nsTop 91
        nsLeft 6
        nsBottom 165
        nsRight 46
        description "stairs"
        sightAngle 180
        onMeCheck 8
        lookStr "It's an incremental elevation adjustment device."
    )

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

)
