(version 2)
(include "sci.sh")
(exports
    0 rm840
)
(use "Main")
(use "Polygon")
(use "n958")
(use "Cycle")
(use "Game")
(use "View")
(use "Obj")
(script 840)


(local
    local0

)
(instance public rm840 of Rm
    (properties
        picture 840
    )

    (method (init)
        (if (proc0_6(77))
            (send gOwner:
                setScale()
                x(160)
                y(137)
                init()
                normalize()
            )
        )(else
            (send gOwner:
                setScale()
                x(160)
                y(189)
                init()
                normalize()
            )
        )
        (super:init())
        (send gLongSong:
            number(840)
            setLoop(-1)
            play(self)
        )
        (if (proc0_6(77))
            (send global2:addObstacle((send ((Polygon:new())):
                    type(2)
                    init(48 83 129 83 143 143 167 164 167 173 132 189 32 189 32 83 50 83)
                    yourself()
                )
 (send ((Polygon:new())):
                    type(2)
                    init(162 189 195 158 195 83 319 83 319 189)
                    yourself()
                )
))
        )
        (if (proc0_6(77))
            (send global2:setScript(secondEntrance))
        )(else
            proc0_4(77)
            (send global2:setScript(firstEntrance))
        )
    )


    (method (dispose)
        proc958_0(0 41 36 39)
        (super:dispose())
    )


    (method (cue)
        (if (local0)
            (firstEntrance:cue())
            = local0 0
        )
    )

)
(instance firstEntrance of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gQg3Messager:say(2 6 4 0 self))
            )
            (case 1
                (if (proc0_6(150))
                    (send gQg3Messager:say(2 6 5 0 self))
                )(else
                    (self:cue())
                )
            )
            (case 2
                (send gOwner:
                    solvePuzzle(339 3)
                    setMotion(MoveTo 158 155 self)
                )
            )
            (case 3
                (send (ScriptID(36 1)):
                    x(160)
                    y(200)
                    ignoreActors(1)
                    setScale()
                    init()
                    setCycle(Walk)
                    setMotion(MoveTo 72 174 self)
                )
                (send (ScriptID(39 1)):
                    x(160)
                    y(200)
                    ignoreActors(1)
                    setScale()
                    init()
                    setStep(3 2)
                    moveSpeed(12)
                    setCycle(Walk)
                    setMotion(MoveTo 198 161)
                )
            )
            (case 4
                (send (ScriptID(41 1)):
                    x(160)
                    y(200)
                    ignoreActors(1)
                    setScale()
                    init()
                    setCycle(Walk)
                    setMotion(MoveTo 118 149)
                )
                (reesha:
                    init()
                    setCycle(Walk)
                    setMotion(MoveTo 250 168 self)
                )
            )
            (case 5
                = cycles 1
            )
            (case 6
                = local0 1
            )
            (case 7
                (johariBiz:init())
                (send global2:drawPic((send global2:picture) 9))
                = cycles 2
            )
            (case 8
                = local0 1
            )
            (case 9
                (manuBiz:init())
                (send global2:drawPic((send global2:picture) 9))
                = cycles 2
            )
            (case 10
                = local0 1
            )
            (case 11
                (egoBiz:init())
                (send global2:drawPic((send global2:picture) 9))
                = cycles 2
            )
            (case 12
                = local0 1
            )
            (case 13
                (yesufuBiz:init())
                (send global2:drawPic((send global2:picture) 9))
                = cycles 2
            )
            (case 14
                = local0 1
            )
            (case 15
                (reeshaBiz:init())
                (send global2:drawPic((send global2:picture) 9))
                = seconds 3
            )
            (case 16
                = local0 1
            )
            (case 17
                (johariBiz:setCycle(End self))
            )
            (case 18
                = local0 1
            )
            (case 19
                (manuBiz:setCycle(End self))
            )
            (case 20
                = local0 1
            )
            (case 21
                (egoBiz:setCycle(End self))
            )
            (case 22
                = local0 1
            )
            (case 23
                (yesufuBiz:setCycle(End self))
            )
            (case 24
                = local0 1
            )
            (case 25
                (reeshaBiz:setCycle(End self))
            )
            (case 26
                = seconds 2
            )
            (case 27
                (send global2:newRoom(549))
                (self:dispose())
            )
        )
    )

)
(instance secondEntrance of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (johariBiz:
                    view(842)
                    loop(1)
                    cel(1)
                    x(37)
                    y(125)
                    init()
                )
                (yesufuBiz:
                    view(842)
                    loop(0)
                    cel(2)
                    x(159)
                    y(81)
                    init()
                )
                (manuBiz:
                    view(842)
                    loop(1)
                    cel(0)
                    x(83)
                    y(91)
                    init()
                )
                (reeshaBiz:
                    view(842)
                    loop(0)
                    cel(0)
                    x(149)
                    y(136)
                    init()
                )
                = seconds 3
            )
            (case 1
                (if (not proc0_6(117))
                    (if (12)
                        = gGOwnerMaxStamina[18] (send gOwner:maxMana())
                        = gGOwnerMaxStamina[16] (send gOwner:maxHealth())
                        (send gQg3Messager:say(2 6 3 0 self))
                    )(else
                        = gGOwnerMaxStamina[16] (send gOwner:maxHealth())
                        (send gQg3Messager:say(2 6 2 0 self))
                    )
                )(else
                    (self:cue())
                )
            )
            (case 2
                (switch (global125)
                    (case 0
                        (send global2:newRoom(851))
                    )
                    (case 3
                        (send global2:newRoom(852))
                    )
                    (case 1
                        (send global2:newRoom(853))
                    )
                    (case 2
                        (send global2:newRoom(854))
                    )
                )
            )
        )
    )

)
(instance egoBiz of Prop
    (properties
        x 155
        y 111
        view 841
        signal $4000
    )
)
(instance johariBiz of Prop
    (properties
        x 29
        y 129
        view 841
        loop 3
        signal $4000
    )
)
(instance yesufuBiz of Prop
    (properties
        x 228
        y 116
        view 841
        loop 1
        signal $4000
    )
)
(instance manuBiz of Prop
    (properties
        x 84
        y 123
        view 841
        loop 4
        signal $4000
    )
)
(instance reesha of Actor
    (properties
        x 160
        y 200
        view 831
        cel 2
        signal $4000
    )
)
(instance reeshaBiz of Prop
    (properties
        x 278
        y 134
        view 841
        loop 2
        signal $4000
    )
)
