(version 2)
(include "sci.sh")
(exports
    0 rm800
)
(use "Main")
(use "TellerIcon")
(use "n026")
(use "Polygon")
(use "CueObj")
(use "n958")
(use "Cycle")
(use "Game")
(use "View")
(use "Obj")
(script 800)


(local
    local0
    local1
    local2[4] = (0 -2 11 999 )
    local6[2]
    local8[6] = (0 6 -7 9 10 999 )
    local14[4] = (0 3 8 999 )
    local18[3] = (0 -7 999 )
    local21[3]

)
(instance public rm800 of Rm
    (properties
        noun 4
        picture 800
    )

    (method (init)
        = local6[0] @local2
        = local21[0] @local8
        = local21[1] @local14
        (send gOwner:
            setScale(189)
            x(-10)
            y(182)
            noun(2)
            init()
            normalize()
        )
        (egoTell:init(gOwner @local2 @local6))
        (manuTell:init(ScriptID(41 1) @local8 @local21 @local18))
        proc0_3()
        (send global2:addObstacle((send ((Polygon:new())):
                type(3)
                init(136 189 148 184 109 184 132 161 193 162 200 156 159 159 140 155 102 155 0 167 0 189)
                yourself()
            )
))
        (super:init())
        (city:init())
        (skyTowers:init())
        (jungle:init())
        (tree:init())
        (send gQg3Walkers:addToFront(city))
        (send (ScriptID(41 1)):
            x(-20)
            y(175)
            setScale()
            noun(1)
            ignoreActors(1)
            init()
        )
        (if ((== gGClientModNum 550) and (== global155 0))
            proc26_0()
        )
        (if (== gGClientModNum 550)
            (send gLongSong:changeTo(180))
            (send gOwner:
                x(104)
                y(171)
            )
            (send (ScriptID(41 1)):
                x(157)
                y(167)
            )
        )
        (send global2:setScript(egoEnters))
        (apeManGuard:
            init()
            setScale(250)
            setCycle(Walk)
            setScript(guardPatrols)
        )
    )


    (method (doit)
        (if (script)
            0
        )(else
            (if (< (send gOwner:x) 10)
                (send global2:setScript(blockEgo))
            )
        )
        (super:doit())
    )


    (method (dispose)
        proc958_0(0 41)
        (send gQg3Walkers:delete(city))
        (super:dispose())
    )

)
(instance egoEnters of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gOwner:setMotion(MoveTo 104 171))
                (send (ScriptID(41 1)):
                    setCycle(Walk)
                    setMotion(MoveTo 157 167 self)
                )
            )
            (case 1
                (if (proc0_6(150))
                    (send gQg3Messager:say(3 6 14 0 self))
                )(else
                    (self:cue())
                )
            )
            (case 2
                (send (ScriptID(41 1)):ignoreActors(0))
                (send gQg3Messager:say(1 6 1))
                proc0_3()
                (self:dispose())
            )
        )
    )

)
(instance guardPatrols of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (apeManGuard:
                    setCycle(Walk)
                    setMotion(MoveTo 261 70 self)
                )
            )
            (case 1
                (apeManGuard:loop(2))
                = seconds 5
            )
            (case 2
                (apeManGuard:setMotion(MoveTo 330 78 self))
            )
            (case 3
                = state -1
                = seconds 10
            )
        )
    )

)
(instance egoExits of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                = seconds 2
            )
            (case 1
                (if (not local1)
                    (send gQg3Messager:say(1 6 3))
                )(else
                    (send gQg3Messager:say(1 6 2))
                )
                (send gOwner:setMotion(MoveTo 115 153 self))
            )
            (case 2
                (send gOwner:
                    setPri(1)
                    setLoop(3)
                    setMotion(MoveTo 115 173 self)
                )
            )
            (case 3
                (send global2:newRoom(810))
            )
        )
    )

)
(instance blockEgo of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (if (> local0 2)
                    (send gQg3Messager:say(1 6 5))
                )(else
                    (send gQg3Messager:say(1 6 4))
                )
                (send gOwner:
                    setLoop(1)
                    setMotion(MoveTo 30 175 self)
                )
            )
            (case 1
                (apeMan:
                    setScale()
                    init()
                    setCycle(Walk)
                    setMotion(MoveTo 10 170 self)
                )
            )
            (case 2
                = global365 575
                = gGMonsterMonHP 180
                (send global2:newRoom(550))
                proc0_3()
                (apeMan:dispose())
                (self:dispose())
            )
        )
    )

)
(instance apeMan of Actor
    (properties
        x -10
        y 170
        view 570
    )
)
(instance apeManGuard of Actor
    (properties
        x 319
        y 78
        noun 5
        view 570
    )
)
(instance city of Feature
    (properties
        x 121
        y 81
        noun 4
        nsTop 11
        nsBottom 152
        nsRight 243
        sightAngle 40
    )

    (method (doVerb theVerb)
        (switch (theVerb)
            (case 3
                (send global2:setScript(egoExits))
            )
            (default 
                (super:doVerb(theVerb))
            )
        )
    )

)
(instance skyTowers of Feature
    (properties
        x 203
        y 19
        noun 9
        nsTop -4
        nsLeft 94
        nsBottom 43
        nsRight 313
        sightAngle 180
    )
)
(instance jungle of Feature
    (properties
        x 258
        y 153
        noun 7
        nsTop 118
        nsLeft 197
        nsBottom 189
        nsRight 319
        sightAngle 180
    )
)
(instance tree of Feature
    (properties
        x 22
        y 97
        noun 8
        nsTop 46
        nsLeft 2
        nsBottom 149
        nsRight 42
        sightAngle 180
    )
)
(instance egoTell of Teller
    (properties)

    (method (doChild)
        return 
            (switch (query)
                (case -2
                    (if (not (send global2:script))
                        (send global2:setScript(egoExits))
                    )
                )
                (default 
                    return query
                )
            )
    )

)
(instance manuTell of Teller
    (properties)

    (method (doChild)
        return 
            (switch (query)
                (case -7
                    = local1 1
                    (super:doChild(query))
                )
                (default 
                    return query
                )
            )
    )

)
