(version 2)
(include "sci.sh")
(exports
    0 rm140
)
(use "Main")
(use "GloryWindow")
(use "PseudoMouse")
(use "IconI")
(use "GameControls")
(use "Cycle")
(use "Game")
(use "User")
(use "View")
(use "Obj")
(script 140)


(local
    local0
    local1
    local2 =     71
    local3[11]
    local14[19]
    local33[15] = (28 34 50 66 82 98 35 47 59 71 83 95 107 114 119 )
    local48[15] = (100 11 12 12 13 13 207 207 207 207 207 207 209 12 209 )
    local63[15] = (0 1 2 3 4 5 7 9 10 1 9 11 12 6 12 )
    local78[14] = (1 2 3 4 5 7 8 9 10 11 12 13 6 14 )
    local92[15] = (0 1 2 3 4 5 13 6 7 8 9 10 11 12 14 )
    theGGOwnerMaxStamina[51] = (0 150 80 130 150 100 150 130 100 0 0 100 0 0 90 0 80 150 100 100 100 80 0 100 0 0 0 0 150 120 0 100 100 150 100 100 100 0 100 100 100 100 100 0 100 67 78 68 20 23 27 )
    theGGOwnerMaxStamina_3[11] = (0 50 0 0 50 0 50 0 50 )
    theGGOwnerMaxStamina_4[11] = (100 100 50 100 100 100 100 100 100 100 50 )
    local180 =     1
    local181[39]
    local220
    local221 =     50
    theGGOwnerMaxStamina_2[14]
    theTheGGOwnerMaxStamina[14]
    local250 =     1
    local251
    local252[6] = (71 159 245 71 159 245 )
    local258[6] = (42 44 43 44 46 45 )
    local264
    local265[10]
    local275[10]
    local285[5]

)
(procedure (localproc_1008)
    (var temp0)
    (if ((== global125 3) or (== global125 0))
        = temp0 1
        (while (< temp0 15)
            = theGGOwnerMaxStamina[temp0] gGOwnerMaxStamina[(- temp0 1)]
            ++temp0
        )
        (if (not gGOwnerMaxStamina[10])
            = theGGOwnerMaxStamina[11] 50
        )
        = local180 0
    )(else
        (if (== global125 1)
            == temp0 16
            (while (< temp0 30)
                = theGGOwnerMaxStamina[temp0] gGOwnerMaxStamina[(- temp0 16)]
                ++temp0
            )
            = local180 1
        )(else
            (if (== global125 2)
                == temp0 31
                (while (< temp0 45)
                    = theGGOwnerMaxStamina[temp0] gGOwnerMaxStamina[(- temp0 31)]
                    ++temp0
                )
                = local180 2
            )
        )
    )
    StrCpy(@local181 @global157)
    = local220 StrLen(@local181)
)


(procedure (localproc_10b2 param1 param2 param3)
    Display(rest param3 100 + param2 5 + param1 1 102 58 106 30 101 1 105 123)
    Display(rest param3 100 + param2 4 + param1 1 102 82 106 30 101 1 105 123)
)


(procedure (localproc_10fb)
    (var temp0[4], temp4)
    = temp4 1
    (while (< temp4 15)
        = gGOwnerMaxStamina[(- temp4 1)] theGGOwnerMaxStamina_2[temp4]
        ++temp4
    )
    = gGGOwnerMaxStamina_2[
        (if (not gGOwnerMaxStamina[14])
(            = gGOwnerMaxStamina[14] 50
)        )(else
            0
        )
] gGOwnerMaxStamina[14]
    (if (== global125 3)
        = gGGOwnerMaxStamina_3 gGOwnerMaxStamina[14]
    )
    DrawCel(145 6 0 92 134 15)
    Message(0 140 8 0 5 1 @local285)
    Format(@temp0 @local285 local221)
    Display(@temp0 100 97 133 102 58 106 30 101 1 105 123)
    Display(@temp0 100 96 133 102 43 106 30 101 1 105 123)
    DrawCel(145 6 0 89 172 15)
    Message(0 140 8 0 5 1 @local285)
    localproc_10b2(170 86 Format(@temp0 @local285 = gGOwnerMaxStamina[16] (send gOwner:maxHealth())))
    DrawCel(145 6 0 287 159 15)
    localproc_10b2(157 284 Format(@temp0 @local285 = gGOwnerMaxStamina[17] (send gOwner:maxStamina())))
    DrawCel(145 6 0 287 172 15)
    localproc_10b2(170 284 Format(@temp0 @local285 = gGOwnerMaxStamina[18] (send gOwner:maxMana())))
    DrawCel(145 6 0 285 132 15)
    localproc_10b2(130 283 Format(@temp0 @local285 gGOwnerMaxStamina[14]))
)


