(include "sci.sh")
(use "Main")
(use "Class_255_0")
(use "rssScript")
(use "SQRoom")
(use "PolyPath")
(use "Polygon")
(use "Class_950_0")
(use "n958")
(use "Cycle")
(use "Obj")
(script 306)



(instance public rm306 of SQRoom
    (properties
        picture 306
        horizon 15
        north 299
        east 310
    )

    (method (init)
        proc958_0(128 0 300)
        (if (> (butte:policeLanded) 0)
            Load(rsVIEW 305)
            Load(rsPIC 300)
        )(else
            proc958_0(128 7 5)
        )
        (self:
            setRegions(703)
            setFeatures(theRoom)
        )
        (send gEgo:
            illegalBits(0)
            setPri(
                (if (== global12 north)
                    4
                )(else
                    (if (> (send gEgo:y) 115)
                        15
                    )(else
                        8
                    )
                )
)
            init()
        )
        (switch (global12)
            (case north
                proc0_2()
                (self:
                    setScript(enterScript)
                    style(42)
                )
            )
            (case east
                proc0_2()
                (self:
                    style(40)
                    setScript(enterScript)
                )
            )
            (default 
                proc0_3()
                (send gEgo:posn(181 135))
            )
        )
        (super:init())
        (butte:junctioned(0))
        (send global2:addObstacle((send ((Polygon:new())):
                type(2)
                init(202 0 252 52 189 101 193 114 136 109 88 67 148 0)
                yourself()
            )
 (send ((Polygon:new())):
                type(1)
                init(111 0 112 37 95 46 82 71 95 99 74 118 82 124 93 124 125 141 202 143 253 149 283 140 301 139 319 135 319 189 0 189 0 0)
                yourself()
            )
 (send ((Polygon:new())):
                type(1)
                init(319 52 319 94 269 99 255 124 197 115 197 105 268 48)
                yourself()
            )
 (send ((Polygon:new())):
                type(2)
                init(319 124 274 115 272 101 319 103)
                yourself()
            )
 (send ((Polygon:new())):
                type(2)
                init(285 0 319 0 319 22 285 14)
                yourself()
            )
))
        (if ((== (butte:curPolice1Room) 306) or (== (butte:curPolice2Room) 306))
            (butte:junctioned(1))
            (copEnters:start(3))
            (send (ScriptID(703 4)):
                posn(132 131)
                setCycle(Walk)
                init()
                setScript(copEnters)
            )
        )(else
            (butte:junctioned(0))
        )
    )


    (method (doit)
        (var temp0)
        (if (script)
        )(else
            (if ((== script fallScript) and (== (send gEgo:edgeHit) 3))
                0
            )(else
                (if (not script and (== (send gEgo:edgeHit) 1))
                    proc0_2()
                    (self:setScript(exitScript))
                )
            )
        )
        (super:doit())
        = temp0 (send gEgo:onControl(1))
        (if (script)
        )(else
            (if ((butte:junctioned) and not (send (ScriptID(703 4)):script))
                (send (ScriptID(703 4)):setScript(copEnters))
            )(else
                (if ((((((& temp0 $0010) or (& temp0 $0020)) or (& temp0 $0040)) or (& temp0 $0080)) or (& temp0 $0100)) or (& temp0 $0002))
                    proc0_2()
                    (self:setScript(fallScript 0 temp0))
                )
            )
        )
        (if (script)
        )(else
            (if ((< (send gEgo:x) 167) and (< (send gEgo:y) 67))
                (send gEgo:setPri(4))
            )(else
                (if ((> (send gEgo:x) 270) and (> (send gEgo:y) 113))
                    (send gEgo:setPri(11))
                )(else
                    (send gEgo:setPri(8))
                )
            )
        )
    )

)
(instance fallScript of Script
    (properties)

    (method (changeState newState)
        (var temp0[2])
        (switch (= state newState)
            (case 0
                (if (& register $0002)
                    (send gEgo:setPri(15))
                )(else
                    (if (& register $0010)
                        0
                    )(else
                        (if (& register $0020)
                            (send gEgo:setPri(3))
                        )(else
                            (if (& register $0040)
                                (send gEgo:setPri(2))
                            )(else
                                (if (& register $0080)
                                    (send gEgo:
                                        x(- (send gEgo:x) 7)
                                        setPri(1)
                                    )
                                )(else
                                    (if (& register $0100)
                                        (send gEgo:setPri(3))
                                    )
                                )
                            )
                        )
                    )
                )
                (send global2:setScript(ScriptID(703 1)))
                (self:dispose())
            )
        )
    )

)
(instance enterScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (if (== global12 299)
                    (if (< (send gEgo:x) 190)
                        (send gEgo:
                            x(120)
                            y(30)
                            setMotion(MoveTo 99 50 self)
                        )
                    )(else
                        (send gEgo:
                            x((send gEgo:x))
                            y(65531)
                            setMotion(MoveTo + (send gEgo:x) 23 30 self)
                        )
                    )
                )(else
                    (if ((< 75 (send gEgo:y)) and (< (send gEgo:y) 110))
                        (send gEgo:
                            x(- 319 (/ CelWide((send gEgo:view) (send gEgo:loop) (send gEgo:cel)) 2))
                            setMotion(MoveTo 283 99 self)
                        )
                    )(else
                        (send gEgo:x((- 319 (/ CelWide((send gEgo:view) (send gEgo:loop) (send gEgo:cel)) 2))))
                        = cycles 1
                    )
                )
            )
            (case 1
                proc0_3()
                (self:dispose())
            )
        )
    )

)
(instance exitScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send gEgo:setMotion(MoveTo (send gEgo:x) 65533 self))
            )
            (case 1
                (send global2:newRoom((send global2:north)))
            )
        )
    )

)
(instance copEnters of Script
    (properties)

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


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (if (== (butte:oldPoliceRoom) 299)
                    (send (ScriptID(703 4)):posn(121 50))
                )
                (send (ScriptID(703 4)):
                    setPri(4)
                    init()
                    illegalBits(0)
                    setCycle(Walk)
                    setMotion(PolyPath 101 57 self)
                )
            )
            (case 1
                (send (ScriptID(703 4)):
                    setPri(8)
                    setMotion(PolyPath 97 78 self)
                )
            )
            (case 2
                (send (ScriptID(703 4)):setMotion(PolyPath 132 131 self))
            )
            (case 3
                (send (ScriptID(703 4)):setMotion(PolyPath (send gEgo:x) (send gEgo:y) self))
            )
        )
    )

)
(instance theRoom of Feature
    (properties
        nsBottom 200
        nsRight 320
        description "buttes"
        lookStr "You're surrounded by spires of sand and rock.  Over the years, the ravages of wind, water and time have exposed strata in the butte which seem to serve nicely as steps.   Far below, the serene and tempting Sea of Estros beckons to you."
    )

    (method (doVerb param1)
        (switch (param1)
            (case 4
                (send (ScriptID(703 6)):doVerb(param1))
            )
            (case 1
                Print("You're surrounded by spires of sand and rock.  Over the years, the ravages of wind, water and time have exposed strata in the butte which seem to serve nicely as steps.   Far below, the serene and tempting Sea of Estros beckons to you.")
            )
            (default 
                (super:doVerb())
            )
        )
    )

)
