(include "sci.sh")
(use "Main")
(use "Class_255_0")
(use "rssScript")
(use "MoveToY")
(use "SQRoom")
(use "Polygon")
(use "Class_950_0")
(use "n958")
(use "DPath")
(use "Cycle")
(use "Obj")
(script 299)



(instance public rm299 of SQRoom
    (properties
        picture 299
        east 300
        south 306
    )

    (method (init)
        (if (> (butte:policeLanded) 0)
            Load(rsVIEW 305)
            Load(rsPIC 300)
        )(else
            proc958_0(128 7 5)
        )
        proc958_0(128 0 300)
        (self:
            setRegions(703)
            setFeatures(theRoom)
        )
        (switch (gWest)
            (case south
                proc0_2()
                (send gEgo:
                    init()
                    setPri(15)
                )
                (self:
                    setScript(enterScript)
                    style(43)
                )
            )
            (case east
                proc0_2()
                (send gEgo:
                    init()
                    hide()
                    setPri(8)
                )
                (self:
                    setScript(enterScript)
                    style(40)
                )
            )
            (default 
                proc0_3()
                (send gEgo:
                    init()
                    view(0)
                    posn(205 130)
                    setPri(8)
                )
            )
        )
        (send global2:addObstacle((send ((Polygon:new())):
                type(2)
                init(319 189 262 189 232 186 231 169 250 162 222 149 220 143 229 137 265 143 268 147 300 147 308 122 319 118)
                yourself()
            )
 (send ((Polygon:new())):
                type(2)
                init(207 165 200 173 213 178 221 189 208 189 169 189 116 187 108 186 90 173 85 165 85 144 184 144)
                yourself()
            )
 (send ((Polygon:new())):
                type(2)
                init(319 94 315 96 303 96 296 105 270 118 217 118 212 122 93 119 69 128 57 140 61 153 108 189 0 189 0 0 319 0)
                yourself()
            )
))
        (super:init())
        (if ((== (butte:curPolice1Room) 299) or (== (butte:curPolice2Room) 299))
            (butte:junctioned(1))
            (send (ScriptID(703 4)):
                posn(190 134)
                setCycle(Walk)
                init()
                setScript(copEnters)
            )
        )(else
            (butte:junctioned(0))
        )
    )


    (method (doit)
        (var temp0)
        (if (script)
            0
        )(else
            (if (== (send gEgo:onControl(0)) 2048)
                proc0_2()
                (self:setScript(exitScript))
            )
        )
        (super:doit())
        = temp0 (send gEgo:onControl(1))
        (if (script)
            0
        )(else
            (if ((butte:junctioned) and not (send (ScriptID(703 4)):script))
                (send (ScriptID(703 4)):
                    posn(315 107)
                    init()
                    setScript(copEnters)
                )
            )(else
                (if ((((((((& temp0 $0010) or (& temp0 $0040)) or (& temp0 $0080)) or (& temp0 $0100)) or (& temp0 $1000)) or (& temp0 $2000)) or (& temp0 $0002)) or (& temp0 $0004))
                    proc0_2()
                    (self:setScript(fallScript 0 temp0))
                )
            )
        )
        (if (not script and (((> (send gEgo:y) 179) and (> (send gEgo:x) 230)) or ((> (send gEgo:y) 148) and (< (send gEgo:x) 152))))
            (send gEgo:setPri(15))
        )(else
            (if (not script)
                (send gEgo:setPri(8))
            )
        )
    )


    (method (newRoom param1)
        (if ((== script fallScript) and (== (send gEgo:edgeHit) 3))
            = param1 0
        )(else
            (super:newRoom(param1))
        )
    )

)
(instance fallScript of Script
    (properties)

    (method (changeState newState)
        (var temp0[2])
        (switch (= state newState)
            (case 0
                (if (& register $0010)
                    (send gEgo:setPri(5))
                )(else
                    (if (& register $0080)
                        (send gEgo:setPri(3))
                    )(else
                        (if (& register $1000)
                            (send gEgo:
                                setPri(5)
                                x(- (send gEgo:x) 7)
                            )
                        )(else
                            (if (& register $2000)
                                (send gEgo:
                                    x(+ (send gEgo:x) 7)
                                    setPri(5)
                                )
                            )(else
                                (if (& register $0002)
                                    (send gEgo:setPri(5))
                                )(else
                                    (if (& register $0040)
                                        (send gEgo:setPri(6))
                                    )(else
                                        (if (& register $0004)
                                            (send gEgo:setPri(10))
                                        )
                                    )
                                )
                            )
                        )
                    )
                )
                (send global2:setScript(ScriptID(703 1)))
                (self:dispose())
            )
        )
    )

)
(instance enterScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (if (== gWest 306)
                    (if (< (send gEgo:x) 190)
                        (send gEgo:
                            posn(182 247)
                            setLoop(2)
                            setPri(15)
                            setMotion(MoveTo 182 225 self)
                        )
                    )(else
                        (send gEgo:
                            x(
                                (if (> (send gEgo:x) 250)
                                    250
                                )(else
                                    (send gEgo:x)
                                )
)
                            y(186)
                        )
                        = cycles 1
                    )
                )(else
                    (if (== gWest 300)
                        = cycles 1
                    )
                )
            )
            (case 1
                (if ((== gWest 306) and (< (send gEgo:x) 190))
                    = cycles 1
                )(else
                    (if (== gWest 300)
                        (send gEgo:
                            init()
                            show()
                            illegalBits(0)
                            x(322)
                            y(101)
                            setMotion(MoveTo 308 101 self)
                        )
                    )(else
                        proc0_3()
                        (send gEgo:illegalBits(32768))
                        (send client:setScript(0))
                    )
                )
            )
            (case 2
                (if (== gWest 300)
                    proc0_3()
                    proc0_1(1 0 4)
                    (send client:setScript(0))
                )(else
                    (send gEgo:
                        setLoop(1)
                        setPri(15)
                        setMotion(MoveTo 152 205 self)
                    )
                )
            )
            (case 3
                (send gEgo:
                    setPri(15)
                    setMotion(MoveTo 118 186 self)
                )
            )
            (case 4
                (send gEgo:setMotion(MoveTo 97 180 self))
            )
            (case 5
                (send gEgo:
                    illegalBits(32768)
                    setLoop(-1)
                )
                proc0_3()
                (self:dispose())
            )
        )
    )

)
(instance exitScript of Script
    (properties)

    (method (changeState newState)
        (var temp0, temp1)
        (switch (= state newState)
            (case 0
                (if (< (send gEgo:x) 190)
                    (send gEgo:
                        setLoop(-1)
                        setHeading(134 self)
                    )
                )(else
                    (send global2:newRoom((send global2:south)))
                )
            )
            (case 1
                = temp0 CelHigh((send gEgo:view) (send gEgo:loop) (send gEgo:cel))
                (send gEgo:setMotion(MoveToY (+ 190 temp0) self))
            )
            (case 2
                (if (> (send gEgo:x) 189)
                    (send gEgo:x(189))
                )
                (send global2:newRoom((send global2:south)))
            )
        )
    )

)
(instance copEnters of Script
    (properties)

    (method (doit)
        (if (not (send global2:script) and (== state 0))
            (self:cue())
        )
        (if (((< (send (ScriptID(703 4)):distanceTo(gEgo)) 80) and not (send global2:script)) and not (== (send gEgo:onControl()) 16384))
            (send (ScriptID(703 4)):setScript(ScriptID(703 5)))
            (self:dispose())
        )
        (super:doit())
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                0
            )
            (case 1
                (send (ScriptID(703 4)):
                    setCycle(Walk)
                    setMotion(DPath 218 137 211 169 227 154 182 123 320 115 self)
                )
            )
        )
    )

)
(instance theRoom of Feature
    (properties
        x 160
        y 90
        nsBottom 200
        nsRight 320
        description "buttes"
        lookStr "All around you stretch the dunes and stony outcroppings of the Estros buttes. Nearby, a slender, rigid rod of angry red rock arches its way upward, poking searchingly into the sky and plunging down into the beautiful butte of Estros.  What lovely scenery!"
    )

    (method (doVerb param1)
        (switch (param1)
            (case 4
                (send (ScriptID(703 6)):doVerb(param1))
            )
            (case 1
                Print("All around you stretch the dunes and stony outcroppings of the Estros buttes. Nearby, a slender, rigid rod of angry red rock arches its way upward, poking searchingly into the sky and plunging down into the beautiful butte of Estros.  What lovely scenery!")
            )
            (default 
                (super:doVerb())
            )
        )
    )

)
