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


(local
    local0

)
(instance public rm614 of SQRoom
    (properties
        picture 614
        south 611
        west 613
    )

    (method (init)
        (ulence:roomVer(22891))
        (switch (gWest)
            (case 611
                (if (> (send gEgo:x) 245)
                    proc0_2()
                    (send gEgo:
                        posn(254 241)
                        setMotion(MoveTo 320 174)
                    )
                )(else
                    (if (> (send gEgo:x) 230)
                        (send gEgo:x(Random(202 302)))
                    )(else
                        (if (> (send gEgo:x) 195)
                            (send gEgo:x(Random(85 201)))
                        )(else
                            (send gEgo:x(Random(20 84)))
                        )
                    )
                )
            )
            (default 
                (send gEgo:
                    x(24)
                    y(181)
                )
            )
        )
        (send gEgo:
            init()
            ignoreActors(1)
            illegalBits(0)
        )
        (super:init())
        (self:
            setFeatures(sign1 sign2 gate building)
            setRegions(706)
            addObstacle((send ((Polygon:new())):
                    type(2)
                    init(0 0 319 0 319 189 317 189 317 152 266 161 206 161 179 153 86 153 83 161 0 161)
                    yourself()
                )
)
        )
        (if ((> Random(0 100) 20) and (== (ulence:status) 1))
            (ulence:
                status(2)
                bikerComing(1)
            )
            Load(rsVIEW 634)
            Load(rsVIEW 635)
            Load(rsSOUND 50)
        )(else
            (ulence:bikerComing(0))
        )
        (send (ScriptID(706 7)):
            init()
            nsLeft(0)
            nsTop(86)
            nsBottom(189)
            nsRight(319)
        )
        (send (ScriptID(706 8)):
            init()
            nsLeft(0)
            nsTop(0)
            nsBottom(86)
            nsRight(319)
        )
    )


    (method (doit param1)
        (if ((== (ulence:status) 4) and (< (send (ScriptID(706 1)):distanceTo(gEgo)) 15))
            proc0_2()
            (ulence:status(6))
            (send gEgo:setScript(0))
            (ulence:deathLoop(0))
            (self:setScript(ScriptID(706 3)))
        )
        (if (script)
            0
        )(else
            (if (((== (ulence:status) 2) and (send gEgo:inRect(20 171 46 182))) and local0)
                proc0_2()
                (ulence:status(3))
                (send (ScriptID(706 1)):
                    init()
                    view(634)
                    hide()
                    posn(308 217)
                    setScript(runOverScript)
                )
                = local0 0
                (send gEgo:setScript(ScriptID(706 4)))
            )
        )
        (super:doit(rest param1))
        (if (> (send gEgo:x) 60)
            = local0 1
        )
    )

)
(instance runOverScript of Script
    (properties)

    (method (changeState newState)
        (var temp0[2])
        (switch (= state newState)
            (case 0
                (ulence:egoBusy(1))
                (send gLongSong:
                    vol(25)
                    number(50)
                    loop(-1)
                    playBed()
                    fade(127 10 10 0)
                )
                = seconds 3
            )
            (case 1
                (send (ScriptID(706 6)):
                    init()
                    fade()
                )
                (send (ScriptID(706 1)):
                    show()
                    setLoop(7)
                    setMotion(MoveTo 246 - (send gEgo:y) 5 self)
                )
            )
            (case 2
                (ulence:status(4))
                proc0_3()
                (send (ScriptID(706 1)):
                    setLoop(1)
                    setPri(+ (send gEgo:priority) 1)
                    setMotion(MoveTo 65485 - (send gEgo:y) 5 self)
                )
            )
            (case 3
                (send gLongSong:fade())
                (send (ScriptID(706 6)):fade())
                (send (ScriptID(706 1)):hide())
                = seconds 3
            )
            (case 4
                (if (<> (ulence:status) 6)
                    (ulence:
                        status(1)
                        fieldOff(0)
                        bikerComing(0)
                        egoBusy(0)
                    )
                    (send gEgo:setScript(0))
                    proc0_3()
                    Print("Boy, that was close!")
                )
                (self:dispose())
            )
        )
    )

)
(instance building of Feature
    (properties
        x 155
        y 84
        nsTop 7
        nsBottom 161
        nsRight 311
        description "building"
        sightAngle 45
        onMeCheck 2
        lookStr "Droids-B-Us building."
    )

    (method (doVerb param1 param2 param3)
        (switch (param1)
            (case 11
                Print("It's got the dry, musty smell of a store that's filed for Chapter XI.")
            )
            (case 10
                Print("The poor taste of the building is only matched by the poor taste of the architect.")
            )
            (default 
                (super:doVerb(param1 rest param3))
            )
        )
    )

)
(instance gate of Feature
    (properties
        x 125
        y 115
        nsTop 76
        nsLeft 60
        nsBottom 154
        nsRight 191
        description "gate"
        sightAngle 45
        onMeCheck 8
        lookStr "The gate is down, the store is CLOSED"
    )
)
(instance sign1 of Feature
    (properties
        x 125
        y 59
        nsTop 45
        nsLeft 37
        nsBottom 73
        nsRight 214
        description "sign"
        sightAngle 45
        onMeCheck 16
        lookStr "For all of your droid-related needs see us - when we're open!"
    )
)
(instance sign2 of Feature
    (properties
        x 126
        y 130
        nsTop 122
        nsLeft 108
        nsBottom 138
        nsRight 145
        description "sign"
        sightAngle 45
        onMeCheck 4
        lookStr "The sign indicates that this establishment is not open for business."
    )
)
