-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMrSunder.lua
105 lines (97 loc) · 2.77 KB
/
MrSunder.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
--bars
MrSunderOffsetX = 200;
MrSunderOffsetY = 50;
MrSunderBarYPadding = 50;
MrSunderBarXPadding = 0;
--MrSunderBarCount = 5; //not using this atm.
--vars
MrSunderLastFail = 0;
MrSunderLastCast = 0;
MrSunderLastCastTarget = "";
MrSunderSpellID = 0;
MrSunder = {};
MrSunder.Events = {
"CHAT_MSG_SPELL_SELF_DAMAGE",
"CHAT_MSG_SPELL_PERIODIC_CREATURE_DAMAGE",
"CHAT_MSG_COMBAT_HOSTILE_DEATH",
"CHAT_MSG_ADDON";
};
function MrSunder_OnLoad()
MrSunder_ToggleEvents(true);
local _, englishClass = UnitClass("player");
end
function MrSunder_OnEvent()
if(event == "CHAT_MSG_COMBAT_HOSTILE_DEATH") then
if(strfind(arg1, "dies.")) then
MrSunder_RemoveBar(string.gsub(arg1, " dies.", ""));
end
return;
end
if(event == "CHAT_MSG_ADDON" and arg1 == "MRSUNDER") then
local a,b = MrSunder_StringSplit(arg2, "_");
MrSunder_Populate(a, b);
return;
end
if(strfind(arg1, "Sunder Armor")) then
if(event == "CHAT_MSG_SPELL_SELF_DAMAGE") then
MrSunderLastFail = GetTime();
return;
end
--create / refresh bar as a sunder stack has been applied
local a,b = MrSunder_StringSplit(arg1, " is afflicted");
MrSunder_Populate(a, GetTime());
end
if(MrSunderLastCast - MrSunderLastFail < 0) then
MrSunderLastFail = 0;
MrSunderLastCast = 0;
end
if(MrSunderLastCast > 0) then
--send data for successful sunder application.,
MrSunder_SendAddonMessage(MrSunderLastCastTarget .. "_" .. MrSunderLastCast);
MrSunderLastCast = 0;
end
end
function MrSunder_ToggleEvents(bool)
for k, v in pairs(MrSunder.Events) do
if(bool) then
this:RegisterEvent(v);
else
this:UnregisterEvent(v);
end
end
end
function MrSunder_SetSpellID()
if(MrSunderSpellID ~= 0) then
return
end
local i = 1
while true do
local spellName = GetSpellName(i, "spell")
if(spellName == "Sunder Armor") then
MrSunderSpellID = i;
return i;
end
if not spellName then
break
end
i = i + 1
end
end
function MrSunder_CastSunder()
CastSpellByName("Sunder Armor");
MrSunder_SetSpellID();
local start, _ = GetSpellCooldown(MrSunderSpellID, "spell");
if(GetTime() - start == 0) then
MrSunderLastCast = GetTime();
MrSunderLastCastTarget = UnitName("target");
--success, test with self_damage fail (miss, dodge)
end
end
function MrSunder_SendAddonMessage(msg)
if GetNumRaidMembers() == 0 then
SendAddonMessage("MRSUNDER", msg, "PARTY");
else
SendAddonMessage("MRSUNDER", msg, "RAID");
end
end
--TODO: Player blacklist, sunder use tracking, next sunder alert (if unitname = Targetunit name and t < x and targethealth > y),