(version 2)
(include "sci.sh")
(exports
    0 rm520
)
(use "Main")
(use "PAvoider")
(use "PolyPath")
(use "Polygon")
(use "CueObj")
(use "StopWalk")
(use "Grooper")
(use "Cycle")
(use "Game")
(use "User")
(use "View")
(use "Obj")
(script 520)


(local
    local0

)
(instance public rm520 of Rm
    (properties
        noun 6
        picture 520
        vanishingY -20
    )

    (method (init)
        proc0_2()
        (send global2:addObstacle((send ((Polygon:new())):
                type(2)
                init(0 189 0 0 319 0 319 142 278 149 222 158 222 172 202 172 202 158 161 158 153 154 123 158 111 150 114 145 95 140 61 140 61 126 93 126 93 101 121 101 121 96 100 96 100 91 43 91 42 104 35 143 17 189)
                yourself()
            )
))
        (send (ScriptID(58 0)):view(416))
        (send (ScriptID(58 2)):
            view(416)
            nsLeft(45)
            nsTop(38)
        )
        (send (ScriptID(58 4)):
            view(416)
            nsLeft(41)
            nsTop(30)
        )
        (send (ScriptID(58 3)):
            view(416)
            nsLeft(45)
            nsTop(38)
        )
        (send (ScriptID(58 1)):
            setScale(180)
            view(414)
            loop(0)
            cel(0)
            x(111)
            y(93)
            noun(2)
            ignoreActors(1)
            init()
        )
        (spear1:init())
        (ring:init())
        (log:init())
        (thornWall:init())
        (thornFeat:init())
        (spear2:
            approachVerbs(4)
            init()
        )
        (send gOwner:
            changeGait(1)
            x(5)
            y(46)
            setScale(180)
            ignoreActors(1)
            init()
        )
        (send (ScriptID(39 1)):
            view(983)
            x(12)
            y(55)
            origStep(2054)
            setScale(180)
            setPri(-1)
            setCycle(StopWalk -1)
            setLoop(-1)
            setLoop(yesufuStopGroop)
            noun(9)
            init()
        )
        (send global2:setScript(enterRoom))
        (super:init())
    )


    (method (doit param1)
        (if ((send gOwner:mover) and (== (send gOwner:view) 523))
            (send gOwner:
                view(1)
                origStep(2053)
                setStep()
                setLoop(-1)
                setScale(180)
                setCycle(StopWalk 5)
            )
            (spear2:init())
        )
        (super:doit(rest param1))
    )


    (method (dispose)
        (send gQg3Walkers:delete(global2))
        DisposeScript(39)
        DisposeScript(58)
        (super:dispose())
    )


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

)
(instance egoActions of Actions
    (properties)

    (method (doVerb theVerb)
        return 
            (switch (theVerb)
                (case 3
                    (if ((send global2:script))
                        0
                    )(else
                        (if ((((< 100 (send ((User:curEvent)):y)) and (< (send ((User:curEvent)):y) 160)) and (< 145 (send ((User:curEvent)):x))) and (< (send ((User:curEvent)):x) 300))
                            (if (local0)
                                (send global2:setScript(egoGetRing))
                            )(else
                                return 0
                            )
                            return 1
                        )
                    )
                )
                (default 
                    (super:doVerb(theVerb))
                )
            )
    )

)
(instance egoWalkToRing of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send (ScriptID(39 1)):
                    setCycle(0)
                    cel(0)
                    setScript(0)
                )
                (send gOwner:setMotion(MoveTo 209 128 self))
            )
            (case 1
                (send gOwner:
                    view(4)
                    setLoop(0)
                    cel(0)
                    setCycle(End self)
                )
            )
            (case 2
                (ring:dispose())
                (send gOwner:setCycle(Beg self))
            )
            (case 3
                (send gOwner:
                    view(13)
                    setLoop(0)
                    setCycle(End self)
                )
            )
            (case 4
                (send gQg3Messager:say(1 6 5 0 self))
            )
            (case 5
                (send gOwner:solvePuzzle(289 5 9))
                (send gOwner:
                    normalize()
                    setMotion(MoveTo 143 160 self)
                )
            )
            (case 6
                (send client:setScript(exitRoom))
            )
        )
    )

)
(instance climbLog of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send (ScriptID(39 1)):
                    setScript(0)
                    view(983)
                    setCycle(StopWalk -1)
                    setScale(180)
                    setLoop(-1)
                    setHeading(90)
                    setLoop(yesufuStopGroop)
                )
                (spear1:init())
                (send gOwner:
                    view(1)
                    origStep(2053)
                    setStep()
                    setLoop(-1)
                    setScale(180)
                    setCycle(StopWalk 5)
                    setMotion(PolyPath 137 153 self)
                )
                (if (not (send gGQg3KDHandler:contains(spear2)))
                    (spear2:init())
                )
            )
            (case 1
                (send gQg3Walkers:addToFront(global2))
                (egoActions:init())
                (send gOwner:actions(egoActions))
                (User:canControl(0))
                (send gOwner:
                    y(142)
                    setPri(10)
                    setMotion(MoveTo 177 137 self)
                )
            )
            (case 2
                (send gOwner:
                    x(180)
                    y(142)
                    setPri(10)
                    loop(0)
                    setScale(180)
                    setMotion(MoveTo 192 122 self)
                )
            )
            (case 3
                (send gOwner:
                    view(4)
                    loop(0)
                    cel(0)
                    setCycle(End self)
                )
            )
            (case 4
                (ring:dispose())
                (send gOwner:setCycle(Beg self))
            )
            (case 5
                (send gQg3Messager:say(1 6 5 0 self))
            )
            (case 6
                (send gOwner:
                    normalize()
                    setPri(10)
                    setMotion(MoveTo 180 142 self)
                )
            )
            (case 7
                (send gOwner:
                    x(177)
                    y(137)
                    setMotion(MoveTo 152 141 self)
                )
            )
            (case 8
                (send gOwner:
                    x(142)
                    y(153)
                    setMotion(MoveTo 130 160 self)
                )
            )
            (case 9
                (send client:setScript(exitRoom))
            )
        )
    )

)
(instance getLog of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gOwner:
                    view(1)
                    origStep(2053)
                    setStep()
                    setLoop(-1)
                    setScale(180)
                    setCycle(StopWalk 5)
                    setMotion(PolyPath 133 159 self)
                )
                (if (not (send gGQg3KDHandler:contains(spear2)))
                    (spear2:init())
                )
            )
            (case 1
                (log:dispose())
                (logInThorn:init())
                proc0_3()
                (self:dispose())
            )
        )
    )

)
(instance exitRoom of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send (ScriptID(39 1)):
                    view(983)
                    origStep(2053)
                    setScale(180)
                    setPri(-1)
                    setCycle(StopWalk -1)
                    setLoop(-1)
                    setLoop(yesufuStopGroop)
                    setMotion(PolyPath (send (ScriptID(39 1)):x) 160 self)
                )
            )
            (case 1
                (send gQg3Messager:say(1 6 4 0 self))
            )
            (case 2
                = gGOwnerMoveSpeed (send gOwner:moveSpeed)
                (send gOwner:
                    setSpeed(6)
                    setMotion(PolyPath (send gOwner:x) 220 self)
                )
                (send (ScriptID(39 1)):setMotion(PolyPath (send (ScriptID(39 1)):x) 220))
            )
            (case 3
                (send global2:newRoom(500))
            )
        )
    )

)
(instance egoGetRing of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send (ScriptID(39 1)):
                    setScript(0)
                    view(983)
                    setCycle(StopWalk -1)
                    setScale(180)
                    setHeading(90)
                    setLoop(-1)
                    setLoop(yesufuStopGroop)
                )
                (spear1:init())
                (send gOwner:setMotion(PolyPath 260 160 self))
            )
            (case 1
                (send gOwner:setMotion(MoveTo 209 128 self))
            )
            (case 2
                (send gOwner:
                    view(4)
                    loop(0)
                    cel(0)
                    setCycle(End self)
                )
            )
            (case 3
                (ring:dispose())
                (send gOwner:setCycle(Beg self))
            )
            (case 4
                (send gOwner:
                    view(13)
                    loop(0)
                    setCycle(End self)
                )
            )
            (case 5
                (send gQg3Messager:say(1 6 5 0 self))
            )
            (case 6
                (send gOwner:solvePuzzle(289 5 9))
                (send gOwner:
                    normalize()
                    setMotion(MoveTo 260 160 self)
                )
            )
            (case 7
                (send client:setScript(exitRoom))
            )
        )
    )

)
(instance burnWall of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gOwner:setMotion(PolyPath 225 160 self))
            )
            (case 1
                (send gOwner:
                    view(4)
                    loop(0)
                    cel(0)
                    setCycle(End self)
                )
            )
            (case 2
                (fire:
                    setCycle(Fwd)
                    init()
                )
                (send gOwner:setCycle(Beg self))
            )
            (case 3
                = seconds 5
            )
            (case 4
                (send gOwner:normalize())
                = local0 1
                (fire:dispose())
                (thornWall:dispose())
                (thornFeat:dispose())
                proc0_3()
                (self:dispose())
            )
        )
    )

)
(instance useSpear of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gOwner:
                    view(523)
                    setScale()
                    scaleX(128)
                    scaleY(128)
                    cel(0)
                    setLoop(0)
                    setCycle(End self)
                )
                (spear2:dispose())
            )
            (case 1
                (send gOwner:
                    loop(1)
                    setCycle(Fwd)
                )
                = cycles 1
            )
            (case 2
                proc0_3()
                (self:dispose())
            )
        )
    )

)
(instance yesufuGetRing of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                = seconds 60
            )
            (case 1
                proc0_2()
                (send gOwner:setCycle(Beg))
                (send (ScriptID(39 1)):
                    view(983)
                    setCycle(StopWalk -1)
                    setScale(180)
                    setLoop(-1)
                    setLoop(yesufuStopGroop)
                    setMotion(MoveTo (ring:x) (ring:y) self)
                )
            )
            (case 2
                (send (ScriptID(39 1)):
                    view(521)
                    setLoop(2)
                    setScale()
                    scaleX(128)
                    scaleY(128)
                    cel(0)
                    setCycle(CT 3 1 self)
                )
            )
            (case 3
                (ring:dispose())
                (send (ScriptID(39 1)):setCycle(End self))
            )
            (case 4
                (send (ScriptID(39 1)):
                    view(983)
                    setCycle(StopWalk -1)
                    setScale(180)
                    setLoop(-1)
                    setLoop(yesufuStopGroop)
                    setMotion(MoveTo 85 137 self)
                )
            )
            (case 5
                (send gQg3Messager:say(1 6 3 0 self))
            )
            (case 6
                (send gOwner:
                    normalize()
                    setScale(180)
                    setMotion(MoveTo 260 160 self)
                )
            )
            (case 7
                (send client:setScript(exitRoom))
            )
        )
    )

)
(instance enterRoom of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send (ScriptID(39 1)):setMotion(MoveTo 70 110 self))
                (send gOwner:setMotion(MoveTo 60 110 self))
            )
            (case 1
                (send (ScriptID(39 1)):setMotion(PolyPath 111 96 self))
            )
            (case 2
            )
            (case 3
                (send (ScriptID(39 1)):setHeading(0))
                (send gQg3Messager:say(1 6 1 0 self))
            )
            (case 4
                (send (ScriptID(39 1)):setMotion(PolyPath 75 110 self))
            )
            (case 5
                (send (ScriptID(39 1)):setHeading(180))
                = cycles 12
            )
            (case 6
                (send gQg3Messager:say(1 6 2 0 self))
            )
            (case 7
                (send (ScriptID(39 1)):setMotion(MoveTo 85 137 self))
            )
            (case 8
                (send (ScriptID(39 1)):
                    view(521)
                    setLoop(0)
                    cel(0)
                    setScale()
                    scaleX(128)
                    scaleY(128)
                    setCycle(End self)
                )
                (spear1:dispose())
            )
            (case 9
                (send (ScriptID(39 1)):
                    setLoop(1)
                    cel(0)
                    setCycle(Fwd)
                    ignoreActors(1)
                    setScript(yesufuGetRing)
                )
                (send gOwner:
                    setSpeed(gGOwnerMoveSpeed)
                    setAvoider(PAvoider)
                    ignoreActors(0)
                )
                proc0_3()
                (self:dispose())
            )
        )
    )

)
(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))
    )

)
(instance thornFeat of Feature
    (properties
        x 215
        y 130
        noun 8
        sightAngle 40
        onMeCheck $0004
    )

    (method (doVerb theVerb param2)
        (switch (theVerb)
            (case 19
                (thornWall:doVerb(theVerb))
            )
            (default 
                (super:doVerb(theVerb rest param2))
            )
        )
    )

)
(instance spear1 of View
    (properties
        x 64
        y 135
        view 520
        loop 2
        signal $4000
    )
)
(instance spear2 of View
    (properties
        x 208
        y 169
        noun 7
        approachX 185
        approachY 169
        view 520
        loop 2
        signal $4000
    )

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

)
(instance ring of View
    (properties
        x 209
        y 116
        noun 5
        view 520
        loop 6
        signal $4000
    )

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

)
(instance thornWall of View
    (properties
        x 222
        y 118
        noun 8
        view 520
        loop 5
        cel 1
        signal $4000
    )

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

)
(instance log of View
    (properties
        x 138
        y 154
        noun 3
        view 520
        loop 1
        signal $4000
    )

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

)
(instance fire of Prop
    (properties
        x 236
        y 146
        view 520
        loop 4
        cel 6
    )
)
(instance logInThorn of View
    (properties
        x 143
        y 132
        noun 4
        view 520
        loop 1
        cel 1
        priority 10
        signal $4010
    )

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

)
