(version 2)
(include "sci.sh")
(exports
    2 fallDown
    3 uhuraCompete
    4 yesufuCompete
    5 oppActs
    6 proc471_6
    7 proc471_7
    8 proc471_8
)
(use "Main")
(use "GloryControls")
(use "rm470")
(use "IconI")
(use "PolyPath")
(use "StopWalk")
(use "Timer")
(use "SysWindow")
(use "Cycle")
(use "User")
(use "Obj")
(script 471)


(local
    local0
    local1
    local2
    local3
    local4
    local5
    local6
    local7
    local8[10] = (0 0 2 3 1 0 0 2 2 4 )
    local18
    local19
    local20
    local21
    local22
    local23
    local24
    local25
    local26
    local27
    local28
    local29
    local30
    local31
    local32
    local33
    local34[20] = (0 0 0 0 0 0 4 1 14 1 7 8 0 11 0 19 5 25 )

)
(procedure public (proc471_6 param1 param2)
    = local2 param1
    = local3 param2
    = local30 0
    = local29 local30
    = local27 local29
    = local26 local27
    = local25 local26
    = local24 local25
    = local21 local24
    = local20 local21
    = local19 local20
    = local18 local19
    = local7 local18
    = local6 local7
    = local5 local6
    = local4 local5
    (if (== param1 1)
        = local23 (+ 150 (* local3 25))
        = local31 983
        = local32 472
        = local33 473
        = local1 ScriptID(39 1)
    )(else
        = local23 (+ 170 (* local3 25))
        = local31 971
        = local32 471
        = local33 474
        = local1 ScriptID(34 1)
    )
)


(procedure public (proc471_7)
    (var temp0)
    (if (<> local3 1)
        = temp0 local0
        (if (not temp0)
            (bridgeControls:init())
        )
        SetPort((bridgeWin:window))
        (bridgeControls:
            enable(0 1 2 3)
            eachElementDo(217)
        )
        (send gGame:setCursor(999))
        (if (not temp0)
            (bridgeControls:
                show()
                dispose()
            )
        )
    )
)


(procedure public (proc471_8)
    (var temp0)
    = temp0 local0
    (if (not temp0)
        (thiefControls:init())
    )
    SetPort((bridgeWin:window))
    (thiefControls:
        enable(4 0 1 3 2 5 6)
        eachElementDo(217)
    )
    (send gGame:setCursor(999))
    (if (not temp0)
        (thiefControls:
            show()
            dispose()
        )
    )
)


(procedure (localproc_012e param1)
    (var temp0)
    = temp0 local28
    = local28 0
    (if (IsObject(temp0) and (send temp0:isKindOf(Timer)))
        (if (param1)
            (send temp0:
                seconds(-1)
                ticks(1)
                doit()
            )
        )
        (send temp0:
            dispose()
            delete()
        )
    )
)


(procedure (localproc_01e4)
    (var theThiefControls)
    (if (== global362 2)
        = theThiefControls thiefControls
    )(else
        (if (<> local3 1)
            = theThiefControls bridgeControls
        )(else
            return 
        )
    )
    (send theThiefControls:state((& (bridgeControls:state) $ffdf)))
)


(procedure (localproc_0219)
    (if ((<> local3 1) and local0)
        SetPort((bridgeWin:window))
        (bridgeControls:
            disable(0 1 2 3)
            eachElementDo(217)
        )
        (send gGame:setCursor(999))
        SetPort(0)
    )
)


(procedure (localproc_02ae)
    (if (local0)
        SetPort((bridgeWin:window))
        (thiefControls:
            disable(4 0 1 3 2 5)
            eachElementDo(217)
        )
        (send gGame:setCursor(999))
    )
)


(procedure (localproc_033a)
    (var temp0, temp1, temp2)
    = temp0 (- gGOwnerMaxStamina[2] local23)
    = temp1 (+ 
        (if (local21)
            50
        )(else
            25
        )
 (/ temp0 5))
    (if (< temp1 15)
        = temp1 15
    )
    (if (<= Random(1 100) temp1)
        = local25 1
        (while (== local19 (= temp2 Random(1 4)))
        )
        = local24 temp2
    )(else
        = local25 0
        = local24 local19
    )
)


(procedure (localproc_0392 param1)
    (var temp0)
    localproc_012e(0)
    (switch (local3)
        (case 1
            (if (< gGOwnerMaxStamina[2] (- local23 Random(1 40)))
                (while (== local24 (= temp0 Random(1 4)))
                )
                = local19 temp0
                (if (local20)
                    = local18 1
                )(else
                    = local20 1
                    = local25 -1
                )
                = local27 -1
            )(else
                = local25 1
                = local27 0
                = local19 local24
                (if (== local19 0)
                    = local19 Random(1 4)
                )
            )
            (send gOwner:setScript(egoActs param1 local19))
        )
        (case 2
            = local28 (Timer:setReal(param1 5))
        )
        (case 3
            = local28 (Timer:setReal(param1 3))
        )
    )
)


