(version 2)
(include "sci.sh")
(exports
    0 gloryInv
    1 pageCode
    2 invLook
)
(use "Main")
(use "GloryWindow")
(use "Print")
(use "IconI")
(use "SysWindow")
(use "InvI")
(use "Obj")
(script 16)


(local
    local0
    local1
    local2[2]
    gGameSetCursor
    local5

)
(procedure (localproc_015c)
    (var temp0, temp1)
    = temp1 -32768
    = temp0 0
    (while (<= temp0 10)
        (if (& global200 temp1)
            (send gMainIconBar:disable(temp0))
        )
        = temp1 (>> temp1 $0001)
        ++temp0
    )
)


(class NumInvItem of InvI
    (properties
        view 0
        loop 0
        cel 0
        nsLeft 0
        nsTop 0
        nsRight 0
        nsBottom 0
        state $0000
        cursor 999
        type $4000
        message 0
        modifiers $0000
        signal $0002
        maskView 0
        maskLoop 0
        maskCel 0
        highlightColor 0
        lowlightColor 0
        noun 0
        modNum 16
        helpVerb 0
        owner 0
        script 0
        value 0
        amount 0
        realOwner 0
        mustKeep 0
    )

    (method (init param1)
        (super:init(rest param1))
        = cursor Cursor
    )


    (method (select param1)
        (if (== local1 gOwner)
            (if ((super:select(rest param1)))
                (Cursor:
                    view(view)
                    loop(loop)
                    cel(cel)
                )
            )
        )(else
            (self:doVerb(73 (send gInv:indexOf(self))))
            (send gInv:highlightedIcon(invSelect))
        )
    )


    (method (doVerb theVerb)
        (var temp0, temp1, temp2, temp3[20], temp23[60])
        Message(0 16 noun 1 0 1 @temp3)
        = temp2 (send gInv:indexOf(self))
        (if (== gClientModNum 310)
            = temp0 0
        )(else
            (if (== gClientModNum 430)
                = temp0 14
            )(else
                = temp0 14
            )
        )
        = temp1 
            (if (>= temp2 10)
                (< temp2 24)
            )(else
                0
            )
        return 
            (switch (theVerb)
                (case 1
                    (if (== local1 gOwner)
                        (if (> amount 1)
                            Message(0 16 0 theVerb 1 1 @temp23)
                            (Print:addTextF(@temp23 @temp3 amount value))
                        )(else
                            Message(0 16 0 theVerb 2 1 @temp23)
                            (Print:addTextF(@temp23 @temp3 value))
                        )
                    )(else
                        (if ((not temp1 or ((== global331[(+ (- temp2 10) temp0)] 1) and (== gClientModNum 310))) or ((== global331[(+ (- temp2 10) temp0)] 1) and (== gClientModNum 430)))
                            Message(0 16 0 theVerb 3 1 @temp23)
                            (Print:addTextF(@temp23 @temp3))
                        )(else
                            Message(0 16 0 theVerb 4 1 @temp23)
                            (Print:addTextF(@temp23 @temp3 
                                (if (not temp1)
                                    amount
                                )(else
                                    global331[(+ (- temp2 10) temp0)]
                                )
))
                        )
                    )
                    (Print:init())
                    (Print:
                        addText(noun theVerb 0 2 0 0 16)
                        init()
                    )
                )
                (case 73
                    (if (mustKeep)
                        (if (== temp2 46)
                            (Print:
                                addText(0 theVerb 5 1 0 0 16)
                                init()
                            )
                        )(else
                            Message(0 16 0 theVerb 6 1 @temp23)
                            (Print:
                                addTextF(@temp23 @temp3)
                                init()
                            )
                        )
                    )(else
                        (if (== local1 gOwner)
                            (if (> amount 1)
                                --amount
                                Message(0 16 0 theVerb 7 1 @temp23)
                                (Print:
                                    addTextF(@temp23 @temp3)
                                    init()
                                )
                                (self:roomGets())
                            )(else
                                (if (== (send gMainIconBar:curInvIcon) self)
                                    (send gMainIconBar:
                                        disable(7)
                                        curInvIcon(0)
                                    )
                                )
                                Message(0 16 0 theVerb 8 1 @temp23)
                                (Print:
                                    addTextF(@temp3)
                                    init()
                                )
                                (self:
                                    realOwner(gClientModNum)
                                    loseItem()
                                    roomGets()
                                    checkPage()
                                )
                            )
                            (if ((< (+ (send gOwner:wtCarried()) value) (send gOwner:maxLoad())) and proc0_6(5))
                                proc0_5(5)
                                (send gOwner:
                                    setMotion(0)
                                    changeGait(-1 0)
                                )
                            )
                            return 1
                        )(else
                            (send gOwner:get(temp2 1))
                            (send gMainIconBar:
                                curInvIcon(self)
                                enable(7)
                            )
                            (send gInv:curIcon(0))
                            (if ((>= temp2 10) and (< temp2 24))
                                (if (== global331[(+ (- temp2 10) temp0)] 1)
                                    = global331[(+ (- temp2 10) temp0)] 0
                                    Message(0 16 0 theVerb 9 1 @temp23)
                                    (Print:
                                        addTextF(@temp3)
                                        init()
                                    )
                                )(else
                                    --global331[+ (- temp2 10) temp0]
                                    Message(0 16 0 theVerb 10 1 @temp23)
                                    (Print:
                                        addTextF(@temp3)
                                        init()
                                    )
                                )
                            )(else
                                Message(0 16 0 theVerb 9 1 @temp23)
                                (Print:
                                    addTextF(@temp3)
                                    init()
                                )
                            )
                            = owner 0
                            (self:checkPage())
                        )
                        return 1
                    )
                )
                (default 
                    (if (== local1 gOwner)
                        (Print:
                            addText(0 0 11 1 0 0 16)
                            init()
                        )
                    )(else
                        (self:doVerb(73 (send gInv:indexOf(self))))
                    )
                )
            )
    )


    (method (loseItem)
        (self:
            owner(gClientModNum)
            realOwner(gClientModNum)
            amount(0)
        )
    )


    (method (roomGets)
        (var temp0)
        (if (not proc999_5(gClientModNum 310 430))
            return 
        )
        (if (== gClientModNum 310)
            = temp0 0
        )(else
            (if (== gClientModNum 430)
                = temp0 14
            )(else
                = temp0 14
            )
        )
        (if ((>= (send gInv:indexOf(self)) 10) and (< (send gInv:indexOf(self)) 24))
            ++global331[- (+ (send gInv:indexOf(self)) temp0) 10]
        )(else
            (self:loseItem())
        )
    )


    (method (checkPage)
        (var temp0, temp1)
        (if (== local5 2)
            = temp1 0
            = temp0 0
            (while (< temp0 47)
                (if (== (send ((send gInv:at(temp0))):owner) local1)
                    = temp1 1
                    = temp0 48
                )
                ++temp0
            )
            (send gInv:hide())
            (if (temp1)
                (if (> temp0 47)
                    (send gInv:
                        show(local1)
                        selectIcon(invSelect)
                    )
                )(else
                    = local0 1
                    (invPageUp:select())
                )
            )
        )(else
            (send gInv:hide())
            (pageCode:init(local1))
        )
    )

)
(instance public gloryInv of Inv
    (properties
        normalHeading 9
        empty 27
    )

    (method (init)
        = gInv self
        (send gInv:
            add(theRoyals theSword theFineDagger theFineSpear theChainmail theShield theGrapnel theToolkit theGuildCard theTinderbox theDaggers theCurePills theHealPills theManaPills theRations theWaterskin theDispell theFish theMeat theFruit theBeads theSkins theHorn theRocks theVine theOil theRope theGagGift thePin theHoney theFeather theAmulet theLeopard theBird theOpal theVineFruit theGem thePeaceWater theHeartGift theOrchid theRobe theBridge theEye theNote theWood theMagicSpear theMagicDrum invPageDown invPageUp invLook invSelect invDrop ok invHelp dummyIcon)
            eachElementDo(212 -1)
            eachElementDo(213 -1)
            eachElementDo(110)
            window(invWin)
            helpIconItem(invHelp)
            selectIcon(invSelect)
            okButton(ok)
            state(2048)
        )
        (send gOwner:get(0))
        (send gOwner:get(14))
    )


    (method (showSelf param1)
        (var temp0, temp1, cursorLoop, cursorCel, gMainIconBarCurInvIcon)
        (send gSounds:pause())
        (if (gPseudoMouse and (send gPseudoMouse:respondsTo(#stop)))
            (send gPseudoMouse:stop())
        )
        (if ((send gMainIconBar:height))
            (send gMainIconBar:hide())
        )
        (if (not window)
            = window (SysWindow:new())
        )
        (if ((send window:window))
            (send window:dispose())
            = window 0
        )
        (if (not okButton)
            = okButton NodeValue((self:first()))
        )
        (if (not local5)
            = curIcon 0
        )
        (if ((self:show(
            (if (paramTotal)
                param1
            )(else
                gOwner
            )
)))
            (if (not local5)
                = cursorLoop (Cursor:loop)
                = cursorCel (Cursor:cel)
                = local5 1
                (self:doit())
                = local5 0
                (if (IsObject(curIcon) and (send curIcon:isKindOf(NumInvItem)))
                    (if (not (send gMainIconBar:curInvIcon))
                        (send gMainIconBar:enable((send gMainIconBar:useIconItem)))
                    )
                    (send gMainIconBar:
                        curIcon((send ((send gMainIconBar:useIconItem)):
                                cursor((send curIcon:cursor))
                                yourself()
                            )
)
                        curInvIcon(curIcon)
                    )
                    = temp1 (send ((send gMainIconBar:curIcon)):cursor)
                    (if (temp1)
                        (send gGame:setCursor((= temp1 (send ((send gMainIconBar:curIcon)):cursor))))
                    )
                )(else
                    (if (IsObject((send gMainIconBar:curInvIcon)))
                        = gMainIconBarCurInvIcon (send gMainIconBar:curInvIcon)
                        (Cursor:
                            view((send gMainIconBarCurInvIcon:view))
                            loop((send gMainIconBarCurInvIcon:loop))
                            cel((send gMainIconBarCurInvIcon:cel))
                        )
                    )(else
                        (Cursor:
                            loop(cursorLoop)
                            cel(cursorCel)
                        )
                    )
                )
                = curIcon 0
            )(else
                (while ((send (= temp0 (send ((send gUser:curEvent)):new())):type))
                )
            )
        )
    )


    (method (hide)
        (if (& state $0020)
            (send gSounds:pause(0))
            = state (& state $ffdf)
        )
        (if (window)
            (send window:dispose())
        )
    )


    (method (advance)
        (var temp0, temp1)
        (asm
            ldi     1
            sat     temp1
code_0ef4:  lst     temp1
            pToa    size
            le?     
            bnt     code_0f4a
            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_0f27
            pushi   1
            pushi   #first
            pushi   0
            self    4
            push    
            callk   NodeValue, 2
            sat     temp0
code_0f27:  lst     temp0
            lofsa   dummyIcon
            ne?     
            bnt     code_0f3d
            pushi   #signal
            pushi   0
            lat     temp0
            send    4
            push    
            ldi     4
            and     
            not     
            bnt     code_0f3d
code_0f3d:  lst     temp1
            ldi     1
            add     
            push    
            pToa    size
            mod     
            sat     temp1
            jmp     code_0ef4
code_0f4a:  pushi   218
            pushi   #view
            lst     temp0
            pTos    state
            ldi     32
            and     
            push    
            self    8
            ret     
        )
    )


    (method (retreat)
        (var temp0, temp1)
        (asm
            ldi     1
            sat     temp1
code_0f5f:  lst     temp1
            pToa    size
            le?     
            bnt     code_0fb6
            pushi   64
            pushi   1
            pushi   #indexOf
            pushi   1
            pTos    highlightedIcon
            self    6
            push    
            lat     temp1
            sub     
            push    
            pToa    size
            mod     
            push    
            self    6
            sat     temp0
            pushi   1
            push    
            callk   IsObject, 2
            not     
            bnt     code_0f93
            pushi   1
            pushi   #last
            pushi   0
            self    4
            push    
            callk   NodeValue, 2
            sat     temp0
code_0f93:  lst     temp0
            lofsa   dummyIcon
            ne?     
            bnt     code_0fa9
            pushi   #signal
            pushi   0
            lat     temp0
            send    4
            push    
            ldi     4
            and     
            not     
            bnt     code_0fa9
code_0fa9:  lst     temp1
            ldi     1
            add     
            push    
            pToa    size
            mod     
            sat     temp1
            jmp     code_0f5f
code_0fb6:  pushi   218
            pushi   #view
            lst     temp0
            pTos    state
            ldi     32
            and     
            push    
            self    8
            ret     
        )
    )


    (method (noClickHelp)
        (super:noClickHelp())
        (send gGame:setCursor(942 1))
    )


    (method (drawInvWindow param1 param2)
        (var temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7, invFirst, temp9, temp10, temp11, temp12, temp13, temp14, temp15, temp16, temp17, temp18, temp19, temp20, temp21, invWindow, temp23[50], temp73[20])
        = temp5 0
        = temp4 temp5
        = temp3 temp4
        = temp2 temp3
        = temp1 temp2
        = temp0 temp1
        = invFirst (self:first())
        (while (invFirst)
            = temp9 NodeValue(invFirst)
            (if ((send temp9:isKindOf(InvI)))
                (if ((send temp9:ownedBy(param1)))
                    (send temp9:signal((& (send temp9:signal) $fffb)))
                    ++temp0
                    = temp6 CelWide((send temp9:view) (send temp9:loop) (send temp9:cel))
                    (if (> temp6 (+ 3 temp2))
                        = temp2 (- temp6 3)
                    )
                    = temp7 CelHigh((send temp9:view) (send temp9:loop) (send temp9:cel))
                    (if (> temp7 (+ 3 temp1))
                        = temp1 (- temp7 3)
                    )
                )(else
                    (send temp9:signal((| (send temp9:signal) $0004)))
                )
            )(else
                ++temp3
                = temp5 (+ temp5 CelWide((send temp9:view) (send temp9:loop) (send temp9:cel)))
                = temp7 CelHigh((send temp9:view) (send temp9:loop) (send temp9:cel))
                (if (> temp7 temp4)
                    = temp4 temp7
                )
            )
            = invFirst (self:next(invFirst))
        )
        (if (== (dummyIcon:owner) param1)
            --temp0
        )
        (if (not temp0)
            return 0
        )
        (if (<= temp0 6)
            = temp17 1
            = temp11 temp0
        )(else
            = temp17 Sqrt(temp0)
            (if ((> temp17 1) and (>= (* temp17 temp17) temp0))
                --temp17
            )
            (if (> temp17 3)
                = temp17 3
            )
            = temp11 (/ temp0 temp17)
            (if (<= (* temp17 temp11) temp0)
                ++temp11
            )
            (if (> temp17 1)
                (if (> temp11 8)
                    = temp11 8
                )(else
                    (if (< temp11 6)
                        = temp11 6
                    )
                )
            )
            (if (>= (* temp11 (- temp17 1)) temp0)
                --temp17
            )
        )
        = temp12 proc999_3((+ 4 temp5) (* temp11 (+ 1 temp2)))
        = temp10 (* temp17 (+ 2 temp1))
        = temp13 (/ (- 190 temp10) 2)
        = temp14 (/ (- 320 temp12) 2)
        = temp15 (+ temp13 temp10)
        = temp16 (+ temp14 temp12)
        = invWindow (self:window)
        (if (invWindow)
            (send (= invWindow (self:window)):
                top(temp13)
                left(temp14)
                right(temp16)
                bottom(temp15)
                open()
            )
        )
        = temp21 temp11
        (if (temp0)
            = temp19 (+ 2 
                (if ((send invWindow:respondsTo(#yOffset)))
                    (send invWindow:yOffset)
                )(else
                    0
                )
)
            = temp18 (+ 2 
                (if ((send invWindow:respondsTo(#xOffset)))
                    (send invWindow:xOffset)
                )(else
                    0
                )
)
            = temp20 temp18
            = invFirst (self:first())
            (while (invFirst)
                = temp9 NodeValue(invFirst)
                (if (not (& (send temp9:signal) $0004) and (send temp9:isKindOf(InvI)))
                    (if (not & (send temp9:signal) $0080)
                        = temp6 CelWide((send temp9:view) (send temp9:loop) (send temp9:cel))
                        = temp7 CelHigh((send temp9:view) (send temp9:loop) (send temp9:cel))
                        (send temp9:
                            nsLeft(+ temp18 (/ (- temp2 temp7) 2))
                            nsTop(+ temp19 (/ (- temp1 temp7) 2))
                        )
                        (send temp9:
                            nsRight(+ (send temp9:nsLeft) temp6)
                            nsBottom(+ (send temp9:nsTop) temp7)
                        )
                        (if (--temp21)
                            = temp18 (+ temp18 temp2)
                        )(else
                            = temp21 temp11
                            = temp19 (+ temp19 temp1)
                            = temp18 temp20
                        )
                    )(else
                        = temp18 (send temp9:nsLeft)
                        = temp19 (send temp9:nsTop)
                    )
                    (send temp9:show())
                    (if (== temp9 param2)
                        (send temp9:highlight())
                    )
                )
                = invFirst (self:next(invFirst))
            )
        )
        = temp18 (/ (- (- (send invWindow:right) (send invWindow:left)) temp5) 2)
        = temp10 (- (send invWindow:bottom) (send invWindow:top))
        = temp19 32767
        = invFirst (self:first())
        (while (invFirst)
            = temp9 NodeValue(invFirst)
            (if (not (send temp9:isKindOf(InvI)))
                = temp6 CelWide((send temp9:view) (send temp9:loop) (send temp9:cel))
                = temp7 CelHigh((send temp9:view) (send temp9:loop) (send temp9:cel))
                (if (not & (send temp9:signal) $0080)
                    (if (== temp19 32767)
                        = temp19 (- temp10 temp7)
                    )
                    (send temp9:
                        nsLeft(temp18)
                        nsTop(temp19)
                        nsBottom(temp10)
                        nsRight(+ temp18 temp6)
                    )
                )
                = temp18 (+ (send temp9:nsLeft) temp6)
                = temp19 (send temp9:nsTop)
                (send temp9:
                    signal(& (send temp9:signal) $fffb)
                    show()
                )
            )
            = invFirst (self:next(invFirst))
        )
        (if (== param1 gOwner)
            Message(0 16 0 0 25 1 @temp73)
            Display(Format(@temp23 @temp73 (send gOwner:maxLoad())) 105 999 100 + (/ temp12 2) 12 - temp10 12 102 (send window:color))
            Message(0 16 0 0 26 1 @temp73)
            Display(Format(@temp23 @temp73 (send gOwner:wtCarried())) 105 999 100 2 - temp10 12 102 
                (if (>= (send gOwner:wtCarried()) (send gOwner:maxLoad()))
                    65
                )(else
                    (send window:color)
                )
)
            Graph(grDRAW_LINE - temp10 16 + (/ temp12 2) 10 - temp10 6 + (/ temp12 2) 10 58 -1 -1)
            Graph(grDRAW_LINE - temp10 16 0 - temp10 16 temp12 58 -1 -1)
            Graph(grUPDATE_BOX - temp10 17 0 temp10 temp12 1)
        )
        (dummyIcon:
            nsTop(0)
            nsLeft(0)
            nsRight((send window:right))
            nsBottom((send window:bottom))
            owner(param1)
            signal(2)
        )
        return 1
    )

)
(instance invWin of GloryWindow
    (properties
        yOffset 28
    )

    (method (open)
        (invLook:nsLeft((- (/ (- (self:right) (self:left)) 2) 75)))
        = bottom (+ bottom 15)
        (super:open())
    )

)
(instance public pageCode of Code
    (properties)

    (method (init param1)
        (var temp0, temp1, temp2)
        (if (not local5)
            = gGameSetCursor (send gGame:setCursor())
        )
        = local1 param1
        (send gInv:selectIcon(invSelect))
        (if (== local1 gOwner)
            (send gInv:window(invWin))
            (invDrop:
                noun(5)
                loop(6)
                signal(1)
            )
        )(else
            (if (== gClientModNum 310)
                = temp2 0
            )(else
                = temp2 14
            )
            (invDrop:
                noun(3)
                loop(8)
                signal(3)
            )
        )
        (invSelect:message(-1))
        = global205 0
        (invPageUp:owner(0))
        (invPageDown:owner(0))
        = temp0 0
        (while (< temp0 47)
            (send ((send gInv:at(temp0))):owner(0))
            (if (((== (send ((send gInv:at(temp0))):realOwner) local1) or ((((<> local1 gOwner) and (>= temp0 10)) and (< temp0 24)) and global331[(+ (- temp0 10) temp2)])) and (< ++global205 25))
                (if (== global205 24)
                    = temp1 temp0
                )
                (send ((send gInv:at(temp0))):owner(local1))
            )
            ++temp0
        )
        (if (> global205 24)
            (send ((send gInv:at(temp1))):owner(0))
            (invPageDown:
                highlightColor(-1)
                owner(local1)
            )
        )
        (send gInv:showSelf(local1))
    )

)
(instance dummyIcon of InvI
    (properties
        view 932
        loop 5
        cursor 942
        signal $0002
    )

    (method (show)
    )


    (method (select)
        return 0
    )


    (method (highlight)
    )


    (method (onMe param1)
        return 
            (if (((>= (send param1:x) nsLeft) and (>= (send param1:y) nsTop)) and (<= (send param1:x) nsRight))
                <= (send param1:y) nsBottom
            )(else
                0
            )
    )


    (method (doVerb)
        return 0
    )

)
(instance invPageDown of InvI
    (properties
        view 932
        loop 5
        cursor 942
        signal $0003
        noun 1
        modNum 16
        helpVerb 9
    )

    (method (show)
        (super:show())
        DrawCel(932 loop 2 + nsLeft CelWide(view loop cel) nsTop -1)
    )


    (method (select)
        (var temp0)
        = temp0 0
        (while (< temp0 47)
            (if (== (send ((send gInv:at(temp0))):realOwner) local1)
                (if (== (send ((send gInv:at(temp0))):owner) local1)
                    (send ((send gInv:at(temp0))):owner(1))
                )(else
                    (send ((send gInv:at(temp0))):owner(local1))
                )
            )
            ++temp0
        )
        = local5 2
        (invPageUp:
            owner(local1)
            highlightColor(-1)
        )
        (invPageDown:owner(0))
        (send gInv:
            hide()
            showSelf(local1)
        )
        return 0
    )


    (method (doVerb theVerb)
        (if (<> theVerb 1)
            (self:select())
        )(else
            (Print:
                addText(noun 1 0 1 0 0 16)
                init()
            )
        )
    )

)
(instance invPageUp of InvI
    (properties
        view 932
        loop 5
        cursor 942
        signal $0003
        noun 2
        modNum 16
        helpVerb 9
    )

    (method (show)
        (super:show())
        DrawCel(932 loop 2 + nsLeft CelWide(view loop cel) nsTop -1)
    )


    (method (select)
        (var temp0)
        = temp0 0
        (while (< temp0 47)
            (if (== (send ((send gInv:at(temp0))):realOwner) local1)
                (if (== (send ((send gInv:at(temp0))):owner) 1)
                    (send ((send gInv:at(temp0))):owner(local1))
                )(else
                    (send ((send gInv:at(temp0))):owner(0))
                )
            )
            ++temp0
        )
        = local5 1
        (send gInv:hide())
        (invPageUp:owner(0))
        (if (not local0)
            (invPageDown:
                owner(local1)
                highlightColor(-1)
            )
        )
        = local0 0
        (send gInv:showSelf(local1))
        return 0
    )


    (method (doVerb theVerb)
        (if (<> theVerb 1)
            (self:select())
        )(else
            (Print:
                addText(noun 1 0 1 0 0 16)
                init()
            )
        )
    )

)
(instance public invLook of IconI
    (properties
        view 932
        loop 2
        cel 0
        cursor 941
        message 1
        signal $0081
        noun 3
        modNum 16
        helpVerb 9
    )

    (method (highlight param1)
        (if (== (invDrop:noun) noun)
            (invDrop:highlight(rest param1))
        )
        (super:highlight(rest param1))
    )

)
(instance invSelect of IconI
    (properties
        view 932
        loop 0
        cel 0
        cursor 942
        noun 4
        modNum 16
        helpVerb 9
    )
)
(instance invDrop of IconI
    (properties
        view 932
        loop 6
        cel 0
        cursor 944
        message 73
        noun 5
        modNum 16
        helpVerb 9
    )

    (method (onMe param1)
        return 
            (if (== noun 3)
                return 0
            )(else
                (super:onMe(rest param1))
            )
    )

)
(instance invHelp of IconI
    (properties
        view 932
        loop 1
        cel 0
        cursor 949
        message 9
        signal $0003
        noun 6
        modNum 16
        helpVerb 9
    )

    (method (show)
        (super:show())
        DrawCel(932 7 0 - (+ nsLeft CelWide(view loop cel)) 28 nsTop -1)
    )

)
(instance ok of IconI
    (properties
        view 932
        loop 3
        cel 0
        cursor 942
        signal $0043
        noun 7
        modNum 16
        helpVerb 9
    )
)
(instance theRoyals of NumInvItem
    (properties
        view 905
        loop 4
        cel 3
        message 59
        value 2
        mustKeep 1
    )

    (method (doVerb theVerb)
        (var temp0[30], temp30[20], temp50[20], temp70[20], temp90, temp91[20])
        (switch (theVerb)
            (case 1
                Format(@temp30 "Dinars: %d." global424)
                (if (== message 59)
                    (Print:addText(@temp30))
                )(else
                    = temp90 0
                    (if (global424)
                        Message(0 16 0 0 14 1 @temp30)
                        Format(@temp0 @temp30 global424)
                        (Print:addText(@temp0))
                    )
                    (if (amount)
                        Message(0 16 0 0 13 1 @temp50)
                        Format(@temp0 @temp50 amount)
                        = temp90 (+ temp90 10)
                        (Print:addText(@temp0 0 temp90))
                    )
                    (if (global410)
                        Message(0 16 0 0 15 1 @temp70)
                        Format(@temp0 @temp70 global410)
                        = temp90 (+ temp90 10)
                        (Print:addText(@temp0 0 temp90))
                    )
                    (if ((global424 or amount) or global410)
                        Message(0 16 0 0 17 1 @temp91)
                        Format(@temp0 @temp91 + (+ global424 amount) global410)
                        = temp90 (+ temp90 15)
                        (Print:addText(@temp0 0 temp90))
                    )(else
                        (Print:addText(0 10 12 1 0 0 16))
                    )
                )
                (Print:init())
                (Print:
                    addText(0 theVerb 27 1 0 0 16)
                    init()
                )
            )
            (case 73
                (Print:
                    addText(0 73 16 1 0 0 16)
                    init()
                )
            )
            (default 
                (super:doVerb(theVerb))
            )
        )
    )

)
(instance theSword of NumInvItem
    (properties
        view 905
        loop 2
        message 11
        noun 54
        value 420
        mustKeep 1
    )

    (method (doVerb theVerb)
        (var temp0[30], temp30[160])
        (switch (theVerb)
            (case 1
                Message(0 16 0 theVerb 2 1 @temp30)
                (if (state)
                    Message(0 16 0 1 18 1 @temp0)
                )(else
                    Message(0 16 0 1 19 1 @temp0)
                )
                (Print:
                    addTextF(@temp30 @temp0 value)
                    init()
                )
                (if (state)
                    (Print:
                        addText(0 theVerb 18 2 0 0 16)
                        init()
                    )
                )(else
                    (Print:
                        addText(0 theVerb 19 2 0 0 16)
                        init()
                    )
                )
            )
            (default 
                (super:doVerb(theVerb))
            )
        )
    )

)
(instance theFineDagger of NumInvItem
    (properties
        view 905
        loop 6
        cel 1
        message 12
        noun 8
        value 60
        mustKeep 1
    )
)
(instance theFineSpear of NumInvItem
    (properties
        view 905
        loop 10
        cel 4
        message 13
        noun 9
        value 240
    )
)
(instance theChainmail of NumInvItem
    (properties
        view 905
        loop 2
        cel 1
        message 14
        noun 10
        value 2100
        mustKeep 1
    )
)
(instance theShield of NumInvItem
    (properties
        view 905
        loop 2
        cel 2
        message 15
        noun 11
        value 720
        mustKeep 1
    )
)
(instance theGrapnel of NumInvItem
    (properties
        view 905
        loop 2
        cel 7
        message 16
        noun 12
        value 80
        mustKeep 1
    )

    (method (doVerb theVerb param2)
        (if (== theVerb 36)
            (theRope:
                owner(0)
                realOwner(0)
            )
            = cel 8
            = state 1
            = noun 56
            (send gInv:curIcon(self))
            (self:
                select()
                checkPage()
            )
        )(else
            (super:doVerb(theVerb rest param2))
        )
    )

)
(instance theToolkit of NumInvItem
    (properties
        view 905
        loop 4
        cel 2
        message 17
        noun 22
        value 30
    )
)
(instance theGuildCard of NumInvItem
    (properties
        view 905
        loop 4
        message 18
        noun 23
        value 2
    )
)
(instance theTinderbox of NumInvItem
    (properties
        view 905
        loop 6
        message 19
        noun 24
        value 5
        mustKeep 1
    )
)
(instance theDaggers of NumInvItem
    (properties
        view 905
        loop 4
        cel 1
        message 20
        noun 25
        value 90
    )
)
(instance theCurePills of NumInvItem
    (properties
        view 905
        cel 5
        message 21
        noun 26
        value 5
    )
)
(instance theHealPills of NumInvItem
    (properties
        view 905
        cel 6
        message 22
        noun 27
        value 5
    )
)
(instance theManaPills of NumInvItem
    (properties
        view 905
        cel 7
        message 23
        noun 28
        value 5
    )
)
(instance theRations of NumInvItem
    (properties
        view 905
        cel 1
        message 24
        noun 29
        value 20
    )
)
(instance theWaterskin of NumInvItem
    (properties
        view 905
        loop 6
        cel 5
        message 25
        noun 30
        value 20
    )
)
(instance theDispell of NumInvItem
    (properties
        view 905
        cel 8
        message 26
        noun 31
        value 40
    )
)
(instance theFish of NumInvItem
    (properties
        view 905
        loop 4
        cel 6
        message 27
        noun 32
        value 20
    )
)
(instance theMeat of NumInvItem
    (properties
        view 905
        loop 4
        cel 7
        message 28
        noun 33
        value 20
    )
)
(instance theFruit of NumInvItem
    (properties
        view 905
        loop 4
        cel 8
        message 29
        noun 34
        value 20
    )
)
(instance theBeads of NumInvItem
    (properties
        view 905
        loop 6
        cel 3
        message 30
        noun 35
        value 10
    )
)
(instance theSkins of NumInvItem
    (properties
        view 905
        loop 10
        cel 3
        message 31
        noun 36
        value 120
    )
)
(instance theHorn of NumInvItem
    (properties
        view 905
        loop 10
        cel 2
        message 32
        noun 37
        value 40
    )
)
(instance theRocks of NumInvItem
    (properties
        view 905
        cel 2
        message 33
        noun 38
        value 30
    )
)
(instance theVine of NumInvItem
    (properties
        view 905
        loop 10
        cel 8
        message 34
        noun 39
        value 30
    )
)
(instance theOil of NumInvItem
    (properties
        view 905
        loop 6
        cel 4
        message 35
        noun 40
        value 30
        mustKeep 1
    )
)
(instance theRope of NumInvItem
    (properties
        view 905
        loop 6
        cel 2
        message 36
        noun 41
        value 200
        mustKeep 1
    )

    (method (doVerb theVerb param2)
        (if (== theVerb 16)
            = realOwner (= owner 0)
            (send gInv:curIcon(theGrapnel))
            (theGrapnel:
                noun(56)
                cel(8)
                state(1)
                select()
            )
            (self:checkPage())
        )(else
            (super:doVerb(theVerb rest param2))
        )
    )

)
(instance theGagGift of NumInvItem
    (properties
        view 905
        loop 2
        cel 4
        message 37
        noun 53
        value 30
        mustKeep 1
    )

    (method (select param1)
        return 
            (if ((super:select(rest param1)))
                (if (== cel 4)
                    (if ((send (ScriptID(gClientModNum)):script))
                        (Print:
                            addText(51 0 22 0 0 0 16)
                            init()
                        )
                        return 0
                    )(else
                        (if (> (send gOwner:view) 5)
                            (Print:
                                addText(51 0 23 0 0 0 16)
                                init()
                            )
                            return 0
                        )(else
                            = cel 6
                            = value 5
                            (send gInv:curIcon(ok))
                            (if (== (send gMainIconBar:curInvIcon) self)
                                (send gMainIconBar:
                                    curInvIcon(0)
                                    disable(7)
                                )
                            )
                            (send gInv:hide())
                            (send (ScriptID(gClientModNum)):setScript(ScriptID(30)))
                            return 0
                        )
                    )
                )(else
                    (send gInv:curIcon(ok))
                    (send gInv:hide())
                    (if (== (send gMainIconBar:curInvIcon) self)
                        (send gMainIconBar:
                            curInvIcon(0)
                            disable(7)
                            advanceCurIcon()
                        )
                    )
                    proc0_2()
                    (send gOwner:
                        learn(30)
                        solvePuzzle(206 4 2)
                    )
                    (send gQg3Messager:say(51 0 24 0 0 16))
                    (self:
                        mustKeep(0)
                        loseItem()
                        realOwner(0)
                        owner(0)
                    )
                    proc0_3()
                    localproc_015c()
                )
            )(else
                0
            )
    )


    (method (doVerb theVerb)
        (var temp0[30], temp30[160])
        (switch (theVerb)
            (case 1
                Message(0 16 0 theVerb 2 1 @temp30)
                (if (== cel 4)
                    Message(0 16 53 1 29 1 @temp0)
                )(else
                    Message(0 16 53 1 28 1 @temp0)
                )
                (Print:
                    addTextF(@temp30 @temp0 value)
                    init()
                )
                (if (== cel 4)
                    (Print:
                        addText(53 1 29 2 0 0 16)
                        init()
                    )
                )(else
                    (Print:
                        addText(53 1 28 2 0 0 16)
                        init()
                    )
                )
            )
            (default 
                (super:doVerb(theVerb))
            )
        )
    )

)
(instance thePin of NumInvItem
    (properties
        view 905
        cel 3
        message 39
        noun 42
        value 2
    )
)
(instance theHoney of NumInvItem
    (properties
        view 905
        loop 4
        cel 4
        message 40
        noun 43
        value 20
        mustKeep 1
    )
)
(instance theFeather of NumInvItem
    (properties
        view 905
        loop 4
        cel 5
        message 41
        noun 44
        value 2
    )
)
(instance theAmulet of NumInvItem
    (properties
        view 905
        loop 6
        cel 6
        message 42
        noun 45
        value 10
    )
)
(instance theLeopard of NumInvItem
    (properties
        view 905
        loop 6
        cel 7
        message 43
        noun 46
        value 30
        mustKeep 1
    )
)
(instance theBird of NumInvItem
    (properties
        view 905
        loop 6
        cel 8
        message 44
        noun 47
        value 30
        mustKeep 1
    )
)
(instance theOpal of NumInvItem
    (properties
        view 905
        loop 8
        message 45
        noun 48
        value 6
        mustKeep 1
    )
)
(instance theVineFruit of NumInvItem
    (properties
        view 905
        loop 8
        cel 1
        message 46
        noun 49
        value 20
        mustKeep 1
    )
)
(instance theGem of NumInvItem
    (properties
        view 905
        loop 8
        cel 2
        message 47
        noun 50
        value 6
        mustKeep 1
    )
)
(instance thePeaceWater of NumInvItem
    (properties
        view 905
        loop 8
        cel 4
        message 48
        noun 13
        value 80
    )
)
(instance theHeartGift of NumInvItem
    (properties
        view 905
        loop 8
        cel 5
        message 49
        noun 14
        value 20
        mustKeep 1
    )
)
(instance theOrchid of NumInvItem
    (properties
        view 905
        loop 8
        cel 6
        message 50
        noun 55
        value 12
        mustKeep 1
    )

    (method (doVerb theVerb)
        (var temp0[30], temp30[160])
        (switch (theVerb)
            (case 1
                Message(0 16 0 theVerb 2 1 @temp30)
                (if (state)
                    Message(0 16 0 1 21 1 @temp0)
                )(else
                    Message(0 16 0 1 20 1 @temp0)
                )
                (Print:
                    addTextF(@temp30 @temp0 value)
                    init()
                )
                (if (state)
                    (Print:
                        addText(0 theVerb 21 2 0 0 16)
                        init()
                    )
                )(else
                    (Print:
                        addText(0 theVerb 20 2 0 0 16)
                        init()
                    )
                )
            )
            (default 
                (super:doVerb(theVerb))
            )
        )
    )

)
(instance theRobe of NumInvItem
    (properties
        view 905
        loop 10
        cel 5
        message 51
        noun 15
        value 30
        mustKeep 1
    )
)
(instance theBridge of NumInvItem
    (properties
        view 905
        loop 10
        cel 6
        message 52
        noun 16
        value 300
    )
)
(instance theEye of NumInvItem
    (properties
        view 905
        loop 10
        cel 7
        message 53
        noun 17
        value 6
        mustKeep 1
    )
)
(instance theNote of NumInvItem
    (properties
        view 905
        message 54
        noun 18
        value 2
    )
)
(instance theWood of NumInvItem
    (properties
        view 905
        loop 8
        cel 8
        message 55
        noun 19
        value 60
        mustKeep 1
    )
)
(instance theMagicSpear of NumInvItem
    (properties
        view 905
        loop 10
        message 56
        noun 20
        value 240
        mustKeep 1
    )
)
(instance theMagicDrum of NumInvItem
    (properties
        view 905
        loop 10
        cel 1
        message 57
        noun 21
        value 180
        mustKeep 1
    )
)
