(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 "User")
(use "PicView")
(use "Obj")
(script 305)



(instance public rm305 of SQRoom
    (properties
        picture 305
        south 315
        west 300
    )

    (method (init)
        (if (Btest(16))
            (send (ScriptID(703 4)):
                init()
                view(13)
                loop(0)
                posn(0 80)
            )
        )
        (if (((== (butte:curPolice1Room) 305) or (== (butte:curPolice2Room) 305)) and ((< (butte:policeLanded) 0) or Btest(16)))
            (send (ScriptID(703 4)):
                posn(0 80)
                init()
                forceUpd()
            )
        )
        (if (((< (butte:policeLanded) 0) and ((== (butte:curPolice1Room) 305) or (== (butte:curPolice2Room) 305))) and (== (send gEgo:view) 0))
            (butte:junctioned(1))
            (send (ScriptID(703 4)):
                init()
                setScript(copEnters)
            )
        )(else
            (butte:junctioned(0))
        )
        proc958_0(128 0 305 300)
        proc958_0(132 124 125)
        (send global2:addObstacle((send ((Polygon:new())):
                type(2)
                init(124 0 319 0 319 116 258 116 246 113 245 91 165 102 147 90 145 80 122 72)
                yourself()
            )
 (send ((Polygon:new())):
                type(1)
                init(0 0 112 0 112 71 60 70 0 66)
                yourself()
            )
 (send ((Polygon:new())):
                type(1)
                init(0 85 66 84 127 89 143 103 135 112 104 117 103 130 90 132 86 151 59 178 62 189 0 189)
                yourself()
            )
 (send ((Polygon:new())):
                type(1)
                init(319 189 186 189 187 165 170 152 165 125 250 125 254 122 319 123)
                yourself()
            )
))
        (if (> (butte:policeLanded) 0)
            Load(rsPIC 300)
        )(else
            proc958_0(128 7 5)
        )
        (self:
            setRegions(703)
            setFeatures(theStairs theRoom)
        )
        proc0_3()
        (switch (gWest)
            (case south
                (send gEgo:init())
                (self:style(43))
            )
            (case west
                (self:style(41))
                (send gEgo:
                    init()
                    y(
                        (if (< (send gEgo:y) 67)
                            67
                        )(else
                            (if (> (send gEgo:y) 88)
                                88
                            )(else
                                (send gEgo:y)
                            )
                        )
)
                    setHeading(90 self)
                )
            )
            (default 
                proc0_2()
                (send gLongSong:
                    number(18)
                    loop(-1)
                    vol(127)
                    flags(1)
                    playBed()
                )
                (if (Btest(2))
                    (self:setScript(egoLands))
                )(else
                    (send gEgo:
                        view(378)
                        loop(0)
                        cel(0)
                        x(218)
                        y(97)
                        setPri(7)
                        normal(0)
                        moveHead(0)
                        init()
                    )
                    (self:setScript(egoExits))
                )
            )
        )
        proc0_14(10)
        (super:init())
        (if ((== gWest 300) or (== gWest 315))
            (send gEgo:
                setPri(8)
                ignoreActors(0)
                illegalBits(0)
            )
            (pod:
                loop(1)
                cel(10)
                init()
                stopUpd()
            )
            (door:
                init()
                setPri(5)
            )
        )
    )


    (method (doit)
        (var temp0)
        (if (script)
            0
        )(else
            (if (== (send gEgo:edgeHit) 3)
                proc0_2()
                (self:setScript(exitSouthScript))
            )
        )
        (super:doit())
        = temp0 (send gEgo:onControl(1))
        (if (script)
        )(else
            (if (== (send gEgo:edgeHit) 3)
                proc0_2()
                (self:setScript(exitSouthScript))
            )(else
                (if ((butte:junctioned) and not (send (ScriptID(703 4)):script))
                    (if (== (butte:oldPoliceRoom) 300)
                        (send (ScriptID(703 4)):posn(65531 75))
                    )(else
                        (if (== (butte:oldPoliceRoom) 315)
                            (send (ScriptID(703 4)):posn(150 250))
                        )
                    )
                    (send (ScriptID(703 4)):init())
                    (send (ScriptID(703 4)):setScript(copEnters))
                )(else
                    (if ((((((& temp0 $0002) or (& temp0 $0004)) or (& temp0 $0010)) or (& temp0 $0080)) or (& temp0 $0100)) or (& temp0 $0200))
                        proc0_2()
                        (self:setScript(fallScript 0 temp0))
                    )(else
                        (if ((& temp0 $4000) and (== (send gEgo:view) 0))
                            (send gEgo:view(0))
                        )(else
                            (if (((<> script exitSouthScript) and not (& temp0 $4000)) and (== (send gEgo:view) 0))
                                (send gEgo:view(0))
                            )
                        )
                    )
                )
            )
        )
        (if (script)
        )(else
            (if ((< (send gEgo:y) 96) and (> (send gEgo:x) 142))
                (send gEgo:setPri(5))
            )(else
                (if (> (send gEgo:y) 113)
                    (send gEgo:setPri(15))
                )(else
                    (if (> (send gEgo:y) 86)
                        (send gEgo:setPri(13))
                    )(else
                        (send gEgo:setPri(8))
                    )
                )
            )
        )
    )


    (method (newRoom param1)
        (if (== param1 531)
            (send gLongSong:stop())
        )
        (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 $0100)
                    (send gEgo:setPri(3))
                )(else
                    (if (& register $0200)
                        (send gEgo:
                            x(+ (send gEgo:x) 10)
                            setPri(4)
                        )
                    )(else
                        (if (& register $0002)
                            (send gEgo:
                                x(- (send gEgo:x) 10)
                                setPri(4)
                            )
                        )(else
                            (if ((& register $0010) and (> (send gEgo:x) 170))
                                (send gEgo:setPri(6))
                            )(else
                                (send gEgo:setPri(4))
                            )
                        )
                    )
                )
                (send global2:setScript(ScriptID(703 1)))
            )
        )
    )

)
(instance exitSouthScript of Script
    (properties)

    (method (changeState newState)
        (var temp0, temp1)
        (switch (= state newState)
            (case 0
                (send gEgo:setHeading((+ 180 (/ (- (send gEgo:x) 210) 3)) self))
            )
            (case 1
                = temp0 (+ CelHigh((send gEgo:view) (send gEgo:loop) (send gEgo:cel)) 1)
                (send gEgo:setMotion(MoveToY (+ 189 temp0) self))
            )
            (case 2
                (send global2:newRoom((send global2:south)))
            )
        )
    )

)
(instance egoLands of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (podFlash:
                    init()
                    setCycle(Fwd)
                )
                = cycles 1
            )
            (case 1
                (send gLongSong2:
                    number(838)
                    vol(127)
                    loop(1)
                    play()
                )
                = cycles 24
            )
            (case 2
                (pod:
                    init()
                    setCycle(CT 9 1 self)
                )
            )
            (case 3
                (send gLongSong2:fade())
                (door:
                    init()
                    setPri(+ (pod:priority) 1)
                )
                (pod:setCycle(End self))
            )
            (case 4
                (send gLongSong2:stop())
                (podFlash:dispose())
                = cycles 3
            )
            (case 5
                proc0_3()
                (send global2:newRoom(531))
            )
        )
    )

)
(instance egoExits of Script
    (properties)

    (method (doit param1)
        (super:doit(rest param1))
        (if ((== state 1) and (== (send gLongSong2:prevSignal) -1))
            (self:cue())
        )
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (door:init())
                (pod:
                    setCel(10)
                    init()
                )
                (if (Btest(16))
                    (send (ScriptID(703 4)):init())
                )
                = cycles 1
            )
            (case 1
                (send gLongSong2:
                    number(124)
                    loop(1)
                    vol(127)
                    play()
                )
            )
            (case 2
                (send gLongSong2:
                    number(142)
                    play()
                )
                (door:setCycle(End))
                = cycles 1
            )
            (case 3
                (door:setCycle(End self))
            )
            (case 4
                (send gLongSong2:stop())
                (send gEgo:setCycle(End self))
            )
            (case 5
                (pod:
                    priority(-1)
                    stopUpd()
                )
                (send gEgo:
                    view(0)
                    loop(1)
                    normal(1)
                    moveHead(1)
                    x(221)
                    y(97)
                )
                proc0_1()
                = cycles 3
            )
            (case 6
                (send gLongSong2:
                    number(142)
                    play()
                )
                (door:
                    setPri(3)
                    setCycle(Beg self)
                )
            )
            (case 7
                (send gLongSong2:stop())
                proc0_3()
                (User:canControl(1))
                (send client:setScript(0))
            )
        )
    )

)
(instance enterPod of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send gEgo:setMotion(PolyPath 221 97 self))
                = cycles 10
            )
            (case 1
                (if ((send gCast:contains(ScriptID(703 4))))
                    (send gEgo:setMotion(0))
                    proc0_13(gEgo ScriptID(703 4))
                    (send (ScriptID(703 4)):setScript(ScriptID(703 5)))
                    (self:dispose())
                )(else
                    (send gEgo:setMotion(PolyPath 221 97 self))
                )
            )
            (case 2
                (if ((send gCast:contains(ScriptID(703 4))))
                    (send gEgo:setMotion(0))
                    proc0_13(gEgo ScriptID(703 4))
                    (send (ScriptID(703 4)):setScript(ScriptID(703 5)))
                    (self:dispose())
                )(else
                    = cycles 1
                )
            )
            (case 3
                (send gLongSong2:
                    number(142)
                    play()
                )
                (door:setCycle(End self))
            )
            (case 4
                (send gEgo:
                    view(378)
                    normal(0)
                    loop(1)
                    cel(0)
                    x(224)
                    y(75)
                    illegalBits(0)
                    cycleSpeed(1)
                    setCycle(End self)
                )
            )
            (case 5
                (door:setPri((+ (send gEgo:priority) 1)))
                (send gLongSong2:
                    number(142)
                    loop(1)
                    vol(127)
                    play()
                )
                (door:
                    cel(9)
                    init()
                    setCycle(Beg self)
                )
            )
            (case 6
                (send gLongSong2:
                    number(125)
                    play()
                )
                (send gEgo:dispose())
                proc0_3()
                = cycles 2
            )
            (case 7
                (if (< (butte:policeLanded) 0)
                    Bset(16)
                )
                (send global2:newRoom(531))
            )
        )
    )

)
(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))
            (send (ScriptID(703 4)):setScript(ScriptID(703 5)))
        )
        (super:doit())
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                0
            )
            (case 1
                (send (ScriptID(703 4)):
                    illegalBits(0)
                    setCycle(Walk)
                    setMotion(MoveTo 146 95 self)
                )
            )
            (case 2
                (send (ScriptID(703 4)):setMotion(MoveTo (send gEgo:x) (send gEgo:y) self))
            )
        )
    )

)
(instance podFlash of Prop
    (properties)
)
(instance public pod of Prop
    (properties)

    (method (doVerb param1)
        (switch (param1)
            (case 2
                proc0_2()
                (send global2:setScript(enterPod))
            )
            (case 11
                Print("The smells of stressed carbon fiber, cooling engines and ozone fill the air.")
            )
            (case 10
                Print("Tasting the cooling time pod wouldn't be a good idea.")
            )
            (default 
                (super:doVerb(param1))
            )
        )
    )

)
(instance door of Prop
    (properties
        x 194
        y 61
        view 305
        loop 2
        priority 10
        signal 16
    )
)
(instance theStairs of Feature
    (properties
        nsBottom 200
        nsRight 320
        description "stairs"
        onMeCheck 16384
        lookStr "The shale-like shelves provide a stairway to the unknown."
    )
)
(instance theRoom of Feature
    (properties
        nsBottom 200
        nsRight 320
        description "buttes"
        lookStr "You've seen a lot of plateaus and sloping hills before, but this one's a butte.  Everywhere you look, the horizon undulates in the enticing peaks, curves and crevices for which Estros is famous."
    )

    (method (doVerb param1)
        (switch (param1)
            (case 4
                (send (ScriptID(703 6)):doVerb(param1))
            )
            (case 1
                Print("You've seen a lot of plateaus and sloping hills before, but this one's a butte.  Everywhere you look, the horizon undulates in the enticing peaks, curves and crevices for which Estros is famous.")
            )
            (default 
                (super:doVerb())
            )
        )
    )

)
