(version 2)
(include "sci.sh")
(exports
    0 rm400
)
(use "Main")
(use "OccasionalCycle")
(use "FPRoom")
(use "Inset")
(use "Scaler")
(use "RandCycle")
(use "Polygon")
(use "CueObj")
(use "Door")
(use "n958")
(use "Cycle")
(use "View")
(use "Obj")
(script 400)


(local
    local0
    local1
    local2 =     1

)
(instance public rm400 of FPRoom
    (properties
        noun 20
        picture 400
        style $0064
        horizon 83
        north 220
    )

    (method (init)
        proc958_0(128 401 402)
        (if (== global119 22)
            (self:setRegions(91))
        )
        (send gEgo:
            init()
            normalize()
            setScale(Scaler 95 47 182 126)
        )
        (switch (gGNumber)
            (case north
                (send gEgo:
                    x(210)
                    y(90)
                )
                (if ((== global119 15) and not proc0_2(9))
                    proc958_0(128 400 403)
                    (banker:
                        init()
                        approachVerbs(2)
                        setCycle(OccasionalCycle 1 45 200 2 8)
                        setScale(-1 gEgo)
                    )
                    (sheriff:
                        init()
                        approachVerbs(2)
                        setCycle(OccasionalCycle 1 45 200 2 8)
                        setScale(-1 gEgo)
                    )
                    (send global2:setScript(sOverhearBaddies))
                )(else
                    (send gGame:handsOn())
                )
            )
            (case 410
                (send gEgo:edgeHit(0))
                (send gEgo:heading(180))
                (send gGame:handsOn())
            )
            (case 235
                (send global2:setScript(sAfterROFL))
            )
            (case 680
                (send gGame:handsOn())
            )
            (default 
                = style 100
                (send gEgo:
                    x(160)
                    y(160)
                )
                (send gGame:handsOn())
            )
        )
        (super:init())
        (if (((<> global119 22) and (<> global119 14)) and (<> gGNumber 410))
            (send gGameMusic1:
                number(410)
                loop(-1)
                play()
                setVol(100)
            )
        )
        (send global2:addObstacle((send ((Polygon:new())):
                type(2)
                init(2 180 63 180 155 172 229 162 289 170 301 164 214 156 181 166 217 80 217 0 319 0 319 189 0 189 0 0 198 0 190 93 155 144 42 147 42 139 70 127 90 127 90 124 69 124 36 136 29 146 3 146)
                yourself()
            )
))
        (frontDoor:
            init()
            stopUpd()
        )
        (if (((<> gGNumber 235) and (== global119 22)) and proc0_2(33))
            (cannister:
                init()
                stopUpd()
                ignoreActors()
            )
            (glint:
                init()
                hide()
                stopUpd()
                setScript(sRandomTwinkle)
            )
        )
        (bankRoof:
            init()
            setOnMeCheck(1 4)
        )
        (brothel:
            init()
            setOnMeCheck(1 8)
        )
        (cactus:
            init()
            setOnMeCheck(1 32)
        )
        (clutter:
            init()
            setOnMeCheck(1 64)
        )
        (fence:
            init()
            setOnMeCheck(1 128)
        )
        (gazebo:
            init()
            setOnMeCheck(1 256)
        )
        (momsFront:
            init()
            setOnMeCheck(1 512)
        )
        (saloonFront:
            init()
            setOnMeCheck(1 1024)
        )
        (smithie:
            init()
            setOnMeCheck(1 2048)
        )
        (window1:
            init()
            setOnMeCheck(1 16)
        )
        (window2:
            init()
            setOnMeCheck(1 16)
        )
        (window3:
            init()
            setOnMeCheck(1 16)
        )
        (window4:
            init()
            setOnMeCheck(1 16)
        )
        (window5:
            init()
            setOnMeCheck(1 16)
        )
        (window6:
            init()
            setOnMeCheck(1 16)
        )
        (window7:
            init()
            setOnMeCheck(1 16)
        )
        (signPost:
            setCycle(OccasionalCycle 1 45 200 2 8)
            init()
        )
        (tree1:
            setCycle(OccasionalCycle 1 30 120 1 10)
            init()
            ignoreActors()
            setPri(15)
        )
        (if (((== gGNumber north) and (== global119 15)) and not proc0_2(9))
            (tree2:
                init()
                ignoreActors()
                stopUpd()
                setPri(14)
            )
            (tree3:
                init()
                ignoreActors()
                stopUpd()
                setPri(14)
            )
        )(else
            (tree2:
                setCycle(OccasionalCycle -1 40 160 2 15)
                init()
                ignoreActors()
                setPri(15)
            )
            (tree3:
                setCycle(OccasionalCycle 1 20 100 2 8)
                init()
                ignoreActors()
                setPri(15)
            )
        )
        (bunting:init())
        (if (proc0_2(1))
            (glow:
                setCycle(RandCycle)
                init()
            )
        )(else
            (curtains:
                setCycle(OccasionalCycle 1 30 120 1 5)
                init()
            )
        )
        (if (== gGNumber 410)
            Animate((send gOldCast:elements) 1)
            proc0_15(0 16)
        )
    )


    (method (dispose)
        (if ((<> global119 14) and (<> gNewRoomNumber 410))
            (send gGameMusic1:fade())
        )
        DisposeScript(32)
        (super:dispose())
    )

)
(instance sMiss of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send gGame:handsOff())
                (send gEgo:
                    view(402)
                    cel(0)
                    setCycle(End self)
                )
            )
            (case 1
                (puff:
                    x(Random(260 319))
                    y(Random(21 31))
                    init()
                    show()
                )
                = ticks 30
            )
            (case 2
                (puff:
                    hide()
                    stopUpd()
                )
                = cycles 2
            )
            (case 3
                (send gFpMessager:say(7 47 0 0 self))
            )
            (case 4
                (send gEgo:normalize())
                (send gGame:handsOn())
                (self:dispose())
            )
        )
    )

)
(instance sAfterROFL of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send gGameMusic2:stop())
                (send gGameMusic1:
                    number(410)
                    loop(-1)
                    play()
                    setVol(100)
                )
                proc0_3(83)
                = seconds 2
            )
            (case 1
                (send gFpMessager:say(6 0 4 0 self))
            )
            (case 2
                ++global119
                (send gGame:handsOn())
                (self:dispose())
            )
        )
    )

)
(instance sShotTheCannister of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send gGame:handsOff())
                (signPost:setCycle(Beg))
                (send gEgo:
                    view(402)
                    cel(0)
                    setCycle(End self)
                )
            )
            (case 1
                (send gFpMessager:say(5 47 0 1 self))
            )
            (case 2
                (gunSound:play(self))
            )
            (case 3
                (send gFpMessager:say(5 47 0 2 self))
            )
            (case 4
                (send gGame:points(20 146))
                (cannister:
                    setLoop(2)
                    setCycle(Fwd)
                )
                = cycles 1
            )
            (case 5
                = ticks 180
            )
            (case 6
                (send global2:newRoom(235))
                (self:dispose())
            )
        )
    )

)
(instance sRandomTwinkle of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (glint:stopUpd())
                = seconds Random(8 20)
            )
            (case 1
                (glint:show())
                = cycles 5
            )
            (case 2
                (glint:hide())
                (self:changeState(0))
            )
        )
    )

)
(instance sOverhearBaddies of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                = cycles 5
            )
            (case 1
                (send gGameMusic1:fade(0 2 1 0))
                (send gGameMusic2:
                    number(703)
                    loop(-1)
                    play()
                    setVol(0)
                    fade(100 2 1 0)
                )
                = cycles 10
            )
            (case 2
                (send gFpMessager:say(3 0 0 0 self))
            )
            (case 3
                (send gGameMusic1:fade(127 3 1 0))
                (send gGameMusic2:fade(0 3 1 1))
                proc0_3(9)
                (send gGame:handsOn())
                (self:dispose())
            )
        )
    )

)
(instance banker of Prop
    (properties
        x 118
        y 135
        noun 4
        view 403
        cycleSpeed 10
        detailLevel 2
    )

    (method (doVerb theVerb param2)
        (var temp0)
        (switch (theVerb)
            (case 2
                (if (< local0 3)
                    ++local0
                )
                (switch (local0)
                    (case 1
                        = temp0 8
                    )
                    (case 2
                        = temp0 9
                    )
                    (default 
                        = temp0 10
                    )
                )
                (send gFpMessager:say(noun theVerb temp0))
            )
            (default 
                (super:doVerb(theVerb rest param2))
            )
        )
    )

)
(instance sheriff of Prop
    (properties
        x 95
        y 134
        noun 10
        view 403
        loop 1
        cycleSpeed 10
        detailLevel 2
    )

    (method (doVerb theVerb param2)
        (var temp0)
        (switch (theVerb)
            (case 2
                (if (< local1 3)
                    ++local1
                )
                (switch (local1)
                    (case 1
                        = temp0 8
                    )
                    (case 2
                        = temp0 9
                    )
                    (default 
                        = temp0 10
                    )
                )
                (send gFpMessager:say(noun theVerb temp0))
            )
            (default 
                (super:doVerb(theVerb rest param2))
            )
        )
    )

)
(instance frontDoor of Door
    (properties
        x 64
        y 122
        noun 1
        approachX 67
        approachY 127
        view 400
        entranceTo 410
        lockedCase 6
        openSnd 2146
        closeSnd 2147
        openVerb 4
        moveToX 89
        moveToY 126
        enterType 0
        exitType 0
    )

    (method (init)
        (super:init())
        (if (== global119 14)
            = noun 2
        )
        = locked 
            (if (((> global119 14) and not proc0_2(107)) or (== global119 15))
                0
            )(else
                1
            )
    )


    (method (cue)
        (if (== doorState 1)
            proc0_15(1 16)
        )
        (super:cue())
    )

)
(instance signPost of Prop
    (properties
        x 16
        y 114
        noun 11
        view 400
        loop 1
        detailLevel 2
    )

    (method (doit)
        (if ((== cel (self:lastCel())) and local2)
            = local2 0
            (signSound:play(self))
        )
        (super:doit())
    )


    (method (cue)
        = local2 1
    )

)
(instance tree1 of Prop
    (properties
        x 22
        y 63
        noun 12
        view 400
        loop 2
        signal $1000
        detailLevel 2
    )
)
(instance tree2 of Prop
    (properties
        x 280
        y 14
        noun 12
        view 400
        loop 3
        cel 2
        signal $1000
        detailLevel 2
    )
)
(instance tree3 of Prop
    (properties
        x 282
        y 64
        noun 12
        view 400
        loop 4
        cel 2
        signal $1000
        detailLevel 2
    )
)
(instance curtains of Prop
    (properties
        x 101
        y 68
        noun 13
        view 400
        loop 5
        detailLevel 2
    )
)
(instance glow of Prop
    (properties
        x 101
        y 68
        noun 14
        view 400
        loop 6
        detailLevel 2
    )
)
(instance glint of Prop
    (properties
        x 290
        y 17
        noun 5
        view 401
        loop 1
        signal $4000
        detailLevel 2
    )
)
(instance puff of View
    (properties
        x 295
        y 19
        view 400
        loop 7
        cel 1
    )
)
(instance bigCannister of View
    (properties
        x 161
        y 36
        noun 9
        view 71
        loop 1
    )

    (method (doVerb theVerb param2)
        (switch (theVerb)
            (case 47
                (send gFpMessager:say(5 47 11))
            )
            (default 
                (super:doVerb(theVerb rest param2))
            )
        )
    )

)
(instance cannister of Prop
    (properties
        x 290
        y 17
        noun 5
        view 401
        detailLevel 2
    )

    (method (doVerb theVerb param2)
        (switch (theVerb)
            (case 47
                (if (proc0_2(83))
                    (send gFpMessager:say(7 theVerb 4))
                )(else
                    (if (proc0_1(gEgo 2))
                        (send global2:setScript(sShotTheCannister))
                    )(else
                        (send gFpMessager:say(noun theVerb 2))
                    )
                )
            )
            (default 
                (super:doVerb(theVerb rest param2))
            )
        )
    )

)
(instance bankRoof of Feature
    (properties
        x 87
        y 13
        noun 23
        sightAngle 40
    )
)
(instance brothel of Feature
    (properties
        x 73
        y 84
        noun 15
        sightAngle 40
        approachX 73
        approachY 84
    )
)
(instance cactus of Feature
    (properties
        x 36
        y 175
        noun 19
        sightAngle 40
        approachX 36
        approachY 175
    )
)
(instance clutter of Feature
    (properties
        x 246
        y 47
        noun 21
        sightAngle 40
    )
)
(instance fence of Feature
    (properties
        x 145
        y 182
        noun 18
        sightAngle 40
        approachX 145
        approachY 182
    )
)
(instance gazebo of Feature
    (properties
        x 271
        y 127
        noun 17
        sightAngle 40
        approachX 271
        approachY 127
    )
)
(instance momsFront of Feature
    (properties
        x 236
        y 18
        noun 25
        sightAngle 40
    )
)
(instance saloonFront of Feature
    (properties
        x 188
        y 24
        noun 24
        sightAngle 40
    )
)
(instance smithie of Feature
    (properties
        x 25
        y 17
        noun 22
        sightAngle 40
    )
)
(instance window1 of Feature
    (properties
        x 49
        y 62
        noun 16
        sightAngle 40
        approachX 49
        approachY 62
    )
)
(instance window2 of Feature
    (properties
        x 89
        y 61
        noun 16
        sightAngle 40
        approachX 89
        approachY 61
    )
)
(instance window3 of Feature
    (properties
        x 106
        y 59
        noun 16
        sightAngle 40
        approachX 106
        approachY 59
    )
)
(instance window4 of Feature
    (properties
        x 126
        y 59
        noun 16
        sightAngle 40
        approachX 126
        approachY 59
    )
)
(instance window5 of Feature
    (properties
        x 96
        y 108
        noun 16
        sightAngle 40
        approachX 96
        approachY 108
    )
)
(instance window6 of Feature
    (properties
        x 112
        y 107
        noun 16
        sightAngle 40
        approachX 112
        approachY 107
    )
)
(instance window7 of Feature
    (properties
        x 131
        y 108
        noun 16
        sightAngle 40
        approachX 131
        approachY 108
    )
)
(instance bunting of Feature
    (properties
        x 289
        y 26
        noun 7
        nsTop 21
        nsLeft 260
        nsBottom 31
        nsRight 319
        sightAngle 40
    )

    (method (doVerb theVerb param2)
        (switch (theVerb)
            (case 1
                (if (proc0_2(1))
                    (send gFpMessager:say(noun theVerb 1))
                )(else
                    (if (< (send gEgo:x) 145)
                        (send gFpMessager:say(noun theVerb 2))
                    )(else
                        (send global2:setInset(inBunting))
                    )
                )
            )
            (case 47
                (if (not (send gOldCast:contains(cannister)))
                    (send gFpMessager:say(noun theVerb 5))
                )(else
                    (if (proc0_2(83))
                        (send gFpMessager:say(noun theVerb 4))
                    )(else
                        (if (proc0_1(gEgo 2))
                            (send global2:setScript(sMiss))
                        )(else
                            (send gFpMessager:say(noun theVerb 2))
                        )
                    )
                )
            )
            (default 
                (super:doVerb(theVerb rest param2))
            )
        )
    )

)
(instance gunSound of FPSound
    (properties
        flags $0001
        number 2101
    )
)
(instance signSound of FPSound
    (properties
        flags $0001
        number 2951
    )
)
(instance inBunting of Inset
    (properties
        picture 235
        hideTheCast 1
        noun 8
    )

    (method (init param1)
        (super:init(rest param1))
        (send gGameMusic2:mute(0 6))
        proc0_8(1)
        (if ((== global119 22) and proc0_2(33))
            (bigCannister:
                stopUpd()
                init()
            )
        )
    )


    (method (dispose)
        proc0_8(0)
        (send gGameMusic2:mute(1 6))
        (bigCannister:dispose())
        (super:dispose())
    )


    (method (doVerb theVerb param2)
        (switch (theVerb)
            (case 1
                (if (proc0_2(33))
                    (send gFpMessager:say(noun theVerb 3))
                )(else
                    (send gFpMessager:say(noun theVerb 5))
                )
            )
            (case 8
                (self:dispose())
            )
            (default 
                (super:doVerb(theVerb rest param2))
            )
        )
    )

)