(procedure (localproc_12ac param1)
    (var temp0, temp1, temp2)
    = temp0 FirstNode((send param1:elements))
    (while (temp0)
        = temp1 NextNode(temp0)
        = temp2 NodeValue(temp0)
        (if (not IsObject(temp2))
            return 
        )
        (if ((send temp2:respondsTo(#owner)))
            (send temp2:owner(0))
        )
        = temp0 temp1
    )
)


(procedure (localproc_12f6)
    (var temp0)
    StrCpy(@global157 @local181)
    (if (<> gGClientModNum 54)
        localproc_12ac(gInv)
    )
    (send gOwner:get(43))
    (send gOwner:get(15))
    (send gOwner:get(14 20))
    (send ((send gInv:at(14))):amount(20))
    = global424 200
    (switch (local180)
        (case 3
            (send ((send gInv:at(1))):state(1))
            (send gOwner:get(1))
            (send gOwner:get(4))
            (send gOwner:get(5))
            (if (gGOwnerMaxStamina[12])
                = temp0 19
                (while (< temp0 30)
                    (if (not gGOwnerMaxStamina[temp0])
                        = gGOwnerMaxStamina[temp0] theGGOwnerMaxStamina_3[(- temp0 19)]
                    )
                    ++temp0
                )
            )
        )
        (case 0
            (send gOwner:get(1))
            (send gOwner:get(4))
            (send gOwner:get(5))
            (if (gGOwnerMaxStamina[12])
                = temp0 19
                (while (< temp0 30)
                    (if (not gGOwnerMaxStamina[temp0])
                        = gGOwnerMaxStamina[temp0] theGGOwnerMaxStamina_3[(- temp0 19)]
                    )
                    ++temp0
                )
            )
        )
        (case 1
            (send gOwner:get(27))
            (send gOwner:get(2))
            (if (gGOwnerMaxStamina[12])
                = temp0 19
                (while (< temp0 30)
                    (if (not gGOwnerMaxStamina[temp0])
                        = gGOwnerMaxStamina[temp0] theGGOwnerMaxStamina_4[(- temp0 19)]
                    )
                    ++temp0
                )
            )
        )
        (default 
            (send gOwner:get(7))
            (send gOwner:get(6))
            (send gOwner:get(2))
            (if (not (send gOwner:has(10)))
                (send gOwner:get(10 5))
            )(else
                (if (< (send ((send gInv:at(10))):amount) 5)
                    (send ((send gInv:at(10))):amount(5))
                )
            )
            (if (gGOwnerMaxStamina[12])
                = temp0 19
                (while (< temp0 30)
                    (if (not gGOwnerMaxStamina[temp0])
                        = gGOwnerMaxStamina[temp0] theGGOwnerMaxStamina_3[(- temp0 19)]
                    )
                    ++temp0
                )
            )
        )
    )
)


(procedure (localproc_1a39 param1)
    (var newEvent, temp1)
    (fightChar:
        setCycle(0)
        stopUpd()
    )
    (mageChar:
        setCycle(0)
        stopUpd()
    )
    (thiefChar:
        setCycle(0)
        stopUpd()
    )
    (theTitle:
        setLoop(0)
        cel(temp1)
        x(local252[param1])
        y(local258[
            (switch (param1)
                (case 0
                    = temp1 0
                )
                (case 1
                    = temp1 1
                )
                (case 2
                    = temp1 2
                )
            )
])
        priority(0)
        signal(21)
    )
    = newEvent (Event:new())
    (if ((theTitle:onMe(newEvent)) or (not HaveMouse() and not local251))
        (send gGame:setCursor(999 1 
            (switch (param1)
                (case 0
                    50
                )
                (case 1
                    140
                )
                (default 
                    235
                )
            )
 150))
    )
    (send newEvent:dispose())
)


(procedure (localproc_1b0c)
    (var temp0[4])
    Message(0 140 1 6 2 1 @local265)
    Message(0 140 1 6 3 1 @local275)
    (quest:
        init()
        show()
        dispose()
    )
    Message(0 140 8 0 5 1 @temp0)
    Format(@temp0 @local285 local221)
    Display(@temp0 100 97 133 102 58 106 30 101 1 105 123)
    Display(@temp0 100 96 133 102 43 106 30 101 1 105 123)
    return local0
)


(instance public rm140 of Rm
    (properties
        picture 140
        style $000a
        vanishingY 40
    )

    (method (init param1)
        (send gLongSong:
            number(3)
            play()
            hold()
        )
        (if (== gGClientModNum 54)
            (send global2:picture(145))
            (super:init(rest param1))
            localproc_1008()
            (selectChar:start(1))
            (send global2:setScript(selectChar))
        )(else
            (super:init(rest param1))
            Load(rsVIEW 145)
            (super:init())
            proc0_2()
            (send gMainIconBar:disable())
            (send gGame:setCursor(999 1 153 155))
            = global34 0
            = gPseudoMouse 0
            (send gQg3MDHandler:add(theTitle fightChar mageChar thiefChar self))
            (send gQg3KDHandler:add(self theTitle fightChar mageChar thiefChar))
            (send gQg3DirHandler:add(self))
            (theTitle:
                loop(3)
                init()
            )
            (fightChar:init())
            (mageChar:init())
            (thiefChar:init())
            (roundRobin:start(0))
            (self:setScript(roundRobin))
        )
    )


    (method (dispose)
        DisposeScript(934)
        UnLoad(128 145)
        UnLoad(128 142)
        = global34 1
        = gPseudoMouse PseudoMouse
        (send gMainIconBar:enable())
        (super:dispose())
    )


    (method (handleEvent pEvent param2)
        (if (local250)
            (if (== (send pEvent:type) 4)
                (switch ((send pEvent:message))
                    (case 9
                        (send pEvent:type(64))
                        (send pEvent:message(3))
                    )
                    (case 3840
                        (send pEvent:type(64))
                        (send pEvent:message(7))
                    )
                    (case 13
                        = local250 0
                        proc0_2()
                        (switch ((theTitle:cel))
                            (case 0
                                = local180 0
                            )
                            (case 1
                                = local180 1
                            )
                            (case 2
                                = local180 2
                            )
                        )
                        (roundRobin:
                            state(11)
                            cue()
                        )
                    )
                    (default 
                        (super:handleEvent(pEvent rest param2))
                    )
                )
            )
            (if ((send pEvent:claimed) or not local251)
                0
            )(else
                (if (& (send pEvent:type) $0040)
                    (switch ((send pEvent:message))
                        (case 7
                            (send pEvent:claimed(1))
                            (send script:
                                state(
                                    (switch ((theTitle:cel))
                                        (case 0
                                            8
                                        )
                                        (case 1
                                            1
                                        )
                                        (case 2
                                            3
                                        )
                                        (default 
                                            7
                                        )
                                    )
)
                                cue()
                            )
                        )
                        (case 3
                            (send pEvent:claimed(1))
                            (send script:
                                state(
                                    (switch ((theTitle:cel))
                                        (case 0
                                            3
                                        )
                                        (case 1
                                            8
                                        )
                                        (case 2
                                            1
                                        )
                                        (default 
                                            1
                                        )
                                    )
)
                                cue()
                            )
                        )
                    )
                )(else
                    (super:handleEvent(pEvent rest param2))
                )
            )
        )(else
            (super:handleEvent(pEvent rest param2))
        )
    )

)
(instance selectChar of Script
    (properties)

    (method (changeState newState)
        (var temp0)
        (switch (= state newState)
            (case 0
                = global125 local180
                = global362 global125
                (send global2:picture(145))
                DrawPic(145)
                = global157 0
                = cycles 2
            )
            (case 1
                (pointsAvail:init())
                (switch (local180)
                    (case 2
                        = temp0 2
                    )
                    (case 0
                        = temp0 1
                    )
                    (case 1
                        = temp0 0
                    )
                )
                (theChar:
                    setLoop(temp0)
                    init()
                )
                DrawPic(145 dpCLOSEREOPEN_HCENTER)
                = ticks 60
            )
            (case 2
                (switch (global125)
                    (case 0
                        Message(0 140 2 0 0 1 @local3)
                        Display(@local3 100 140 31 105 123 102 0)
                        Display(@local3 105 123 100 139 30 102 30)
                    )
                    (case 1
                        Message(0 140 3 0 0 1 @local3)
                        Display(@local3 100 140 31 105 123 102 0)
                        Display(@local3 105 123 100 139 30 102 30)
                    )
                    (case 2
                        Message(0 140 4 0 0 1 @local3)
                        Display(@local3 100 145 31 105 123 102 0)
                        Display(@local3 105 123 100 144 30 102 30)
                    )
                    (case 3
                        Message(0 140 5 0 0 1 @local3)
                        Display(@local3 100 137 31 105 123 102 0)
                        Display(@local3 105 123 100 136 30 102 30)
                    )
                )
                (startControls:
                    init()
                    show()
                    dispose()
                )
                (send gLongSong:fade(0 2 5 1))
                (if (local264)
                    (send global2:newRoom(130))
                )(else
                    (send global2:newRoom(110))
                )
            )
        )
    )

)
(instance startControls of GameControls
    (properties)

    (method (init param1)
        (var temp0)
        (if (<> gGClientModNum 54)
            = local181 0
        )
        (self:add(namePlate))
        = temp0 1
        (while (< temp0 6)
            (self:add((send ((selectionIcon:new())):
                    nsLeft(local48[temp0])
                    nsTop(local33[temp0])
                    cel(local63[temp0])
                    maskCel(local63[temp0])
                    state(local78[(- temp0 1)])
                    yourself()
                )
))
            = theTheGGOwnerMaxStamina[temp0] theGGOwnerMaxStamina[(+ temp0 (* local180 15))]
            = theGGOwnerMaxStamina_2[temp0] theGGOwnerMaxStamina[(+ temp0 (* local180 15))]
            ++temp0
        )
        (self:add((send ((selectionIcon:new())):
                nsLeft(local48[13])
                nsTop(local33[temp0])
                cel(local63[temp0])
                maskCel(local63[temp0])
                state(local78[12])
                yourself()
            )
))
        = theTheGGOwnerMaxStamina[13] theGGOwnerMaxStamina[(+ 13 (* local180 15))]
        = theGGOwnerMaxStamina_2[13] theGGOwnerMaxStamina[(+ 13 (* local180 15))]
        = temp0 6
        (while (< temp0 13)
            (self:add((send ((selectionIcon:new())):
                    nsLeft(local48[temp0])
                    nsTop(local33[temp0])
                    cel(local63[temp0])
                    maskCel(local63[temp0])
                    state(local78[(- temp0 1)])
                    yourself()
                )
))
            = theTheGGOwnerMaxStamina[temp0] theGGOwnerMaxStamina[(+ temp0 (* local180 15))]
            = theGGOwnerMaxStamina_2[temp0] theGGOwnerMaxStamina[(+ temp0 (* local180 15))]
            ++temp0
        )
        (self:add((send ((selectionIcon:new())):
                nsLeft(local48[14])
                nsTop(local33[temp0])
                cel(local63[temp0])
                maskCel(local63[temp0])
                state(local78[13])
                yourself()
            )
))
        = theTheGGOwnerMaxStamina[14] theGGOwnerMaxStamina[(+ 14 (* local180 15))]
        = theGGOwnerMaxStamina_2[14] theGGOwnerMaxStamina[(+ 14 (* local180 15))]
        (self:add(startIcon cancelIcon dummyIcon))
        (super:init(rest param1))
    )


    (method (show)
        = state (| state $0020)
        DrawCel(145 5 0 118 154 15)
        DrawCel(145 0 0 4 128 15)
        (self:eachElementDo(217))
        (send (= curIcon (= highlightedIcon (self:at(0)))):highlight(1))
        localproc_10fb()
        (send gGame:setCursor(999 1 (+ (send curIcon:nsLeft) 5) (- (send curIcon:nsBottom) 2)))
        (self:
            doit()
            hide()
        )
    )


    (method (advance)
        (var temp0, temp1)
        (asm
            ldi     1
            sat     temp1
code_0755:  lst     temp1
            pToa    size
            le?     
            bnt     code_07aa
            pushi   64
            pushi   1
            lst     temp1
            pushi   #indexOf
            pushi   1
            pTos    highlightedIcon
            self    6
            add     
            push    
            pToa    size
            mod     
            push    
            self    6
            sat     temp0
            pushi   1
            push    
            callk   IsObject, 2
            not     
            bnt     code_0787
            pushi   1
            pushi   #first
            pushi   0
            self    4
            push    
            callk   NodeValue, 2
            sat     temp0
code_0787:  lst     temp0
            lofsa   dummyIcon
            ne?     
            bnt     code_079d
            pushi   #signal
            pushi   0
            lat     temp0
            send    4
            push    
            ldi     4
            and     
            not     
            bnt     code_079d
code_079d:  lst     temp1
            ldi     1
            add     
            push    
            pToa    size
            mod     
            sat     temp1
            jmp     code_0755
code_07aa:  pushi   218
            pushi   #view
            lst     temp0
            pTos    state
            ldi     32
            and     
            push    
            self    8
            ret     
        )
    )


    (method (dispatchEvent param1)
        (var temp0, temp1, temp2, temp3, temp4, temp5, temp6, highlightedIconState)
        (if (local220)
            (if (& (startIcon:signal) $0004)
                (self:enable(startIcon))
                (startIcon:show())
            )
        )(else
            (if (not & (startIcon:signal) $0004)
                (self:disable(startIcon))
                (startIcon:show())
            )
        )
        = temp1 (send param1:x)
        = temp0 (send param1:y)
        = temp2 (send param1:type)
        = temp6 0
        = temp3 (send param1:message)
        = temp4 (send param1:modifiers)
        = temp5 (self:firstTrue(#onMe param1))
        (if (IsObject(param1))
            (send param1:dispose())
        )
        (if (IsObject(temp5))
            (if (& temp2 $0040)
                (switch (temp3)
                    (case 3
                        (if (highlightedIcon and (send highlightedIcon:state))
                            (self:select(temp5 1))
                        )
                    )
                    (case 7
                        (if (highlightedIcon and (send highlightedIcon:state))
                            (self:select(temp5 0))
                        )
                    )
                    (case 1
                        (if (not highlightedIcon)
                            = highlightedIcon (self:at((- size 1)))
                        )
                        (self:retreat())
                    )
                    (case 5
                        (if (not highlightedIcon)
                            = highlightedIcon (self:at(0))
                        )
                        (self:advance())
                    )
                    (case 2
                        (if ((send temp5:state))
                            (self:select(temp5 3))
                        )
                    )
                    (case 4
                        (if ((send temp5:state))
                            (self:select(temp5 2))
                        )
                    )
                )
            )(else
                (if (== temp2 0)
                    (if (not IsObject(temp5))
                        (if (IsObject(highlightedIcon))
                            (send highlightedIcon:highlight(0))
                            = highlightedIcon 0
                        )
                    )(else
                        (if (temp5 and (<> temp5 highlightedIcon))
                            = oldMouseY 0
                            (self:highlight(temp5))
                        )
                    )
                )(else
                    (if (not IsObject(highlightedIcon))
                        0
                    )(else
                        (if (== temp2 1)
                            (if (== temp5 namePlate)
                                0
                            )(else
                                (if (not (send temp5:state))
                                    (self:select(temp5 1))
                                )(else
                                    (if (== temp4 3)
                                        (self:select(temp5 3))
                                    )(else
                                        (self:select(temp5 2))
                                    )
                                )
                            )
                        )(else
                            (if (== temp2 4)
                                (switch (temp3)
                                    (case 27
                                        = temp6 1
                                        return 0
                                    )
                                    (case 13
                                        (if ((== highlightedIcon startIcon) or (== highlightedIcon cancelIcon))
                                            (self:select(highlightedIcon 1))
                                        )
                                    )
                                    (case 9
                                        = highlightedIconState (send highlightedIcon:state)
                                        (if (< highlightedIconState 1)
                                            0
                                        )(else
                                            = highlightedIconState (send highlightedIcon:state)
                                            (if (< highlightedIconState 7)
                                                (send highlightedIcon:highlight(0))
                                                = highlightedIcon (self:at((+ highlightedIconState 5)))
                                                (self:advance())
                                            )(else
                                                (if (< highlightedIconState 13)
                                                    (send highlightedIcon:highlight(0))
                                                    = highlightedIcon (self:at((- highlightedIconState 5)))
                                                    (self:retreat())
                                                )
                                            )
                                        )
                                    )
                                    (default 
                                        (if (<> highlightedIcon namePlate)
                                            0
                                        )(else
                                            (if ((((<= 97 temp3) and (<= temp3 122)) or ((<= 65 temp3) and (<= temp3 90))) or ((<= 48 temp3) and (<= temp3 57)))
                                                (self:select(namePlate temp3))
                                            )(else
                                                (if (== temp3 32)
                                                    (self:select(namePlate temp3))
                                                )(else
                                                    (if (== temp3 8)
                                                        (self:select(namePlate temp3))
                                                    )
                                                )
                                            )
                                        )
                                    )
                                )
                            )
                        )
                    )
                )
            )
        )
        return temp6
    )

)
(instance selectionIcon of IconI
    (properties
        view 145
        loop 1
        maskView 145
        maskLoop 2
        highlightColor 9
        lowlightColor 91
    )

    (method (show)
        (self:highlight(0))
        = nsRight (+ nsLeft 
            (if (< state 7)
                102
            )(else
                111
            )
)
        = nsBottom (+ nsTop 12)
    )


    (method (select param1)
        (switch (param1)
            (case 1
                (if (not local221)
                    0
                )(else
                    (if ((< local221 5) and theGGOwnerMaxStamina_2[local92[state]])
                        = theGGOwnerMaxStamina_2[local92[state]] (+ theGGOwnerMaxStamina_2[local92[state]] local221)
                        = local221 0
                    )(else
                        (if (not theGGOwnerMaxStamina_2[local92[state]])
                            (if (>= local221 30)
                                = theGGOwnerMaxStamina_2[local92[state]] (+ theGGOwnerMaxStamina_2[local92[state]] 10)
                                = local221 (- local221 30)
                            )
                        )(else
                            = theGGOwnerMaxStamina_2[local92[state]] (+ theGGOwnerMaxStamina_2[local92[state]] 5)
                            = local221 (- local221 5)
                        )
                    )
                )
            )
            (case 0
                (if (== theGGOwnerMaxStamina_2[local92[state]] theTheGGOwnerMaxStamina[local92[state]])
                    0
                )(else
                    (if ((== theGGOwnerMaxStamina_2[local92[state]] 10) and not theTheGGOwnerMaxStamina[local92[state]])
                        = theGGOwnerMaxStamina_2[local92[state]] 0
                        = local221 (+ local221 30)
                    )(else
                        (if ((< theGGOwnerMaxStamina_2[local92[state]] 10) and not theTheGGOwnerMaxStamina[local92[state]])
                            = local221 (+ local221 (+ 20 theGGOwnerMaxStamina_2[local92[state]]))
                            = theGGOwnerMaxStamina_2[local92[state]] 0
                        )(else
                            (if (< (- theGGOwnerMaxStamina_2[local92[state]] theTheGGOwnerMaxStamina[local92[state]]) 5)
                                = local221 (+ local221 (- theGGOwnerMaxStamina_2[local92[state]] theTheGGOwnerMaxStamina[local92[state]]))
                                = theGGOwnerMaxStamina_2[local92[state]] (- theGGOwnerMaxStamina_2[local92[state]] (- theGGOwnerMaxStamina_2[local92[state]] theTheGGOwnerMaxStamina[local92[state]]))
                            )(else
                                = theGGOwnerMaxStamina_2[local92[state]] (- theGGOwnerMaxStamina_2[local92[state]] 5)
                                = local221 (+ local221 5)
                            )
                        )
                    )
                )
            )
            (case 3
                (if (not local221)
                    0
                )(else
                    (if (not theGGOwnerMaxStamina_2[local92[state]])
                        (if (>= local221 30)
                            = theGGOwnerMaxStamina_2[local92[state]] (+ theGGOwnerMaxStamina_2[local92[state]] 10)
                            = local221 (- local221 30)
                        )(else
                            0
                        )
                    )(else
                        = theGGOwnerMaxStamina_2[local92[state]] (+ theGGOwnerMaxStamina_2[local92[state]] 1)
                        = local221 (- local221 1)
                    )
                )
            )
            (case 2
                (if (== theGGOwnerMaxStamina_2[local92[state]] theTheGGOwnerMaxStamina[local92[state]])
                    0
                )(else
                    (if ((== theGGOwnerMaxStamina_2[local92[state]] 10) and not theTheGGOwnerMaxStamina[local92[state]])
                        = theGGOwnerMaxStamina_2[local92[state]] 0
                        = local221 (+ local221 30)
                    )(else
                        = theGGOwnerMaxStamina_2[local92[state]] (- theGGOwnerMaxStamina_2[local92[state]] 1)
                        = local221 (+ local221 1)
                    )
                )
            )
        )
        (self:highlight(1))
        localproc_10fb()
    )


    (method (highlight param1)
        (var temp0, temp1[4], temp5, temp6)
        = temp0 
            (if (< state 7)
                92
            )(else
                285
            )
        DrawCel(view 6 
            (if (< state 7)
                0
            )(else
                1
            )
 temp0 + nsTop 1 15)
        (if (param1)
            DrawCel(view loop cel nsLeft nsTop 15)
            = temp5 43
            = temp6 58
        )(else
            DrawCel(maskView maskLoop maskCel nsLeft nsTop 15)
            = temp5 82
            = temp6 58
        )
        Message(0 140 8 0 5 1 @local285)
        Display(Format(@temp1 @local285 theGGOwnerMaxStamina_2[local92[state]]) 100 + temp0 1 nsTop 102 temp6 106 25 101 -1 105 123)
        Message(0 140 8 0 5 1 @local285)
        Display(Format(@temp1 @local285 theGGOwnerMaxStamina_2[local92[state]]) 100 temp0 nsTop 102 temp5 106 25 101 -1 105 123)
    )


    (method (onMe param1)
        return 
            (if ((super:onMe(rest param1)))
                return = helpVerb 1
            )(else
                (if (helpVerb)
                    (self:highlight(0))
                    = helpVerb 0
                )
                return 0
            )
    )

)
(instance dummyIcon of IconI
    (properties
        view 145
        loop 0
        cel 0
        nsTop 0
        nsRight 319
        nsBottom 189
    )

    (method (show)
    )


    (method (select)
    )


    (method (highlight)
    )

)
(instance startIcon of IconI
    (properties
        view 145
        loop 3
        cel 0
        nsLeft 127
        nsTop 158
        maskView 145
        maskLoop 3
        maskCel 3
    )

    (method (select)
        (var temp0, temp1)
        return 
            (if (& (startIcon:signal) $0004)
                return 0
            )(else
                = local1 0
                (if (local221 and localproc_1b0c())
                    return 0
                )(else
                    proc0_2()
                    localproc_12f6()
                    = temp0 1
                    (while (< temp0 15)
                        = gGGOwnerMaxStamina_2[(- temp0 1)] theGGOwnerMaxStamina_2[temp0]
                        ++temp0
                    )
                    (startControls:state((& (startControls:state) $ffdf)))
                )
            )
    )


    (method (highlight param1)
        (if (param1)
            DrawCel(view loop 2 nsLeft nsTop 15)
        )(else
            DrawCel(view loop 0 nsLeft nsTop 15)
        )
    )

)
(instance cancelIcon of IconI
    (properties
        view 145
        loop 4
        cel 0
        nsLeft 127
        nsTop 173
    )

    (method (select)
        = local1 1
        (if (localproc_1b0c())
            proc0_2()
            proc0_5(144)
            = local264 1
            (startControls:state((& (startControls:state) $ffdf)))
        )
    )


    (method (highlight param1)
        (if (param1)
            DrawCel(view loop 2 nsLeft nsTop 15)
        )(else
            DrawCel(view loop 0 nsLeft nsTop 15)
        )
    )

)
(instance namePlate of IconI
    (properties
        view 145
        loop 1
        cel 0
        nsLeft 63
        nsTop 3
        nsRight 263
        nsBottom 15
        maskView 145
        maskLoop 7
    )

    (method (show)
    )


    (method (select param1)
        (var temp0[4])
        TextSize(@temp0[0] @local181 3 0)
        return 
            (if (== param1 8)
                (if (local220)
                    StrAt(@local181 --local220 0)
                    DrawCel(maskView maskLoop maskCel + nsLeft 39 - nsTop 1 15)
                    (self:highlight(1))
                )
            )(else
                (if (<= temp0[3] 150)
                    StrAt(@local181 local220 param1)
                    StrAt(@local181 ++local220 0)
                    (self:highlight(1))
                )(else
                    return 1
                )
            )
    )


    (method (highlight param1)
        (var temp0, temp1, theLoop)
        (if (param1)
            = theLoop loop
            = temp0 43
            = temp1 58
        )(else
            = theLoop 2
            = temp0 82
            = temp1 58
        )
        DrawCel(view theLoop cel nsLeft nsTop 15)
        Display(@local181 100 + nsLeft 41 + nsTop 4 102 temp1 106 172 101 0 105 3)
        Display(@local181 100 + nsLeft 40 + nsTop 4 102 temp0 106 172 101 0 105 3)
    )

)
(instance theChar of View
    (properties
        x 162
        y 154
        view 140
        priority 14
        signal $0010
    )
)
(instance pointsAvail of View
    (properties
        x 92
        y 130
        view 145
        loop 6
        priority 15
        signal $0010
    )
)
(instance fightChar of Prop
    (properties
        x 78
        y 139
        view 140
        loop 1
        signal $4000
    )

    (method (handleEvent pEvent)
        (if (not local251)
            (send pEvent:claimed(1))
            return 
        )(else
            (if ((self:onMe(pEvent)))
                = local250 0
                proc0_2()
                = local180 0
                (theTitle:cel(0))
                (roundRobin:
                    state(11)
                    cue()
                )
                (send pEvent:claimed(1))
            )(else
                (super:handleEvent(pEvent))
            )
        )
    )

)
(instance mageChar of Prop
    (properties
        x 158
        y 139
        view 140
        signal $4000
    )

    (method (handleEvent pEvent)
        (if (not local251)
            (send pEvent:claimed(1))
            return 
        )(else
            (if ((self:onMe(pEvent)))
                = local250 0
                proc0_2()
                = local180 1
                (theTitle:cel(1))
                (roundRobin:
                    state(11)
                    cue()
                )
                (send pEvent:claimed(1))
            )(else
                (super:handleEvent(pEvent))
            )
        )
    )

)
(instance thiefChar of Prop
    (properties
        x 238
        y 140
        view 140
        loop 2
        signal $4000
    )

    (method (handleEvent pEvent)
        (if (not local251)
            (send pEvent:claimed(1))
            return 
        )(else
            (if ((self:onMe(pEvent)))
                = local250 0
                proc0_2()
                = local180 2
                (theTitle:cel(2))
                (roundRobin:
                    state(11)
                    cue()
                )
                (send pEvent:claimed(1))
            )(else
                (super:handleEvent(pEvent))
            )
        )
    )

)
(instance chooseTitle of View
    (properties
        x 159
        y 167
        view 141
        cel 3
    )

    (method (handleEvent)
    )

)
(instance theTitle of View
    (properties
        x -10
        y -20
        view 141
        cel 2
        signal $0015
    )

    (method (handleEvent pEvent)
        (var temp0)
        (if (not local251)
            (send pEvent:claimed(1))
            (roundRobin:cue())
            return 
        )(else
            (if ((self:onMe((send pEvent:x) (send pEvent:y))))
                (roundRobin:
                    state(11)
                    cue()
                )
                = local250 0
                proc0_2()
                (switch ((self:x))
                    (case 71
                        = temp0 0
                    )
                    (case 159
                        = temp0 1
                    )
                    (case 245
                        = temp0 2
                    )
                )
                = local180 temp0
                (send pEvent:claimed(1))
            )(else
                (super:handleEvent(pEvent))
            )
        )
    )

)
(instance roundRobin of Script
    (properties)

    (method (changeState newState)
        (var temp0[2])
        (switch (= state newState)
            (case 0
                (User:canControl(1))
                (User:canInput(1))
                (chooseTitle:
                    init()
                    addToPic()
                )
                = seconds 2
            )
            (case 1
                Message(0 140 7 0 0 1 @local14)
                Display(@local14 105 123 100 101 153 102 0)
                Display(@local14 105 123 100 100 152 102 30)
                = ticks 1
            )
            (case 2
                = seconds 0
                (if ((send gGQg3KDHandler:contains(fireBall)))
                    (fireBall:dispose())
                )
                localproc_1a39(0)
                (send gLongSong2:
                    number(946)
                    play()
                )
                (fightChar:setCycle(End self))
                = local251 1
            )
            (case 3
                (if (== (theTitle:x) 71)
                    Message(0 140 2 0 0 1 @local3)
                    Display(@local3 105 123 100 50 29 102 0)
                    Display(@local3 105 123 100 49 28 102 30)
                )
                = seconds 3
            )
            (case 4
                (fightChar:setCycle(Beg self))
            )
            (case 5
                Load(rsVIEW 142)
                = seconds 0
                (if ((send gGQg3KDHandler:contains(fireBall)))
                    (fireBall:dispose())
                )
                localproc_1a39(1)
                (send gLongSong2:
                    number(948)
                    play()
                )
                (mageChar:setCycle(CT 4 1 self))
            )
            (case 6
                (if (== (theTitle:x) 159)
                    Message(0 140 6 0 0 1 @local3)
                    Display(@local3 105 123 100 124 29 102 0)
                    Display(@local3 105 123 100 123 28 102 30)
                )
                (send gLongSong2:
                    number(947)
                    play()
                )
                (fireBall:
                    loop(0)
                    x(157)
                    y(94)
                    init()
                    setCycle(End self)
                )
                (mageChar:setCycle(End self))
            )
            (case 7
            )
            (case 8
                (mageChar:setCycle(Beg self))
            )
            (case 9
                (if ((send gGQg3KDHandler:contains(fireBall)))
                    (fireBall:dispose())
                )
                = seconds 0
                localproc_1a39(2)
                (thiefChar:setCycle(End self))
            )
            (case 10
                (if (== (theTitle:x) 245)
                    Message(0 140 4 0 0 1 @local3)
                    Display(@local3 105 123 100 226 30 102 0)
                    Display(@local3 105 123 100 225 29 102 30)
                )
                (send gLongSong2:
                    number(949)
                    play()
                )
                (thiefChar:setCycle(Beg self))
            )
            (case 11
                (self:changeState((= state 1)))
            )
            (case 12
                (send gQg3MDHandler:delete(fightChar mageChar thiefChar theTitle self))
                (send gQg3KDHandler:delete(self fightChar mageChar thiefChar theTitle))
                (switch ((theTitle:cel))
                    (case 0
                        (fightChar:hide())
                    )
                    (case 1
                        (mageChar:hide())
                        (fireBall:hide())
                    )
                    (case 2
                        (thiefChar:hide())
                    )
                )
                (send gGame:setCursor(gCursorNumber 0))
                (send global2:drawPic((send global2:picture) 9))
                = cycles 5
            )
            (case 14
                (send gQg3DirHandler:delete(self))
                (send gGQg3KDHandler:eachElementDo(111))
                Animate(0)
                (User:canControl(0))
                (User:canInput(0))
                (send global2:setScript(selectChar))
            )
        )
    )

)
(instance fireBall of Actor
    (properties
        y 139
        view 142
        priority 14
        signal $4810
    )
)
(instance quest of GameControls
    (properties)

    (method (init param1)
        (send gGame:setCursor(999))
        (send (= window (GloryWindow:new())):
            top(60)
            left(77)
            bottom(135)
            right(243)
            priority(15)
            yourself()
        )
        (self:add(titleIcon yesIcon noIcon))
        (super:init(rest param1))
    )

)
(instance titleIcon of IconI
    (properties
        view 935
        loop 2
        cel 0
        nsTop 0
        signal $0004
        maskView 361
        maskLoop 3
    )

    (method (show)
        (var temp0[50])
        (if (local1)
            Message(0 140 1 6 4 1 @temp0)
        )(else
            Message(0 140 1 6 1 1 @temp0)
        )
        Display(@temp0 106 155 100 5 3 102 17)
    )

)
(instance yesIcon of IconI
    (properties
        view 935
        loop 2
        cel 0
        nsTop 40
        signal $0101
        maskView 361
        maskLoop 3
    )

    (method (show)
        = nsRight 80
        = nsBottom (+ nsTop 15)
        DrawCel(view loop cel nsLeft nsTop -1)
        Display(@local265 100 20 + nsTop 3 102 17)
        (if (& signal $0004)
            (self:mask())
        )
        (if (gPseudoMouse and (send gPseudoMouse:respondsTo(#stop)))
            (send gPseudoMouse:stop())
        )
    )


    (method (select)
        = local0 1
        (quest:state((& (quest:state) $ffdf)))
    )


    (method (highlight param1)
        (var temp0)
        (if (param1)
            DrawCel(view loop 1 nsLeft nsTop -1)
            = temp0 46
        )(else
            DrawCel(view loop 0 nsLeft nsTop -1)
            = temp0 17
        )
        Display(@local265 100 20 + nsTop 3 102 temp0)
    )

)
(instance noIcon of IconI
    (properties
        view 935
        loop 2
        cel 0
        nsTop 55
        signal $0101
        maskView 361
        maskLoop 3
    )

    (method (show)
        (var temp0[15])
        = nsRight 80
        = nsBottom (+ nsTop 15)
        DrawCel(view loop cel nsLeft nsTop -1)
        Display(@local275 100 20 + nsTop 3 102 17)
        (if (& signal $0004)
            (self:mask())
        )
        (if (gPseudoMouse and (send gPseudoMouse:respondsTo(#stop)))
            (send gPseudoMouse:stop())
        )
    )


    (method (select)
        = local0 0
        (quest:state((& (quest:state) $ffdf)))
    )


    (method (highlight param1)
        (var temp0)
        (if (param1)
            DrawCel(view loop 1 nsLeft nsTop -1)
            = temp0 46
        )(else
            DrawCel(view loop 0 nsLeft nsTop -1)
            = temp0 17
        )
        Display(@local275 100 20 + nsTop 3 102 temp0)
    )

)
