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



(instance public rm310 of SQRoom
    (properties
        picture 310
        horizon 15
        north 300
        east 315
        south 320
        west 306
    )

    (method (init)
        proc958_0(128 0 300)
        (if (> (butte:policeLanded) 0)
            Load(rsVIEW 305)
            Load(rsPIC 300)
        )(else
            proc958_0(128 7 5)
        )
        (switch (gWest)
            (case north
                proc0_2()
                (self:
                    setScript(enterScript)
                    style(42)
                )
            )
            (case south
                proc0_2()
                (self:
                    setScript(enterScript)
                    style(43)
                )
                (send gEgo:
                    illegalBits(0)
                    setPri(6)
                )
            )
            (case east
                (self:
                    setScript(enterScript)
                    style(40)
                )
                (send gEgo:
                    setPri(13)
                    cel(4)
                    x(305)
                    y(
                        (if (< (send gEgo:y) 103)
                            103
                        )(else
                            (send gEgo:y)
                        )
)
                )
            )
            (case west
                (if (< (send gEgo:y) 110)
                    (send gEgo:setPri(12))
                )(else
                    (send gEgo:setPri(14))
                )
                (self:
                    style(41)
                    setScript(enterScript)
                )
            )
            (default 
                (send gEgo:
                    illegalBits(0)
                    posn(155 92)
                    setPri(6)
                )
                proc0_3()
            )
        )
        (if (((== gWest 300) and not (butte:sawGirlShadow)) and not Btest(32))
            (shadow:
                init()
                setScript(shadowMoves)
            )
        )
        (send gEgo:init())
        (super:init())
        (if ((== gWest 300) or (== gWest 320))
            (self:
                setFeatures(theBridge theRoom)
                addObstacle((send ((Polygon:new())):
                        type(1)
                        init(157 0 157 11 128 13 124 30 89 49 60 78 69 94 109 107 195 175 199 189 0 189 0 0)
                        yourself()
                    )
 (send ((Polygon:new())):
                        type(1)
                        init(319 0 319 189 273 189 259 173 265 150 236 105 185 76 185 46 225 41 278 12 280 0)
                        yourself()
                    )
)
            )
        )(else
            (send global2:
                setFeatures(theStairs theRoom)
                addObstacle((send ((Polygon:new())):
                        type(2)
                        init(0 102 34 105 32 115 0 123)
                        yourself()
                    )
 (send ((Polygon:new())):
                        type(1)
                        init(319 189 0 189 0 129 20 123 44 121 55 112 54 104 21 95 0 94 0 43 17 41 57 21 167 0 319 0 319 100 272 103 260 106 196 116 180 128 162 136 155 145 213 141 236 152 226 159 259 158 287 154 285 149 227 145 226 135 288 123 319 120)
                        yourself()
                    )
)
            )
            (send gEgo:illegalBits(32768))
        )
        (if (== (butte:curPolice1Room) 310)
            (butte:junctioned(1))
            (send (ScriptID(703 4)):
                loop(1)
                setPri(13)
                posn(240 120)
                init()
                setScript(
                    (if ((== gWest 300) or (== gWest 320))
                        copOnLedge
                    )(else
                        (if (== gWest 306)
                            egoOnLedge
                        )(else
                            copEnters
                        )
                    )
)
            )
        )(else
            (if (== (butte:curPolice2Room) 310)
                (butte:junctioned(1))
                (send (ScriptID(703 4)):
                    posn(136 70)
                    setPri(8)
                    init()
                    loop(
                        (if (== (butte:oldPoliceRoom) 320)
                            3
                        )(else
                            2
                        )
)
                    setScript(
                        (if ((== gWest 300) or (== gWest 320))
                            copEnters
                        )(else
                            copOnStairs
                        )
)
                )
            )(else
                (butte:junctioned(0))
            )
        )
        (self:setRegions(703))
    )


    (method (doit)
        (var temp0)
        (if (script)
        )(else
            (if (== (send gEgo:edgeHit) 1)
                proc0_2()
                (self:setScript(exitNorthScript))
            )
        )
        (super:doit())
        = temp0 (send gEgo:onControl(1))
        (if ((((== script ScriptID(703 1)) and (== (send gEgo:edgeHit) 3)) and (< (send gEgo:x) 160)) and (> (send gEgo:y) 38))
            (butte:egoSwims(1))
            proc0_2()
            (self:setScript(exitScript))
        )(else
            (if (script)
            )(else
                (if (== (send gEgo:edgeHit) 3)
                    proc0_2()
                    (self:setScript(exitScript))
                )(else
                    (if ((butte:junctioned) and not (send (ScriptID(703 4)):script))
                        (if (== (butte:curPolice1Room) 310)
                            (if ((== gWest 300) or (== gWest 320))
                                (send (ScriptID(703 4)):
                                    posn(325 120)
                                    setPri(13)
                                    init()
                                    setScript(copOnLedge)
                                )
                            )(else
                                (if (== gWest 306)
                                    (send (ScriptID(703 4)):
                                        posn(325 120)
                                        setPri(13)
                                        init()
                                        setScript(egoOnLedge)
                                    )
                                )(else
                                    (if (== (butte:oldPoliceRoom) 300)
                                        (send (ScriptID(703 4)):posn(177 0))
                                    )(else
                                        (if (== (butte:oldPoliceRoom) 315)
                                            (send (ScriptID(703 4)):posn(325 110))
                                        )(else
                                            (if (== (butte:oldPoliceRoom) 320)
                                                (send (ScriptID(703 4)):posn(195 250))
                                            )
                                        )
                                    )
                                    (send (ScriptID(703 4)):
                                        init()
                                        setScript(copEnters)
                                    )
                                )
                            )
                        )(else
                            (if (== (butte:curPolice2Room) 310)
                                (butte:junctioned(1))
                                (if ((== gWest 300) or (== gWest 320))
                                    (if (== (butte:oldPoliceRoom) 300)
                                        (send (ScriptID(703 4)):posn(177 0))
                                    )(else
                                        (if (== (butte:oldPoliceRoom) 315)
                                            (send (ScriptID(703 4)):posn(325 110))
                                        )(else
                                            (if (== (butte:oldPoliceRoom) 320)
                                                (send (ScriptID(703 4)):posn(195 250))
                                            )
                                        )
                                    )
                                    (send (ScriptID(703 4)):
                                        init()
                                        setScript(copEnters)
                                    )
                                )(else
                                    (if (== (butte:oldPoliceRoom) 300)
                                        (send (ScriptID(703 4)):posn(177 0))
                                    )(else
                                        (if (== (butte:oldPoliceRoom) 320)
                                            (send (ScriptID(703 4)):posn(195 200))
                                        )
                                    )
                                    (send (ScriptID(703 4)):
                                        init()
                                        setScript(copOnStairs)
                                    )
                                )
                            )
                        )
                    )(else
                        (if (((((& temp0 $0002) or (& temp0 $0004)) or (& temp0 $0040)) or (& temp0 $0080)) or (& temp0 $0008))
                            (if ((== gWest 300) or (== gWest 320))
                                proc0_2()
                                (self:setScript(fallScript 0 temp0))
                            )
                        )(else
                            (if (((((& temp0 $0010) or (& temp0 $0100)) or (& temp0 $2000)) or (& temp0 $0020)) and ((== gWest 306) or (== gWest 315)))
                                proc0_2()
                                (self:setScript(fallScript 0 temp0))
                            )
                        )
                    )
                )
            )
        )
        return 
            (if (script)
            )(else
                (if ((== gWest 315) and (> (send gEgo:y) 150))
                    (send gEgo:setPri(14))
                )(else
                    (if ((== gWest 315) and (send gEgo:setPri(13)))
                    )(else
                        (if ((== gWest 306) and (> (send gEgo:y) 110))
                            (send gEgo:setPri(14))
                        )(else
                            (if ((== gWest 306) and (send gEgo:setPri(12)))
                            )(else
                                0
                            )
                        )
                    )
                )
            )
    )

)
(instance fallScript of Script
    (properties)

    (method (changeState newState)
        (var temp0[2])
        (switch (= state newState)
            (case 0
                (if (& register $0100)
                    (send gEgo:setPri((- (send gEgo:priority) 3)))
                )(else
                    (if (& register $0002)
                        (send gEgo:
                            posn(+ (send gEgo:x) 7 - (send gEgo:y) 5)
                            setPri(- (send gEgo:priority) 3)
                        )
                    )(else
                        (if (& register $0004)
                            (send gEgo:
                                x(+ (send gEgo:x) 10)
                                setPri(- (send gEgo:priority) 3)
                            )
                        )(else
                            (if (& register $0040)
                                (send gEgo:x((- (send gEgo:x) 10)))
                            )(else
                                (if (& register $0080)
                                    (send gEgo:
                                        x(- (send gEgo:x) 7)
                                        setPri(- (send gEgo:priority) 3)
                                    )
                                )(else
                                    (if (& register $0010)
                                        (if (< (send gEgo:y) 150)
                                            (send gEgo:setPri((- (send gEgo:priority) 1)))
                                        )(else
                                            (send gEgo:setPri(15))
                                        )
                                    )(else
                                        (if (& register $2000)
                                            (send gEgo:
                                                x(+ (send gEgo:x) 6)
                                                setPri(- (send gEgo:priority) 1)
                                            )
                                        )(else
                                            (if (& register $0008)
                                                (send gEgo:
                                                    posn(+ (send gEgo:x) 4 - (send gEgo:y) 5)
                                                    setPri(- (send gEgo:priority) 3)
                                                )
                                            )(else
                                                (if (& register $0020)
                                                    (send gEgo:setPri(9))
                                                )
                                            )
                                        )
                                    )
                                )
                            )
                        )
                    )
                )
                (send global2:setScript(ScriptID(703 1)))
                (self:dispose())
            )
        )
    )

)
(instance exitScript of Script
    (properties)

    (method (changeState newState)
        (var temp0, temp1)
        (switch (= state newState)
            (case 0
                (if (not (butte:egoSwims))
                    (send gEgo:setHeading(180 self))
                )(else
                    (self:cue())
                )
            )
            (case 1
                = temp0 CelHigh((send gEgo:view) (send gEgo:loop) (send gEgo:cel))
                (send gEgo:setMotion(MoveToY (+ 189 temp0) self))
            )
            (case 2
                (send global2:newRoom((send global2:south)))
            )
        )
    )

)
(instance exitNorthScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (if (not 
                (if (== gWest 300)
                )(else
                    == gWest 320
                )
)
                    (butte:onLedgeFlag(1))
                    (send gEgo:setMotion(MoveTo 133 65534 self))
                )(else
                    (send gEgo:setMotion(MoveTo (send gEgo:x) 65534 self))
                )
            )
            (case 1
                (send global2:newRoom((send global2:north)))
            )
        )
    )

)
(instance enterScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (if (== gWest 300)
                    (if ((butte:onLedgeFlag))
                        (butte:onLedgeFlag(0))
                        = gWest 306
                        (send gEgo:
                            illegalBits(0)
                            setPri(9)
                            posn((send gEgo:x) 0)
                            setMotion(MoveTo - (send gEgo:x) 50 17 self)
                        )
                    )(else
                        (send gEgo:
                            view(0)
                            illegalBits(0)
                            setPri(6)
                            x(
                                (if (<= (send gEgo:x) 203)
                                    (send gEgo:x)
                                )(else
                                    203
                                )
)
                            y(48)
                            setMotion(MoveTo 180 49 self)
                        )
                    )
                )(else
                    (if (== gWest 320)
                        (send gEgo:
                            posn(
                                (if (> (send gEgo:x) 190)
                                    - (send gEgo:x) 5
                                )(else
                                    + (send gEgo:x) 5
                                )
 189)
                            setMotion(MoveTo 192 140 self)
                        )
                    )(else
                        (if (((== gWest 306) and (< 75 (send gEgo:y))) and (< (send gEgo:y) 110))
                            (send gEgo:
                                x(+ 0 (/ CelWide((send gEgo:view) (send gEgo:loop) (send gEgo:cel)) 2))
                                setMotion(MoveTo 21 99 self)
                            )
                        )(else
                            (if (== gWest 315)
                                (send gEgo:x((- 319 (/ CelWide((send gEgo:view) (send gEgo:loop) (send gEgo:cel)) 2))))
                                = cycles 1
                            )(else
                                (send gEgo:x((+ 0 (/ CelWide((send gEgo:view) (send gEgo:loop) (send gEgo:cel)) 2))))
                                = cycles 1
                            )
                        )
                    )
                )
            )
            (case 1
                proc0_3()
                (self:dispose())
            )
        )
    )

)
(instance copOnStairs of Script
    (properties)

    (method (doit)
        (if (not (send global2:script) and (== state 0))
            (self:cue())
        )
        (super:doit())
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                0
            )
            (case 1
                (send (ScriptID(703 4)):
                    setCycle(Walk)
                    setMotion(MoveTo 136 70 self)
                )
            )
            (case 2
                (if (== (send (ScriptID(703 4)):loop) 2)
                    (send (ScriptID(703 4)):setScript(ScriptID(703 5)))
                    (self:dispose())
                )(else
                    (send (ScriptID(703 4)):setMotion(MoveTo 182 -1 self))
                )
            )
        )
    )

)
(instance copOnLedge of Script
    (properties)

    (method (doit)
        (if (not (send global2:script) and (== state 0))
            (self:cue())
        )
        (super:doit())
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                0
            )
            (case 1
                (send (ScriptID(703 4)):
                    setCycle(Walk)
                    setMotion(MoveTo 240 (send (ScriptID(703 4)):y) self)
                )
            )
            (case 2
                (send (ScriptID(703 4)):setMotion(MoveTo (send (ScriptID(703 4)):x) (- (send (ScriptID(703 4)):y) 3)))
                (if ((< (send gEgo:y) 140) and not (send global2:script))
                    ScriptID(703 3)
                    (send (ScriptID(703 4)):setScript(ScriptID(703 5)))
                    (self:dispose())
                )(else
                    = cycles 1
                )
            )
            (case 3
                (send (ScriptID(703 4)):setMotion(MoveTo (- (send (ScriptID(703 4)):x) 3) (send (ScriptID(703 4)):y) self))
            )
            (case 4
                (send (ScriptID(703 4)):setMotion(MoveTo (+ (send (ScriptID(703 4)):x) 3) (- (send (ScriptID(703 4)):y) 3)))
                (if ((< (send gEgo:y) 110) and not (send global2:script))
                    ScriptID(703 3)
                    (send (ScriptID(703 4)):setScript(ScriptID(703 5)))
                    (self:dispose())
                )(else
                    = cycles 1
                )
            )
            (case 5
                (send (ScriptID(703 4)):setMotion(MoveTo 330 (send (ScriptID(703 4)):y) self))
            )
        )
    )

)
(instance egoOnLedge of Script
    (properties)

    (method (doit)
        (if (not (send global2:script) and (== state 0))
            (self:cue())
        )
        (super:doit())
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                0
            )
            (case 1
                1
                (send (ScriptID(703 4)):
                    setCycle(Walk)
                    setMotion(MoveTo 169 135 self)
                )
            )
            (case 2
                2
                (if (not (send global2:script))
                    (send (ScriptID(703 4)):setScript(ScriptID(703 5)))
                )
                (self:dispose())
            )
        )
    )

)
(instance copEnters of Script
    (properties)

    (method (doit)
        (if (not (send global2:script) and (== state 0))
            (self:cue())
        )
        (if ((< (send (ScriptID(703 4)):distanceTo(gEgo)) 60) and not (send global2:script))
            (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(PolyPath (send gEgo:x) (send gEgo:y) self)
                )
            )
        )
    )

)
(instance shadow of Actor
    (properties
        x 38
        y 187
        description "mysterious shadow"
        lookStr "A mysterious shadow quickly moves from your view."
        view 310
    )
)
(instance shadowMoves of Script
    (properties)

    (method (doit param1)
        (super:doit(rest param1))
        (if (((not script and not (send global2:script)) and (== gWest 300)) and not (butte:sawGirlShadow))
            (butte:sawGirlShadow(1))
            (self:cue())
        )
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                0
            )
            (case 1
                1
                (shadow:setCycle(End self))
            )
            (case 2
                2
                (shadow:setMotion(MoveTo (- (shadow:x) CelWide((shadow:view) (shadow:loop) (shadow:cel))) (+ (shadow:y) CelHigh((shadow:view) (shadow:loop) (shadow:cel))) self))
            )
            (case 3
                3
                Print("You get the feeling you're not alone here.")
                (shadow:dispose())
                (self:dispose())
            )
        )
    )

)
(instance theRoom of Feature
    (properties
        nsBottom 200
        nsRight 320
        description "buttes"
        lookStr "As you look around at the towering rock structures; immense and ageless formations carved over millions of years by the magnificent and placid Sea of Estros, you can't help but be overwhelmed with a sense of your own total insignificance."
    )

    (method (doVerb param1)
        (switch (param1)
            (case 4
                (send (ScriptID(703 6)):doVerb(param1))
            )
            (case 1
                Print("As you look around at the towering rock structures; immense and ageless formations carved over millions of years by the magnificent and placid Sea of Estros, you can't help but be overwhelmed with a sense of your own total insignificance.")
            )
            (default 
                (super:doVerb())
            )
        )
    )

)
(instance theStairs of Feature
    (properties
        nsBottom 200
        nsRight 320
        description "stairs"
        onMeCheck 16384
        lookStr "Looking out across the butte you see a stairway of wind-eroded rock winding its way down to the water below."
    )
)
(instance theBridge of Feature
    (properties
        nsBottom 200
        nsRight 320
        description "bridge"
        onMeCheck 2048
        lookStr "Looking out across the expanse you see a natural bridge of rock."
    )
)
