vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | SmartHeal.default['healstack']=1 |
2 | SmartHeal.StackValue=0 |
||
3 | SmartHeal.HealStack={} |
||
4 | SmartHeal.AddOnMessagePrefix="SMH" |
||
5 | |||
6 | function SmartHeal:HealStackOnLoad() |
||
7 | this:RegisterEvent("VARIABLES_LOADED") |
||
8 | end |
||
9 | |||
10 | function SmartHeal:HealStackOnEvent(event) |
||
11 | |||
12 | if (event=="VARIABLES_LOADED") then |
||
13 | |||
14 | this:RegisterEvent("SPELLCAST_START") |
||
15 | this:RegisterEvent("SPELLCAST_STOP") |
||
16 | this:RegisterEvent("SPELLCAST_FAILED") |
||
17 | this:RegisterEvent("SPELLCAST_INTERRUPTED") |
||
18 | this:RegisterEvent("CHAT_MSG_ADDON") |
||
19 | |||
20 | elseif(event=="SPELLCAST_START") then |
||
21 | |||
22 | SmartHeal.CastedSpell=arg1 |
||
23 | SmartHeal.StackUnitId=SmartHeal.CacheUnitId |
||
24 | SmartHeal.StackValue=SmartHeal.HealedValue or 0 |
||
25 | SmartHeal:HealStack_OnCast(1) |
||
26 | |||
27 | elseif(event=="SPELLCAST_STOP" or event=="SPELLCAST_INTERRUPTED") then |
||
28 | |||
29 | SmartHeal:HealStack_OnCast(-1) |
||
30 | SmartHeal.CastedSpell=nil |
||
31 | SmartHeal.StackUnitId=nil |
||
32 | SmartHeal.StackValue=0 |
||
33 | |||
34 | elseif (event=="CHAT_MSG_ADDON" and arg1==SmartHeal.AddOnMessagePrefix) then |
||
35 | |||
36 | SmartHeal:HealStack_ParseMsg() |
||
37 | |||
38 | end |
||
39 | |||
40 | end |
||
41 | |||
42 | function SmartHeal:HealStack_OnCast(stacktype) |
||
43 | |||
44 | |||
45 | if ( not SmartHeal.CastedSpell |
||
46 | or not SmartHeal.StackUnitId |
||
47 | or not SmartHeal.spellList |
||
48 | or GetNumRaidMembers()==0 |
||
49 | |||
50 | ) then return end |
||
51 | |||
52 | local TargetName=UnitName(SmartHeal.StackUnitId) |
||
53 | |||
54 | if ( SmartHeal:getConfig("healstack") |
||
55 | and (SmartHeal.spellList[SmartHeal.CastedSpell] and not SmartHeal.spellList[SmartHeal.CastedSpell].HoT) |
||
56 | and TargetName |
||
57 | ) then |
||
58 | |||
59 | if(not stacktype) then stacktype=1 end |
||
60 | local msg="STACK "..TargetName.." "..floor(SmartHeal.StackValue*stacktype) |
||
61 | SendAddonMessage(SmartHeal.AddOnMessagePrefix,msg,"RAID") |
||
62 | end |
||
63 | |||
64 | end |
||
65 | |||
66 | function SmartHeal:HealStack_ParseMsg() |
||
67 | |||
68 | local _,_,cmd,msg=string.find(arg2,"^(%w+) (.*)") |
||
69 | if(cmd=="STACK") then |
||
70 | SmartHeal:HealStackUpdate(msg) |
||
71 | --SmartHeal:ErrorMsg(msg) |
||
72 | end |
||
73 | |||
74 | |||
75 | end |
||
76 | |||
77 | function SmartHeal:HealStackUpdate(msg) |
||
78 | |||
79 | local _,_,TargetName,StackValue=string.find(msg,"^(%w+) (%-?%d+)$") |
||
80 | |||
81 | if (not TargetName or not StackValue) then return end |
||
82 | |||
83 | if (SmartHeal.HealStack[TargetName]) then |
||
84 | SmartHeal.HealStack[TargetName]=SmartHeal.HealStack[TargetName]+tonumber(StackValue) |
||
85 | else |
||
86 | SmartHeal.HealStack[TargetName]=tonumber(StackValue) |
||
87 | end |
||
88 | |||
89 | if (SmartHeal.HealStack[TargetName]<0) then |
||
90 | SmartHeal.HealStack[TargetName]=0 |
||
91 | end |
||
92 | |||
93 | end |
||
94 | |||
95 | function SmartHeal:HealStackOnUpdate() |
||
96 | |||
97 | if (GetNumRaidMembers()==0 or SmartHeal.HealStackUpdating) then return end |
||
98 | |||
99 | SmartHeal.HealStackUpdating=true |
||
100 | |||
101 | local BarTables={ ["CT_RAMember"]={count=40}, |
||
102 | ["CT_RA_EmergencyFrameFrame"]={count=5}, |
||
103 | ["CT_RAMTGroupMember"]={count=10}, |
||
104 | ["CT_RAPTGroupMember"]={count=10}, |
||
105 | } |
||
106 | |||
107 | for ParentFrame, properties in BarTables do |
||
108 | |||
109 | for i=1,properties.count do |
||
110 | |||
111 | local UnitId,unitName,CTRA_FrameName |
||
112 | |||
113 | if (ParentFrame=="CT_RAMember") then |
||
114 | CTRA_FrameName=ParentFrame..i |
||
115 | UnitId="raid"..i |
||
116 | unitName=UnitName("raid"..i) |
||
117 | elseif(ParentFrame=="CT_RAMTGroupMember") then |
||
118 | CTRA_FrameName=ParentFrame..i.."MTTT" |
||
119 | unitName=getglobal(CTRA_FrameName).Name |
||
120 | UnitId=GetUnitIdFromName(unitName) |
||
121 | elseif (ParentFrame=="CT_RA_EmergencyFrameFrame" or ParentFrame=="CT_RAPTGroupMember") then |
||
122 | CTRA_FrameName=ParentFrame..i |
||
123 | unitName=getglobal(CTRA_FrameName).Name |
||
124 | UnitId=GetUnitIdFromName(unitName) |
||
125 | end |
||
126 | |||
127 | local HPBarFrameName=CTRA_FrameName.."HPBar" |
||
128 | local HPBarObj=getglobal(HPBarFrameName) |
||
129 | local StackValue=0 |
||
130 | |||
131 | if(UnitId and SmartHeal.HealStack[unitName] and SmartHeal.HealStack[unitName]>0) then |
||
132 | StackValue=min((UnitHealthMax(UnitId)-UnitHealth(UnitId)),SmartHeal.HealStack[unitName]) |
||
133 | end |
||
134 | |||
135 | if(UnitId and UnitExists(UnitId) and not UnitIsDeadOrGhost(UnitId) and UnitIsConnected(UnitId) and UnitIsVisible(UnitId) |
||
136 | and StackValue>0 and HPBarObj and HPBarObj:IsShown()) then |
||
137 | |||
138 | getglobal(HPBarFrameName.."_SMHStack"):SetHeight(HPBarObj:GetHeight()) |
||
139 | getglobal(HPBarFrameName.."_SMHStack"):SetPoint("TOPLEFT","$parent","TOPLEFT",UnitHealth(UnitId)/UnitHealthMax(UnitId)*HPBarObj:GetWidth(),0) |
||
140 | getglobal(HPBarFrameName.."_SMHStack"):SetWidth(StackValue/UnitHealthMax(UnitId)*HPBarObj:GetWidth()) |
||
141 | getglobal(HPBarFrameName.."_SMHStack"):Show() |
||
142 | |||
143 | else |
||
144 | getglobal(HPBarFrameName.."_SMHStack"):Hide() |
||
145 | end |
||
146 | |||
147 | end |
||
148 | end |
||
149 | |||
150 | SmartHeal.HealStackUpdating=nil |
||
151 | |||
152 | end |
||
153 | |||
154 | function GetUnitIdFromName(name1) |
||
155 | |||
156 | for i=1,40 do |
||
157 | local name2, rank, _, _, _, _, _, _, _ = GetRaidRosterInfo(i) |
||
158 | if (name1 == name2 and rank) then |
||
159 | return "raid"..i |
||
160 | end |
||
161 | end |
||
162 | |||
163 | return nil |
||
164 | |||
165 | end |