(version 2)
(include "sci.sh")
(exports
    0 rm530
)
(use "Main")
(use "TellerIcon")
(use "OccasionalCycle")
(use "PAvoider")
(use "PolyPath")
(use "Polygon")
(use "StopWalk")
(use "Grooper")
(use "Cycle")
(use "Game")
(use "View")
(use "Obj")
(script 530)


(local
    local0[4] = (0 5 -6 999 )
    local4[2]
    local6[5] = (0 3 4 2 999 )
    local11[2]

)
(instance public rm530 of Rm
    (properties
        picture 400
        vanishingY -200
    )

    (method (init)
        (send global2:addObstacle((send ((Polygon:new())):
                type(2)
                init(0 117 87 135 161 145 158 152 115 153 138 174 222 186 316 185 317 168 264 148 319 147 319 189 0 189)
                yourself()
            )
 (send ((Polygon:new())):
                type(2)
                init(319 122 137 123 0 101 0 0 319 0)
                yourself()
            )
))
        = local4[0] @local0
        (egoTeller:init(gOwner @local0 @local4))
        (send gOwner:
            x(330)
            y(150)
            changeGait(1)
            normalize()
            setScale(190)
            noun(2)
            init()
        )
        = local11[0] @local6
        (yesufuTeller:init(ScriptID(39 1) @local6 @local11))
        (send (ScriptID(39 1)):
            view(501)
            loop(0)
            cel(4)
            x(215)
            y(166)
            setScale(190)
            setCycle(OccasionalCycle self 1 70 130)
            noun(1)
            init()
        )
        (super:init())
        (tree:addToPic())
        (grass:addToPic())
        (rock:addToPic())
        (tree2:addToPic())
        (rock3:addToPic())
        (rock4:addToPic())
        (trap:addToPic())
        (send global2:setScript(enterRoom))
    )


    (method (doit param1)
        (if ((send global2:script))
            0
        )(else
            (if (<= (send gOwner:x) 5)
                (send global2:setScript(exitEgo))
            )(else
                (if (>= (send gOwner:x) 315)
                    (send global2:setScript(exitEgoR))
                )
            )
        )
        (super:doit(rest param1))
    )


    (method (dispose)
        DisposeScript(39)
        (super:dispose())
    )


    (method (doVerb theVerb)
        (switch (theVerb)
            (case 65
                (send gQg3Messager:say(3 6 7))
            )
            (default 
                (super:doVerb(theVerb))
            )
        )
    )

)
(instance enterRoom of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gOwner:setMotion(PolyPath 200 150 self))
            )
            (case 1
                proc0_3()
                (self:dispose())
            )
        )
    )

)
(instance freeYesufu of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gQg3Messager:say(1 4 0 0 self))
            )
            (case 1
                proc0_4(30)
                (send gOwner:
                    setMotion(PolyPath 215 156 self)
                    solvePuzzle(287 8 9)
                )
            )
            (case 2
                (send gOwner:
                    view(4)
                    setLoop(3)
                    cel(0)
                    setCycle(End self)
                )
            )
            (case 3
                (send (ScriptID(39 1)):
                    setLoop(1)
                    cel(0)
                    setCycle(End self)
                )
                (send gOwner:setCycle(Beg self))
            )
            (case 4
            )
            (case 5
                (send gQg3Messager:say(1 6 1 0 self))
            )
            (case 6
                (send gOwner:
                    normalize()
                    setMotion(PolyPath 200 128 self)
                )
                (send (ScriptID(39 1)):
                    view(983)
                    setCycle(StopWalk -1)
                    setLoop(-1)
                    setLoop(yesufuStopGroop)
                    setStep(6 4)
                    xStep(6)
                    yStep(4)
                    setMotion(PolyPath 200 140)
                )
            )
            (case 7
                (send gOwner:setMotion(PolyPath -20 103 self))
                (send (ScriptID(39 1)):setMotion(PolyPath -20 114))
            )
            (case 8
                (send gOwner:addHonor(50))
                (send global2:newRoom(500))
            )
        )
    )

)
(instance exitEgo of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gOwner:setMotion(PolyPath (- (send gOwner:x) 20) (send gOwner:y) self))
            )
            (case 1
                (send global2:newRoom(500))
            )
        )
    )

)
(instance exitEgoR of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gOwner:setMotion(PolyPath (+ (send gOwner:x) 20) (send gOwner:y) self))
            )
            (case 1
                (send global2:newRoom(500))
            )
        )
    )

)
(instance egoTeller of Teller
    (properties)

    (method (doChild)
        (if (== query -6)
            (send gOwner:
                setAvoider(PAvoider)
                setMotion(PolyPath -10 103)
            )
        )
    )

)
(instance yesufuTeller of Teller
    (properties)

    (method (doVerb theVerb param2)
        (switch (theVerb)
            (case 4
                (if ((send global2:script))
                    0
                )(else
                    (send global2:setScript(freeYesufu))
                )
            )
            (default 
                (super:doVerb(theVerb rest param2))
            )
        )
    )

)
(instance tree of View
    (properties
        x 240
        y 114
        view 400
        loop 2
        cel 1
    )

    (method (onMe)
        return 0
    )

)
(instance grass of View
    (properties
        x 268
        y 200
        view 400
        loop 1
    )

    (method (onMe)
        return 0
    )

)
(instance rock of View
    (properties
        x 311
        y 120
        view 400
        cel 2
    )

    (method (onMe)
        return 0
    )

)
(instance tree2 of View
    (properties
        x 161
        y 75
        view 400
        cel 1
    )

    (method (onMe)
        return 0
    )

)
(instance rock2 of View
    (properties
        x 9
        y 57
        view 400
        cel 2
    )

    (method (onMe)
        return 0
    )

)
(instance rock3 of View
    (properties
        x 33
        y 76
        view 400
        cel 2
    )

    (method (onMe)
        return 0
    )

)
(instance rock4 of View
    (properties
        x 36
        y 145
        view 400
        cel 2
    )

    (method (onMe)
        return 0
    )

)
(instance trap of View
    (properties
        x 194
        y 153
        view 401
        loop 3
        cel 1
        signal $4000
    )

    (method (onMe)
        return 0
    )

)
(instance yesufuStopGroop of Grooper
    (properties)

    (method (doit param1)
        (if (IsObject((send (ScriptID(39 1)):cycler)) and (send ((send (ScriptID(39 1)):cycler)):isKindOf(StopWalk)))
            (send (ScriptID(39 1)):view((send ((send (ScriptID(39 1)):cycler)):vWalking)))
        )
        (super:doit(rest param1))
    )

)
