You are not logged in.

Applications: [GameMaster: OPEN] | [Volunteer Testers: OPEN]


This forum will be permanently shut down on Friday 13.07.2018
Please copy or save all important information from old forum before they will be deactivated
We have moved to new board. https://forum.runesofmagic.gameforge.com/Come join us.

ghostwolf82

Professional

  • "ghostwolf82" started this thread

Posts: 859

Location: Kalvans Trunk

Occupation: It's dark in here

  • Send private message

1

Thursday, June 6th 2013, 4:06am

Party Healer - Needs an update

I had plans to eventually update this (since I picked up where Sixpax left off on his other works), but real life is once again pulling me away from my desk. I am very happy for this, but alas, this means some projects are going to get sidelined. This is one of them - for now. If someone else wants to pick up where Sixpax and I left off in the mean-time, feel free. The original two threads for this addon are gone, so our old ideas on theory-crafting this into fruition are no longer able to be used as a reference to guide anyone in the future. There are three text files and a .wav file (the .zip is too large to attatch to the forums, so just find the debuff.wav built into the game, and you have it) . The following are the three text files for reference...

PartyHealer.toc

Source code

1
PartyHealer.xml


PartyHealer.lua

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
local PartyHealer = {}
_G.PartyHealer = PartyHealer

-- PartyHealer
-- Change log:
--    1) Fixed an incorrect character in the French translation for Mother Earth's Fountain.

-- Local variables used throughout
local PHvn = "0.5.8"                    -- Code version
local PHcolor = {    blue = "|cff7f7fcc",
                    white = "|cffffffff" }
local PHlogging = false                    -- Display debug messages
local PHsetting = { SmallHeal = 1000,    -- Amount of HP that smallest heal returns
                    BigHeal = 3000,        -- Amount of HP that bigest heal returns
                    GroupHeal = true,    -- Group healing enabled?
                    FocusTank = true,    -- Tank in focus1 slot?
                    RaidHeal = false,    -- Raid healing enabled?
                    HealType = "score",    -- Type of healing used (score/onlyhp/onlypct)
                    Sound = true }        -- Enable sounds
