forked from Tercioo/Details-Damage-Meter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcustom_healingdone.lua
306 lines (245 loc) · 9.34 KB
/
custom_healingdone.lua
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
local _detalhes = _G.Details
local _
local addonName, Details222 = ...
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--local pointers
local _cstr = string.format --lua local
local _math_floor = math.floor --lua local
local _table_sort = table.sort --lua local
local tinsert = table.insert --lua local
local _table_size = table.getn --lua local
local setmetatable = setmetatable --lua local
local ipairs = ipairs --lua local
local pairs = pairs --lua local
local rawget= rawget --lua local
local _math_min = math.min --lua local
local _math_max = math.max --lua local
local _bit_band = bit.band --lua local
local _unpack = unpack --lua local
local type = type --lua local
local _GetSpellInfo = _detalhes.getspellinfo -- api local
local IsInRaid = IsInRaid -- api local
local IsInGroup = IsInGroup -- api local
local GetNumGroupMembers = GetNumGroupMembers -- api local
local _GetNumPartyMembers = GetNumPartyMembers or GetNumSubgroupMembers -- api local
local _GetNumRaidMembers = GetNumRaidMembers or GetNumGroupMembers -- api local
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--constants
local atributo_custom = _detalhes.atributo_custom
local ToKFunctions = _detalhes.ToKFunctions
local SelectedToKFunction = ToKFunctions [1]
local FormatTooltipNumber = ToKFunctions [8]
local TooltipMaximizedMethod = 1
function atributo_custom:UpdateHealingDoneBracket()
SelectedToKFunction = ToKFunctions [_detalhes.ps_abbreviation]
FormatTooltipNumber = ToKFunctions [_detalhes.tooltip.abbreviation]
TooltipMaximizedMethod = _detalhes.tooltip.maximize_method
end
local temp_table = {}
local target_func = function(main_table)
local i = 1
for name, amount in pairs(main_table) do
local t = temp_table [i]
if (not t) then
t = {"", 0}
temp_table [i] = t
end
t[1] = name
t[2] = amount
i = i + 1
end
end
local spells_used_func = function(main_table, target)
local i = 1
for spellid, spell_table in pairs(main_table) do
local target_amount = spell_table.targets [target]
if (target_amount) then
local t = temp_table [i]
if (not t) then
t = {"", 0}
temp_table [i] = t
end
t[1] = spellid
t[2] = target_amount
i = i + 1
end
end
end
local function SortOrder (main_table, func, ...)
for i = 1, #temp_table do
temp_table [i][1] = ""
temp_table [i][2] = 0
end
func (main_table, ...)
_table_sort (temp_table, _detalhes.Sort2)
return temp_table
end
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--healing done tooltip
function atributo_custom:healdoneTooltip (actor, target, spellid, combat, instance)
if (spellid) then
if (instance:GetCustomObject():IsSpellTarget()) then
local targetname = actor.nome
local this_actor = combat (2, targetname)
if (this_actor) then
for name, _ in pairs(this_actor.healing_from) do
local healer = combat (2, name)
if (healer) then
local spell = healer.spells._ActorTable [spellid]
if (spell) then
local on_me = spell.targets [targetname]
if (on_me) then
GameCooltip:AddLine(healer.nome, FormatTooltipNumber (_, on_me))
end
end
end
end
end
return
else
local name, _, icon = _GetSpellInfo(spellid)
GameCooltip:AddLine(name)
GameCooltip:AddIcon (icon, 1, 1, 14, 14)
GameCooltip:AddLine(Loc ["STRING_HEAL"] .. ": ", spell.total)
GameCooltip:AddLine(Loc ["STRING_HITS"] .. ": ", spell.counter)
GameCooltip:AddLine(Loc ["STRING_CRITICAL_HITS"] .. ": ", spell.c_amt)
end
elseif (target) then
if (target == "[all]") then
SortOrder (actor.targets, target_func)
for i = 1, #temp_table do
local t = temp_table [i]
if (t[2] < 1) then
break
end
GameCooltip:AddLine(t[1], FormatTooltipNumber (_, t[2]))
_detalhes:AddTooltipBackgroundStatusbar()
GameCooltip:AddIcon ([[Interface\FriendsFrame\StatusIcon-Offline]], 1, 1, 14, 14)
end
elseif (target == "[raid]") then
local roster = combat.raid_roster
SortOrder (actor.targets, target_func)
for i = 1, #temp_table do
local t = temp_table [i]
if (t[2] < 1) then
break
end
if (roster [t[1]]) then
GameCooltip:AddLine(t[1], FormatTooltipNumber (_, t[2]))
end
end
elseif (target == "[player]") then
local target_amount = actor.targets [_detalhes.playername]
if (target_amount) then
GameCooltip:AddLine(targetactor.nome, FormatTooltipNumber (_, target_amount))
end
else
SortOrder (actor.spells._ActorTable, spells_used_func, target)
for i = 1, #temp_table do
local t = temp_table [i]
if (t[2] < 1) then
break
end
local name, _, icon = _GetSpellInfo(t[1])
GameCooltip:AddLine(name, FormatTooltipNumber (_, t[2]))
GameCooltip:AddIcon (icon, 1, 1, 14, 14)
end
end
else
actor:ToolTip_HealingDone (instance)
end
end
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--healing done search
function atributo_custom:healdone (actor, source, target, spellid, combat, instance_container)
if (spellid) then --spell is always healing done
local spell = actor.spells._ActorTable [spellid]
local melee = actor.spells._ActorTable [1]
if (spell) then
if (target) then
if (target == "[all]") then
for target_name, amount in pairs(spell.targets) do
--add amount
--we need to pass a object here in order to get name and class, so we just get the main heal actor from the combat
instance_container:AddValue (combat (1, target_name), amount, true)
--
atributo_custom._TargetActorsProcessedTotal = atributo_custom._TargetActorsProcessedTotal + amount
--add to processed container
if (not atributo_custom._TargetActorsProcessed [target_name]) then
atributo_custom._TargetActorsProcessed [target_name] = true
atributo_custom._TargetActorsProcessedAmt = atributo_custom._TargetActorsProcessedAmt + 1
end
end
return 0, true
elseif (target == "[raid]") then
local roster = combat.raid_roster
for target_name, amount in pairs(spell.targets) do
if (roster [target_name]) then
--add amount
instance_container:AddValue (combat (1, target_name), amount, true)
atributo_custom._TargetActorsProcessedTotal = atributo_custom._TargetActorsProcessedTotal + amount
--add to processed container
if (not atributo_custom._TargetActorsProcessed [target_name]) then
atributo_custom._TargetActorsProcessed [target_name] = true
atributo_custom._TargetActorsProcessedAmt = atributo_custom._TargetActorsProcessedAmt + 1
end
end
end
return 0, true
elseif (target == "[player]") then
local target_amount = spell.targets [_detalhes.playername]
if (target_amount) then
--add amount
instance_container:AddValue (combat (1, _detalhes.playername), target_amount, true)
atributo_custom._TargetActorsProcessedTotal = atributo_custom._TargetActorsProcessedTotal + target_amount
--add to processed container
if (not atributo_custom._TargetActorsProcessed [_detalhes.playername]) then
atributo_custom._TargetActorsProcessed [_detalhes.playername] = true
atributo_custom._TargetActorsProcessedAmt = atributo_custom._TargetActorsProcessedAmt + 1
end
end
return 0, true
else
local target_amount = actor.targets [target]
if (target_amount) then
--add amount
instance_container:AddValue (combat (1, target), target_amount, true)
atributo_custom._TargetActorsProcessedTotal = atributo_custom._TargetActorsProcessedTotal + target_amount
--add to processed container
if (not atributo_custom._TargetActorsProcessed [target]) then
atributo_custom._TargetActorsProcessed [target] = true
atributo_custom._TargetActorsProcessedAmt = atributo_custom._TargetActorsProcessedAmt + 1
end
end
return 0, true
end
else
return spell.total
end
else
return 0
end
elseif (target) then
if (target == "[all]") then
local total = 0
for target_name, amount in pairs(actor.targets) do
total = total + amount
end
return total
elseif (target == "[raid]") then
local total = 0
for target_name, amount in pairs(actor.targets) do
if (combat.raid_roster [target_name]) then
total = total + amount
end
end
return total
elseif (target == "[player]") then
return actor.targets [_detalhes.playername] or 0
else
return actor.targets [targetactor] or 0
end
else
return actor.total or 0
end
end