-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathBuffBlock.lua
More file actions
218 lines (205 loc) · 7.12 KB
/
BuffBlock.lua
File metadata and controls
218 lines (205 loc) · 7.12 KB
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
local BB_PlayerName = nil;
local BB_default = {};
local BuffBlockMenuObjects = {}
local BuffBlockMenuStrings = {
[00]= "Battle Shout",
[01]= "Blessing of Salvation",
[02]= "Greater Blessing of Salvation",
[03]= "Divine Spirit",
[04]= "Prayer of Spirit",
[05]= "Arcane Intellect",
[06]= "Arcane Brilliance",
[07]= "Blessing of Protection"
}
function BuffBlock_OnLoad()
this:RegisterEvent("PLAYER_AURAS_CHANGED");
this:RegisterEvent("VARIABLES_LOADED");
DEFAULT_CHAT_FRAME:AddMessage("Buff Block, by Armilus. /BB for options", 1, 1, 0.5);
SLASH_BB1 = "/BB";
SlashCmdList["BB"] = BuffBlock_Command;
end
function BuffBlock_Init()
BB_PlayerName = UnitName("player").." of "..GetCVar("realmName");
if (BUFF_CONFIG == nil) then
BUFF_CONFIG = {};
end
if (BUFF_CONFIG[BB_PlayerName] == nil) then
BUFF_CONFIG[BB_PlayerName] = BB_default;
end
end
function BuffBlock_OnEvent()
if (event == "PLAYER_AURAS_CHANGED") then
Kill_Buffs();
elseif (event == "VARIABLES_LOADED") then
BuffBlock_Init();
end
end
function BuffBlock_Command()
if BuffBlockOptions:IsShown() then
BuffBlockOptions:Hide();
else
BuffBlockOptions:Show();
end
end
function BuffBlock_GetOption(num)
local labelString = getglobal(this:GetName().."Text");
local label = BuffBlockMenuStrings[num] or "";
BuffBlockMenuObjects[num] = this
if num == 00 and BUFF_CONFIG[BB_PlayerName].BATTLESHOUT
or num == 01 and BUFF_CONFIG[BB_PlayerName].SALVATION
or num == 02 and BUFF_CONFIG[BB_PlayerName].GREATERSALVATION
or num == 03 and BUFF_CONFIG[BB_PlayerName].DIVINESPIRIT
or num == 04 and BUFF_CONFIG[BB_PlayerName].PRAYEROFSPIRIT
or num == 05 and BUFF_CONFIG[BB_PlayerName].ARCANEINTELLECT
or num == 06 and BUFF_CONFIG[BB_PlayerName].ARCANEBRILLIANCE
or num == 07 and BUFF_CONFIG[BB_PlayerName].BLESSINGOFPROTECTION
or nil then
this:SetChecked(true);
else
this:SetChecked(nil);
end
labelString:SetText(label);
end
function BuffBlock_SetOption(num)
local checked = this:GetChecked()
if num == 00 then
if checked then
BUFF_CONFIG[BB_PlayerName].BATTLESHOUT = 1
DEFAULT_CHAT_FRAME:AddMessage("Blocking "..BuffBlockMenuStrings[num]);
else
BUFF_CONFIG[BB_PlayerName].BATTLESHOUT = nil
DEFAULT_CHAT_FRAME:AddMessage("Stopped blocking "..BuffBlockMenuStrings[num]);
end
elseif num == 01 then
if checked then
BUFF_CONFIG[BB_PlayerName].SALVATION = 1
DEFAULT_CHAT_FRAME:AddMessage("Blocking "..BuffBlockMenuStrings[num]);
else
BUFF_CONFIG[BB_PlayerName].SALVATION = nil
DEFAULT_CHAT_FRAME:AddMessage("Stopped blocking "..BuffBlockMenuStrings[num]);
end
elseif num == 02 then
if checked then
BUFF_CONFIG[BB_PlayerName].GREATERSALVATION = 1
DEFAULT_CHAT_FRAME:AddMessage("Blocking "..BuffBlockMenuStrings[num]);
else
BUFF_CONFIG[BB_PlayerName].GREATERSALVATION = nil
DEFAULT_CHAT_FRAME:AddMessage("Stopped blocking "..BuffBlockMenuStrings[num]);
end
elseif num == 03 then
if checked then
BUFF_CONFIG[BB_PlayerName].DIVINESPIRIT = 1
DEFAULT_CHAT_FRAME:AddMessage("Blocking "..BuffBlockMenuStrings[num]);
else
BUFF_CONFIG[BB_PlayerName].DIVINESPIRIT = nil
DEFAULT_CHAT_FRAME:AddMessage("Stopped blocking "..BuffBlockMenuStrings[num]);
end
elseif num == 04 then
if checked then
BUFF_CONFIG[BB_PlayerName].PRAYEROFSPIRIT = 1
DEFAULT_CHAT_FRAME:AddMessage("Blocking "..BuffBlockMenuStrings[num]);
else
BUFF_CONFIG[BB_PlayerName].PRAYEROFSPIRIT = nil
DEFAULT_CHAT_FRAME:AddMessage("Stopped blocking "..BuffBlockMenuStrings[num]);
end
elseif num == 05 then
if checked then
BUFF_CONFIG[BB_PlayerName].ARCANEINTELLECT = 1
DEFAULT_CHAT_FRAME:AddMessage("Blocking "..BuffBlockMenuStrings[num]);
else
BUFF_CONFIG[BB_PlayerName].ARCANEINTELLECT = nil
DEFAULT_CHAT_FRAME:AddMessage("Stopped blocking "..BuffBlockMenuStrings[num]);
end
elseif num == 06 then
if checked then
BUFF_CONFIG[BB_PlayerName].ARCANEBRILLIANCE = 1
DEFAULT_CHAT_FRAME:AddMessage("Blocking "..BuffBlockMenuStrings[num]);
else
BUFF_CONFIG[BB_PlayerName].ARCANEBRILLIANCE = nil
DEFAULT_CHAT_FRAME:AddMessage("Stopped blocking "..BuffBlockMenuStrings[num]);
end
elseif num == 07 then
if checked then
BUFF_CONFIG[BB_PlayerName].BLESSINGOFPROTECTION = 1
DEFAULT_CHAT_FRAME:AddMessage("Blocking "..BuffBlockMenuStrings[num]);
else
BUFF_CONFIG[BB_PlayerName].BLESSINGOFPROTECTION = nil
DEFAULT_CHAT_FRAME:AddMessage("Stopped blocking "..BuffBlockMenuStrings[num]);
end
end
end
function IsShieldEquipped()
local slot = GetInventorySlotInfo("SecondaryHandSlot")
local link = GetInventoryItemLink("player", slot)
if link then
local found, _, id, name = string.find(link, "item:(%d+):.*%[(.*)%]")
if found then
local _,_,_,_,_,itemType = GetItemInfo(tonumber(id))
if(itemType == "Shields") then
return true
end
end
end
return false
end
function Kill_Buffs()
local i = 0;
while not (GetPlayerBuff(i, "HELPFUL") == -1) do
local buffIndex, untilCancelled = GetPlayerBuff(i, "HELPFUL")
local texture = GetPlayerBuffTexture(buffIndex);
--DEFAULT_CHAT_FRAME:AddMessage("DEBUG: "..texture, 1, 1, 0.5);
if BUFF_CONFIG[BB_PlayerName].BATTLESHOUT then
if (string.find(texture,"BattleShout")) then
CancelPlayerBuff(buffIndex);
DEFAULT_CHAT_FRAME:AddMessage("Blocked "..BuffBlockMenuStrings[00], 1, 1, 0.5);
end
end
if BUFF_CONFIG[BB_PlayerName].SALVATION then
if (string.lower(UnitClass("player")) ~= "warrior" or (IsShieldEquipped() and GetShapeshiftFormInfo(2))) then
if (string.find(texture,"SealOfSalvation")) then
CancelPlayerBuff(buffIndex);
DEFAULT_CHAT_FRAME:AddMessage("Blocked "..BuffBlockMenuStrings[01], 1, 1, 0.5);
end
end
end
if BUFF_CONFIG[BB_PlayerName].GREATERSALVATION then
if (string.lower(UnitClass("player")) ~= "warrior" or (IsShieldEquipped() and GetShapeshiftFormInfo(2))) then
if (string.find(texture,"GreaterBlessingofSalvation")) then
CancelPlayerBuff(buffIndex);
DEFAULT_CHAT_FRAME:AddMessage("Blocked "..BuffBlockMenuStrings[02], 1, 1, 0.5);
end
end
end
if BUFF_CONFIG[BB_PlayerName].DIVINESPIRIT then
if (string.find(texture,"DivineSpirit")) then
CancelPlayerBuff(buffIndex);
DEFAULT_CHAT_FRAME:AddMessage("Blocked "..BuffBlockMenuStrings[03], 1, 1, 0.5);
end
end
if BUFF_CONFIG[BB_PlayerName].PRAYEROFSPIRIT then
if (string.find(texture,"PrayerofSpirit")) then
CancelPlayerBuff(buffIndex);
DEFAULT_CHAT_FRAME:AddMessage("Blocked "..BuffBlockMenuStrings[04], 1, 1, 0.5);
end
end
if BUFF_CONFIG[BB_PlayerName].ARCANEINTELLECT then
if (string.find(texture,"MagicalSentry")) then
CancelPlayerBuff(buffIndex);
DEFAULT_CHAT_FRAME:AddMessage("Blocked "..BuffBlockMenuStrings[05], 1, 1, 0.5);
end
end
if BUFF_CONFIG[BB_PlayerName].ARCANEBRILLIANCE then
if (string.find(texture,"ArcaneIntellect")) then
CancelPlayerBuff(buffIndex);
DEFAULT_CHAT_FRAME:AddMessage("Blocked "..BuffBlockMenuStrings[06], 1, 1, 0.5);
end
end
if BUFF_CONFIG[BB_PlayerName].BLESSINGOFPROTECTION then
if (string.find(texture,"SealOfProtection")) then
CancelPlayerBuff(buffIndex);
DEFAULT_CHAT_FRAME:AddMessage("Blocked "..BuffBlockMenuStrings[07], 1, 1, 0.5);
end
end
i = i + 1;
end
end