local PHdefault = { SmallHeal = 1000, BigHeal = 3000, GroupHeal = true, FocusTank = true, RaidHeal = false, HealType = "score", Sound = true }
local PHplayerClass                        -- Player's class (set in LOADING_END event)
local PHallunits = {}                    -- Table of all people to consider for healing (updated from OnUpdate)
local PHstatus = {}                        -- Table of hurt unit's status (updated from OnUpdate)
local PHregen = {}                        -- Table to track when the last Regenerate/Blossoming Life was cast.
local PHsickunits = {}                    -- Table of people with debuffs that can be removed with Cleanse/Purify
local PHsickupdate = GetTime()            -- Last time the PHsickunits table was updated
local PHmemberchange = false            -- Flag to notify OnUpdate whether to update the PHallunits table
local PHmemberupdate = GetTime()        -- Last time a party/raid member change occurred
local PHsoundtime = GetTime()            -- Last time sound was played
local PHunitno = 1                        -- Index number in PHallunits table to check during OnUpdate
local PHpreview = false                    -- Preview/display spell cast instead of actually casting.
local PHgrphealPage,PHgrphealSlot = 0,0    -- Page,Slot for group healing spell (Group Heal/Mother Earth's Fountain)
local PHscanslots = true                -- Notify OnUpdate to scan action bar slots for spells
local PHscantime = GetTime()            -- When scan of action bar slots was requested
local PHheals = {}                        -- Table of healing spells (set in FindSpellSlots)
local PHcures = {}                        -- Table of debuff removal spells (set in FindSpellSlots)

local PHclassColor = {
    WARRIOR = {0.9, 0, 0},        -- warrior
    RANGER = {0.45, 0.64, 0.01},  -- scout
    THIEF = {0, 0.64, 0.57},      -- rogue
    MAGE = {1, 0.5, 0},           -- mage
    AUGUR = {0.16, 0.55, 0.93},   -- priest
    KNIGHT = {1, 0.9, 0},         -- knight
    DRUID = {0, 0.49, 0},         -- druid
    WARDEN = {0.65, 0.42, 0.13},  -- warden
    GM = {0.93, 0.39, 0.70},      -- GM's are pink
    UNKNOWN = {0.5, 0.5, 0.5},      -- uknown is gray
}

local PHhealNames = {
    ['Regenerate']        = "hot",
    ['Blossoming Life']    = "hot",
    ['Heal']            = "bigheal",
    ['Restore Life']    = "bigheal",
    ['Urgent Heal']        = "smallheal",
    ['Recover']            = "smallheal",
    ['Healing Salve']    = "healbuff",
    ['Curing Seed']        = "healbuff",
    ['Group Heal']        = "groupheal",
    ['Mother Earth's Fountain'] = "groupheal",
    ['Healing Wind']    = "healingwind",
    
    -- Spanish translation spell names
    ['Regeneraci195179n']        = "hot",        -- Regenerate
    ['Florecer de la vida']        = "hot",        -- Blossoming Life
    ['Curaci195179n']         = "bigheal",    -- Heal
    ['Restaurar vida']            = "bigheal",    -- Restore Life
    ['Curaci195179n urgente']    = "smallheal",    -- Urgent Heal
    ['Recuperaci195179n']        = "smallheal",    -- Recover
    ['B195161lsamo curativo']    = "healbuff",    -- Healing Salve
    ['Semilla curativa']        = "healbuff",    -- Curing Seed
    ['Curaci195179n grupal']    = "groupheal",    -- Group Heal
    ['Fuente de la Madre Tierra']    = "groupheal",    -- Mother Earth's Fountain
    ['Viento curativo']            = "healingwind",-- elite skill druid-warrior Healing Wind
    
    -- German translation spell names
    ['Regenerieren']            = "hot",        -- Regenerate
    ['Bl195188hendes Leben']    = "hot",        -- Blossoming Life
    ['Heilung']                    = "bigheal",    -- Heal
    ['Leben wiederherstellen']    = "bigheal",    -- Restore Life
    ['Schnellheilung']            = "smallheal",    -- Urgent Heal
    ['Erholung']                = "smallheal",    -- Recover
    ['Salbe']                    = "healbuff",    -- Healing Salve
    ['Samen der Heilung']        = "healbuff",    -- Curing Seed
    ['Gruppenheilung']            = "groupheal",    -- Group Heal
    ['Quell von Mutter Erde']    = "groupheal",    -- Mother Earth's Fountain
    ['Heilender Wind']            = "healingwind", -- elite skill druid-warrior Healing Wind 

    -- French translation spell names
    ['R195169g195169n195169ration']    = "hot",        -- Regenerate
    ['Bougeonnement de vie']                = "hot",        -- Blossoming Life
    ['Soin']                                = "bigheal",    -- Heal
    ['R195169tablissement']                = "bigheal",    -- Restore Life
    ['Soin urgent']                            = "smallheal",    -- Urgent Heal
    ['R195169cuperation']                    = "smallheal",    -- Recover
    ['Salve curative']                        = "healbuff",    -- Healing Salve
    ['Graine curative']                        = "healbuff",    -- Curing Seed
    ['Soins collectifs']                    = "groupheal",    -- Group Heal
    ['Fontaine de la Terre M195168re']    = "groupheal",    -- Mother Earth's Fountain
    ['Vent curateur']                        = "healingwind",-- elite skill druid-warrior Healing Wind
}

-- The number assigned represents the debuff Type (see table below) that can be removed.
local PHcureNames = {
    ['Cleanse']            = 10,    -- Harmful Effect
    ['Purify']            = 9,    -- Curse
    ['Antidote']        = 6,    -- Poison
    ['Calm Heart']        = 15,    -- Fear
    
    -- Spanish translation cure names
    ['Limpieza']                = 10,    -- Cleanse (Harmful Effect)
    ['Purificaci195179n']        = 9,    -- Purify (Curse)
    ['Ant195173doto']            = 6,    -- Antidote (Poison)
    ['Coraz195179n sosegado']    = 15,    -- Calm Heart (Fear)
    
    -- German translation cure names
    ['Reinigung']        = 10,    -- Cleanse (Harmful Effect)
    ['Reinigen']        = 9,    -- Purify (Curse)
    ['Gegengift']        = 6,    -- Antidote (Poison)
    ['Gelassenheit']    = 15,    -- Calm Heart (Fear)

    -- French translation cure names
--    ['Purification']    = 10, -- Cleanse (Harmful Effect)
--    ['Purification']    = 9, -- Purify (Curse)
    ['Antidote']        = 6, -- Antidote (Poison)
    ['Sang froid']        = 15, -- Calm Heart (Fear) 
}

local PHdebuffTypes = {
    [0]        = "Earth",
    [1]        = "Water",
    [2]        = "Fire",
    [3]        = "Wind",
    [4]        = "Light",
    [5]        = "Dark",
    [6]        = "Poison",
    [7]        = "Transform",
    [8]        = "Helpless",
    [9]        = "Curse",
    [10]    = "Harmful Effect",
    [11]    = "Beneficial Effect", -- some buffs are removable
    [12]    = "Immobilization",
    [13]    = "Stun",
    [14]    = "Special",    -- ??
    [15]    = "Fear",
}

local function Print(outstr, a1, a2, a3)
    DEFAULT_CHAT_FRAME:AddMessage(tostring(outstr), a1, a2, a3)
end

local function Logger(outstr)
    if PHlogging then
        DEFAULT_CHAT_FRAME:AddMessage("#PH: "..tostring(outstr), 0.5, 0.8, 0.4)
    end
end

local function Preview(outstr)
    if PHpreview then
        DEFAULT_CHAT_FRAME:AddMessage("#PartyHealer: "..tostring(outstr), 0.8, 0.1, 0.9)
    end
end

local function ShowTable(tbl, indent)
    indent = indent or 0
    for key,value in pairs(tbl) do
        if type(value) == "table" then
            Logger(string.rep(" ", indent)..tostring(key).." : (table)")
            ShowTable(value, indent+3)
        else
            Logger(string.rep(" ", indent)..tostring(key).." = "..tostring(value))
        end
    end
end

local function PHClearBars()
    for k = 1, 6 do
        getglobal("PartyHealer_Bar"..k):SetValue(0)
        getglobal("PartyHealer_Bar"..k.."TextLeft"):SetText("")
        getglobal("PartyHealer_Bar"..k.."TextRight"):SetText("")
    end
end

local function ShowValue(value)
    if (value == true) then
        return "On"
    elseif (value == false) then
        return "Off"
    else
        return tostring(value)
    end
end

local function FindSpellSlots()
    local skill = {}
    local i,skillname,_1,icon,slot

    Logger(PHcolor.blue.."###### Reading skill book ######|r")
    for page = 1,4 do
        slot = 1
        skillname,_1,icon = GetSkillDetail(page, slot)
        while skillname ~= nil do
            if (PHhealNames[skillname] ~= nil) or (PHcureNames[skillname] ~= nil) then
                Logger("  Found spell "..PHcolor.white..skillname.."|r on page,slot "..PHcolor.white..page..","..slot.."|r")
                skill[icon] = { name = skillname,
                                page = page,
                                slot = slot }
            end
            slot = slot + 1
            skillname,_1,icon = GetSkillDetail(page, slot)
        end
    end

--    if PHlogging then
--        ShowTable(skill)
--    end
    
    Logger(PHcolor.blue.."###### Finding spells on action bar ######|r")

    -- Reset to default slots
    PHheals = {}
    PHcures = {}
    
    -- Discover spells on the action bar based on icon paths from GetActionInfo()
    i = 1
    for actionslot = 1,80 do
        icon = GetActionInfo(actionslot)
        if (icon ~= nil) then
        --    Logger("Slot "..actionslot..": "..icon)
            if (skill[icon] ~= nil) then
                skillname = skill[icon].name
                if PHhealNames[skillname] ~= nil then
                    PHheals[PHhealNames[skillname]] = skill[icon]
                    PHheals[PHhealNames[skillname]].actionslot = actionslot
                elseif PHcureNames[skillname] ~= nil then
                    PHcures[PHcureNames[skillname]] = skill[icon]
                    PHcures[PHcureNames[skillname]].actionslot = actionslot
                end
                Logger("  Found spell "..PHcolor.white..skillname.."|r on slot "..PHcolor.white..actionslot.."|r")
                i = i + 1
            end
        end
    end

--    if PHlogging then
--        ShowTable(PHheals)
--    end
    
    Logger("Heal locations:")
    for healtype,tbl in pairs(PHheals) do
        Logger("  "..PHcolor.blue..tbl.name.."|r="..PHcolor.white..tbl.actionslot.."|r")
    end

    Logger("Cure locations:")
    for debufftype,tbl in pairs(PHcures) do
        Logger("  "..PHcolor.blue..tbl.name.."|r="..PHcolor.white..tbl.actionslot.."|r ("..PHdebuffTypes[debufftype]..")|r")
    end
end

local function UpdateAllUnits()
    local j = 0
    local health
    
    Logger("Updating PHallunits table")

    PHallunits = {}
    
    j=j+1; PHallunits[j] = "target"
    
    for i = 1,10 do
        j=j+1; PHallunits[j] = "focus"..i
    end

    j=j+1; PHallunits[j] = "player"
    
    -- Check all raid members if PHsetting.RaidHeal == true
    if PHsetting.RaidHeal and (GetNumRaidMembers() > 1) then
        for i = 1, 36 do
            if UnitExists("raid"..i) then
                j=j+1; PHallunits[j] = "raid"..i
            end
        end
    else
        for i = 1, GetNumPartyMembers()-1 do
            j=j+1; PHallunits[j] = "party"..i
        end
    end
end

local function UnitIsSick(thisunit, matchType)
    local cnt = 1
    local debuff,_2,_3,_4,debuffType = UnitDebuff(thisunit, cnt)

    while debuff ~= nil do
        if (matchType == nil) or (matchType == debuffType) then
            if PHcures[debuffType] ~= nil then
                Logger(thisunit.." has "..PHcolor.white..debuff.."|r (type: "..PHcolor.white..debuffType.."|r)")
                return true
            end
        end

        cnt = cnt + 1
        debuff,_2,_3,_4,debuffType = UnitDebuff(thisunit, cnt)
    end

    return nil
end

local function UpdateSickTable(thisunit)
    local Button3 = getglobal("PartyHealer_Button3")
    
    for checkunit,debuffType in pairs(PHsickunits) do    -- Check existing sickunits to see if they are still sick
        PHsickunits[checkunit] = UnitIsSick(checkunit)
    end
    
    if next(PHsickunits) == nil then    -- Table empty
        Button3:SetText("---")
    else
        if PHsetting.Sound and ((GetTime() - PHsoundtime) >= 8) then
            PlaySoundByPath("Interface//Addons//PartyHealer//sounds//debuff.wav")
            PHsoundtime = GetTime()
        end
        Button3:SetText("(CURE)")
    end
end

local function UpdateStatusTable(thisunit)
    --    Logger("Updating PHstatus table")

    local function ModifyPHstatus(thisunit, j)
        PHstatus[j] = {    unit = thisunit,
                        HP = UnitHealth(thisunit),
                        maxHP = UnitMaxHealth(thisunit),
                        chgHP = UnitChangeHealth(thisunit) }

        PHstatus[j].pctHP = PHstatus[j].HP/PHstatus[j].maxHP
        PHstatus[j].chgpct = PHstatus[j].chgHP/PHstatus[j].maxHP

        -- Decrease the score based on where they fall in the list (increases their heal priority)
        if PHsetting.FocusTank and UnitIsUnit(thisunit, "focus1") then
            PHstatus[j].score = PHstatus[j].pctHP * 0.80
        elseif (thisunit == "target") then
            PHstatus[j].score = PHstatus[j].pctHP * 0.85
        elseif string.find(thisunit, "focus") then
            PHstatus[j].score = PHstatus[j].pctHP * 0.90
        elseif thisunit == "player" then
            PHstatus[j].score = PHstatus[j].pctHP * 0.95
        else
            PHstatus[j].score = PHstatus[j].pctHP
        end

        -- Decrease the score by half of the % damage the person lost in the last tick
        if PHstatus[j].chgpct < 0 then
            PHstatus[j].score = PHstatus[j].score * (1 + (PHstatus[j].chgpct / 2))
        end
        PHstatus[j].score = math.floor(PHstatus[j].score * 100)
    end

    local j = 0
    for i in pairs(PHstatus) do        -- Check to see if they are already in the PHstatus table
        if UnitIsUnit(thisunit, PHstatus[i].unit) then
            j = i
        end
    end
    
    if j == 0 then
        j = #PHstatus + 1
    end

    if UnitIsPlayer(thisunit) and (not UnitCanAttack("player", thisunit)) 
    and (UnitHealth(thisunit)> 0) and ((UnitHealth(thisunit)/UnitMaxHealth(thisunit)) <= .95) then
        ModifyPHstatus(thisunit, j)
    else
        table.remove(PHstatus, j)
    end

    if #PHstatus > 0 then
        -- Sort by specified type (HP, Pct HP, or Health score)
        if PHsetting.HealType == "onlyhp" then
            table.sort(PHstatus, function(a,b) return (a.HP < b.HP) end)
        elseif PHsetting.HealType == "onlypct" then
            table.sort(PHstatus, function(a,b) return (a.pctHP < b.pctHP) end)
        else
            table.sort(PHstatus, function(a,b) return (a.score < b.score) end)
        end

        -- Update bars
        for i = 1,6 do
            local healthBar = getglobal("PartyHealer_Bar"..i)
            local healthName = getglobal("PartyHealer_Bar"..i.."TextLeft")
            local healthPct = getglobal("PartyHealer_Bar"..i.."TextRight")

            if (type(PHstatus[i]) == "table") then
                -- Display names
                -- healthName:SetColor(unpack(PHclassColor[UnitClassToken(PHstatus[i].unit)]))  -- colored names
                healthName:SetText(UnitName(PHstatus[i].unit))

                -- Set bar color based on class:
                -- healthBar:SetBarColor(unpack(PHclassColor[UnitClassToken(PHstatus[i].unit)] or {0.5, 0.5, 0.5}))
                
                -- Set bar color based whether they are a party memeber or not:
                if (UnitIsUnit(PHstatus[i].unit, "player") or UnitInParty(PHstatus[i].unit)) then
                    healthBar:SetBarColor(0.16, 0.55, 0.93) -- Party members are blue
                else
                    healthBar:SetBarColor(1, 0.5, 0)        -- Non-party members are orange
                end

                healthBar:SetValue(math.floor(100 * PHstatus[i].pctHP))
                
                if (PHsetting.HealType == "onlyhp") then
                    healthPct:SetText(string.format("%s", PHstatus[i].HP))
                elseif (PHsetting.HealType == "onlypct") then
                    healthPct:SetText(string.format("%s%%", math.floor(100 * PHstatus[i].pctHP)))
                else
                    healthPct:SetText(string.format("[%s]", PHstatus[i].score))
                end
            else
                healthBar:SetValue(0)
                healthName:SetText("")
                healthName:SetColor(1,1,1)
                healthPct:SetText("")
            end
        end
    else
        PHClearBars()
    end
end

function PartyHealer.ChangeHealType()
    local Button4 = getglobal("PartyHealer_Button4")
    
    if PHsetting.HealType == "score" then
        PHsetting.HealType = "onlyhp"
        Button4:SetText("HealType:[HP]")
    elseif PHsetting.HealType == "onlyhp" then
        PHsetting.HealType = "onlypct"
        Button4:SetText("HealType:[%]")
    else
        PHsetting.HealType = "score"
        Button4:SetText("HealType:[#]")
    end
    Logger("PartyHealer heal type: "..PHcolor.white..PHsetting.HealType.."|r")
end

function PartyHealer.ChangeRaidHeal()
    local Button5 = getglobal("PartyHealer_Button5")

    PHsetting.RaidHeal = (not PHsetting.RaidHeal)
    Button5:SetText("RaidHeal: "..ShowValue(PHsetting.RaidHeal))
    Logger("PartyHealer raid healing: "..PHcolor.white..ShowValue(PHsetting.RaidHeal).."|r")
    
    PHmemberchange = true            -- Signal OnUpdate to update the PHallunits table
    PHmemberupdate = GetTime()
end

function PartyHealer.ChangeGroupHeal()
    local Button6 = getglobal("PartyHealer_Button6")

    PHsetting.GroupHeal = (not PHsetting.GroupHeal)
    Button6:SetText("GroupHeal: "..ShowValue(PHsetting.GroupHeal))
    Logger("PartyHealer group healing: "..PHcolor.white..ShowValue(PHsetting.GroupHeal).."|r")
end

function PartyHealer.ChangeFocusTank()
    local Button7 = getglobal("PartyHealer_Button7")

    PHsetting.FocusTank = (not PHsetting.FocusTank)
    Button7:SetText("FocusTank: "..ShowValue(PHsetting.FocusTank))
    Logger("PartyHealer focus tank: "..PHcolor.white..ShowValue(PHsetting.FocusTank).."|r")

    if PHsetting.FocusTank then
        if (not UnitExists("focus1")) then
            for i = 1,GetNumPartyMembers()-1 do
                if UnitClassToken("party"..i) == "KNIGHT" then
                    FocusUnit(1, "party"..i)
                    break
                end
            end
        end
        if (not UnitExists("focus1")) then
            for i = 1,GetNumPartyMembers()-1 do
                if UnitClassToken("party"..i) == "WARRIOR" then
                    FocusUnit(1, "party"..i)
                    break
                end
            end
        end
    end
end
    
local function PHFreeFocusSlot()
    for y = 12,1,-1 do
        if (not UnitExists("focus"..y)) then
            return y
        end
    end

    return 12 -- All slots occupied, so no choice but to overwrite the focus12 slot
end

local function PHCastHeal(Skill, thisunit)
    local focus_slot = PHFreeFocusSlot()
    local retval = false
    local _1,cooldown
    
    if (not UnitExists(thisunit)) or (not UnitIsPlayer(thisunit)) or UnitCanAttack("player", thisunit) or (UnitHealth(thisunit) == 0) then
        return false
    end

    for i,tbl in ipairs(Skill) do
    --    Logger("i="..tostring(i).."  tbl.name="..tostring(tbl.name).."  tbl.slot="..tostring(tbl.slot).."  UnitName = "..tostring(UnitName(thisunit)))
        if (tbl.slot ~= 0) then    -- Check to make sure skill is on action bar
            _1,cooldown = GetActionCooldown(tbl.slot)
            if cooldown == 0 then
                FocusUnit(focus_slot, "target")  -- Remember original target
                TargetUnit(thisunit)
                if GetActionUsable(tbl.slot) then    -- Check to make sure target in range
                    Logger("- Casting "..PHcolor.white..tbl.name.."|r on "..PHcolor.white..UnitName(thisunit).."|r")
                    Preview("Casting "..PHcolor.white..tbl.name.."|r on "..PHcolor.white..UnitName(thisunit).."|r")
                    if (not PHpreview) then
                        UseAction(tbl.slot)
                        if (PHheals['hot'] ~= nil) and (tbl.slot == PHheals['hot'].actionslot) then    -- Spell is the HoT so track when it was cast
                            PHregen[UnitGUID(thisunit)] = GetTime()
                        end
                    end
                    retval = true
                else
                    Logger(PHcolor.white..UnitName(thisunit).."|r out of range")
                end
                TargetUnit("focus"..focus_slot)   -- Reset original target
                FocusUnit(focus_slot, "")
               
                if retval then
                    return true
                end
            end
        else
            Logger("Skill "..PHcolor.white..tbl.name.."|r not ready")
        end
    end
    return false
end

local function PHBuffList(thisunit)
    local cnt = 1
    local buffstr = "/"
    local buff = UnitBuff(thisunit,cnt)

    while buff ~= nil do
        buffstr = buffstr..buff.."/"
        cnt = cnt + 1
        buff = UnitBuff(thisunit,cnt)
    end

    return string.gsub(buffstr, "(%()(.)(%))", "%2")
end

local function HealUnit(unitstatus)
    local Skill = {}
    local i = 0
    local thisunit = unitstatus.unit
    local lostHP = (unitstatus.maxHP - unitstatus.HP)  -- amount of health lost
    local tbuffs = PHBuffList(thisunit)
    local unitid = UnitGUID(thisunit)
    local retval

    if  PHregen[unitid] == nil then
        PHregen[unitid] = 0
    end

    -- Healing table defined here
    if (PHheals['healbuff'] ~= nil) and UnitIsUnit(thisunit, "focus1") and PHsetting.FocusTank and (not string.find(tbuffs, PHheals['healbuff'].name)) then -- Healing Salve / Curing Seed
        i=i+1; Skill[i] = { slot = PHheals['healbuff'].actionslot, name = PHheals['healbuff'].name }
    end
    if (PHheals['hot'] ~= nil) and ((not string.find(tbuffs, PHheals['hot'].name)) or ((GetTime() - PHregen[unitid]) >= 18)) then -- Regenerate / Blossoming Life
        i=i+1; Skill[i] = { slot = PHheals['hot'].actionslot, name = PHheals['hot'].name }
    end
    if (PHheals['bigheal'] ~= nil) and (lostHP >= PHsetting.BigHeal) then -- Heal / Restore Life
        i=i+1; Skill[i] = { slot = PHheals['bigheal'].actionslot, name = PHheals['bigheal'].name }
    end
    if (PHheals['smallheal'] ~= nil) and ((lostHP >= PHsetting.SmallHeal) or (unitstatus.pctHP <= .80)) then -- Urgent Heal / Recover
        i=i+1; Skill[i] = { slot = PHheals['smallheal'].actionslot, name = PHheals['smallheal'].name }
    end
   
    if (i > 0) and (UnitHealth(thisunit) > 0) then  -- At least 1 criteria met for healing
        if PHlogging or IsShiftKeyDown() then
            local c1,c2,c3
            if (unitstatus.chgpct <= -0.20) or (unitstatus.pctHP <= .25) then
                c1,c2,c3 = 1,0,0  -- change color of output text if unit took a big hit or has low health
            end
            Print("+--------------------------------------------", c1, c2, c3)
            Print("| "..UnitName(thisunit).." ("..thisunit..")", c1, c2, c3)
            Print("| Health: ("..tostring((math.floor(100 * unitstatus.pctHP))).."%)".." maxHP: "..unitstatus.maxHP..", HP: "..unitstatus.HP..", Score: "..unitstatus.score, c1, c2, c3)
        --    Print("| Buffs: "..tbuffs, c1, c2, c3)
            Print("+--------------------------------------------", c1, c2, c3)
        end

        -- Capture value returned from PHCastHeal to tell whether a spell was cast
        retval = PHCastHeal(Skill, thisunit)
       
        if retval then
            return true
        end
    end

    return false
end

function PartyHealer.Cure()
    local Skill = {}
    local i = 0
    local retval
    
    Logger("#----------PartyHealer.Cure----------#")    

     if (UnitCastingTime("player") ~= nil) then
        Logger("- Spell being cast")
        return true
    end
   
    if next(PHcures) == nil then
        Logger("Player has no debuff removal spells")
        return false
    end

    for j,thisunit in ipairs(PHallunits) do
        i = 0
        if (PHsickunits[thisunit] ~= nil) then
            for debuffType,tbl in pairs(PHcures) do
                if UnitIsSick(thisunit, debuffType) then
                    i=i+1; Skill[i] = { slot = tbl.actionslot, name = tbl.name }
                end
            end
            
            if i > 0 then    -- At least one Cure spell ready and thisunit has removable debuff

                -- Capture value returned from PHCastHeal to tell whether a spell was cast
                retval = PHCastHeal(Skill, thisunit)
               
                if retval then
                    return true
                end
            end
        end
    end
    
    return false
end

function PartyHealer.HoT()
    local Skill = {}
    local unitid
    local retval

    Logger("#----------PartyHealer.HoT----------#")

    if (UnitCastingTime("player") ~= nil) then
        Logger("- Spell being cast")
        return true
    end
    
    if (PHheals['hot'] == nil) then
        Logger("No HoT spell found on action bar")
        return false
    end
    
    for i,thisunit in ipairs(PHallunits) do
        if UnitExists(thisunit) and (UnitHealth(thisunit) > 0) and (not UnitCanAttack("player", thisunit)) then
            unitid = UnitGUID(thisunit)
            if PHregen[unitid] == nil then
                PHregen[unitid] = 0
            end

            if ((not string.find(PHBuffList(thisunit), PHheals['hot'].name)) or ((GetTime() - PHregen[unitid]) >= 18)) then
                Skill[1] = { slot = PHheals['hot'].actionslot, name = PHheals['hot'].name }

                -- Capture value returned from PHCastHeal to tell whether a spell was cast
                retval = PHCastHeal(Skill, thisunit)

                if retval then
                    return true
                end
            end
        end
    end
end

function PartyHealer.Main()
    local function NaturesPower()
        local cnt = 1
        local buff, icon, power = UnitBuffInfo("player", cnt)

        while buff ~= nil do
            if (buff == "Nature's Power") or (buff == "Poder de la Naturaleza") or (buff == "Naturmacht") or (buff == "Pouvoir de la Nature") then
                return power
            end
            cnt = cnt + 1
            buff, icon, power = UnitBuffInfo("player", cnt)
        end
        return 0
    end
    
    local _1, cooldown
    local partyhurt = 0
    
    Logger("#----------PartyHealer.Main----------#")
    
    if (UnitCastingTime("player") ~= nil) then
        Logger("- Spell being cast")
        return true
    end

    for i,unitstatus in ipairs(PHstatus) do
        Logger(i..") "..UnitName(unitstatus.unit).." ("..unitstatus.unit..") maxHP: "..unitstatus.maxHP.." HP: "..unitstatus.HP.." ("..math.floor(unitstatus.pctHP * 100).."%) Score: "..unitstatus.score)
        if unitstatus.score < 75 then
            partyhurt = partyhurt + 1
        end
    end
    
    -- Group Healing code
    if PHsetting.GroupHeal and (partyhurt >= 3) and (PHheals['groupheal'] ~= nil) then
        if PHplayerClass == "AUGUR" or ((PHplayerClass == "DRUID") and (NaturesPower() >= 2)) then
            _1,cooldown = GetActionCooldown(PHheals['groupheal'].actionslot)
            if cooldown == 0 then
                Logger("- Casting "..PHheals['groupheal'].name)
                Preview("Casting "..PHcolor.white..PHheals['groupheal'].name.."|r")
                if (not PHpreview) then
                    UseAction(PHheals['groupheal'].actionslot)
                end
            elseif (PHheals['healingwind'] ~= nil) and GetActionUsable(PHheals['healingwind'].actionslot) then
                Logger("- Casting "..PHheals['healingwind'].name)
                Preview("Casting "..PHcolor.white..PHheals['healingwind'].name.."|r")
                if (not PHpreview) then
                    UseAction(PHheals['healingwind'].actionslot)
                end            
            end
            return true
        end
    end

    for i,unitstatus in ipairs(PHstatus) do
        if HealUnit(unitstatus) then
            return true
        end
    end

    return false
end

function PartyHealer:OnLoad(this)
    this:RegisterEvent("SAVE_VARIABLES")
    this:RegisterEvent("VARIABLES_LOADED")
    this:RegisterEvent("LOADING_END")
    this:RegisterEvent("EXCHANGECLASS_SUCCESS")
    this:RegisterEvent("PARTY_MEMBER_CHANGED")
    this:RegisterEvent("UNIT_BUFF_CHANGED")
--    this:RegisterEvent("ACTIONBAR_SLOT_CHANGED")
--    this:RegisterEvent("FOCUS_CHANGED")
--    this:RegisterEvent("UNIT_TARGET_CHANGED")

    SaveVariablesPerCharacter("PartyHealer_SavedValues")
    SaveVariables("PartyHealer_Settings")
    
    SlashCmdList['PartyHealer'] = PartyHealer.SlashCmdHandler
    SLASH_PartyHealer1 = "/pheal" -- Slash command
end

function PartyHealer.SlashCmdHandler(editBox, msg)
    local outstr
    
    msg = string.lower(msg)

    if msg == "on" then
        if (not PartyHealer_MainFrame:IsVisible()) then
            PartyHealer_MainFrame:Show()
        end
    elseif msg == "off" then
        if PartyHealer_MainFrame:IsVisible() then
            PartyHealer_MainFrame:Hide()
        end
    elseif msg == "scan" then
        FindSpellSlots()
        
        outstr = "Heal locations:/"
        for healtype,tbl in pairs(PHheals) do
            outstr = outstr..PHcolor.blue..tbl.name.."|r="..PHcolor.white..tbl.actionslot.."|r/"
        end
        Print(outstr)

        outstr = "Cure locations:/"
        for debufftype,tbl in pairs(PHcures) do
            outstr = outstr..PHcolor.blue..tbl.name.."|r="..PHcolor.white..tbl.actionslot.."|r/"
        end
        Print(outstr)
    elseif string.find(msg, "smallheal") then
        local smallheal = tonumber((string.gsub(msg, "(smallheal )(.*)", "%2")))
        if smallheal < PHsetting.BigHeal then
            PHsetting.SmallHeal = smallheal
            Print(PHcolor.blue.."PartyHealer small heal value: "..PHcolor.white..PHsetting.SmallHeal.."|r")
        else
            Print(PHcolor.blue.."Small heal value must be lower than big heal ("..PHsetting.BigHeal..")|r")
        end
    elseif string.find(msg, "bigheal") then
        local bigheal = tonumber((string.gsub(msg, "(bigheal )(.*)", "%2")))
        if bigheal > PHsetting.SmallHeal then
            PHsetting.BigHeal = bigheal
            Print(PHcolor.blue.."PartyHealer big heal value: "..PHcolor.white..PHsetting.BigHeal.."|r")
        else
            Print(PHcolor.blue.."Big heal value must be higher than small heal ("..PHsetting.SmallHeal..")|r")
        end
    elseif msg == "sound" then
        PHsetting.Sound = (not PHsetting.Sound)
        Print(PHcolor.blue.."PartyHealer sounds: "..PHcolor.white..ShowValue(PHsetting.Sound).."|r")
    elseif msg == "info" then
        outstr = "Heal locations:/"
        for htype,tbl in pairs(PHheals) do
            outstr = outstr..PHcolor.blue..tbl.name.."|r="..PHcolor.white..tbl.actionslot.."|r/"
        end
        Print(outstr)

        outstr = "Cure locations:/"
        for debufftype,tbl in pairs(PHcures) do
            outstr = outstr..PHcolor.blue..tbl.name.."|r="..PHcolor.white..tbl.actionslot.."|r/"
        end
        Print(outstr)

        Print(PHcolor.blue.. "Focus Tank: "   ..PHcolor.white.. ShowValue(PHsetting.FocusTank) .."|r")
        Print(PHcolor.blue.. "Group Healing: "..PHcolor.white.. ShowValue(PHsetting.GroupHeal) .."|r")
        Print(PHcolor.blue.. "Heal Type: "    ..PHcolor.white.. ShowValue(PHsetting.HealType)  .."|r")
        Print(PHcolor.blue.. "Raid Heal: "    ..PHcolor.white.. ShowValue(PHsetting.RaidHeal)  .."|r")
        Print(PHcolor.blue.. "Small Heal: "   ..PHcolor.white.. ShowValue(PHsetting.SmallHeal) .."|r")
        Print(PHcolor.blue.. "Big Heal: "     ..PHcolor.white.. ShowValue(PHsetting.BigHeal)   .."|r")
        Print(PHcolor.blue.. "Sounds: "       ..PHcolor.white.. ShowValue(PHsetting.Sound)     .."|r")
    elseif msg == "go" then
        PartyHealer.Main()
    elseif msg == "hot" then
        PartyHealer.HoT()
    elseif (msg == "cure") then
        PartyHealer.Cure()
    elseif (msg == "preview") then
        PHpreview = true
        PartyHealer.Main()
        PHpreview = false
    elseif msg == "logit" then
        PHlogging = (not PHlogging)
        Print("PartyHealer logging: "..ShowValue(PHlogging))
    else
        Logger("You typed: "..msg)
        Print("Usage: /pheal <option>")
        Print("Options:")
        Print("   on = Turn PartyHealer on")
        Print("   off = Turn PartyHealer off")
        Print("   info = Show current PartyHealer settings")
        Print("   scan = Re-read action bar slots")
        if PHheals['smallheal'] ~= nil then
            Print("   smallheal <value> = Set amount of HP that "..PHheals['smallheal'].name.." returns")
        end
        if PHheals['bigheal'] ~= nil then
            Print("   bigheal <value> = Set amount of HP that "..PHheals['bigheal'].name.." returns")
        end
        Print("   sound = Toggle sounds on/off")
        Print("   go = Cast most efficient heal")
        Print("   hot = Cast only HoT's")
        Print("   cure = Cast debuff removal spell")
        Print("   preview = Just list the spell that would be cast")
    end
end

function PartyHealer:OnEvent(this, event, ...)
--    Logger("OnEvent : "..tostring(event))

    if event == "SAVE_VARIABLES" then
        local point,relativePoint,relativeTo,offsetX,offsetY = this:GetAnchor()

        PartyHealer_Settings.point = point
        PartyHealer_Settings.relativePoint = relativePoint
        PartyHealer_Settings.relativeTo = relativeTo:GetName()
        PartyHealer_Settings.offsetX = offsetX
        PartyHealer_Settings.offsetY = offsetY

        for index,value in pairs(PHsetting) do
            PartyHealer_SavedValues[index] = value
        end

        Logger("Settings and SavedValues saved")
    elseif event == "VARIABLES_LOADED" then
        Print(PHcolor.blue.."PartyHealer v"..PHvn.." by Sixpax. Type "..PHcolor.white.."/pheal"..PHcolor.blue.." for commandline options.|r")
        
        if not PartyHealer_SavedValues then
            PartyHealer_SavedValues = {}
            
            for index,value in pairs(PHsetting) do
                PartyHealer_SavedValues[index] = value
            end
        else
            for index,value in pairs(PartyHealer_SavedValues) do
                PHsetting[index] = value
            end

            for index,value in pairs(PHdefault) do    -- Check to see if the correct index names were loaded
                if PHsetting[index] == nil then        -- if not, set them to the default value
                    Logger("PHsetting."..index.." missing, using default value")
                    PHsetting[index] = PHdefault[index]
                end
            end
        end

        Logger(PHcolor.blue.."###### PartyHealer_SavedValues: ######|r")
        if PHlogging then
            ShowTable(PartyHealer_SavedValues)
        end

        Logger(PHcolor.blue.."############# PHsettings: #############|r")
        if PHlogging then
            ShowTable(PHsetting)
        end
        
        if not PartyHealer_Settings then
            PartyHealer_Settings = {}
            PartyHealer_Settings.point = "CENTER"
            PartyHealer_Settings.relativePoint = "CENTER"
            PartyHealer_Settings.relativeTo = "UIParent"
            PartyHealer_Settings.offsetX = 0
            PartyHealer_Settings.offsetY = 0
        end
        
        this:ClearAllAnchors()
        this:SetAnchor(PartyHealer_Settings.point, PartyHealer_Settings.relativePoint, PartyHealer_Settings.relativeTo, PartyHealer_Settings.offsetX, PartyHealer_Settings.offsetY)
    elseif (event == "LOADING_END") or (event == "EXCHANGECLASS_SUCCESS") then
        local class1,class2 = UnitClassToken("player")
        
        if class1 == nil then
            PHplayerClass = PHplayerClass or "Unknown"
        elseif (class1 == "AUGUR") or (class2 == "AUGUR") then
            PHplayerClass = "AUGUR"
        elseif (class1 == "DRUID") or (class2 == "DRUID") then
            PHplayerClass = "DRUID"
        else
            PHplayerClass = "NONHEALER"
        end
        
        Logger("Player Healing Class: "..PHplayerClass)

        if (PHplayerClass ~= "AUGUR") and (PHplayerClass ~= "DRUID") then
            Logger("Main or secondary class must be Priest or Druid to use PartyHealer")
            if PartyHealer_MainFrame:IsVisible() then
                PartyHealer_MainFrame:Hide()
            end
        end

        PHscanslots = true
        PHscantime = GetTime()

        -- Button 3 (Cleanse/Purify) empty by default
        local Button3 = getglobal("PartyHealer_Button3")
        Button3:SetText("---")
        
        local Button4 = getglobal("PartyHealer_Button4")
        if PHsetting.HealType == "onlypct" then
            Button4:SetText("HealType:[%]")
        elseif PHsetting.HealType == "onlyhp" then
            Button4:SetText("HealType:[HP]")
        elseif PHsetting.HealType == "score" then
            Button4:SetText("HealType:[#]")
        end

        local Button5 = getglobal("PartyHealer_Button5")
        Button5:SetText("RaidHeal: "..ShowValue(PHsetting.RaidHeal))

        local Button6 = getglobal("PartyHealer_Button6")
        Button6:SetText("GroupHeal: "..ShowValue(PHsetting.GroupHeal))

        local Button7 = getglobal("PartyHealer_Button7")
        Button7:SetText("FocusTank: "..ShowValue(PHsetting.FocusTank))
        
        PHmemberchange = true            -- Signal OnUpdate to update the PHallunits table
        PHmemberupdate = GetTime()
        PHregen = {}                    -- Erase the HoT tracking table because GUID's change when zoning.
    elseif (event == "PARTY_MEMBER_CHANGED") then
        PHmemberchange = true            -- Signal OnUpdate to update the PHallunits table
        PHmemberupdate = GetTime()
    elseif (event == "UNIT_BUFF_CHANGED") then
    --    Logger("arg1="..tostring(arg1).." arg2="..tostring(arg2).." arg3="..tostring(arg3).." arg4="..tostring(arg4))
        if UnitIsPlayer(arg1) and (not UnitCanAttack("player", arg1)) and (UnitDebuff(arg1, 1) ~= nil) then
            if (arg1 == "player") or UnitInParty(arg1) or (PHsetting.RaidHeal and UnitInRaid(arg1)) then
                PHsickunits[arg1] = UnitIsSick(arg1)
            end
        end
--    elseif (event == "ACTIONBAR_SLOT_CHANGED") then    -- apparently this triggers even when you just click an action bar icon
--        FindSpellSlots()
    else
        Logger("Event unknown: "..event)
    end
end

function PartyHealer:OnUpdate(this, elapsed_time)
--    Logger("PartyHealer:OnUpdate")
    
    -- Make sure this is the only place that calls UpdateAllUnits() and UpdateStatusTable()
    
    -- Only update PHallunits table when the last "change" event was more than 2 seconds ago to prevent
    -- rapid spamming of the table update code.

    if PHscanslots and ((GetTime() - PHscantime) >= 3) then
        PHscanslots = false
        FindSpellSlots()
    end

    if PHmemberchange and ((GetTime() - PHmemberupdate) >= 2) then
        UpdateAllUnits()
        PHstatus = {}
        PHunitno = 1
        PHmemberchange = false
    elseif PHunitno >= #PHallunits then
        PHunitno = 1
    else
        PHunitno = PHunitno + 1
    end

    if #PHallunits > 0 then        -- This should always be true, but just in case :)
        UpdateStatusTable(PHallunits[PHunitno])
    else
        PHClearBars()
    end

    if ((GetTime() - PHsickupdate) >= 1) then
        UpdateSickTable()
        PHsickupdate = GetTime()
    end
end


PartyHealer.xml

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
<Ui xmlns="http://www.runewaker.com/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.runewaker.com/UI.xsd">
    <Script file="PartyHealer.lua"/>

    <StatusBar name="PartyHealer_StatusBarTemplate" virtual="true" minValue="0" maxValue="100">
        <Size>
            <AbsDimension x="160" y="12"/>
        </Size>
        <Layers>
            <Layer>
                <Texture file="Interface\Common\Block-Fill">
                    <Color r="0" g="0" b="0" a="0.1"/>
                </Texture>
            </Layer>
        </Layers>
        <Frames>
            <Frame name="$parentText">
                <Layers>
                    <Layer level="ARTWORK">
                        <FontString name="$parentLeft" inherits="GameTitleFont" justifyH="LEFT" text="">
                            <Size>
                                <AbsDimension x="77" y="12"/>
                            </Size>
                            <Anchors>
                                <Anchor point="TOPLEFT"/>
                            </Anchors>
                            <FontHeight>
                                <AbsValue val="10"/>
                            </FontHeight>
                        </FontString>

                        <FontString name="$parentRight" inherits="GameTitleFont" justifyH="RIGHT" text="">
                            <Size>
                                <AbsDimension x="83" y="12"/>
                            </Size>
                            <Anchors>
                                <Anchor point="TOPRIGHT"/>
                            </Anchors>
                            <FontHeight>
                                <AbsValue val="10"/>
                            </FontHeight>
                        </FontString>
                    </Layer>
                </Layers>
            </Frame>
        </Frames>
        <BarTexture file="Interface\Common\Bar\Smooth"/>
        <BarColor r="0.5" g="0.5" b="0.5" a="0.5"/>
    </StatusBar>

    <Frame name="PartyHealer_MainFrame" hidden="false" parent="UIParent" frameStrata="BACKGROUND" movable="true" enableMouse="true">
        <Size>
            <AbsDimension x="170" y="115"/>
        </Size>
        <Backdrop bgFile="Interface\Tooltips\Tooltip-Background" edgeFile="Interface\Tooltips\Tooltip-border" tile="true">
            <BackgroundInsets>
                <AbsInset top="4" left="4" bottom="4" right="4"/>
            </BackgroundInsets>
            <EdgeSize>
                <AbsValue val="16"/>
            </EdgeSize>
            <TileSize>
                <AbsValue val="16"/>
            </TileSize>
        </Backdrop>
        <Anchors>
            <Anchor point="CENTER">
                <Offset>
                    <AbsDimension x="-400" y="75"/>
                </Offset>
            </Anchor>
        </Anchors>

        <Frames>
            <Frame name="PartyHealer_Head">
                <Size>
                    <AbsDimension x="170" y="20"/>
                </Size>
                <Anchors>
                    <Anchor point="TOPLEFT" relativeTo="PartyHealer_MainFrame" relativePoint="TOPLEFT">
                        <Offset>
                            <AbsDimension x="0" y="0"/>
                        </Offset>
                    </Anchor>
                </Anchors>
                <Layers>
                    <Layer>
                        <FontString name="PartyHealer_Title" hidden="false" inherits="GameTitleFont" text="Party Healer">
                            <Size>
                                <AbsDimension x="170" y="20"/>
                            </Size>
                            <FontHeight>
                                <AbsValue val="15"/>
                            </FontHeight>
                        </FontString>
                    </Layer>
                </Layers>
            </Frame>

            <Frame name="PartyHealer_Body">
                <Frames>
                    <StatusBar name="PartyHealer_Bar1" inherits="PartyHealer_StatusBarTemplate">
                        <Anchors>
                            <Anchor point="TOPLEFT" relativeTo="PartyHealer_Head" relativePoint="BOTTOMLEFT">
                                <Offset>
                                    <AbsDimension x="5" y="0"/>
                                </Offset>
                            </Anchor>
                        </Anchors>
                    </StatusBar>

                    <StatusBar name="PartyHealer_Bar2" inherits="PartyHealer_StatusBarTemplate">
                        <Anchors>
                            <Anchor point="TOPLEFT" relativeTo="PartyHealer_Bar1" relativePoint="BOTTOMLEFT">
                                <Offset>
                                    <AbsDimension x="0" y="3"/>
                                </Offset>
                            </Anchor>
                        </Anchors>
                    </StatusBar>

                    <StatusBar name="PartyHealer_Bar3" inherits="PartyHealer_StatusBarTemplate">
                        <Anchors>
                            <Anchor point="TOPLEFT" relativeTo="PartyHealer_Bar2" relativePoint="BOTTOMLEFT">
                                <Offset>
                                    <AbsDimension x="0" y="3"/>
                                </Offset>
                            </Anchor>
                        </Anchors>
                    </StatusBar>

                    <StatusBar name="PartyHealer_Bar4" inherits="PartyHealer_StatusBarTemplate">
                        <Anchors>
                            <Anchor point="TOPLEFT" relativeTo="PartyHealer_Bar3" relativePoint="BOTTOMLEFT">
                                <Offset>
                                    <AbsDimension x="0" y="3"/>
                                </Offset>
                            </Anchor>
                        </Anchors>
                    </StatusBar>

                    <StatusBar name="PartyHealer_Bar5" inherits="PartyHealer_StatusBarTemplate">
                        <Anchors>
                            <Anchor point="TOPLEFT" relativeTo="PartyHealer_Bar4" relativePoint="BOTTOMLEFT">
                                <Offset>
                                    <AbsDimension x="0" y="3"/>
                                </Offset>
                            </Anchor>
                        </Anchors>
                    </StatusBar>

                    <StatusBar name="PartyHealer_Bar6" inherits="PartyHealer_StatusBarTemplate">
                        <Anchors>
                            <Anchor point="TOPLEFT" relativeTo="PartyHealer_Bar5" relativePoint="BOTTOMLEFT">
                                <Offset>
                                    <AbsDimension x="0" y="3"/>
                                </Offset>
                            </Anchor>
                        </Anchors>
                    </StatusBar>
                    
                </Frames>
            </Frame>

            <Frame name="PartyHealer_Buttons">
                <!-- Anchors>
                    <Anchor point="TOPLEFT" relativeTo="PartyHealer_MainFrame" relativePoint="BOTTOMLEFT"/>                
                </Anchors -->

                <Frames>
                    <Button name="PartyHealer_Button1" inherits="UIPanelButtonTemplate" text="BestHeal">
                        <Size>
                            <AbsDimension x="60" y="25"/>
                        </Size>
                        <Anchors>
                            <Anchor point="TOPLEFT" relativeTo="PartyHealer_MainFrame" relativePoint="BOTTOMLEFT">
                                <offset>
                                    <AbsDimension x="5" y="5"/>
                                </offset>
                            </Anchor>
                        </Anchors>
                        <Scripts>
                            <OnClick>
                                PartyHealer.Main()
                            </OnClick>
                        </Scripts>
                    </Button>
                </Frames>

                <Frames>
                    <Button name="PartyHealer_Button2" inherits="UIPanelButtonTemplate" text="HoT">
                        <Size>
                            <AbsDimension x="55" y="25"/>
                        </Size>
                        <Anchors>
                            <Anchor point="TOPLEFT" relativeTo="PartyHealer_Button1" relativePoint="TOPRIGHT">
                                <offset>
                                    <AbsDimension x="0" y="0"/>
                                </offset>
                            </Anchor>
                        </Anchors>
                        <Scripts>
                            <OnClick>
                                PartyHealer.HoT()
                            </OnClick>
                        </Scripts>
                    </Button>
                </Frames>
                
                <Frames>
                    <Button name="PartyHealer_Button3" inherits="UIPanelButtonTemplate" text="---">
                        <Size>
                            <AbsDimension x="55" y="25"/>
                        </Size>
                        <Anchors>
                            <Anchor point="TOPLEFT" relativeTo="PartyHealer_Button2" relativePoint="TOPRIGHT">
                                <offset>
                                    <AbsDimension x="0" y="0"/>
                                </offset>
                            </Anchor>
                        </Anchors>
                        <Scripts>
                            <OnClick>
                                PartyHealer.Cure()
                            </OnClick>
                        </Scripts>
                    </Button>
                </Frames>

                <Frames>
                    <Button name="PartyHealer_Button4" inherits="UIPanelButtonTemplate" text="HealType:[#]">
                        <Size>
                            <AbsDimension x="85" y="20"/>
                        </Size>
                        <Anchors>
                            <Anchor point="BOTTOMRIGHT" relativeTo="PartyHealer_MainFrame" relativePoint="TOPRIGHT">
                                <offset>
                                    <AbsDimension x="0" y="0"/>
                                </offset>
                            </Anchor>
                        </Anchors>
                        <Scripts>
                            <OnClick>
                                PartyHealer.ChangeHealType()
                            </OnClick>
                        </Scripts>
                    </Button>
                </Frames>

                <Frames>
                    <Button name="PartyHealer_Button5" inherits="UIPanelButtonTemplate" text="RaidHeal:">
                        <Size>
                            <AbsDimension x="85" y="20"/>
                        </Size>
                        <Anchors>
                            <Anchor point="BOTTOMLEFT" relativeTo="PartyHealer_MainFrame" relativePoint="TOPLEFT">
                                <offset>
                                    <AbsDimension x="0" y="0"/>
                                </offset>
                            </Anchor>
                        </Anchors>
                        <Scripts>
                            <OnClick>
                                PartyHealer.ChangeRaidHeal()
                            </OnClick>
                        </Scripts>
                    </Button>
                </Frames>

                <Frames>
                    <Button name="PartyHealer_Button6" inherits="UIPanelButtonTemplate" text="GroupHeal:">
                        <Size>
                            <AbsDimension x="85" y="20"/>
                        </Size>
                        <Anchors>
                            <Anchor point="BOTTOMLEFT" relativeTo="PartyHealer_Button5" relativePoint="TOPLEFT">
                                <offset>
                                    <AbsDimension x="0" y="0"/>
                                </offset>
                            </Anchor>
                        </Anchors>
                        <Scripts>
                            <OnClick>
                                PartyHealer.ChangeGroupHeal()
                            </OnClick>
                        </Scripts>
                    </Button>
                </Frames>

                <Frames>
                    <Button name="PartyHealer_Button7" inherits="UIPanelButtonTemplate" text="FocusTank:">
                        <Size>
                            <AbsDimension x="85" y="20"/>
                        </Size>
                        <Anchors>
                            <Anchor point="BOTTOMLEFT" relativeTo="PartyHealer_Button4" relativePoint="TOPLEFT">
                                <offset>
                                    <AbsDimension x="0" y="0"/>
                                </offset>
                            </Anchor>
                        </Anchors>
                        <Scripts>
                            <OnClick>
                                PartyHealer.ChangeFocusTank()
                            </OnClick>
                        </Scripts>
                    </Button>
                </Frames>

            </Frame>
        </Frames>

        <Scripts>
            <OnLoad>
                PartyHealer:OnLoad(this)
            </OnLoad>

            <OnEvent>
                PartyHealer:OnEvent(this, event, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9)
            </OnEvent>
            
            <OnUpdate>
                PartyHealer:OnUpdate(this, elapsedTime)
            </OnUpdate>
            
            <OnMouseDown>
                if IsShiftKeyDown() then
                    PartyHealer_MainFrame:StartMoving("TOPLEFT");
                end
            </OnMouseDown>

            <OnMouseUp>
                PartyHealer_MainFrame:StopMovingOrSizing();
            </OnMouseUp>
        </Scripts>
        
    </Frame>
</Ui>