(version 2)
(include "sci.sh")
(exports
    0 hero
    1 stopGroop
)
(use "Main")
(use "n026")
(use "PolyPath")
(use "StopWalk")
(use "Grooper")
(use "Ego")
(use "Sound")
(use "Cycle")
(use "Obj")
(script 28)



(procedure (localproc_010a param1 param2)
    (if (< param1 param2)
        (if (>= 
        (if (< 
        (if (gGGOwnerMaxStamina_3)
            (- gGOwnerMaxStamina[14] gGGOwnerMaxStamina_3)
        )
 0)
            0
        )(else
            (if (gGGOwnerMaxStamina_3)
                (- gGOwnerMaxStamina[14] gGGOwnerMaxStamina_3)
            )
        )
 param2)
            return 1
        )
    )
    (if (>= param1 param2)
        (if (< 
        (if (< 
        (if (gGGOwnerMaxStamina_3)
            (- gGOwnerMaxStamina[14] gGGOwnerMaxStamina_3)
        )
 0)
            0
        )(else
            (if (gGGOwnerMaxStamina_3)
                (- gGOwnerMaxStamina[14] gGGOwnerMaxStamina_3)
            )
        )
 param2)
            return -1
        )
    )
    return 0
)


(procedure (localproc_09bc param1 param2)
    (self:useSkill(param1 param2))
    return * gGOwnerMaxStamina[param1] param2
)


