(include "sci.sh")
(use "Main")
(use "Class_255_0")
(use "PolyPath")
(use "Class_950_0")
(use "SysWindow")
(use "Sound")
(use "Cycle")
(use "Game")
(use "PicView")
(use "Obj")
(script 706)


(local
    local0
    local1
    local2

)
(class ulence of Rgn
    (properties
        script 0
        number 0
        timer 0
        keep 0
        initialized 0
        lookStr 0
        regionVer 22891
        roomVer 0
        beenInBar 0
        status 0
        deathLoop 0
        fieldOff 0
        bikerComing 0
        saveWindow 0
        egoBusy 0
    )

    (method (init param1)
        (if (<> gSq4Win Sq1Window)
            = saveWindow gSq4Win
            = gSq4Win Sq1Window
        )
        (super:init(rest param1))
        proc0_14(1)
        Load(rsVIEW 636)
        Load(rsSOUND 50)
        Load(rsSOUND 135)
        Load(rsSOUND 58)
        (forceField:init())
        (if (not proc999_5(gNumber 615 620))
            (send gLongSong:
                number(58)
                loop(-1)
                vol(127)
                play()
            )
        )
    )


    (method (doit)
        (var temp0)
        (super:doit())
        (if (script)
            0
        )(else
            (if (((== (send gEgo:edgeHit) 3) and proc999_5(gNumber 609 610 611)) and (== (ulence:fieldOff) 0))
                proc0_2()
                (send gEgo:
                    setMotion(0)
                    y(- (send gEgo:y) 2)
                )
                = local0 1
                (send global2:setScript(ScriptID(706 2)))
            )(else
                (if (((& (send gEgo:onControl(1)) $2000) and not local0) and (== (ulence:fieldOff) 0))
                    proc0_2()
                    (send gEgo:setMotion(0))
                    (switch (gNumber)
                        (case 611
                            (send gEgo:x((- (send gEgo:x) 2)))
                        )
                        (case 612
                            (if ((> (send gEgo:x) 185) and (< (send gEgo:y) 123))
                                (send gEgo:y((+ (send gEgo:y) 2)))
                            )(else
                                (send gEgo:
                                    y(+ (send gEgo:y) 2)
                                    x(+ (send gEgo:x) 2)
                                )
                            )
                        )
                        (case 613
                            (send gEgo:y((+ (send gEgo:y) 2)))
                        )
                        (case 614
                            (send gEgo:x((- (send gEgo:x) 4)))
                        )
                    )
                    = local0 1
                    (send global2:setScript(ScriptID(706 2)))
                )(else
                    (if ((& (send gEgo:onControl(1)) $1000) and local0)
                        = local0 0
                    )
                )
            )
        )
    )


    (method (dispose)
        = gSq4Win saveWindow
        (super:dispose())
    )


    (method (newRoom param1 param2)
        = keep proc999_5(param1 609 610 611 612 613 614 615 620)
        = initialized 0
        (super:newRoom(param1 rest param2))
    )

)
(class Sq1Window of SysWindow
    (properties
        top 0
        left 0
        bottom 0
        right 0
        color 0
        back 15
        priority 15
        window 0
        type 0
        title 0
        brTop 0
        brLeft 0
        brBottom 190
        brRight 320
        underBits 0
        pUnderBits 0
        lsTop 0
        lsLeft 0
        lsBottom 0
        lsRight 0
        bordWid 3
    )

    (method (dispose)
        SetPort(0)
        Graph(8 underBits)
        Graph(8 pUnderBits)
        Graph(13 lsTop lsLeft lsBottom lsRight)
        (super:dispose())
    )


    (method (open)
        (var temp0, temp1)
        SetPort(0)
        = color gColor
        = back gBack
        = temp1 1
        (if (<> priority -1)
            = temp1 (| temp1 $0002)
        )
        = lsTop (- top bordWid)
        = lsLeft (- left bordWid)
        = lsRight (+ right bordWid)
        = lsBottom (+ bottom bordWid)
        = underBits Graph(7 lsTop lsLeft lsBottom lsRight 1)
        (if (<> priority -1)
            = pUnderBits Graph(7 lsTop lsLeft lsBottom lsRight 2)
        )
        Graph(11 lsTop lsLeft lsBottom lsRight temp1 back priority)
        Graph(4 + lsTop 1 + lsLeft 1 + lsTop 1 - lsRight 2 global131 priority)
        Graph(4 - lsBottom 2 + lsLeft 1 - lsBottom 2 - lsRight 2 global131 priority)
        Graph(4 + lsTop 1 + lsLeft 1 - lsBottom 2 + lsLeft 1 global131 priority)
        Graph(4 + lsTop 1 - lsRight 2 - lsBottom 2 - lsRight 2 global131 priority)
        Graph(12 lsTop lsLeft lsBottom lsRight 1)
        = type 129
        (super:open())
    )

)
(instance public theDeathScript of Script
    (properties)

    (method (changeState newState)
        (var temp0[2])
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gEgo:
                    view(635)
                    cel(0)
                    setLoop((ulence:deathLoop))
                    setCycle(End self)
                )
            )
            (case 1
                = seconds 4
            )
            (case 2
                proc0_10(0 6)
            )
        )
    )

)
(instance public theZapScript of Script
    (properties)

    (method (changeState newState)
        (var temp0[2])
        (switch (= state newState)
            (case 0
                Load(rsVIEW 635)
                ++local1
                (send gEgo:view(636))
                (switch (gNumber)
                    (case 609
                        (if ((send gEgo:inRect(15 187 317 191)))
                            (send gEgo:setLoop(2))
                        )
                    )
                    (case 612
                        (if ((> (send gEgo:x) 185) and (< (send gEgo:y) 123))
                            (send gEgo:setLoop(3))
                        )(else
                            (send gEgo:setLoop(7))
                        )
                    )
                    (case 611
                        (if ((send gEgo:inRect(0 181 235 190)))
                            (send gEgo:setLoop(2))
                        )
                    )
                    (case 610
                        (send gEgo:setLoop(2))
                    )
                    (case 614
                        (send gEgo:setLoop(0))
                    )
                    (case 613
                        (send gEgo:setLoop(3))
                    )
                )
                (zapSound:play())
                = cycles 2
            )
            (case 1
                (zapSound:stop())
                (if (not local2)
                    proc0_1((send gEgo:loop) 0)
                )
                = cycles 3
            )
            (case 2
                (if (local2)
                    Print("As the moist surface of your oral muscle comes in contact with the fully energized force field, you realize your mistake.")
                    = local1 4
                )
                (switch (local1)
                    (case 1
                        Print("\"YOUCH!\", you mumble to yourself. A Force Field prevents your continued movement in that direction.")
                        proc0_3()
                        (self:dispose())
                    )
                    (case 2
                        Print("\"AH! CRIPES! I hate it when that happens!\"")
                        proc0_3()
                        (self:dispose())
                    )
                    (case 3
                        (switch (Random(0 5))
                            (case 0
                                Print("\"GEEEZ!\" Much like life at Sierra, you find the force field a real eye-opening experience.")
                            )
                            (case 1
                                Print("Thousands of volts pass through your cranium, turning your brain into a gray, quivering mass of neurons which effectively terminates all interpretation of sensory impulses.")
                            )
                            (default 
                                Print("\"AH! CRIPES!\", you mumble to yourself. A Force Field prevents your continued movement in that direction.")
                            )
                        )
                        proc0_3()
                        (self:dispose())
                    )
                    (default 
                        (send gEgo:
                            view(635)
                            setLoop(0)
                            setCel(2)
                        )
                        = cycles 1
                    )
                )
            )
            (case 3
                (if (== gNumber 613)
                    (send gEgo:setPri(1))
                )
                (send gEgo:setCycle(End self))
            )
            (case 4
                proc0_10(1 7)
            )
        )
    )

)
(instance tongueScript of Script
    (properties)

    (method (changeState newState)
        (var temp0[2])
        (switch (= state newState)
            (case 0
                = local2 1
                (send gEgo:setMotion(PolyPath gPEventX gPEventY self))
            )
            (case 1
                (send global2:setScript(theZapScript))
                (self:dispose())
            )
        )
    )

)
(instance public theDodgeR of Script
    (properties)

    (method (changeState newState)
        (var temp0[2])
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gEgo:
                    setMotion(0)
                    setHeading(90 self)
                )
                Print("You hear a high-pitched whine from the east.")
            )
            (case 1
                proc0_3()
                (send gEgo:
                    view(635)
                    setLoop(0)
                    setCel(0)
                )
            )
            (case 2
                (ulence:status(5))
                proc0_2()
                (send gEgo:
                    posn(+ (send gEgo:x) 12 - (send gEgo:y) 10)
                    setLoop(2)
                    setCycle(End self)
                )
            )
            (case 3
                proc0_11(77 5)
                proc0_1((send gEgo:loop) 0)
                (send gEgo:
                    posn(+ (send gEgo:x) 24 + (send gEgo:y) 5)
                    heading(90 self)
                )
            )
            (case 4
                (self:dispose())
            )
        )
    )


    (method (handleEvent pEvent)
        (var temp0)
        (if ((send pEvent:claimed))
            return 
        )(else
            (if ((== (send gIconBar:curIcon) (send gIconBar:at(0))) and ((== (send pEvent:message) 0) or (& (send pEvent:type) $0040)))
                (self:cue())
                (send pEvent:claimed(1))
            )(else
                (super:handleEvent(pEvent))
            )
        )
    )

)
(instance public theDodgeL of Script
    (properties)

    (method (changeState newState)
        (var temp0[2])
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gEgo:
                    setMotion(0)
                    setHeading(270 self)
                )
                Print("You hear a high-pitched whine from the west.")
            )
            (case 1
                proc0_3()
                (send gEgo:
                    view(635)
                    setLoop(1)
                    setCel(0)
                )
            )
            (case 2
                proc0_2()
                (ulence:status(5))
                (send gEgo:
                    posn(- (send gEgo:x) 14 - (send gEgo:y) 7)
                    setLoop(3)
                    setCycle(End self)
                )
            )
            (case 3
                proc0_11(77 5)
                proc0_1((send gEgo:loop) 0)
                (send gEgo:
                    posn(- (send gEgo:x) 25 + (send gEgo:y) 2)
                    setHeading(225 self)
                )
            )
            (case 4
                (self:dispose())
            )
        )
    )


    (method (handleEvent pEvent)
        (var temp0)
        (if ((send pEvent:claimed))
            return 
        )(else
            (if ((== (send gIconBar:curIcon) (send gIconBar:at(0))) and ((== (send pEvent:message) 0) or (& (send pEvent:type) $0040)))
                (self:cue())
                (send pEvent:claimed(1))
            )(else
                (super:handleEvent(pEvent))
            )
        )
    )

)
(instance public theBiker of Actor
    (properties
        x 1000
        y 1000
        description "Monochrome guy."
        lookStr "It's one of the Monochrome Boys and he seems to be traveling in your direction!"
        yStep 15
        view 632
        signal 24576
        illegalBits 0
        xStep 15
    )

    (method (doVerb param1 param2 param3)
        (switch (param1)
            (case 4
                Print("Sure - stop him. I'm sure he'd love to stop and swap some witty repartee.")
            )
            (case 2
                Print("That would be a bad move.")
            )
            (case 11
                Print("Get closer.")
            )
            (case 10
                Print("Yeah. The appeal is obvious.")
            )
            (default 
                (super:doVerb(param1 rest param3))
            )
        )
    )

)
(instance forceField of Feature
    (properties
        y 189
        nsBottom 189
        nsRight 319
        description "Force field"
        sightAngle 360
        onMeCheck 16384
        lookStr "It's a Wallmart Force Field Generation Unit (FFGU)."
    )

    (method (doVerb param1 param2 param3)
        (switch (param1)
            (case 10
                (if (== (ulence:egoBusy) 1)
                    Print("Not now!")
                )(else
                    proc0_2()
                    Print("Okay.")
                    (send global2:setScript(tongueScript))
                )
            )
            (case 11
                (switch (Random(0 6))
                    (case 0
                        Print("It's supposed to smell like a Wallmart Force Field Generating Unit, but we could only do 16 different odors in EGA so it smells a lot like the time pod.")
                    )
                    (case 1
                        Print("It has the acrid, coppery smell of ozone and wind-corroded metal.")
                    )
                    (case 2
                        Print("You've smelled a lot of force field generators in your time, but this is not one of them.")
                    )
                    (case 3
                        Print("The crackling smell of the FFGU stirs early memories of the force field your parents put around your playpen.")
                    )
                    (default 
                        Print("You can't seem to catch a scent from the FFGU. Maybe you should try tasting it instead.")
                    )
                )
            )
            (default 
                (super:doVerb(param1 rest param3))
            )
        )
    )

)
(instance public theDunes of Feature
    (properties
        y 1
        description "Sand dunes"
        lookStr "In the distance you see sand dunes and sky."
    )

    (method (doVerb param1 param2 param3)
        (switch (param1)
            (case 1
                Print("In the distance you see sand dunes and sky.")
                (if (== gNumber 610)
                    Print("Far away you see a few force field generators.")
                )
            )
            (case 11
                (switch (Random(0 6))
                    (case 0
                        Print("You can't quite smell the faraway dunes.")
                    )
                    (case 1
                        Print("It's the all too familiar silent-but-deadly aroma of Ulence Flats.")
                    )
                    (case 2
                        Print("Above the dunes, you smell an overcast purple sky... As if it's going to purple rain any second now.")
                    )
                    (case 3
                        Print("You inhale deeply, and very quickly sandblast the insides of your nostrils. Good thing you got those Tufflon implants!")
                    )
                    (case 4
                        Print("The spicy scent of the dunes reminds you of a lost weekend you once spent on Arrakis.")
                    )
                    (case 5
                        Print("The smell of the sand fills the air all around you.")
                    )
                    (case 6
                        Print("The air smells damp and oppressive, like a wet nun.")
                    )
                )
            )
            (case 10
                (switch (Random(0 4))
                    (case 0
                        Print("You can't taste the dunes, but your tongue gets a good stretching.")
                    )
                    (case 1
                        Print("Your tongue's too short for that.")
                    )
                    (case 2
                        Print("Your tongue flaps in the breeze.")
                    )
                    (case 3
                        Print("You won't need to lick the dunes here.")
                    )
                    (case 4
                        Print("Unfortunately, your woefully short tongue is nowhere near long enough to taste the faroff dunes of Ulence.")
                    )
                    (case 5
                        Print("There's nothing worth tasting in the air.")
                    )
                )
            )
            (default 
                (super:doVerb(param1 rest param3))
            )
        )
    )

)
(instance public theSand of Feature
    (properties
        y 1
        description "sand"
        lookStr "You see a whole lot of sand."
    )

    (method (doVerb param1 param2 param3)
        (switch (param1)
            (case 11
                (switch (Random(0 3))
                    (case 0
                        Print("It has the dry, itchy, uncomfortable smell of sand up your nose.")
                    )
                    (case 1
                        Print("Mmmmm! The slow-roasted whole grain goodness of sand.")
                    )
                    (case 2
                        Print("It smells like extremely hot sand and burnt nose hair.")
                    )
                    (case 3
                        Print("Funny how much smelling is going on, but the game still makes no scents!")
                    )
                )
            )
            (case 1
                Print("Looks like ordinary sand.")
            )
            (case 10
                (switch (Random(0 4))
                    (case 0
                        Print("The taste is subtle and difficult to pin down, but you LOVE the way it crunches between your teeth!")
                    )
                    (case 1
                        Print("Tastes like ordinary sand.")
                    )
                    (case 2
                        Print("Don't lick it. Who knows where it's been last?")
                    )
                    (case 3
                        Print("It's tough to tell what the sand really tastes like when your tongue is a twitching mass of blisters.")
                    )
                    (case 4
                        Print("Yep, tastes just like you'd expect of flat Ulence.")
                    )
                )
            )
            (case 2
                Print("You don't have time to play in the sand!")
            )
            (default 
                (super:doVerb(param1 rest param3))
            )
        )
    )

)
(instance public theBikeSound of Sound
    (properties
        number 841
        flags 1
    )
)
(instance zapSound of Sound
    (properties
        number 135
        flags 1
    )
)
