(version 2)
(include "sci.sh")
(exports
    0 combatRm
    1 WarriorObj
    2 combatSpell
    3 monsterHPStat
)
(use "Main")
(use "GloryControls")
(use "Print")
(use "IconI")
(use "n958")
(use "Timer")
(use "SysWindow")
(use "Sound")
(use "Cycle")
(use "Game")
(use "User")
(use "View")
(use "Obj")
(script 550)


(local
    local0
    theGLastTicks

)
(procedure (localproc_0344)
    (var temp0, temp1, temp2)
    = temp0 FirstNode((send gGQg3KDHandler:elements))
    (while (temp0)
        = temp1 NextNode(temp0)
        = temp2 NodeValue(temp0)
        (if (not IsObject(temp2))
            return 
        )
        (if ((send temp2:respondsTo(#setCycle)))
            (send temp2:setCycle(0))
            (if ((send temp2:respondsTo(#setMotion)))
                (send temp2:setMotion(0))
            )
        )
        = temp0 temp1
    )
)


(procedure (localproc_03a1)
    proc0_2()
    (if (<= gGOwnerMaxStamina[16] 0)
        = global155 0
    )
    localproc_0344()
    (if ((spellTimer:seconds))
        (spellTimer:dispose())
    )
    (if ((stamTimer:seconds))
        (stamTimer:dispose())
    )
    (if ((duckTimer:seconds))
        (duckTimer:dispose())
    )
    SetCursor(-2)
    (combatControls:state((& (combatControls:state) $ffdf)))
    (send gMainIconBar:enable())
    (if (== gGClientModNum 549)
        (send global2:newRoom(840))
    )(else
        (if (local0)
            proc0_4(6)
        )
        (send global2:newRoom(gGClientModNum))
    )
)


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

    (method (highlight param1)
        (if (not (& signal $0020) or (& signal $0004))
            return 
        )
        (if (param1)
            DrawCel(view loop 2 nsLeft nsTop)
        )(else
            DrawCel(view loop 0 nsLeft nsTop)
        )
    )


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


    (method (cue)
        (if ((((== (send gWarriorObj:view) 26) or (== (send gWarriorObj:view) 27)) or (== (send gWarriorObj:view) 555)) and not ducking)
            = ducking 1
            (duckTimer:setTicks(60 self))
        )(else
            (if (((send gWarriorObj:cel) and (== (send gWarriorObj:cel) (send gWarriorObj:lastCel()))) and not ducking)
                (egoNoise:
                    number(938)
                    play()
                )
                (send gMonster:getHurt())
                (splotch:
                    show()
                    setCycle(End self)
                )
            )
            = ducking 0
            (send gWarriorObj:normalize())
        )
    )


    (method (warriorCast param1 param2)
        (var temp0)
        (if (< gGOwnerMaxStamina[18] global367[(- param1 19)])
            return 
        )(else
            (if ((send gOwner:castSpell(param1)))
                = temp0 param2
                (egoMPStat:update())
                (send gWarriorObj:
                    cel(0)
                    setCycle(End temp0)
                )
            )
        )
    )


    (method (tryAttack theTheCombatIcon param2)
        (var theCombatIcon, temp1, temp2, temp3)
        (send gOwner:trySkill(5 200))
        (egoSPStat:update())
        (egoHPStat:update())
        = theCombatIcon 0
        (if (paramTotal)
            = theCombatIcon theTheCombatIcon
        )
        = temp1 (+ (- (self:attackLevel(param2)) (send gMonster:defenseLevel(0))) 50)
        (if (> temp1 80)
            = temp1 80
        )(else
            (if (< temp1 20)
                = temp1 20
            )
        )
        = temp2 (- temp1 Random(1 100))
        (send gWarriorObj:cel(0))
        (if ((== calledBy 2) or (== calledBy 0))
            = theCombatIcon CombatIcon
        )
        (if (> temp2 (= calledBy 0))
            (send gWarriorObj:setCycle(End theCombatIcon))
        )(else
            = temp3 (- (send gWarriorObj:lastCel()) 1)
            (if (< temp3 1)
                = temp3 1
            )
            (send gWarriorObj:setCycle(CT temp3 1 theCombatIcon))
        )
    )


    (method (attackLevel)
        (var temp0)
        = temp0 (/ (+ (+ (+ (+ (* gGOwnerMaxStamina[5] 8) (* gGOwnerMaxStamina[2] 4)) (* gGOwnerMaxStamina[0] 2)) gGOwnerMaxStamina[1]) gGOwnerMaxStamina[4]) 16)
        (if (< gGOwnerMaxStamina[17] 100)
            = temp0 (- temp0 (/ (- 100 gGOwnerMaxStamina[17]) 5))
        )
        return temp0
    )


    (method (defend theTheCombatIcon)
        (var theCombatIcon)
        = theCombatIcon 0
        (if (paramTotal)
            = theCombatIcon theTheCombatIcon
            (if ((== theCombatIcon iconC) or (== global420 24))
                (send gOwner:trySkill(7 200))
            )(else
                (send gOwner:trySkill(6 200))
            )
        )
        (egoSPStat:update())
        (egoHPStat:update())
        (if (((== calledBy 2) or (== calledBy 0)) or autoDodging)
            = autoDodging 0
            = theCombatIcon CombatIcon
        )
        = calledBy 0
        (send gWarriorObj:
            cel(0)
            setCycle(CT 3 1 theCombatIcon)
        )
    )

)
(class public WarriorObj of Prop
    (properties
        x 100
        y 149
        z 0
        heading 0
        noun 0
        modNum -1
        nsTop 0
        nsLeft 0
        nsBottom 0
        nsRight 0
        sightAngle 26505
        actions 0
        onMeCheck $6789
        approachX 0
        approachY 0
        approachDist 0
        _approachVerbs 0
        yStep 2
        view -1
        loop 0
        cel 0
        priority 12
        underBits 0
        signal $4010
        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 0
        script 0
        cycler 0
        timer 0
        detailLevel 0
        scaler 0
        status 0
        weapValue 0
    )

    (method (cue)
        (switch (status)
            (case 0
                (if ((send gGQg3KDHandler:contains(flames)))
                    (flames:hide())
                )
                = status 1
                (self:
                    view(global421)
                    loop(1)
                    cel(0)
                    setCycle(CT 1 1 self)
                )
                (egoNoise:
                    number(901)
                    play()
                )
            )
            (case 1
                = status 0
                (self:normalize())
            )
        )
    )


    (method (getHurt param1)
        (var temp0)
        (send gWarriorObj:
            status(0)
            cue()
        )
        = temp0 (/ (+ gGOwnerMaxStamina[6] gGOwnerMaxStamina[7]) 6)
        = temp0 (- param1 (/ (* param1 temp0) 100))
        (if ((send gOwner:has(5)))
            = temp0 (- temp0 (- 6 global209))
        )
        = temp0 (+ temp0 Random(0 10))
        (if (> temp0 0)
            = gGOwnerMaxStamina[16] (- gGOwnerMaxStamina[16] temp0)
            (if (< gGOwnerMaxStamina[16] 1)
                = gGOwnerMaxStamina[16] 0
            )
            (egoHPStat:update())
        )
    )


    (method (normalize)
        (send gWarriorObj:
            view(global420)
            loop(0)
            cel(0)
            stopUpd()
        )
        (if ((send gGQg3KDHandler:contains(flames)))
            (flames:
                show()
                setCycle(Fwd)
            )
        )
    )


    (method (autoDodge)
        (var temp0)
        (if (== global209 3)
            return 
        )
        (if (== global209 1)
            = temp0 5
        )(else
            = temp0 10
        )
        (if (< Random(0 100) (/ gGOwnerMaxStamina[7] temp0))
            (iconC:
                autoDodging(
                    (if (== gCalledBy 0)
                        0
                    )(else
                        2
                    )
)
                select()
            )
            return 
        )
        (if (< Random(0 100) (/ gGOwnerMaxStamina[6] temp0))
            (iconD:
                autoDodging(
                    (if (== gCalledBy 0)
                        0
                    )(else
                        2
                    )
)
                select()
            )
        )
    )

)
(class MonsterProp of Prop
    (properties
        x 0
        y 0
        z 0
        heading 0
        noun 0
        modNum -1
        nsTop 0
        nsLeft 0
        nsBottom 0
        nsRight 0
        sightAngle 26505
        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 $4010
        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
    )

    (method (init param1)
        = cycleSpeed (/ 24 global209)
        (super:init(rest param1))
    )


    (method (cue)
        (self:
            setCel(0)
            stopUpd()
        )
    )

)
(class Monster of MonsterProp
    (properties
        x 0
        y 0
        z 0
        heading 0
        noun 0
        modNum -1
        nsTop 0
        nsLeft 0
        nsBottom 0
        nsRight 0
        sightAngle 26505
        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 $4010
        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
        roar 0
        primDamage 0
        secDamage 0
        tertDamage 0
        armorValue 0
        monHP 0
        spellHitX 0
        spellHitY 0
        zapped 0
        picture 0
        mustFight 0
    )

    (method (init param1)
        = gMonster self
        (super:init(rest param1))
    )


    (method (getHurt param1 param2 param3)
        (var temp0)
        (if (< paramTotal 3)
            = temp0 (- (+ (send gWarriorObj:weapValue) (/ gGOwnerMaxStamina[0] 10)) (send gMonster:armorValue))
            (if (< temp0 0)
                = temp0 (/ (send gWarriorObj:weapValue) 5)
            )
            = temp0 (+ temp0 Random(1 10))
            (if (> paramTotal 1)
                (if ((< 0 param2) and (< param2 4))
                    = temp0 (/ temp0 param2)
                )(else
                    = temp0 (+ temp0 param2)
                )
            )
            = temp0 (+ temp0 global142)
            = global142 0
        )(else
            = temp0 param3
        )
        (if ((spellTimer:seconds))
            (spellTimer:
                seconds(0)
                client(0)
            )
            (send gMonster:restart())
        )
        = gGMonsterMonHP (- gGMonsterMonHP temp0)
        (if (< gGMonsterMonHP 0)
            = gGMonsterMonHP 0
        )
        (monsterHPStat:update())
    )


    (method (whimper)
        (if (roar)
            (send gLongSong2:
                number(roar)
                play()
            )
        )
    )


    (method (defenseLevel)
        return 280
    )


    (method (spellHurt param1)
        (var temp0)
        = temp0 0
        (switch (param1)
            (case 25
                = temp0 (+ 10 (/ gGOwnerMaxStamina[25] 30))
                (send gMonster:getHurt(0 0 temp0))
            )
            (case 27
                = temp0 (+ 8 (/ gGOwnerMaxStamina[27] 30))
                (send gMonster:getHurt(0 0 temp0))
            )
            (case 32
                = temp0 (+ 12 (/ gGOwnerMaxStamina[32] 30))
                (send gMonster:getHurt(0 0 temp0))
            )
            (case 22
                Palette(palSET_INTENSITY 0 255 500)
                Palette(palSET_INTENSITY 0 255 100)
                (self:
                    setCycle(0)
                    setScript(0)
                )
                (spellTimer:setReal(combatRm (/ gGOwnerMaxStamina[22] 10)))
            )
        )
    )


    (method (restart)
    )

)
(class StatusBar of Actor
    (properties
        x 0
        y 0
        z 0
        heading 0
        noun 0
        modNum -1
        nsTop 0
        nsLeft 0
        nsBottom 0
        nsRight 0
        sightAngle 26505
        actions 0
        onMeCheck $6789
        approachX 0
        approachY 0
        approachDist 0
        _approachVerbs 0
        yStep 2
        view 553
        loop 1
        cel 0
        priority 1
        underBits 0
        signal $4810
        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 1
        origStep 770
        moveSpeed 6
        blocks 0
        baseSetter 0
        mover 0
        looper 0
        viewer 0
        avoider 0
        code 0
        statMax 0
        xMax 0
    )

    (method (init param1)
        = xMax (self:x)
        (self:x((self:calcVal())))
        (super:init(rest param1))
    )


    (method (calcVal param1)
        (var temp0)
        = temp0 (/ (* param1 100) statMax)
        = temp0 (- 47 (/ (* temp0 47) 100))
        (if ((> param1 1) and (>= temp0 47))
            = temp0 46
        )
        return - xMax temp0
    )


    (method (update param1)
        (var temp0)
        (self:setMotion(MoveTo (self:calcVal(param1)) (self:y) self))
    )

)
(instance public combatRm of Rm
    (properties)

    (method (init param1)
        (if (== gGClientModNum 100)
            = gGClientModNum 400
        )
        = local0 proc0_6(6)
        proc0_5(6)
        (send gLongSong2:setLoop(1))
        (send gLongSong3:setLoop(1))
        = global155 2
        = gWarriorObj WarriorObj
        (send gWarriorObj:
            view(999)
            init()
        )
        (if (not proc999_5(gGClientModNum 400 650 700 800 810 820 830 549 851 852 853))
            (send (ScriptID((Print:
                    addText(4 0 1 1 0 12)
                    addButton(560 4 0 0 2 0 26)
                    addButton(565 4 0 0 3 140 26)
                    addButton(575 4 0 0 5 0 40)
                    addButton(580 4 0 0 6 140 40)
                    addButton(585 4 0 0 7 0 54)
                    addButton(590 4 0 0 8 140 54)
                    addButton(595 4 0 0 9 0 68)
                    addButton(845 4 0 0 10 140 68)
                    addButton(855 4 0 0 11 0 82)
                    addButton(860 4 0 0 12 140 82)
                    init()
                )
)):init())
        )(else
            (send (ScriptID(global365)):init())
        )
        Load(rsVIEW 553)
        (if ((send gOwner:has(1)) and (send ((send gInv:at(1))):state))
            (send gWarriorObj:weapValue(35))
            = gCalledBy 0
            = global420 25
            = global421 555
            proc958_0(128 25 554 555)
            (flames:
                init()
                setCycle(Fwd)
            )
        )(else
            (if ((send gOwner:has(1)))
                (send gWarriorObj:weapValue(20))
                = gCalledBy 0
                = global420 23
                = global421 26
                proc958_0(128 23 26)
            )(else
                (send gWarriorObj:weapValue(10))
                = gCalledBy 2
                = global420 24
                = global421 27
                proc958_0(128 24 27 28 22 552)
                proc958_0(130 21)
                (combatSpell:
                    init()
                    hide()
                )
            )
        )
        (send gWarriorObj:view(global420))
        (send gMainIconBar:disable())
        (splotch:
            init()
            hide()
        )
        proc0_3()
        (super:init(rest param1))
        (if (not gGMonsterMonHP)
            = gGMonsterMonHP (send gMonster:monHP)
        )
        (egoStatus:init())
        (monStatus:init())
        (egoHPStat:
            statMax(
                (if ((send gOwner:maxHealth()))
                    (send gOwner:maxHealth())
                )(else
                    100
                )
)
            init()
        )
        (egoSPStat:
            statMax(
                (if ((send gOwner:maxStamina()))
                    (send gOwner:maxStamina())
                )(else
                    100
                )
)
            init()
        )
        (egoMPStat:
            statMax(
                (if ((send gOwner:maxMana()))
                    (send gOwner:maxMana())
                )(else
                    100
                )
)
            init()
        )
        (monsterHPStat:
            statMax((send gMonster:monHP))
            init()
        )
        (stamTimer:setReal(stamTimer 5))
        (combatControls:
            init()
            show()
            dispose()
        )
    )


    (method (dispose param1)
        proc958_0(0 565 575 580 585 845 590 560 595 855 860)
        UnLoad(128 24)
        UnLoad(128 27)
        UnLoad(128 28)
        UnLoad(128 22)
        UnLoad(128 552)
        UnLoad(128 23)
        UnLoad(128 26)
        UnLoad(128 25)
        UnLoad(128 554)
        UnLoad(128 555)
        UnLoad(128 553)
        (super:dispose(rest param1))
    )


    (method (cue)
        (send gMonster:restart())
    )

)
(instance combatControls of GloryControls
    (properties)

    (method (init param1)
        (super:init(rest param1))
        = icon1 iconA
        = icon2 iconB
        = icon3 iconC
        = icon4 iconD
        = icon5 iconE
        = icon6 iconF
        = icon7 iconMiddle
        (self:
            add(iconA iconB iconC iconD iconE iconF iconMiddle)
            eachElementDo(4 0)
            eachElementDo(33 999)
            eachElementDo(14 129)
        )
        (if (== gCalledBy 2)
            (if (== global125 1)
                = gCalledBy 1
                (if ((send gMonster:mustFight))
                    (combatControls:disable(iconF))
                )
                (if (not gGOwnerMaxStamina[23])
                    (combatControls:disable(iconE))
                )
                (if (not gGOwnerMaxStamina[32])
                    (combatControls:disable(iconA))
                )
                (if (not gGOwnerMaxStamina[24])
                    (combatControls:disable(iconB))
                )
                (if (not gGOwnerMaxStamina[25])
                    (combatControls:disable(iconC))
                )
                (if (not gGOwnerMaxStamina[27])
                    (combatControls:disable(iconD))
                )
                (combatControls:
                    eachElementDo(2 552)
                    eachElementDo(4 0)
                )
            )(else
                (self:eachElementDo(2 551))
                (if (not gGOwnerMaxStamina[12])
                    (iconMiddle:view(550))
                    (if ((send gMonster:mustFight))
                        (self:disable(iconMiddle))
                    )
                )
            )
        )(else
            (if ((send gMonster:mustFight))
                (self:disable(iconMiddle))
            )
        )
        SetCursor(137 242 196 318)
        (send gGame:setCursor(gCursorNumber 1 290 170))
    )


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


    (method (dispatchEvent param1 param2)
        (var temp0[3])
        = gLastTicks GetTime()
        (if ((<> gLastTicks theGLastTicks) and (> gGGOwnerMaxStamina 0))
            --gGGOwnerMaxStamina
            = theGLastTicks gLastTicks
        )
        (super:dispatchEvent(param1 rest param2))
        (send gSounds:eachElementDo(174))
        (send gTimers:eachElementDo(57))
        Animate((send gGQg3KDHandler:elements) 1)
        (if (global37)
            = global37 0
            (send gGQg3KDHandler:eachElementDo(246))
        )
    )

)
(instance combatWin of Window
    (properties
        top 125
        left 239
        bottom 189
        right 320
        type $0083
    )

    (method (open param1)
        (super:open(rest param1))
        DrawCel(550 0 0 0 0 -1)
    )

)
(instance iconA of CombatIcon
    (properties
        view 550
        loop 1
        nsLeft 2
        nsTop 2
        maskView 552
        maskLoop 8
        maskCel 3
    )

    (method (select)
        = calledBy gCalledBy
        (if ((send gGQg3KDHandler:contains(flames)))
            (flames:hide())
        )
        (send gWarriorObj:view(global420))
        (switch (calledBy)
            (case 0
                (send gWarriorObj:loop(1))
                (self:tryAttack(self))
            )
            (case 2
                (send gWarriorObj:loop(1))
                (self:tryAttack(self))
            )
            (case 1
                (send gWarriorObj:
                    view(28)
                    loop(0)
                )
                (self:warriorCast(32 self))
            )
        )
        return 1
    )


    (method (cue)
        (switch (gCalledBy)
            (case 1
                (egoNoise:
                    number(11)
                    play()
                )
                (combatSpell:
                    x(123)
                    y(87)
                    setLoop(2)
                    show()
                    setCycle(Fwd)
                    approachDist(32)
                    setStep(6 6)
                    setMotion(MoveTo (send gMonster:spellHitX) (send gMonster:spellHitY) combatSpell)
                )
            )
            (default 
                (super:cue())
            )
        )
        (send gWarriorObj:normalize())
    )

)
(instance iconB of CombatIcon
    (properties
        view 550
        loop 2
        nsLeft 50
        nsTop 2
        signal $4000
        maskView 552
        maskLoop 8
        maskCel 4
    )

    (method (select)
        = calledBy gCalledBy
        (send gWarriorObj:view(global420))
        (if ((send gGQg3KDHandler:contains(flames)))
            (flames:hide())
            (send gWarriorObj:view(554))
        )
        (switch (calledBy)
            (case 0
                (send gWarriorObj:loop(2))
                (self:tryAttack(self))
            )
            (case 2
                (send gWarriorObj:loop(2))
                (self:tryAttack(self))
            )
            (case 1
                (send gWarriorObj:
                    view(28)
                    loop(0)
                )
                (self:warriorCast(22 self))
            )
        )
        return 1
    )


    (method (cue)
        (switch (gCalledBy)
            (case 1
                (egoNoise:
                    number(942)
                    play()
                )
                (combatSpell:
                    x(123)
                    y(87)
                    show()
                    setLoop(3)
                    approachDist(22)
                    setStep(6 6)
                    setCycle(End combatSpell)
                )
            )
            (default 
                (super:cue())
            )
        )
        (send gWarriorObj:normalize())
    )

)
(instance iconC of CombatIcon
    (properties
        view 550
        loop 3
        nsLeft 2
        nsTop 34
        maskView 552
        maskLoop 8
        maskCel 5
    )

    (method (select)
        (var theAutoDodging)
        = calledBy gCalledBy
        (if (autoDodging)
            = theAutoDodging autoDodging
        )(else
            = theAutoDodging calledBy
        )
        (if ((send gGQg3KDHandler:contains(flames)))
            (flames:hide())
        )
        (send gWarriorObj:view(global421))
        (switch (theAutoDodging)
            (case 0
                (send gWarriorObj:loop(1))
                (self:defend(self))
            )
            (case 2
                (send gWarriorObj:loop(0))
                (self:defend(self))
            )
            (case 1
                (send gWarriorObj:
                    view(28)
                    loop(0)
                )
                (self:warriorCast(25 self))
            )
        )
        return 1
    )


    (method (cue)
        (if (== gCalledBy 1)
            (egoNoise:
                number(13)
                play()
            )
            (combatSpell:
                x(123)
                y(87)
                setLoop(0)
                show()
                setCycle(Fwd)
                approachDist(25)
                setStep(6 6)
                setMotion(MoveTo (send gMonster:spellHitX) (send gMonster:spellHitY) combatSpell)
            )
            (send gWarriorObj:normalize())
        )(else
            (super:cue())
        )
    )

)
(instance iconD of CombatIcon
    (properties
        view 550
        loop 4
        nsLeft 52
        nsTop 34
        maskView 552
        maskLoop 8
        maskCel 6
    )

    (method (select)
        (var theAutoDodging)
        = calledBy gCalledBy
        (if (autoDodging)
            = theAutoDodging autoDodging
        )(else
            = theAutoDodging calledBy
        )
        (if ((send gGQg3KDHandler:contains(flames)))
            (flames:hide())
        )
        (send gWarriorObj:view(global421))
        (switch (theAutoDodging)
            (case 0
                (send gWarriorObj:loop(0))
                (self:defend(self))
            )
            (case 2
                (send gWarriorObj:loop(1))
                (self:defend(self))
            )
            (case 1
                (send gWarriorObj:
                    view(28)
                    loop(0)
                )
                (self:warriorCast(27 self))
            )
        )
        return 1
    )


    (method (cue)
        (if (== gCalledBy 1)
            (egoNoise:
                number(943)
                play()
            )
            (combatSpell:
                x(123)
                y(87)
                setLoop(1)
                show()
                setCycle(Fwd)
                approachDist(27)
                setStep(6 6)
                setMotion(MoveTo (send gMonster:spellHitX) (send gMonster:spellHitY) combatSpell)
            )
            (send gWarriorObj:normalize())
        )(else
            (super:cue())
        )
    )

)
(instance iconE of CombatIcon
    (properties
        view 550
        loop 5
        nsLeft 3
        nsTop 12
        maskView 552
        maskLoop 8
        maskCel 1
    )

    (method (select)
        = calledBy gCalledBy
        (send gWarriorObj:view(global421))
        (switch (calledBy)
            (case 0
                0
            )
            (case 2
                0
            )
            (case 1
                (if ((send gGQg3KDHandler:contains(flames)))
                    (flames:hide())
                )
                (send gWarriorObj:
                    view(28)
                    loop(0)
                )
                (self:warriorCast(23 self))
            )
        )
        return 1
    )


    (method (cue)
        (switch (gCalledBy)
            (case 1
                (egoNoise:
                    number(900)
                    play()
                )
                = global142 (+ 5 (/ gGOwnerMaxStamina[23] 10))
            )
            (default 
                (super:cue())
            )
        )
        (send gWarriorObj:normalize())
    )

)
(instance iconF of CombatIcon
    (properties
        view 550
        loop 6
        nsLeft 58
        nsTop 11
        maskView 552
        maskLoop 8
        maskCel 2
    )

    (method (select)
        (if (& signal $0004)
            return 0
        )
        = calledBy gCalledBy
        (send gWarriorObj:view(global421))
        (switch (calledBy)
            (case 0
                0
            )
            (case 2
                0
            )
            (case 1
                localproc_03a1()
            )
        )
        return 1
    )

)
(instance iconMiddle of CombatIcon
    (properties
        view 550
        loop 7
        nsLeft 23
        nsTop 2
        maskView 550
        maskLoop 8
    )

    (method (select)
        (if (& signal $0004)
            return 0
        )
        = calledBy gCalledBy
        (switch (calledBy)
            (case 0
                localproc_03a1()
            )
            (case 2
                (if (not gGOwnerMaxStamina[12])
                    localproc_03a1()
                )(else
                    = gCalledBy 1
                    (if ((send gMonster:mustFight))
                        (combatControls:disable(iconF))
                    )
                    (if (not gGOwnerMaxStamina[23])
                        (combatControls:disable(iconE))
                    )
                    (if (not gGOwnerMaxStamina[32])
                        (combatControls:disable(iconA))
                    )
                    (if (not gGOwnerMaxStamina[24])
                        (combatControls:disable(iconB))
                    )
                    (if (not gGOwnerMaxStamina[25])
                        (combatControls:disable(iconC))
                    )
                    (if (not gGOwnerMaxStamina[27])
                        (combatControls:disable(iconD))
                    )
                    (combatControls:
                        eachElementDo(2 552)
                        eachElementDo(4 0)
                        eachElementDo(217)
                    )
                )
            )
            (case 1
                = gCalledBy 2
                (combatControls:
                    enable(iconA iconB iconC iconD iconE iconF)
                    eachElementDo(2 551)
                    eachElementDo(4 0)
                    eachElementDo(217)
                )
            )
        )
        Animate((send gGQg3KDHandler:elements) 1)
        return 1
    )

)
(instance public combatSpell of Actor
    (properties
        x 123
        y 87
        view 22
        priority 14
        signal $4010
        moveSpeed 0
    )

    (method (cue)
        (if (< loop 3)
            (self:
                loop(+ loop 3)
                setCel(0)
                setCycle(End self)
            )
            (egoNoise:
                number(930)
                play()
            )
            (send gMonster:spellHurt(approachDist))
        )(else
            (if (== approachDist 22)
                (send gMonster:spellHurt(approachDist))
            )
            (self:
                hide()
                setCycle(0)
            )
        )
    )

)
(instance flames of Prop
    (properties
        x 100
        y 149
        view 554
        priority 14
        signal $4010
    )
)
(instance egoStatus of View
    (properties
        x 30
        y 15
        view 553
        cel 1
        priority 3
        signal $4010
    )
)
(instance monStatus of View
    (properties
        x 260
        y 15
        view 553
        priority 3
        signal $4010
    )
)
(instance egoHPStat of StatusBar
    (properties
        x 30
        y 15
    )

    (method (cue)
        (if (< gGOwnerMaxStamina[16] 1)
            = global155 0
            localproc_03a1()
        )
    )


    (method (calcVal)
        (super:calcVal(gGOwnerMaxStamina[16]))
    )


    (method (update)
        (super:update(gGOwnerMaxStamina[16]))
    )

)
(instance egoSPStat of StatusBar
    (properties
        x 30
        y 26
    )

    (method (calcVal)
        (super:calcVal(gGOwnerMaxStamina[17]))
    )


    (method (update)
        (super:update(gGOwnerMaxStamina[17]))
    )

)
(instance egoMPStat of StatusBar
    (properties
        x 30
        y 37
    )

    (method (calcVal)
        (super:calcVal(gGOwnerMaxStamina[18]))
    )


    (method (update)
        (super:update(gGOwnerMaxStamina[18]))
    )

)
(instance public monsterHPStat of StatusBar
    (properties
        x 260
        y 15
    )

    (method (cue)
        (if (== global155 -1)
            (send gWarriorObj:setScript(sDemonEgoDies))
        )(else
            (if (< gGMonsterMonHP 1)
                = global155 1
                localproc_03a1()
            )
        )
    )


    (method (calcVal)
        (super:calcVal(gGMonsterMonHP))
    )


    (method (update)
        (super:update(gGMonsterMonHP))
    )

)
(instance sDemonEgoDies of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (egoStatus:hide())
                (monStatus:hide())
                (egoHPStat:hide())
                (egoSPStat:hide())
                (egoMPStat:hide())
                (monsterHPStat:hide())
                (combatControls:hide())
                = cycles 3
            )
            (case 1
                (send gQg3Messager:say(1 6 1 0 0 840))
                = cycles 3
            )
            (case 2
                = global155 1
                DisposeScript(40)
                localproc_03a1()
            )
        )
    )

)
(instance splotch of Prop
    (properties
        view 553
        loop 2
        signal $4000
    )

    (method (show param1)
        (self:
            setPri(+ (send gWarriorObj:priority) 1)
            x(+ (send gWarriorObj:x) 
                (if (== (send gWarriorObj:loop) 1)
                    48
                )(else
                    67
                )
)
            y(- (send gWarriorObj:y) 
                (if (== (send gWarriorObj:loop) 1)
                    66
                )(else
                    46
                )
)
        )
        (super:show(rest param1))
    )


    (method (cue)
        (self:
            hide()
            x(-50)
        )
    )

)
(instance duckTimer of Timer
    (properties)
)
(instance spellTimer of Timer
    (properties)
)
(instance stamTimer of Timer
    (properties)

    (method (cue)
        (send gOwner:useStamina(-5))
        (egoSPStat:update())
        (self:setReal(self 2))
    )

)
(instance egoNoise of Sound
    (properties)
)
