forked from JeffP07/TheorycraftClassic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TheoryCraftClassicMitigation.lua
205 lines (202 loc) · 11.2 KB
/
TheoryCraftClassicMitigation.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
local _, class = UnitClass("player")
local _, spellname, spellrank, targetname, damage, crit, armor, i, spelldata, idx
local damagereduction, ul, oldarmor, oldarmorvalue, sunder, absorbed
function TheoryCraft_ParseCombat(self, arg1)
if TheoryCraft_GetStat("DontMitigate") ~= 0 then return end
if (TheoryCraft_Data["outfit"]) and (TheoryCraft_Data["outfit"] ~= -1) and (TheoryCraft_Data["outfit"] ~= 1) then
return
end
_, _, absorbed = strfind(arg1, TheoryCraft_Locale.Absorbed)
_, _, spellname, targetname, damage = strfind(arg1, TheoryCraft_Locale.HitMessage)
crit = nil
ul = UnitLevel("player")
if spellname == nil then
_, _, spellname, targetname, damage = strfind(arg1, TheoryCraft_Locale.CritMessage)
crit = true
end
if (spellname == nil) or (damage == nil) or (tonumber(damage) == nil) then return end
damage = tonumber(damage)+tonumber(absorbed or 0)
i = 1
while (TheoryCraft_Spells[class][i]) and (TheoryCraft_Spells[class][i].name ~= spellname) do
i = i + 1
end
if (TheoryCraft_Spells[class][i] == nil) or (TheoryCraft_Spells[class][i].name ~= spellname) then
return
end
if (TheoryCraft_Spells[class][i].iscombo) then return end
armor = TheoryCraft_Spells[class][i].armor
i = 0
while (i < 25) do
if (TheoryCraft_TooltipData[spellname.."("..i..")"]) then
spellrank = i
end
i = i + 1
end
if spellrank == nil then return end
spelldata = TheoryCraft_TooltipData[TheoryCraft_TooltipData[spellname.."("..(spellrank)..")"]]
if armor then
if (spelldata == nil) then return end
if (spelldata.mindamage == nil) then return end
if (spelldata.maxdamage == nil) then return end
if (crit) and (spelldata.critbonus) then damage = damage/(spelldata.critbonus+1) end
local isplayer = "not found"
if UnitName("target") == targetname then
isplayer = UnitIsPlayer("target")
end
if TheoryCraft_MitigationMobs[targetname] then
isplayer = false
end
if TheoryCraft_MitigationPlayers[targetname] then
isplayer = true
end
if isplayer == "not found" then
return
end
sunder = TheoryCraft_GetStat("Sunder")
if isplayer then
if (TheoryCraft_MitigationPlayers[targetname] == nil) or (TheoryCraft_MitigationPlayers[targetname][1] == nil) then
oldarmorvalue = 0
for i = 0,60 do
if (TheoryCraft_MitigationPlayers[UnitClass("target")..":"..UnitLevel("target")+i]) and (TheoryCraft_MitigationPlayers[UnitClass("target")..":"..UnitLevel("target")+i][1]) then
oldarmorvalue = TheoryCraft_MitigationPlayers[UnitClass("target")..":"..UnitLevel("target")+i][1]-TheoryCraft_GetStat("Sunder")
break
end
if (TheoryCraft_MitigationPlayers[UnitClass("target")..":"..UnitLevel("target")-i]) and (TheoryCraft_MitigationPlayers[UnitClass("target")..":"..UnitLevel("target")-i][1]) then
oldarmorvalue = TheoryCraft_MitigationPlayers[UnitClass("target")..":"..UnitLevel("target")-i][1]-TheoryCraft_GetStat("Sunder")
break
end
end
TheoryCraft_MitigationPlayers[targetname] = {}
TheoryCraft_MitigationPlayers[targetname][1] = oldarmorvalue
end
oldarmorvalue = TheoryCraft_MitigationPlayers[targetname][1]
if not TheoryCraft_MitigationPlayers[targetname] then
if (damage > spelldata.mindamage-1) or (damage < spelldata.maxdamage+1) then
damagereduction = 1-damage/((spelldata.maxdamage+spelldata.mindamage)/2)
if TheoryCraft_MitigationPlayers[targetname] == nil then TheoryCraft_MitigationPlayers[targetname] = {} end
TheoryCraft_MitigationPlayers[targetname][1] = math.floor((85 * damagereduction * ul + 400 * damagereduction)/(1 - damagereduction))
if TheoryCraft_MitigationPlayers[targetname][1] > 0 then
TheoryCraft_MitigationPlayers[targetname][1] = TheoryCraft_MitigationPlayers[targetname][1] + sunder
end
TheoryCraft_Data.armormultinternal = 1
if TheoryCraft_Data.armormultinternal and (TheoryCraft_MitigationPlayers[targetname]) and (TheoryCraft_MitigationPlayers[targetname][1]) then
TheoryCraft_Data.armormultinternal = 1 - (TheoryCraft_MitigationPlayers[targetname][1] / (85 * UnitLevel("player") + 400 + TheoryCraft_MitigationPlayers[targetname][1]))
end
TheoryCraft_DeleteTable(TheoryCraft_UpdatedButtons)
end
else
oldarmor = TheoryCraft_MitigationPlayers[targetname][1]-sunder
if oldarmor < 0 then
oldarmor = 0
end
oldarmor = 1 - (oldarmor / (85 * UnitLevel("player") + 400 + oldarmor))
if damage < spelldata.mindamage*oldarmor-1 then
damagereduction = 1-damage/(spelldata.mindamage-1)
if TheoryCraft_MitigationPlayers[targetname] == nil then TheoryCraft_MitigationPlayers[targetname] = {} end
TheoryCraft_MitigationPlayers[targetname][1] = math.floor((85 * damagereduction * ul + 400 * damagereduction)/(1 - damagereduction))
if TheoryCraft_MitigationPlayers[targetname][1] > 0 then
TheoryCraft_MitigationPlayers[targetname][1] = TheoryCraft_MitigationPlayers[targetname][1] + sunder
end
TheoryCraft_Data.armormultinternal = 1
if TheoryCraft_Data.armormultinternal and (TheoryCraft_MitigationPlayers[targetname]) and (TheoryCraft_MitigationPlayers[targetname][1]) then
TheoryCraft_Data.armormultinternal = 1 - (TheoryCraft_MitigationPlayers[targetname][1] / (85 * UnitLevel("player") + 400 + TheoryCraft_MitigationPlayers[targetname][1]))
end
TheoryCraft_DeleteTable(TheoryCraft_UpdatedButtons)
end
if damage > spelldata.maxdamage*oldarmor+1 then
damagereduction = 1-damage/(spelldata.maxdamage+1)
if TheoryCraft_MitigationPlayers[targetname] == nil then TheoryCraft_MitigationPlayers[targetname] = {} end
TheoryCraft_MitigationPlayers[targetname][1] = math.floor((85 * damagereduction * ul + 400 * damagereduction)/(1 - damagereduction))
if TheoryCraft_MitigationPlayers[targetname][1] > 0 then
TheoryCraft_MitigationPlayers[targetname][1] = TheoryCraft_MitigationPlayers[targetname][1] + sunder
end
TheoryCraft_Data.armormultinternal = 1
if (TheoryCraft_Data.armormultinternal) and (TheoryCraft_MitigationPlayers[targetname]) and (TheoryCraft_MitigationPlayers[targetname][1]) then
TheoryCraft_Data.armormultinternal = 1 - (TheoryCraft_MitigationPlayers[targetname][1] / (85 * UnitLevel("player") + 400 + TheoryCraft_MitigationPlayers[targetname][1]))
end
TheoryCraft_DeleteTable(TheoryCraft_UpdatedButtons)
end
end
if (TheoryCraft_Settings["armorchanges"]) and (oldarmorvalue ~= TheoryCraft_MitigationPlayers[targetname][1]) then
if oldarmorvalue > TheoryCraft_MitigationPlayers[targetname][1] then
Print(targetname.." Armor "..TheoryCraft_MitigationPlayers[targetname][1].." (-"..oldarmorvalue-TheoryCraft_MitigationPlayers[targetname][1]..")")
else
Print(targetname.." Armor "..TheoryCraft_MitigationPlayers[targetname][1].." (+"..TheoryCraft_MitigationPlayers[targetname][1]-oldarmorvalue..")")
end
end
if UnitName("target") == targetname then
if UnitLevel("target") == -1 then
if TheoryCraft_MitigationPlayers[UnitClass("target")..":60"] == nil then
TheoryCraft_MitigationPlayers[UnitClass("target")..":60"] = {}
end
TheoryCraft_MitigationPlayers[UnitClass("target")..":60"][1] = TheoryCraft_MitigationPlayers[targetname][1]
else
if TheoryCraft_MitigationPlayers[UnitClass("target")..":"..UnitLevel("target")] == nil then
TheoryCraft_MitigationPlayers[UnitClass("target")..":"..UnitLevel("target")] = {}
end
TheoryCraft_MitigationPlayers[UnitClass("target")..":"..UnitLevel("target")][1] = TheoryCraft_MitigationPlayers[targetname][1]
end
end
else
if TheoryCraft_MitigationMobs[targetname] then
oldarmorvalue = TheoryCraft_MitigationMobs[targetname][1] or 0
else
oldarmorvalue = 0
end
if not TheoryCraft_MitigationMobs[targetname] then
if (damage > spelldata.mindamage-1) or (damage < spelldata.maxdamage+1) then
damagereduction = 1-damage/((spelldata.maxdamage+spelldata.mindamage)/2)
if TheoryCraft_MitigationMobs[targetname] == nil then TheoryCraft_MitigationMobs[targetname] = {} end
TheoryCraft_MitigationMobs[targetname][1] = math.floor((85 * damagereduction * ul + 400 * damagereduction)/(1 - damagereduction))
if TheoryCraft_MitigationMobs[targetname][1] > 0 then
TheoryCraft_MitigationMobs[targetname][1] = TheoryCraft_MitigationMobs[targetname][1] + sunder
end
TheoryCraft_Data.armormultinternal = 1
if TheoryCraft_Data.armormultinternal and (TheoryCraft_MitigationMobs[targetname]) and (TheoryCraft_MitigationMobs[targetname][1]) then
TheoryCraft_Data.armormultinternal = 1 - (TheoryCraft_MitigationMobs[targetname][1] / (85 * UnitLevel("player") + 400 + TheoryCraft_MitigationMobs[targetname][1]))
end
TheoryCraft_DeleteTable(TheoryCraft_UpdatedButtons)
end
else
oldarmor = TheoryCraft_MitigationMobs[targetname][1]-sunder
if oldarmor < 0 then
oldarmor = 0
end
oldarmor = 1 - (oldarmor / (85 * UnitLevel("player") + 400 + oldarmor))
if damage < spelldata.mindamage*oldarmor-1 then
damagereduction = 1-damage/(spelldata.mindamage-1)
if TheoryCraft_MitigationMobs[targetname] == nil then TheoryCraft_MitigationMobs[targetname] = {} end
TheoryCraft_MitigationMobs[targetname][1] = math.floor((85 * damagereduction * ul + 400 * damagereduction)/(1 - damagereduction))
if TheoryCraft_MitigationMobs[targetname][1] > 0 then
TheoryCraft_MitigationMobs[targetname][1] = TheoryCraft_MitigationMobs[targetname][1] + sunder
end
TheoryCraft_Data.armormultinternal = 1
if TheoryCraft_Data.armormultinternal and (TheoryCraft_MitigationMobs[targetname]) and (TheoryCraft_MitigationMobs[targetname][1]) then
TheoryCraft_Data.armormultinternal = 1 - (TheoryCraft_MitigationMobs[targetname][1] / (85 * UnitLevel("player") + 400 + TheoryCraft_MitigationMobs[targetname][1]))
end
TheoryCraft_DeleteTable(TheoryCraft_UpdatedButtons)
end
if damage > spelldata.maxdamage*oldarmor+1 then
damagereduction = 1-damage/(spelldata.maxdamage+1)
if TheoryCraft_MitigationMobs[targetname] == nil then TheoryCraft_MitigationMobs[targetname] = {} end
TheoryCraft_MitigationMobs[targetname][1] = math.floor((85 * damagereduction * ul + 400 * damagereduction)/(1 - damagereduction))
if TheoryCraft_MitigationMobs[targetname][1] > 0 then
TheoryCraft_MitigationMobs[targetname][1] = TheoryCraft_MitigationMobs[targetname][1] + sunder
end
TheoryCraft_Data.armormultinternal = 1
if TheoryCraft_Data.armormultinternal and (TheoryCraft_MitigationMobs[targetname]) and (TheoryCraft_MitigationMobs[targetname][1]) then
TheoryCraft_Data.armormultinternal = 1 - (TheoryCraft_MitigationMobs[targetname][1] / (85 * UnitLevel("player") + 400 + TheoryCraft_MitigationMobs[targetname][1]))
end
TheoryCraft_DeleteTable(TheoryCraft_UpdatedButtons)
end
end
if (TheoryCraft_Settings["armorchanges"]) and (oldarmorvalue ~= TheoryCraft_MitigationMobs[targetname][1]) then
if oldarmorvalue > TheoryCraft_MitigationMobs[targetname][1] then
Print(targetname.." Armor "..TheoryCraft_MitigationMobs[targetname][1].." (-"..oldarmorvalue-TheoryCraft_MitigationMobs[targetname][1]..")")
else
Print(targetname.." Armor "..TheoryCraft_MitigationMobs[targetname][1].." (+"..TheoryCraft_MitigationMobs[targetname][1]-oldarmorvalue..")")
end
end
end
end
end