(procedure (localproc_043a param1)
    (if ((<= (send gOwner:trySkill(2 (+ 140 (* local3 25)))) 0) or (< gGOwnerMaxStamina[17] 20))
        (send gOwner:useSkill(2 100))
        proc470_1()
        (send param1:setScript(fallDown param1))
    )(else
        (send gOwner:
            view(12)
            setLoop(0)
            setCycle(Walk)
        )
        (if (<> global362 2)
            (if (<> local3 1)
                (if ((uhuraCompete:client))
                    localproc_012e(1)
                )(else
                    proc471_7()
                )
            )
        )(else
            (send gOwner:
                view(12)
                loop(0)
                cel(0)
            )
            proc471_8()
        )
        (send param1:dispose())
    )
)


(procedure (localproc_04d7 param1 param2)
    (send param2:setScript(oppActs param2 param1))
)


(procedure (localproc_04e9)
    (send local1:
        view(local32)
        loop(1)
        cel(
            (if (== local1 ScriptID(34 1))
                5
            )(else
                0
            )
)
        forceUpd()
    )
)


(instance public yesufuCompete of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gOwner:
                    view(12)
                    setScale()
                    setLoop(0)
                    scaleX(109)
                    scaleY(109)
                    setPri(10)
                    x(135)
                    y(80)
                    ignoreActors(1)
                    init()
                )
                (send (ScriptID(39 1)):
                    view(473)
                    loop(1)
                    cel(0)
                    setScale()
                    scaleX(109)
                    scaleY(109)
                    setPri(10)
                    posn(160 76)
                    ignoreActors(1)
                    init()
                )
                = cycles 1
            )
            (case 1
                (send client:setScript(yesufuTimer))
            )
        )
    )

)
(instance yesufuTimer of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                0
                = cycles 1
            )
            (case 1
                1
                (if (> gGOwnerMaxStamina[2] local23)
                    (self:setScript(egosTurn self))
                )(else
                    (self:setScript(oppsTurn self))
                )
            )
            (case 2
                = cycles 2
            )
            (case 3
                3
                (if (== local6 0)
                    (self:setScript(egosTurn self))
                )(else
                    (self:setScript(oppsTurn self))
                )
            )
            (case 4
                4
                (self:changeState(2))
            )
        )
    )

)
(instance public fallDown of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                localproc_012e(0)
                ++local30
                = local18 1
                proc0_2()
                localproc_01e4()
                = cycles 10
            )
            (case 1
                (send gOwner:
                    view(6)
                    cel(0)
                    loop(4)
                    cycleSpeed(10)
                    setCycle(CT 2 1)
                    setPri(11)
                    moveSpeed(1)
                    origStep(522)
                    setMotion(MoveTo + (send gOwner:x) 10 143 self)
                )
            )
            (case 2
                (send gLongSong2:
                    number(920)
                    setLoop(1)
                    play(127)
                )
                (send gOwner:setCycle(End self))
            )
            (case 3
                (send gOwner:
                    cel(0)
                    loop(6)
                    setCycle(End self)
                )
            )
            (case 4
                (if (< gGOwnerMaxStamina[17] 20)
                    (send gQg3Messager:say(4 6 38 0 self 470))
                )(else
                    (if ((not (uhuraCompete:client) or (<= (uhuraCompete:state) 18)) or (== local30 3))
                        = cycles 1
                    )(else
                        (if (Random(0 1))
                            (send gQg3Messager:say(2 6 37 0 self 470))
                        )(else
                            (send gQg3Messager:say(2 6 35 0 self 470))
                        )
                    )
                )
            )
            (case 5
                (if (not (send gOwner:takeDamage(5)))
                    = gGOwnerMaxStamina[16] 1
                )
                (send gOwner:
                    view(0)
                    cycleSpeed(6)
                    ignoreActors(0)
                    moveSpeed(6)
                    normalize()
                    setMotion(PolyPath 32 143 self)
                )
            )
            (case 6
                proc0_3()
                (self:dispose())
            )
        )
    )

)
(instance public uhuraCompete of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                0
                proc0_2()
                (send (ScriptID(34 1)):setMotion(PolyPath 287 144 self))
            )
            (case 1
                1
                (send (ScriptID(34 1)):
                    view(local32)
                    setStep(3 3)
                    setLoop(0)
                    cel(0)
                    setPri(10)
                    setCycle(Fwd)
                    setMotion(MoveTo 287 132 self)
                )
            )
            (case 2
                2
                (send (ScriptID(34 1)):
                    loop(2)
                    cel(0)
                    setScale()
                    scaleX(109)
                    scaleY(109)
                    x(287)
                    y(105)
                    setCycle(End self)
                )
            )
            (case 3
                (send (ScriptID(34 1)):
                    loop(== 1 3)
                    cel(0)
                    x(292)
                    y(76)
                    setCycle(End self)
                )
            )
            (case 4
                4
                (send (ScriptID(34 1)):
                    loop(1)
                    setStep(3 2)
                    setCycle(Walk)
                    scaleX(109)
                    scaleY(109)
                    setMotion(MoveTo 160 (send (ScriptID(34 1)):y) self)
                )
            )
            (case 5
                5
                = ticks 1
            )
            (case 6
                6
                = cycles 12
            )
            (case 7
                7
                (if (== (send global2:notify(3)) 4)
                    (send gOwner:setMotion(MoveTo 135 (send gOwner:y) self))
                )(else
                    (send gQg3Messager:say(2 6 23 0 self 470))
                )
            )
            (case 8
                8
                (if (== (send global2:notify(3)) 4)
                    (self:changeState(19))
                )(else
                    (send gOwner:
                        solvePuzzle(279 3 9)
                        setMotion(MoveTo 135 (send gOwner:y) self)
                    )
                )
            )
            (case 9
                9
                = local4 1
                (send gQg3Messager:say(2 6 24 0 self 470))
            )
            (case 10
                10
                (switch (local4)
                    (case 1
                        (send gQg3Messager:say(2 6 25 0 self 470))
                    )
                    (case 3
                        (send gQg3Messager:say(2 6 29 0 self 470))
                    )
                    (case 2
                        (send gQg3Messager:say(2 6 27 0 self 470))
                    )
                    (case 4
                        (send gQg3Messager:say(2 6 31 0 self 470))
                    )
                )
            )
            (case 11
                11
                = ticks 30
            )
            (case 12
                12
                (if (== register 1)
                    (send gLongSong2:
                        number(922)
                        setLoop(1)
                        play(127)
                    )
                )
                (send local1:
                    view(local33)
                    loop(local8[local4])
                    cel(0)
                    setCycle(End self)
                )
            )
            (case 13
                13
                (if (== local3 1)
                    = ticks Random(10 30)
                )(else
                    = ticks 1
                )
            )
            (case 14
                14
                = local19 0
                localproc_012e(0)
                (switch (local3)
                    (case 1
                        = local19 local4
                        (send gOwner:setScript(egoActs self local19))
                        = cycles Random(10 30)
                    )
                    (case 2
                        = local28 (Timer:setReal(self 5))
                    )
                    (case 3
                        = local28 (Timer:setReal(self 3))
                    )
                )
                proc471_7()
            )
            (case 15
                15
                localproc_012e(0)
                (if ((send gOwner:script))
                    = state (- state 1)
                    = ticks 1
                )(else
                    = ticks 1
                )
            )
            (case 16
                16
                localproc_0219()
                = local30 0
                (if (local18)
                    (switch (local4)
                        (case 1
                            (send gQg3Messager:say(2 6 26 0 0 470))
                        )
                        (case 3
                            (send gQg3Messager:say(2 6 28 0 0 470))
                        )
                        (case 2
                            (send gQg3Messager:say(2 6 30 0 0 470))
                        )
                        (case 4
                            (send gQg3Messager:say(2 6 32 0 0 470))
                        )
                    )
                    (send gOwner:setScript(egoFallGetUp self))
                )(else
                    (if (== local19 local4)
                        (if (== local4 4)
                            (self:changeState(18))
                        )(else
                            ++local4
                            (self:changeState(10))
                        )
                    )(else
                        (send gOwner:setScript(egoFallGetUp self))
                    )
                )
            )
            (case 17
                17
                localproc_012e(0)
                (self:changeState(10))
            )
            (case 18
                18
                (send gQg3Messager:say(2 6 2 1 self 470))
            )
            (case 19
                19
                (send gQg3Messager:say(2 6 2 2 self 470))
            )
            (case 20
                20
                (if (> gGOwnerMaxStamina[2] local23)
                    (self:setScript(egosTurn self))
                )(else
                    (self:setScript(oppsTurn self))
                )
            )
            (case 21
                21
                = cycles 2
            )
            (case 22
                22
                (if (== local6 0)
                    (self:setScript(egosTurn self))
                )(else
                    (self:setScript(oppsTurn self))
                )
            )
            (case 23
                23
                (self:changeState(21))
            )
        )
    )

)
(instance egosTurn of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (if (== local3 1)
                    = ticks Random(10 30)
                )(else
                    = ticks 1
                )
            )
            (case 1
                = local19 0
                localproc_0392(self)
                proc471_7()
            )
            (case 2
                localproc_012e(0)
                (if ((send gOwner:script))
                    = state (- state 1)
                )
                = ticks 1
            )
            (case 3
                localproc_0219()
                = ticks 1
            )
            (case 4
                (if (local18)
                    = local25 -1
                    = local18 0
                    (send gOwner:setScript(egoFallGetUp self))
                )(else
                    (if (== local19 0)
                        = local6 1
                        (self:dispose())
                    )(else
                        localproc_033a()
                        localproc_04d7(local24 self)
                    )
                )
            )
            (case 5
                (if (< local25 0)
                    = local6 1
                    (self:dispose())
                )(else
                    (if (local25)
                        (if (local21)
                            (self:setScript(oppFall self))
                        )(else
                            = local21 1
                            = ticks 1
                        )
                    )(else
                        (if (local21)
                            = local21 0
                            = local6 0
                            = ticks 1
                        )(else
                            = local6 1
                            = ticks 1
                        )
                    )
                )
            )
            (case 6
                (self:dispose())
            )
        )
    )

)
(instance oppsTurn of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                = ticks Random(10 30)
            )
            (case 1
                (if (local18)
                    localproc_012e(0)
                    localproc_0219()
                )
                = local24 Random(1 4)
                localproc_04d7(local24 self)
                = local19 0
            )
            (case 2
                localproc_0392(self)
                proc471_7()
            )
            (case 3
                localproc_012e(0)
                (if ((send gOwner:script))
                    = state (- state 1)
                )
                = ticks 1
            )
            (case 4
                localproc_0219()
                (if (local18)
                    = local27 -1
                    = local18 0
                    (send gOwner:setScript(egoFallGetUp self))
                )(else
                    (if (== local3 1)
                        = ticks 1
                    )(else
                        (if (== local19 0)
                            = local6 1
                            (self:dispose())
                        )(else
                            = local27 (<> local19 local24)
                            = ticks 1
                        )
                    )
                )
            )
            (case 5
                (if (< local27 0)
                    = local6 1
                    (self:dispose())
                )(else
                    (if (local27)
                        (if (local20)
                            (send gOwner:setScript(egoFallGetUp self))
                        )(else
                            = local20 1
                            = local6 1
                            (self:dispose())
                        )
                    )(else
                        (if (local20)
                            = local20 0
                            = local6 1
                            (self:dispose())
                        )(else
                            = local6 0
                            (self:dispose())
                        )
                    )
                )
            )
            (case 6
                (self:dispose())
            )
        )
    )

)
(instance egoFallGetUp of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                = local6 1
                = local20 0
                localproc_01e4()
                (if ((> (send gOwner:y) 90) or local18)
                    = ticks 1
                )(else
                    (self:setScript(fallDown self))
                )
            )
            (case 1
                (if (== local30 3)
                    (send local1:setScript(
                        (if (== local2 0)
                            endUhuraContest
                        )(else
                            endYesufuContest
                        )
))
                    (self:dispose())
                )(else
                    (if ((== local2 0) and (< gGOwnerMaxStamina[17] 20))
                        (send local1:setScript(egoTooTired))
                    )(else
                        (if (== local2 1)
                            (send gQg3Messager:say(8 6 50 0 self 470))
                        )(else
                            = ticks 1
                        )
                    )
                )
            )
            (case 2
                (self:setScript(ScriptID(470 3) self))
            )
            (case 3
                (self:dispose())
            )
        )
    )

)
(instance egoTooTired of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                localproc_01e4()
                proc0_2()
                proc0_4(100)
                = global425 global122
                = cycles 10
            )
            (case 1
                (send gQg3Messager:say(2 6 38 0 self 470))
            )
            (case 2
                (self:setScript(oppDismount self))
            )
            (case 3
                (send local1:
                    view(971)
                    setScale(200)
                    setLoop(-1)
                    setCycle(StopWalk 969)
                    setMotion(PolyPath (send local1:x) 250 self)
                )
            )
            (case 4
                proc0_3()
                (send local1:dispose())
            )
        )
    )

)
(instance oppDismount of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send local1:
                    loop(4)
                    cel(0)
                )
                = local7 0
                = cycles 1
            )
            (case 1
                (send local1:
                    cel(++local7)
                    x(+ (send local1:x) local34[(* local7 2)])
                    y(+ (send local1:y) local34[(+ (* local7 2) 1)])
                )
                = ticks 6
            )
            (case 2
                (if (== local7 8)
                    = cycles 1
                )(else
                    (self:changeState(--state))
                )
            )
            (case 3
                (send gLongSong2:
                    number(920)
                    setLoop(1)
                    play(127)
                )
                (self:dispose())
            )
        )
    )

)
(instance oppFall of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                ++local29
                = local21 0
                localproc_01e4()
                (send local1:
                    view(
                        (if (== local2 1)
                            local33
                        )(else
                            local32
                        )
)
                    setLoop(4)
                    cel(0)
                )
                = local7 0
                = cycles 1
            )
            (case 1
                (send local1:
                    cel(++local7)
                    x(+ (send local1:x) local34[(* local7 2)])
                    y(+ (send local1:y) local34[(+ (* local7 2) 1)])
                )
                = cycles 3
            )
            (case 2
                (if (== local7 8)
                    = cycles 1
                    (send gLongSong2:
                        number(920)
                        setLoop(1)
                        play(127)
                    )
                )(else
                    (self:changeState(--state))
                )
            )
            (case 3
                (send local1:
                    view(local31)
                    setScale(200)
                    setLoop(-1)
                    setPri(-1)
                    setCycle(Walk)
                    setMotion(PolyPath 287 144 self)
                )
                (if (== local2 1)
                    (send local1:setStep(6 4))
                )(else
                    (send local1:setStep(3 2))
                )
            )
            (case 4
                (if (== local2 1)
                    (send gQg3Messager:say(8 6 49 0 self 470))
                )(else
                    (if (== local26 0)
                        ++local26
                        (send gQg3Messager:say(2 6 33 0 self 470))
                    )(else
                        (if (== local26 1)
                            ++local26
                            (send gQg3Messager:say(2 6 34 0 self 470))
                        )(else
                            = ticks 1
                        )
                    )
                )
            )
            (case 5
                (if (== local29 3)
                    (send local1:setScript(
                        (if (== local2 0)
                            endUhuraContest
                        )(else
                            endYesufuContest
                        )
))
                )(else
                    (send local1:
                        view(local32)
                        setLoop(0)
                        cel(0)
                        setStep(3 3)
                        setPri(10)
                        setScale()
                        scaleX(109)
                        scaleY(109)
                        setCycle(Fwd)
                        setMotion(MoveTo 287 132 self)
                    )
                )
            )
            (case 6
                (if (== local2 0)
                    (send local1:posn(287 105))
                )(else
                    (send local1:posn(293 79))
                )
                (send local1:
                    setLoop(2)
                    cel(0)
                    setCycle(End self)
                )
            )
            (case 7
                (if (== local2 0)
                    (send local1:
                        setLoop(3)
                        cel(0)
                        x(292)
                        y(76)
                        setCycle(End self)
                    )
                )(else
                    = ticks 1
                )
            )
            (case 8
                (send local1:
                    setLoop(-1)
                    loop(1)
                    x(295)
                    y(76)
                    setStep(4 2)
                    setCycle(Walk)
                    setMotion(MoveTo 160 76 self)
                )
            )
            (case 9
                (self:dispose())
            )
        )
    )

)
(instance endUhuraContest of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                localproc_01e4()
                proc0_2()
                = cycles 1
            )
            (case 1
                (send gQg3Messager:say(2 6 41 0 self 470))
            )
            (case 2
                (if (> local30 local29)
                    (if (== (send global2:notify(3)) 4)
                        (send gQg3Messager:say(2 6 43 0 self 470))
                    )(else
                        proc0_4(100)
                        = global425 global122
                        (if (== local30 3)
                            (send gQg3Messager:say(2 6 39 0 self 470))
                        )(else
                            (send gQg3Messager:say(2 6 58 0 self 470))
                        )
                    )
                )(else
                    proc0_4(153)
                    (if (== (send global2:notify(3)) 4)
                        (send gQg3Messager:say(2 6 44 0 self 470))
                    )(else
                        (send gQg3Messager:say(2 6 40 0 self 470))
                    )
                )
            )
            (case 3
                (if (< (send local1:y) 85)
                    (self:setScript(oppDismount self))
                )(else
                    = cycles 1
                )
            )
            (case 4
                (send local1:
                    view(971)
                    setLoop(-1)
                    setScale(200)
                    setCycle(StopWalk 969)
                    setMotion(PolyPath (send local1:x) 250 self)
                )
            )
            (case 5
                (if ((== local3 1) or (> (send gOwner:y) 90))
                    localproc_01e4()
                    proc0_3()
                )(else
                    proc471_7()
                )
                (self:dispose())
            )
        )
    )

)
(instance endYesufuContest of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                localproc_01e4()
                proc0_2()
                (if (> local30 local29)
                    proc0_4(76)
                    proc0_4(global407)
                    (send gQg3Messager:say(8 6 40 0 self 470))
                )(else
                    = global406 1
                    (send gOwner:solvePuzzle(280 5 9))
                    (send gQg3Messager:say(8 6 39 0 self 470))
                )
            )
            (case 1
                (if (global406)
                    (send gLongSong:
                        setLoop(1)
                        number(462)
                        play(127 self)
                    )
                )(else
                    = cycles 1
                )
            )
            (case 2
                proc0_4(16)
                (send global2:newRoom(420))
            )
        )
    )

)
(instance public oppActs of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (if (== register 1)
                    (send gLongSong2:
                        number(922)
                        setLoop(1)
                        play(127)
                    )
                )
                (send local1:
                    view(local33)
                    loop(local8[register])
                    cel(0)
                    setCycle(End self)
                )
            )
            (case 1
                = ticks 15
            )
            (case 2
                localproc_04e9()
                (self:dispose())
            )
        )
    )

)
(instance egoActs of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (if (IsObject(local28) and (send local28:isKindOf(Timer)))
                    = caller (send local28:client)
                    localproc_012e(0)
                )
                (if (== register 4)
                    (send gLongSong2:
                        number(922)
                        setLoop(1)
                        play(127)
                    )
                )
                (send gOwner:
                    view(475)
                    loop(- register 1)
                    cel(0)
                    setCycle(End self)
                )
            )
            (case 1
                = ticks 18
            )
            (case 2
                (send gOwner:setCycle(Beg self))
            )
            (case 3
                localproc_043a(self)
            )
            (case 4
                (self:dispose())
            )
        )
    )

)
(instance thiefJumps of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send gLongSong2:
                    number(940)
                    setLoop(1)
                    play(127)
                )
                (send gOwner:
                    view(30)
                    loop(2)
                    cel(0)
                    y(75)
                    setCycle(End self)
                )
            )
            (case 1
                = ticks 6
            )
            (case 2
                (send gOwner:
                    view(12)
                    loop(0)
                    x(+ (send gOwner:x) 12)
                    y(80)
                )
                localproc_043a(self)
            )
            (case 3
                (self:dispose())
            )
        )
    )

)
(instance egoForward of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (if (> (send gOwner:x) 270)
                    localproc_01e4()
                    (send global2:setScript(ScriptID(470 2)))
                    (self:dispose())
                )(else
                    (send gOwner:
                        view(12)
                        loop(0)
                        cel(0)
                        setMotion(MoveTo + (send gOwner:x) (* (send gOwner:xStep) 6) (send gOwner:y))
                        setCycle(End self)
                    )
                )
            )
            (case 1
                (if ((< gGOwnerMaxStamina[2] 130) or (< gGOwnerMaxStamina[17] 20))
                    (send gOwner:useSkill(2 40))
                    proc470_1()
                    (self:setScript(fallDown self))
                )(else
                    (send gOwner:useSkill(2 2))
                    proc471_8()
                    = ticks 1
                )
            )
            (case 2
                (self:dispose())
            )
        )
    )

)
(instance egoBack of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (if (< (send gOwner:x) 55)
                    proc471_8()
                    (self:dispose())
                )(else
                    (send gOwner:
                        view(12)
                        loop(0)
                        cel((send gOwner:lastCel()))
                        setMotion(MoveTo - (send gOwner:x) (* (send gOwner:xStep) 6) (send gOwner:y))
                        setCycle(Beg self)
                    )
                )
            )
            (case 1
                (if ((< gGOwnerMaxStamina[2] 150) or (< gGOwnerMaxStamina[17] 20))
                    (send gOwner:useSkill(2 50))
                    (self:setScript(fallDown self))
                )(else
                    (send gOwner:useSkill(2 3))
                    proc471_8()
                    = ticks 1
                )
            )
            (case 2
                (self:dispose())
            )
        )
    )

)
(instance quitCross of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                = local7 0
                (send gOwner:
                    view(30)
                    loop(2)
                    setCycle(0)
                    setPri(11)
                    cel(0)
                )
                = cycles 1
            )
            (case 1
                (send gOwner:
                    cel(++local7)
                    x(+ (send gOwner:x) local34[(* local7 2)])
                    y(+ (send gOwner:y) local34[(+ (* local7 2) 1)])
                )
                = cycles 10
            )
            (case 2
                (if (== local7 8)
                    = cycles 1
                )(else
                    (self:changeState(--state))
                )
            )
            (case 3
                (send gOwner:
                    view(0)
                    normalize()
                )
                (if (IsObject(local1) and (< (send local1:y) 92))
                    ++local30
                    (send local1:setScript(
                        (if (== local2 0)
                            endUhuraContest
                        )(else
                            endYesufuContest
                        )
))
                )(else
                    proc0_3()
                )
                (send global2:notify(1 0))
                proc470_1()
                (self:dispose())
            )
        )
    )

)
(instance thiefControls of GloryControls
    (properties)

    (method (init param1)
        = local0 1
        (bridgeWin:open())
        = icon1 iconJump
        = icon2 iconDrop
        = icon3 iconLeft
        = icon4 iconRight
        = icon5 iconBack
        = icon6 iconForward
        = icon7 iconQuit
        = window bridgeWin
        (self:
            add(iconRight iconLeft iconBack iconForward iconJump iconDrop iconQuit)
            eachElementDo(212 -1)
            eachElementDo(213 -1)
            eachElementDo(33 999)
            eachElementDo(14 129)
        )
        (iconQuit:signal((| (iconQuit:signal) $0040)))
        (self:
            add(iconDummy)
            enable(iconQuit)
        )
        (super:init(rest param1))
    )


    (method (dispose param1)
        = local0 0
        (super:dispose(rest param1))
    )


    (method (show param1)
        (User:input(1))
        (send gGame:setCursor(999))
        (super:show(rest param1))
    )


    (method (dispatchEvent param1)
        = gLastTicks GetTime()
        (send gTimers:eachElementDo(57))
        Animate((send gGQg3KDHandler:elements) 1)
        (if (global37)
            = global37 0
            (send gGQg3KDHandler:eachElementDo(246))
        )
        (super:dispatchEvent(param1))
    )

)
(class bridgeIcon of IconI
    (properties
        view -1
        loop -1
        cel -1
        nsLeft 0
        nsTop -1
        nsRight 0
        nsBottom 0
        state $0000
        cursor -1
        type $4000
        message -1
        modifiers $0000
        signal $0001
        maskView 0
        maskLoop 0
        maskCel 0
        highlightColor 0
        lowlightColor 0
        noun 0
        modNum 0
        helpVerb 0
    )

    (method (onMe param1)
        return 
            (if (not & signal $0004)
                (if (((((>= (send param1:x) nsLeft) and (>= (send param1:y) nsTop)) and (<= (send param1:x) nsRight)) and (<= (send param1:y) nsBottom)) and not IsItSkip(view loop cel (- (send param1:y) nsTop) (- (send param1:x) nsLeft)))
                    (if (not cursor)
                        = cursor 1
                        (self:highlight(1))
                    )
                    return 1
                )(else
                    (if (cursor)
                        = cursor 0
                        (self:highlight(0))
                    )
                    return 0
                )
            )(else
                return 0
            )
    )

)
(instance bridgeControls of GloryControls
    (properties)

    (method (init param1)
        = local0 1
        (super:init(rest param1))
        (bridgeWin:open())
        = icon1 iconJump
        = icon2 iconDrop
        = icon3 (= icon5 iconLeft)
        = icon4 (= icon6 iconRight)
        = icon7 iconQuit
        = window bridgeWin
        (self:
            add(iconRight iconLeft iconJump iconDrop iconQuit)
            eachElementDo(212 -1)
            eachElementDo(213 -1)
            eachElementDo(33 999)
            eachElementDo(14 129)
        )
        (if ((send gGQg3KDHandler:contains(ScriptID(39 1))))
            (self:disable(iconQuit))
        )
        (iconQuit:signal((| (iconQuit:signal) $0040)))
        (self:add(iconDummy))
        SetCursor(110 200 176 284)
    )


    (method (dispose param1)
        = local0 0
        (super:dispose(rest param1))
    )


    (method (show param1)
        (User:input(1))
        (send gGame:setCursor(999 195 100))
        (super:show(rest param1))
    )


    (method (hide)
        SetCursor(-2)
        (super:hide())
    )


    (method (dispatchEvent param1)
        (var newEvent, temp1, temp2)
        = local18 0
        = gLastTicks (+ global86 GetTime())
        (send gTimers:eachElementDo(57))
        Animate((send gGQg3KDHandler:elements) 1)
        (send gTheDoits:doit())
        (if (global37)
            = global37 0
            (send gGQg3KDHandler:eachElementDo(246))
        )
        (if (IsObject((send global2:script)))
            (send ((send global2:script)):doit())
        )
        (if (gNewEventHandler)
            (send gNewEventHandler:eachElementDo(57))
            = newEvent (Event:new())
            (if ((send newEvent:type) and gNewEventHandler)
                (send gNewEventHandler:firstTrue(#handleEvent newEvent))
            )
            (send newEvent:dispose())
            = gLastTicks (+ global86 GetTime())
        )
        = temp1 (send param1:type)
        return 
            (if (& temp1 $0040)
                = temp1 (& temp1 $ffbf)
                (switch ((send param1:message))
                    (case 1
                        return 0
                    )
                    (case 5
                        return 0
                    )
                    (default 
                        (super:dispatchEvent(param1))
                    )
                )
            )(else
                = temp2 (send param1:message)
                (if (== temp1 4)
                    (if (== temp2 56)
                        return 0
                    )(else
                        (if (== temp2 50)
                            return 0
                        )(else
                            (super:dispatchEvent(param1))
                        )
                    )
                )(else
                    (super:dispatchEvent(param1))
                )
            )
    )

)
(instance iconJump of bridgeIcon
    (properties
        view 470
        loop 1
        cel 0
        nsLeft 2
        nsTop 2
        maskView 470
        maskLoop 10
    )

    (method (select param1)
        return 
            (if ((super:select(rest param1)))
                = local19 4
                (if (== global362 2)
                    localproc_02ae()
                    (send gOwner:setScript(thiefJumps))
                )(else
                    localproc_0219()
                    (send gOwner:setScript(egoActs 0 local19))
                )
                return 1
            )(else
                0
            )
    )

)
(instance iconRight of bridgeIcon
    (properties
        view 470
        loop 4
        cel 0
        nsLeft 52
        nsTop 34
        maskView 470
        maskLoop 10
        maskCel 3
    )

    (method (select param1)
        return 
            (if ((super:select(rest param1)))
                = local19 3
                (if (== global362 2)
                    localproc_02ae()
                )(else
                    localproc_0219()
                )
                (send gOwner:setScript(egoActs 0 local19))
                return 1
            )(else
                0
            )
    )

)
(instance iconLeft of bridgeIcon
    (properties
        view 470
        loop 3
        cel 0
        nsLeft 2
        nsTop 34
        maskView 470
        maskLoop 10
        maskCel 2
    )

    (method (select param1)
        return 
            (if ((super:select(rest param1)))
                = local19 2
                (if (== global362 2)
                    localproc_02ae()
                )(else
                    localproc_0219()
                )
                (send gOwner:setScript(egoActs 0 local19))
                return 1
            )(else
                0
            )
    )

)
(instance iconDrop of bridgeIcon
    (properties
        view 470
        loop 2
        cel 0
        nsLeft 50
        nsTop 2
        maskView 470
        maskLoop 10
        maskCel 1
    )

    (method (select param1)
        return 
            (if ((super:select(rest param1)))
                (if (== global362 2)
                    localproc_02ae()
                )(else
                    localproc_0219()
                )
                = local19 1
                (send gOwner:setScript(egoActs 0 local19))
                return 1
            )(else
                0
            )
    )

)
(instance iconForward of bridgeIcon
    (properties
        view 470
        loop 9
        cel 0
        nsLeft 60
        nsTop 12
        maskView 470
        maskLoop 10
        maskCel 5
    )

    (method (select param1)
        return 
            (if ((super:select(rest param1)))
                localproc_02ae()
                (send gOwner:setScript(egoForward))
                return 1
            )(else
                0
            )
    )

)
(instance iconBack of bridgeIcon
    (properties
        view 470
        loop 8
        cel 0
        nsLeft 3
        nsTop 12
        maskView 470
        maskLoop 10
        maskCel 4
    )

    (method (select param1)
        return 
            (if ((super:select(rest param1)))
                localproc_02ae()
                (send gOwner:setScript(egoBack))
                return 1
            )(else
                0
            )
    )

)
(instance iconQuit of bridgeIcon
    (properties
        view 470
        loop 5
        cel 0
        nsLeft 24
        nsTop 24
        maskView 470
        maskLoop 10
        maskCel 6
    )

    (method (select param1)
        return 
            (if ((super:select(rest param1)))
                localproc_01e4()
                proc470_1()
                (send gOwner:setScript(quitCross))
                return 1
            )(else
                0
            )
    )

)
(instance iconDummy of IconI
    (properties
        nsLeft 20
        nsTop 20
        nsRight 21
        nsBottom 21
        cursor 997
        signal $0080
    )

    (method (show)
    )


    (method (select)
        return 1
    )


    (method (highlight)
    )

)
(instance bridgeWin of Window
    (properties
        top 100
        left 200
        bottom 166
        right 284
        back 28
    )

    (method (open param1)
        (if (window)
            SetPort(window)
        )(else
            (super:open(rest param1))
        )
        DrawCel(470 0 0 0 0 -1)
        DrawCel(470 6 0 3 2 -1)
    )

)