(class public hero of Ego
    (properties
        x 0
        y 0
        z 0
        heading 0
        noun 2
        modNum 28
        nsTop 0
        nsLeft 0
        nsBottom 0
        nsRight 0
        sightAngle 90
        actions 0
        onMeCheck $6789
        approachX 0
        approachY 0
        approachDist 0
        _approachVerbs 0
        yStep 2
        view -1
        loop 0
        cel 0
        priority 0
        underBits 0
        signal $2000
        lsTop 0
        lsLeft 0
        lsBottom 0
        lsRight 0
        brTop 0
        brLeft 0
        brBottom 0
        brRight 0
        palette 0
        scaleSignal $0000
        scaleX 128
        scaleY 128
        maxScale 128
        cycleSpeed 6
        script 0
        cycler 0
        timer 0
        detailLevel 0
        scaler 0
        illegalBits $8000
        xLast 0
        yLast 0
        xStep 3
        origStep 770
        moveSpeed 6
        blocks 0
        baseSetter 0
        mover 0
        looper 0
        viewer 0
        avoider 0
        code 0
        edgeHit 0
    )

    (method (handleEvent pEvent)
        (var thePEventMessage, pEventType, pEventMessage, temp3, temp4)
        = temp4 0
        = pEventType (send pEvent:type)
        = pEventMessage (send pEvent:message)
        (if (script and (send script:handleEvent(pEvent)))
            1
        )(else
            (if (& pEventType $0040)
                = thePEventMessage pEventMessage
                (if ((== thePEventMessage 0) and (& pEventType $0004))
                    return (send pEvent:claimed)
                )
                (if (((& pEventType $0004) and (== thePEventMessage (send gUser:prevDir))) and IsObject(mover))
                    = thePEventMessage 0
                )
                (send gUser:prevDir(thePEventMessage))
                (self:setDirection(thePEventMessage))
                = temp4 1
            )(else
                (if (& pEventType $4000)
                    (if (& pEventType $1000)
                        (if ((self:mover) and proc999_5(gClientModNum 150 160 170 180))
                            = temp3 (send ((self:mover)):caller)
                        )(else
                            = temp3 0
                        )
                        (switch (global67)
                            (case 0
                                (self:setMotion(MoveTo (send pEvent:x) (+ (send pEvent:y) z) temp3))
                            )
                            (case 1
                                (self:setMotion(PolyPath (send pEvent:x) (+ (send pEvent:y) z) temp3))
                            )
                            (case 2
                                (self:setMotion(PolyPath (send pEvent:x) (+ (send pEvent:y) z) 0 0))
                            )
                        )
                        (send gUser:prevDir(0))
                        = temp4 1
                    )(else
                        = temp4 (super:handleEvent(pEvent))
                    )
                )(else
                    = temp4 (super:handleEvent(pEvent))
                )
            )
        )
        return temp4
    )


    (method (doVerb theVerb)
        (var temp0, theTheVerb, temp2, temp3, temp4, temp5)
        = temp0 2
        = theTheVerb theVerb
        = temp2 0
        = temp3 28
        (switch (theVerb)
            (case 22
                (if (< gGOwnerMaxStamina[16] (self:maxHealth()))
                    (if (proc0_6(115))
                        proc0_5(115)
                        (send gOwner:takeDamage(neg (/ (self:maxHealth()) 3)))
                        proc0_4(115)
                    )(else
                        (send gOwner:takeDamage(neg (/ (self:maxHealth()) 3)))
                    )
                    (if (> (send ((send gInv:at(12))):amount) 1)
                        (send ((send gInv:at(12))):amount((- (send ((send gInv:at(12))):amount) 1)))
                    )(else
                        (send ((send gInv:at(12))):
                            amount(0)
                            owner(0)
                            realOwner(0)
                        )
                        (send gMainIconBar:
                            curInvIcon(0)
                            disable(7)
                            advanceCurIcon()
                        )
                    )
                    = temp2 9
                )(else
                    = theTheVerb 0
                    = temp2 11
                )
            )
            (case 23
                (if (< gGOwnerMaxStamina[18] (send gOwner:maxMana()))
                    (send gOwner:useMana(neg (/ (send gOwner:maxMana()) 3)))
                    (if (> (send ((send gInv:at(13))):amount) 1)
                        (send ((send gInv:at(13))):amount((- (send ((send gInv:at(13))):amount) 1)))
                    )(else
                        (send ((send gInv:at(13))):
                            amount(0)
                            owner(0)
                            realOwner(0)
                        )
                        (send gMainIconBar:
                            curInvIcon(0)
                            disable(7)
                            advanceCurIcon()
                        )
                    )
                    = temp2 9
                )(else
                    = theTheVerb 0
                    = temp2 11
                )
            )
            (case 21
                (if (proc0_6(115))
                    proc0_5(115)
                    (if (> (send ((send gInv:at(11))):amount) 1)
                        (send ((send gInv:at(11))):amount((- (send ((send gInv:at(11))):amount) 1)))
                    )(else
                        (send ((send gInv:at(11))):
                            amount(0)
                            owner(0)
                            realOwner(0)
                        )
                        (send gMainIconBar:
                            curInvIcon(0)
                            disable(7)
                            advanceCurIcon()
                        )
                    )
                    = temp2 9
                )(else
                    = theTheVerb 0
                    = temp2 11
                )
            )
            (case 24
                = theTheVerb 0
                (if (< global136 2)
                    (if (> (send ((send gInv:at(14))):amount) 1)
                        (send ((send gInv:at(14))):amount((- (send ((send gInv:at(14))):amount) 1)))
                    )(else
                        (send ((send gInv:at(14))):
                            amount(0)
                            owner(0)
                            realOwner(0)
                        )
                        (send gMainIconBar:
                            curInvIcon(0)
                            disable(7)
                            advanceCurIcon()
                        )
                    )
                    (if (proc0_6(3))
                        proc0_5(3)
                    )(else
                        (if (proc0_6(2))
                            proc0_5(2)
                        )(else
                            ++global136
                        )
                    )
                    = temp2 10
                )(else
                    = temp2 12
                )
            )
            (case 28
                = theTheVerb 0
                (if (< global136 2)
                    (if (> (send ((send gInv:at(18))):amount) 1)
                        (send ((send gInv:at(18))):amount((- (send ((send gInv:at(18))):amount) 1)))
                    )(else
                        (send ((send gInv:at(18))):
                            amount(0)
                            owner(0)
                            realOwner(0)
                        )
                        (send gMainIconBar:
                            curInvIcon(0)
                            disable(7)
                            advanceCurIcon()
                        )
                    )
                    (if (proc0_6(3))
                        proc0_5(3)
                    )(else
                        (if (proc0_6(2))
                            proc0_5(2)
                        )(else
                            ++global136
                        )
                    )
                    = temp2 10
                )(else
                    = temp2 12
                )
            )
            (case 27
                = theTheVerb 0
                (if (< global136 2)
                    (if (> (send ((send gInv:at(17))):amount) 1)
                        (send ((send gInv:at(17))):amount((- (send ((send gInv:at(17))):amount) 1)))
                    )(else
                        (send ((send gInv:at(17))):
                            amount(0)
                            owner(0)
                            realOwner(0)
                        )
                        (send gMainIconBar:
                            curInvIcon(0)
                            disable(7)
                            advanceCurIcon()
                        )
                    )
                    (if (proc0_6(3))
                        proc0_5(3)
                    )(else
                        (if (proc0_6(2))
                            proc0_5(2)
                        )(else
                            ++global136
                        )
                    )
                    = temp2 10
                )(else
                    = temp2 12
                )
            )
            (case 29
                = theTheVerb 0
                (if (< global136 2)
                    (if (> (send ((send gInv:at(19))):amount) 1)
                        (send ((send gInv:at(19))):amount((- (send ((send gInv:at(19))):amount) 1)))
                    )(else
                        (send ((send gInv:at(19))):
                            amount(0)
                            owner(0)
                            realOwner(0)
                        )
                        (send gMainIconBar:
                            curInvIcon(0)
                            disable(7)
                            advanceCurIcon()
                        )
                    )
                    (if (proc0_6(3))
                        proc0_5(3)
                    )(else
                        (if (proc0_6(2))
                            proc0_5(2)
                        )(else
                            ++global136
                        )
                    )
                    = temp2 10
                )(else
                    = temp2 12
                )
            )
            (case 46
                (if (> (send ((send gInv:at(35))):amount) 1)
                    (send ((send gInv:at(35))):amount((- (send ((send gInv:at(35))):amount) 1)))
                )(else
                    (send ((send gInv:at(35))):
                        amount(0)
                        owner(0)
                        realOwner(0)
                    )
                    (send gMainIconBar:
                        curInvIcon(0)
                        disable(7)
                        advanceCurIcon()
                    )
                )
                = theTheVerb 0
                = temp2 10
                proc0_4(115)
            )
            (case 40
                = theTheVerb 0
                (if (< global136 2)
                    (if (> (send ((send gInv:at(29))):amount) 1)
                        (send ((send gInv:at(29))):amount((- (send ((send gInv:at(29))):amount) 1)))
                    )(else
                        (send ((send gInv:at(29))):
                            amount(0)
                            owner(0)
                            realOwner(0)
                        )
                        (send gMainIconBar:
                            curInvIcon(0)
                            disable(7)
                            advanceCurIcon()
                        )
                    )
                    (if (proc0_6(3))
                        proc0_5(3)
                    )(else
                        (if (proc0_6(2))
                            proc0_5(2)
                        )(else
                            ++global136
                        )
                    )
                    = temp2 10
                )(else
                    = temp2 12
                )
            )
            (case 48
                = gGOwnerMaxStamina[17] (send gOwner:maxStamina())
                (send gOwner:
                    drop(37 1)
                    get(15)
                )
            )
            (case 1
                = temp4 Memory(1 (+ Message(2 28 2 1 0 1) 40))
                = temp5 Message(0 28 2 1 0 1 temp4)
                (send gQg3Messager:sayFormat(temp5 temp4 @global157))
                Memory(3 temp4)
                return 1
            )
            (case 66
                (if (< gGOwnerMaxStamina[16] (send gOwner:maxHealth()))
                    = temp2 23
                    = temp5 proc999_2((- (send gOwner:maxHealth()) gGOwnerMaxStamina[16]) (/ gGOwnerMaxStamina[17] 2))
                    = gGOwnerMaxStamina[16] (+ gGOwnerMaxStamina[16] temp5)
                    = gGOwnerMaxStamina[17] (- gGOwnerMaxStamina[17] temp5)
                )(else
                    = temp2 25
                )
            )
            (default 
                (if (>= theVerb 75)
                    = theTheVerb 0
                    = temp2 22
                )(else
                    (if (>= theVerb 10)
                        = theTheVerb 0
                        = temp2 21
                    )
                )
            )
        )
        return (send gQg3Messager:say(temp0 theTheVerb temp2 0 0 temp3))
    )


    (method (facingMe)
        return 1
    )


    (method (motionCue)
        (if (IsObject(mover) and (send mover:completed))
            (send mover:motionCue())
        )
        (if (IsObject(cycler) and (send cycler:completed))
            (send cycler:motionCue())
        )
    )


    (method (setMotion theMover sendParams)
        (if (theMover and (== (send gOwner:view) 20))
            (send gOwner:normalize())
        )
        (super:setMotion(theMover rest sendParams))
    )


    (method (get param1 param2)
        (var temp0, temp1, temp2, temp3)
        = temp1 
            (if (== paramTotal 1)
                1
            )(else
                param2
            )
        = temp2 (send ((send gInv:at(param1))):amount)
        (if ((> gClientModNum 100) and (== param1 0))
            (if ((== (send ((send gInv:at(param1))):message) 59) and (== temp2 0))
                (send ((send gInv:at(param1))):message(10))
            )
        )(else
            (if (== param1 0)
                = temp1 0
            )
        )
        = temp3 (+ (self:wtCarried()) (* temp1 (send ((send gInv:at(param1))):value)))
        = global465 (- temp3 (self:maxLoad()))
        (if (> global465 0)
            (if (not proc0_6(5))
                (send gQg3Messager:say(1 6 1 1 0 28))
                proc0_4(5)
                (self:setStep(1 1))
            )
        )(else
            (if (proc0_6(5))
                proc0_5(5)
                (self:changeGait(-1 0))
            )
        )
        = temp1 (+ temp1 temp2)
        (if (< temp1 0)
            = temp1 0
        )
        (if ((<> param1 0) and (== temp1 0))
            (send ((send gInv:at(param1))):
                amount(temp1)
                realOwner(
                    (if (proc999_5(gClientModNum 310 430))
                        0
                    )(else
                        global2
                    )
)
            )
            (send gMainIconBar:
                curInvIcon(0)
                disable(7)
                curIcon((send gMainIconBar:at(1)))
            )
        )(else
            (send ((send gInv:at(param1))):
                amount(temp1)
                realOwner(self)
            )
        )
        return - temp1 temp2
    )


    (method (has param1)
        return 
            (if (== param1 0)
                return 1
            )(else
                return (send ((send gInv:at(param1))):amount)
            )
    )


    (method (use param1 param2)
        (var temp0, temp1, temp2)
        = temp1 
            (if (== paramTotal 1)
                1
            )(else
                param2
            )
        (if (> temp1 (send ((send gInv:at(param1))):amount))
            = temp1 (send ((send gInv:at(param1))):amount)
        )
        (self:get(param1 neg temp1))
        (if (< (send ((send gInv:at(param1))):amount) 1)
            (send gMainIconBar:
                curInvIcon(0)
                advanceCurIcon()
            )
        )
        return temp1
    )


    (method (drop param1 param2)
        (self:use(param1 
            (if (== paramTotal 2)
                param2
            )(else
                (send ((send gInv:at(param1))):amount)
            )
))
    )


    (method (learn param1 param2)
        (var temp0, theGGOwnerMaxStamina)
        = theGGOwnerMaxStamina 
            (if (== paramTotal 1)
                5
            )(else
                param2
            )
        (if (gGOwnerMaxStamina[12] and (> theGGOwnerMaxStamina gGOwnerMaxStamina[param1]))
            = gGOwnerMaxStamina[param1] theGGOwnerMaxStamina
        )
        return gGOwnerMaxStamina[param1]
    )


    (method (canPickLocks)
        (if (gGOwnerMaxStamina[9])
            (self:has(7))
        )
    )


    (method (useSkill param1 param2)
        (var temp0)
        (asm
            lap     param1
            lagi    gGOwnerMaxStamina
            not     
            bnt     code_0c76
            ldi     0
            ret     
code_0c76:  lsp     param1
            ldi     3
            eq?     
            bnt     code_0c88
            pushi   1
            pushi   115
            callb   proc0_6, 2
            bnt     code_0c88
            ldi     0
            ret     
code_0c88:  lsp     param1
            ldi     10
            eq?     
            bnt     code_0c96
            pushi   #useStamina
            pushi   1
            pushi   1
            self    6
code_0c96:  lsp     param2
            ldi     0
            ge?     
            bnt     code_0ca1
            ldi     1
            jmp     code_0ca3
code_0ca1:  ldi     65535
code_0ca3:  sat     temp0
            pushi   1
            lsp     param2
            callk   Abs, 2
            push    
            lap     param1
            lagi    gGOwnerMaxStamina
            gt?     
            bnt     code_0cbc
            lap     param1
            lsgi    gGOwnerMaxStamina
            lat     temp0
            mul     
            sap     param2
code_0cbc:  ldi     15
            lsgi    gGOwnerMaxStamina
            pushi   1
            lsp     param2
            callk   Abs, 2
            push    
            ldi     19
            add     
            push    
            ldi     20
            div     
            add     
            push    
            ldi     15
            sagi    gGOwnerMaxStamina
            lap     param1
            lsgi    global291
            lap     param2
            add     
            push    
            lap     param1
            sagi    global291
            lap     param1
            lsgi    global291
            lagi    gGOwnerMaxStamina
            ge?     
            bnt     code_0d1e
            lap     param1
            lsgi    global291
            lagi    gGOwnerMaxStamina
            sub     
            push    
            lap     param1
            sagi    global291
            lap     param1
            lsgi    gGOwnerMaxStamina
            pushi   2
            pushi   2
            pushi   4
            callk   Random, 4
            add     
            push    
            lap     param1
            sagi    gGOwnerMaxStamina
            push    
            ldi     300
            gt?     
            bnt     code_0d59
            pushi   300
            lap     param1
            sagi    gGOwnerMaxStamina
            jmp     code_0d59
code_0d1e:  lap     param1
            lsgi    global291
            ldi     0
            lt?     
            bnt     code_0d56
            lap     param1
            lsgi    global291
            lagi    gGOwnerMaxStamina
            add     
            push    
            lap     param1
            sagi    global291
            lap     param1
            lsgi    gGOwnerMaxStamina
            pushi   2
            pushi   2
            pushi   4
            callk   Random, 4
            sub     
            push    
            lap     param1
            sagi    gGOwnerMaxStamina
            push    
            ldi     5
            lt?     
            bnt     code_0d59
            pushi   5
            lap     param1
            sagi    gGOwnerMaxStamina
            jmp     code_0d59
code_0d56:  ldi     0
            ret     
code_0d59:  ret     
        )
    )


    (method (useMana param1)
        (if (gGOwnerMaxStamina[12])
            (if (< (= gGOwnerMaxStamina[18] (- gGOwnerMaxStamina[18] param1)) 0)
                = gGOwnerMaxStamina[18] 0
            )
            (if (> gGOwnerMaxStamina[18] (self:maxMana()))
                = gGOwnerMaxStamina[18] (self:maxMana())
            )
        )
        return gGOwnerMaxStamina[18]
    )


    (method (useStamina param1)
        (var temp0, temp1)
        (if (< paramTotal 2)
            = temp1 1
        )(else
            = temp1 0
        )
        (if (> param1 0)
            (self:useSkill(3 (>> (+ param1 4) $0002)))
        )
        = temp0 (= gGOwnerMaxStamina[17] (- gGOwnerMaxStamina[17] param1))
        (if (> temp0 4)
            proc0_5(1)
            (if (> temp0 (send gOwner:maxStamina()))
                = gGOwnerMaxStamina[17] (send gOwner:maxStamina())
            )
        )(else
            (if (>= temp0 0)
            )(else
                (if ((self:takeDamage((>> (- 2 gGOwnerMaxStamina[17]) $0002))))
                    = gGOwnerMaxStamina[17] 0
                    (if (not proc0_6(1))
                        proc0_4(1)
                        (if ((<> gClientModNum 550) and temp1)
                            (send gQg3Messager:say(1 6 2 1 0 28))
                        )
                    )
                )(else
                    (if (> gGOwnerMaxStamina[16] 0)
                    )(else
                        (if (temp1)
                            proc26_0(7 28)
                        )
                    )
                )
            )
        )
        return gGOwnerMaxStamina[16]
    )


    (method (addHonor param1)
        (var temp0, temp1, temp2[20])
        = temp0 
            (if (< 
            (if (gGGOwnerMaxStamina_3)
                (- gGOwnerMaxStamina[14] gGGOwnerMaxStamina_3)
            )
 0)
                0
            )(else
                (if (gGGOwnerMaxStamina_3)
                    (- gGOwnerMaxStamina[14] gGGOwnerMaxStamina_3)
                )
            )
        (self:useSkill(14 (* param1 3)))
        = temp1 localproc_010a(temp0 10)
        (if (temp1)
            (if (== (= temp1 localproc_010a(temp0 10)) 1)
                (send ((send gInv:at(1))):state(1))
                (send gOwner:solvePuzzle(202 2))
                (send gQg3Messager:say(1 6 13 0 0 28))
            )(else
                (send ((send gInv:at(1))):state(0))
                (send gQg3Messager:say(1 6 14 0 0 28))
            )
        )(else
            = temp1 localproc_010a(temp0 25)
            (if (temp1)
                (if (== (= temp1 localproc_010a(temp0 25)) 1)
                    (if (not gGOwnerMaxStamina[12])
                        = gGOwnerMaxStamina[12] 5
                    )
                    = gGOwnerMaxStamina[33] 10
                    (send gOwner:solvePuzzle(203 2))
                    (send gQg3Messager:say(1 66 19 0 0 28))
                )(else
                    = gGOwnerMaxStamina[33] 0
                    (send gQg3Messager:say(1 66 20 0 0 28))
                )
            )(else
                = temp1 localproc_010a(temp0 50)
                (if (temp1)
                    (if (== (= temp1 localproc_010a(temp0 50)) 1)
                        proc0_4(150)
                        (send gOwner:solvePuzzle(204 2))
                        (send gQg3Messager:say(1 6 17 0 0 28))
                    )(else
                        proc0_5(150)
                        (send gQg3Messager:say(1 6 15 0 0 28))
                    )
                )(else
                    = temp1 localproc_010a(temp0 80)
                    (if (temp1)
                        (if (== (= temp1 localproc_010a(temp0 80)) 1)
                            proc0_4(151)
                            (send gOwner:solvePuzzle(205 2))
                            (send gQg3Messager:say(1 6 18 0 0 28))
                        )(else
                            proc0_5(151)
                            (send gQg3Messager:say(1 6 16 0 0 28))
                        )
                    )
                )
            )
        )
    )


    (method (trySkill param1 param2 param3)
        (var theGGOwnerMaxStamina, temp1, temp2, temp3)
        (if ((> (send gOwner:view) 17) and (< (send gOwner:view) 21))
            (if ((< (send gOwner:view) 21) and proc999_5(param1 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33))
                return 1
            )
        )
        = temp3 1
        = theGGOwnerMaxStamina gGOwnerMaxStamina[param1]
        (if (theGGOwnerMaxStamina)
            (if (== paramTotal 3)
                = theGGOwnerMaxStamina (+ theGGOwnerMaxStamina param3)
            )
            (if (param2)
                (if (((< param1 13) and (<> param1 1)) and (<> param1 4))
                    (self:useStamina((/ (+ param2 39) 40)))
                )
            )(else
                (if ((>= param1 5) and (< param1 13))
                    (self:useStamina(Random(2 8)))
                )
                = param2 proc0_8()
            )
            (if (>= localproc_09bc(4 1) Random(1 500))
                = theGGOwnerMaxStamina (+ theGGOwnerMaxStamina Random(1 20))
            )
            (if (<= param2 theGGOwnerMaxStamina)
                = temp3 1
            )(else
                = temp3 -1
            )
            = temp1 2
            (if (temp1)
                (if (== param1 5)
                    (self:useSkill(0 3))
                    (self:useSkill(2 2))
                )(else
                    (if (((== param1 6) or (== param1 7)) or (== param1 8))
                        (self:useSkill(2 4))
                        (self:useSkill(1 2))
                    )(else
                        (if (== param1 9)
                            (self:useSkill(2 8))
                            (self:useSkill(1 5))
                        )(else
                            (if ((== param1 10) or (== param1 11))
                                (self:useSkill(0 5))
                                (self:useSkill(2 4))
                            )(else
                                (if (== param1 13)
                                    (self:useSkill(1 6))
                                )(else
                                    (if (>= param1 19)
                                        (self:useSkill(12 8))
                                        (self:useSkill(1 4))
                                    )
                                )
                            )
                        )
                    )
                )
                = temp2 100
                (if ((< param1 13) or (== param1 5))
                    = temp2 25
                )
                (self:useSkill(param1 Abs((/ temp2 temp1))))
            )
        )(else
            = temp3 0
        )
        return temp3
    )


    (method (solvePuzzle param1 param2 param3)
        (var temp0, temp1)
        = temp0 0
        (if (>= paramTotal 3)
            (if ((& param3 $0001) and (== global125 0))
                = temp1 0
            )(else
                (if ((& param3 $0002) and (== global125 1))
                    = temp1 1
                )(else
                    (if ((& param3 $0004) and (== global125 2))
                        = temp1 2
                    )(else
                        (if ((& param3 $0008) and (== global125 3))
                            = temp1 3
                        )(else
                            = temp1 -1
                        )
                    )
                )
            )
            (if ((>= paramTotal 3) and (<> global125 temp1))
                return 0
            )
            (if ((((== temp1 3) and (<> global125 3)) and not proc0_6(19)) and not proc0_6(param1))
                = global361 (+ global361 param2)
            )
            (if ((== global125 3) and (== temp1 global362))
                = param3 3
            )
        )
        (if (not proc0_6(param1))
            proc0_4(param1)
            (self:useSkill(1 (* param2 3)))
            = global15 (+ global15 param2)
            (if (> global15 500)
                = global15 500
            )
            (puzzleSound:play())
            = temp0 1
        )
        return temp0
    )


    (method (takeDamage param1)
        (self:useSkill(3 Abs(param1)))
        (if (< (= gGOwnerMaxStamina[16] (- gGOwnerMaxStamina[16] 
            (if (proc0_6(115))
                Abs(param1)
            )(else
                param1
            )
)) 0)
            = gGOwnerMaxStamina[16] 0
        )
        (if (> gGOwnerMaxStamina[16] (self:maxHealth()))
            = gGOwnerMaxStamina[16] (self:maxHealth())
        )
        return > gGOwnerMaxStamina[16] 0
    )


    (method (castSpell param1 param2)
        (var temp0)
        (if (< paramTotal 2)
            (if ((> (send gOwner:view) 17) and (< (send gOwner:view) 21))
                (if ((< (send gOwner:view) 21) and (<> gClientModNum 550))
                    return 1
                )
            )
        )(else
            (if (param2 and (<> gClientModNum 550))
                return 1
            )
        )
        return 
            (if (< gGOwnerMaxStamina[18] global367[(- param1 19)])
                (send gQg3Messager:say(1 6 3 1 0 28))
                return 0
            )(else
                return (self:
                        useMana(global367[- param1 19])
                        trySkill(param1 0)
                    )
            )
    )


    (method (maxMana)
        (var theGGOwnerMaxStamina)
        = theGGOwnerMaxStamina gGOwnerMaxStamina[12]
        return 
            (if (theGGOwnerMaxStamina)
                / (+ (+ gGOwnerMaxStamina[1] theGGOwnerMaxStamina) theGGOwnerMaxStamina) 3
            )(else
                0
            )
    )


    (method (maxStamina)
        return / (+ gGOwnerMaxStamina[2] gGOwnerMaxStamina[3]) 2
    )


    (method (maxHealth)
        return / (+ (+ gGOwnerMaxStamina[0] gGOwnerMaxStamina[3]) gGOwnerMaxStamina[3]) 3
    )


    (method (maxLoad)
        return + 2400 (* gGOwnerMaxStamina[0] 30)
    )


    (method (eatMeal)
        (var temp0)
        = temp0 0
        (if (global136)
            --global136
            = temp0 1
        )(else
            (if ((send ((send gInv:at(14))):amount))
                (send ((send gInv:at(14))):amount((- (send ((send gInv:at(14))):amount) 1)))
                (if (not (send ((send gInv:at(14))):amount))
                    (send ((send gInv:at(14))):
                        owner(0)
                        realOwner(0)
                    )
                )
                = temp0 1
            )(else
                (if ((send ((send gInv:at(18))):amount))
                    = temp0 1
                    (send ((send gInv:at(18))):amount((- (send ((send gInv:at(18))):amount) 1)))
                    (if (not (send ((send gInv:at(18))):amount))
                        (send ((send gInv:at(18))):
                            owner(0)
                            realOwner(0)
                        )
                    )
                )(else
                    (if ((send ((send gInv:at(17))):amount))
                        = temp0 1
                        (send ((send gInv:at(17))):amount((- (send ((send gInv:at(17))):amount) 1)))
                        (if (not (send ((send gInv:at(17))):amount))
                            (send ((send gInv:at(17))):
                                owner(0)
                                realOwner(0)
                            )
                        )
                    )(else
                        (if ((send ((send gInv:at(19))):amount))
                            = temp0 1
                            (send ((send gInv:at(19))):amount((- (send ((send gInv:at(19))):amount) 1)))
                            (if (not (send ((send gInv:at(19))):amount))
                                (send ((send gInv:at(19))):
                                    owner(0)
                                    realOwner(0)
                                )
                            )
                        )(else
                            (if (proc0_6(3))
                                (if ((self:useStamina(8 0)))
                                    (send gQg3Messager:say(1 6 5 1 0 28))
                                )(else
                                    proc26_0(8 28)
                                )
                            )(else
                                (if (proc0_6(2))
                                    proc0_4(3)
                                    (send gQg3Messager:say(1 6 6 1 0 28))
                                )(else
                                    proc0_4(2)
                                    (send gQg3Messager:say(1 6 4 1 0 28))
                                )
                            )
                        )
                    )
                )
            )
        )
        (if (temp0)
            (if (proc0_6(3))
                proc0_5(3)
            )(else
                (if (proc0_6(2))
                    proc0_5(2)
                )
            )
        )
    )


    (method (wtCarried)
        (var temp0, temp1)
        = temp1 1
        = temp0 0
        (while (< temp1 47)
            = temp0 (+ temp0 (* (send ((send gInv:at(temp1))):amount) (send ((send gInv:at(temp1))):value)))
            ++temp1
        )
        = temp0 (+ temp0 (* global410 2))
        = temp0 (+ temp0 (* global424 2))
    )


    (method (changeGait param1 param2)
        (var temp0, theMover)
        = theMover 0
        (if (param2 and (== global100 param1))
            return 
        )
        (if (mover)
            = theMover mover
            = mover 0
        )
        (if (<> param1 -1)
            = global100 param1
        )
        (if ((< view 4) or (== view 5))
            (switch (global100)
                (case 1
                    (self:
                        view(1)
                        origStep(2053)
                        setStep()
                        setCycle(StopWalk 5)
                    )
                )
                (case 2
                    (self:
                        view(2)
                        origStep(1026)
                        setStep()
                        setCycle(StopWalk 2)
                    )
                )
                (default 
                    (self:
                        view(0)
                        origStep(1027)
                        setStep()
                        setCycle(StopWalk 5)
                    )
                )
            )
        )
        (if (proc0_6(5))
            (self:setStep(1 1 0))
        )(else
            (if (not proc999_5(gClientModNum 150 160 170 180) and ((== xStep 1) or (== yStep 1)))
                (if (== view 1)
                    (self:setStep(8 4 0))
                )(else
                    (self:setStep(4 2 0))
                )
            )
        )
        (if (theMover)
            (self:mover(theMover))
            (send ((self:mover)):init())
        )
    )


    (method (normalize param1)
        (if (paramTotal)
            (self:loop(param1))
        )
        (self:
            view(0)
            z(0)
            setPri(-1)
            setLoop(-1)
            setLoop(stopGroop)
            setCycle(StopWalk 5)
            setMotion(0)
            changeGait(-1 0)
            illegalBits(-32768)
            ignoreHorizon()
            setSpeed(gNewSpeed)
        )
    )

)
(instance public stopGroop of Grooper
    (properties)

    (method (doit param1)
        (if (IsObject((send gOwner:cycler)) and (send ((send gOwner:cycler)):isKindOf(StopWalk)))
            (send gOwner:view((send ((send gOwner:cycler)):vWalking)))
        )
        (super:doit(rest param1))
    )


    (method (cue param1)
        (var theCaller)
        (if (not IsObject((send client:mover)))
            (send client:mover(oldMover))
        )(else
            (if (IsObject(oldMover))
                (send oldMover:dispose())
            )
        )
        (if (IsObject(oldCycler))
            (if (IsObject((send client:cycler)))
                (send oldCycler:dispose())
            )(else
                (send client:cycler(oldCycler))
            )
        )
        = theCaller caller
        = caller (= oldMover (= oldCycler 0))
        (if (IsObject(theCaller))
            (send theCaller:cue(rest param1))
        )
    )

)
(instance puzzleSound of Sound
    (properties
        number 950
    )
)
