-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAnzu-Against-Iskar.lua
200 lines (191 loc) · 7.42 KB
/
Anzu-Against-Iskar.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
function getWhoNeedsAnzu()
local afectedByPhantasmalWinds = {}
local countPhantasmalWinds = 0
local afectedByPhantasmalWounds = {}
local countPhantasmalWounds = 0
local afectedByFelBomb = {}
local countFelBomb = 0
local afectedByPhantasmalCorruption = {}
local countPhantasmalCorruption = 0
local firstHealer = nil
local _, _, _, playerClassIndex = pcall(UnitClass, "player") -- [1-11|0]
local _, playerSpec = pcall(UnitGroupRolesAssigned, "player")
local _, raidIndex = pcall(UnitInRaid, "player") -- [1-40|nil]
local enumClasses = {
none = 0,
warrior = 1,
paladin = 2,
hunter = 3,
rogue = 4,
priest = 5,
deathKnight = 6,
shaman = 7,
mage = 8,
warlock = 9,
monk = 10,
druid = 11
}
local enumIskarBuffs = {
phantasmalWinds = GetSpellInfo(181957), -- Vientos Fantasmales/Phantasmal Winds
phantasmalWounds = GetSpellInfo(182325), -- Heridas Fantasmales/Phantasmal Wounds
felBomb = GetSpellInfo(181753), -- Bomba vil/Fel Bomb
phantasmalCorruption = GetSpellInfo(181824), -- Corrupción fantasmal/Phantasmal Corruption
eyeOfAnzu = GetSpellInfo(179202) -- Ojo de Anzu/Eye of Anzu
}
for i = 1, GetNumGroupMembers() do
print("entro>" .. i)
local _, aura_spell0 = pcall(UnitDebuff, "raid" .. i, enumIskarBuffs.phantasmalWinds)
print("phantasmalWinds>" .. aura_spell0)
local _, aura_spell1 = pcall(UnitDebuff, "raid" .. i, enumIskarBuffs.phantasmalWounds)
print("phantasmalWounds>" .. aura_spell1)
local _, aura_spell2 = pcall(UnitDebuff, "raid" .. i, enumIskarBuffs.felBomb)
print("felBomb>" .. aura_spell2)
local _, aura_spell3 = pcall(UnitDebuff, "raid" .. i, enumIskarBuffs.phantasmalCorruption)
print("phantasmalCorruption>" .. aura_spell3)
local _, role = pcall(UnitGroupRolesAssigned, "raid" .. i)
if aura_spell0 ~= nil then
print("<phantasmalWinds")
if raidIndex == i then
table.insert(afectedByPhantasmalWinds, "player")
else
table.insert(afectedByPhantasmalWinds, "raid" .. i)
end
countPhantasmalWinds = countPhantasmalWinds + 1
end
if aura_spell1 ~= nil then
print("<phantasmalWounds")
if raidIndex == i then
table.insert(afectedByPhantasmalWounds, "player")
else
table.insert(afectedByPhantasmalWounds, "raid" .. i)
end
countPhantasmalWounds = countPhantasmalWounds + 1
end
if aura_spell2 ~= nil then
print("<felBomb")
if raidIndex == i then
table.insert(afectedByFelBomb, "player")
else
table.insert(afectedByFelBomb, "raid" .. i)
end
countFelBomb = countFelBomb + 1
end
if aura_spell3 ~= nil and role == "TANK" then
print("<phantasmalCorruption")
if raidIndex == i then
table.insert(afectedByPhantasmalCorruption, "player")
else
table.insert(afectedByPhantasmalCorruption, "raid" .. i)
end
countPhantasmalCorruption = countPhantasmalCorruption + 1
end
if firstHealer == nil then
if role == "HEALER" then
if raidIndex == i then
firstHealer = "player"
else
firstHealer = "raid" .. i
end
end
end
end
print("Pre-retorno de valores")
if countFelBomb >= 1 then
print("<countFelBomb")
local _, anzuAuraName = pcall(UnitAura, "player", enumIskarBuffs.eyeOfAnzu, nil)
if anzuAuraName ~= nil then
if playerSpec == "HEALER" then
if playerClassIndex == enumClasses.druid then
return afectedByFelBomb[1], enumIskarBuffs.felBomb, "HEALER", 88423
elseif playerClassIndex == enumClasses.priest then
return afectedByFelBomb[1], enumIskarBuffs.felBomb, "HEALER", 527
elseif playerClassIndex == enumClasses.paladin then
return afectedByFelBomb[1], enumIskarBuffs.felBomb, "HEALER", 4987
elseif playerClassIndex == enumClasses.shaman then
return afectedByFelBomb[1], enumIskarBuffs.felBomb, "HEALER", 77130
elseif playerClassIndex == enumClasses.monk then
return afectedByFelBomb[1], enumIskarBuffs.felBomb, "HEALER", 115450
end
end
else
for key, value in ipairs(afectedByFelBomb) do
local _, vR = pcall(UnitGroupRolesAssigned, "raid" .. i)
if vR == "HEALER" then
if value ~= "player" then
return value, enumIskarBuffs.felBomb, "ANY", nil
end
end
end
end
return firstHealer, enumIskarBuffs.felBomb, "ANY", nil
end
if countPhantasmalCorruption >= 1 then
print("<countPhantasmalCorruption")
return afectedByPhantasmalCorruption[1], enumIskarBuffs.phantasmalCorruption, "TANK", nil
end
if countPhantasmalWounds >= 1 then
print("<countPhantasmalWounds")
return afectedByPhantasmalWounds[1], enumIskarBuffs.phantasmalWounds, "ANY", nil
end
if countPhantasmalWinds >= 1 then
print("<countPhantasmalWinds")
return afectedByPhantasmalWinds[1], enumIskarBuffs.phantasmalWinds, "ANY", nil
end
print("<default return")
return "player", nil, "ANY", nil
end
local btn = CreateFrame("Button", "AnzuButton", UIParent, "SecureActionButtonTemplate,SecureHandlerStateTemplate,SecureHandlerAttributeTemplate")
local anzu_name, _, anzu_icon = GetSpellInfo(179202) -- obtener el nombre del hechizo de ojo de anzu
btn:SetMovable(true)
btn:SetSize(30,30)
btn:RegisterForDrag("LeftButton")
--btn:SetScale(ExtraActionButton1:GetScale())
btn:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
btn:SetHighlightTexture("Interface\Buttons\ButtonHilight-Square")
btn:SetNormalTexture(anzu_icon)
btn:Show()
btn:SetScript("OnDragStart", function(self, button)
self:StartMoving()
end)
btn:SetScript("OnDragStop", function(self)
self:StopMovingOrSizing()
end)
btn:RegisterEvent("PLAYER_LOGIN")
btn:RegisterEvent('UNIT_AURA')
btn:SetScript('OnEvent', function(self, event, ...)
if(self[event]) then
self[event](self, event, ...)
end
end)
function btn:UNIT_AURA(event, unit)
if unit == "player" then
local enumIskarBuffs = {
phantasmalWinds = GetSpellInfo(181957), -- Vientos Fantasmales/Phantasmal Winds
phantasmalWounds = GetSpellInfo(182325), -- Heridas Fantasmales/Phantasmal Wounds
felBomb = GetSpellInfo(181753), -- Bomba vil/Fel Bomb
phantasmalCorruption = GetSpellInfo(181824), -- Corrupción fantasmal/Phantasmal Corruption
eyeOfAnzu = GetSpellInfo(179202) -- Ojo de Anzu/Eye of Anzu
}
local _, aura_name = pcall(UnitAura, "player", enumIskarBuffs.eyeOfAnzu, nil)
if aura_name ~= nil then
print("tengo el ojo")
local target, iskarSpell, role, dispellID = getWhoNeedsAnzu()
local targetName = UnitName(target)
print("El objetivo es " .. target .. " con el bufo " .. iskarSpell)
if iskarSpell == enumIskarBuffs.felBomb and role == "HEALER" then
local dispellName, _, dispellIcon = GetSpellInfo(dispellID)
self:SetNormalTexture(dispellIcon)
self:SetAttribute("type", "spell")
self:SetAttribute("spell", dispellName, target)
elseif target ~= "player" then
self:SetAttribute("type", "macro")
self:SetAttribute("macrotext", string.format("/targetexact %s\n/click ExtraActionButton1\n/targetlasttarget", targetName))
end
else
self:SetNormalTexture(anzu_icon)
self:SetAttribute("type", nil)
self:SetAttribute("spell", nil, nil)
self:SetAttribute("macrotext", nil)
end
end
end