(version 2)
(include "sci.sh")
(exports
    0 rm500
)
(use "Main")
(use "PolyPath")
(use "Polygon")
(use "Cycle")
(use "Game")
(use "Obj")
(script 500)



(instance public rm500 of Rm
    (properties
        picture 500
        vanishingY -20
    )

    (method (init)
        proc0_2()
        (send global2:addObstacle((send ((Polygon:new())):
                type(2)
                init(15 58 48 58 60 57 70 52 76 49 140 49 145 51 159 50 180 58 185 59 232 59 259 77 270 79 278 86 275 114 276 123 258 133 234 138 196 146 158 149 102 160 63 160 17 114 8 91)
                yourself()
            )
))
        = gGOwnerMoveSpeed (send gOwner:moveSpeed)
        (send gOwner:
            changeGait(1)
            setScale(500)
            setSpeed(6)
            ignoreActors(1)
            init()
        )
        (send (ScriptID(39 1)):
            setScale(500)
            origStep(2053)
            ignoreActors(1)
            init()
        )
        (if (== gGClientModNum 420)
            (send global2:setScript(eventOne))
        )(else
            (if (== gGClientModNum 510)
                (send global2:setScript(eventTwo))
            )(else
                (if (== gGClientModNum 520)
                    (send global2:setScript(eventThree))
                )(else
                    (if (== gGClientModNum 530)
                        (if (proc0_6(30))
                            (send global2:setScript(eventFourFreed))
                        )(else
                            (send global2:setScript(eventFourTrap))
                        )
                    )
                )
            )
        )
        (super:init())
    )


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

)
(instance eventFourTrap of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send gOwner:
                    x(103)
                    y(165)
                    setCycle(Walk)
                    setMotion(PolyPath 65 166 self)
                )
                (send (ScriptID(39 1)):
                    view(501)
                    setLoop(0)
                    x(142)
                    y(161)
                    setCycle(Fwd)
                )
            )
            (case 1
                (send gOwner:setMotion(PolyPath 9 54))
                (send (ScriptID(39 1)):
                    setLoop(1)
                    setCycle(End self)
                )
            )
            (case 2
                (send (ScriptID(39 1)):
                    cycleSpeed(3)
                    moveSpeed(3)
                    view(983)
                    setCycle(Walk)
                    setMotion(PolyPath 6 88 self)
                )
            )
            (case 3
                (send (ScriptID(39 1)):
                    cycleSpeed(6)
                    moveSpeed(6)
                    setMotion(PolyPath 6 54 self)
                )
            )
            (case 4
                (send gOwner:
                    setSpeed(gGOwnerMoveSpeed)
                    setMotion(0)
                )
                (send global2:newRoom(420))
            )
        )
    )

)
(instance eventFourFreed of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send gOwner:
                    x(142)
                    y(161)
                    setCycle(Walk)
                    setMotion(PolyPath 10 74 self)
                )
                (send (ScriptID(39 1)):
                    x(142)
                    y(165)
                    view(983)
                    setCycle(Walk)
                    setMotion(PolyPath 5 74)
                )
            )
            (case 1
                (send (ScriptID(39 1)):
                    cycleSpeed(3)
                    moveSpeed(3)
                    setMotion(PolyPath 5 54 self)
                )
                (send gOwner:setMotion(PolyPath 10 54))
            )
            (case 2
                (send (ScriptID(39 1)):
                    cycleSpeed(6)
                    moveSpeed(6)
                )
                (send gOwner:
                    setSpeed(gGOwnerMoveSpeed)
                    setMotion(0)
                )
                (send global2:newRoom(420))
            )
        )
    )

)
(instance eventThree of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send gOwner:
                    x(255)
                    y(137)
                    setCycle(Walk)
                    setMotion(PolyPath 204 153 self)
                )
                (send (ScriptID(39 1)):
                    x(255)
                    y(141)
                    view(983)
                    setCycle(Walk)
                    setMotion(PolyPath 204 158)
                )
            )
            (case 1
                (send gOwner:setMotion(PolyPath 142 161))
                (send (ScriptID(39 1)):
                    cycleSpeed(3)
                    moveSpeed(3)
                    setMotion(PolyPath 142 164 self)
                )
            )
            (case 2
                (send (ScriptID(39 1)):
                    cycleSpeed(6)
                    moveSpeed(6)
                )
                (send gOwner:setMotion(0))
                (send global2:newRoom(530))
            )
        )
    )

)
(instance eventTwo of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send (ScriptID(39 1)):
                    view(983)
                    x(228)
                    y(57)
                    setCycle(Walk)
                    setMotion(PolyPath 288 87)
                )
                (send gOwner:
                    x(224)
                    y(54)
                    setCycle(Walk)
                    setMotion(PolyPath 283 87 self)
                )
            )
            (case 1
                (send (ScriptID(39 1)):
                    cycleSpeed(3)
                    moveSpeed(3)
                    setMotion(PolyPath 288 123 self)
                )
                (send gOwner:setMotion(PolyPath 283 123))
            )
            (case 2
                (send (ScriptID(39 1)):
                    cycleSpeed(6)
                    moveSpeed(6)
                )
                (send gOwner:setMotion(0))
                (send global2:newRoom(520))
            )
        )
    )

)
(instance eventOne of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send gOwner:
                    x(13)
                    y(57)
                    setCycle(Walk)
                    setMotion(PolyPath 140 57)
                )
                (send (ScriptID(39 1)):
                    view(983)
                    x(15)
                    y(55)
                    setCycle(Walk)
                    setMotion(PolyPath 140 51 self)
                )
            )
            (case 1
                (send (ScriptID(39 1)):
                    cycleSpeed(3)
                    moveSpeed(3)
                    setMotion(PolyPath 170 49 self)
                )
                (send gOwner:setMotion(PolyPath 170 51))
            )
            (case 2
                (send (ScriptID(39 1)):
                    cycleSpeed(6)
                    moveSpeed(6)
                )
                (send gOwner:setMotion(0))
                (send global2:newRoom(510))
            )
        )
    )

)
