Mercurial > wow > degaine
comparison Degaine.lua @ 12:9f8a4f3c8641
Added a blacklist for spells with only stealth in it (for now)
author | contrebasse |
---|---|
date | Fri, 10 Dec 2010 17:18:56 +0100 |
parents | 62abf847fef9 |
children | 7b1f3a9cba48 |
comparison
equal
deleted
inserted
replaced
11:62abf847fef9 | 12:9f8a4f3c8641 |
---|---|
1 local AddonName = ... | 1 local AddonName = ... |
2 -- Draw your weapons automagically | 2 -- Draw your weapons automagically |
3 | 3 |
4 -- Known bugs : | 4 |
5 --------------------------------------------------------------- | |
6 -- Known bugs | |
7 --------------------------------------------------------------- | |
5 -- If you stand up by jumping or walking it won't draw your weapon | 8 -- If you stand up by jumping or walking it won't draw your weapon |
6 -- (it's not possible to know if you were sitting or standing before) | 9 -- (it's not possible to know if you were sitting or standing before) |
7 | 10 |
8 --@debug@ | 11 --@debug@ |
9 local debug = false | 12 local debug = false |
10 --@end-debug@ | 13 --@end-debug@ |
11 | 14 |
15 | |
12 --------------------------------------------------------------- | 16 --------------------------------------------------------------- |
13 -- Globals to local | 17 -- Globals to local |
14 --------------------------------------------------------------- | 18 --------------------------------------------------------------- |
15 -- These need to be globals | 19 -- These need to be globals |
16 -- GLOBALS: Degaine_ToggleAuto, Degaine_isAuto, BINDING_HEADER_DEGAINE | 20 -- GLOBALS: Degaine_ToggleAuto, Degaine_isAuto, BINDING_HEADER_DEGAINE |
35 local playername = UnitName("player") | 39 local playername = UnitName("player") |
36 | 40 |
37 -- vars | 41 -- vars |
38 local t_left = -1 | 42 local t_left = -1 |
39 local delay = 2 -- seconds | 43 local delay = 2 -- seconds |
44 | |
40 | 45 |
41 --------------------------------------------------------------- | 46 --------------------------------------------------------------- |
42 -- Some stuff... | 47 -- Some stuff... |
43 --------------------------------------------------------------- | 48 --------------------------------------------------------------- |
44 -- Bindings | 49 -- Bindings |
58 GOSSIP_SHOW = true, | 63 GOSSIP_SHOW = true, |
59 MERCHANT_SHOW = function() return GossipFrame:IsShown() end, | 64 MERCHANT_SHOW = function() return GossipFrame:IsShown() end, |
60 BANKFRAME_OPENED = true, --function() return GossipFrame:IsShown() end, | 65 BANKFRAME_OPENED = true, --function() return GossipFrame:IsShown() end, |
61 AUCTION_HOUSE_SHOW = true, | 66 AUCTION_HOUSE_SHOW = true, |
62 } | 67 } |
63 local SpellBlacklist = { | |
64 [1784] = true, -- Stealth (Rogue) | |
65 [58984] = true, -- Shadowmeld (Nightelf stealth) | |
66 } | |
67 local events1player = { -- the first arg is "player" | 68 local events1player = { -- the first arg is "player" |
68 UNIT_SPELLCAST_FAILED = true, | 69 UNIT_SPELLCAST_FAILED = true, |
69 UNIT_SPELLCAST_INTERRUPTED = true, | 70 UNIT_SPELLCAST_INTERRUPTED = true, |
70 UNIT_SPELLCAST_SUCCEEDED = true, | 71 UNIT_SPELLCAST_SUCCEEDED = true, |
72 } | |
73 local SpellBlackList = { -- spells that don't stealth weapons (works with events1player) | |
74 [1784] = true, -- Stealth (Rogue) | |
75 [58984] = true, -- Shadowmeld (Nightelf stealth) | |
71 } | 76 } |
72 local events2playername = { -- the 2nd arg is playername | 77 local events2playername = { -- the 2nd arg is playername |
73 CHAT_MSG_SAY = true, | 78 CHAT_MSG_SAY = true, |
74 CHAT_MSG_YELL = true, | 79 CHAT_MSG_YELL = true, |
75 CHAT_MSG_TEXT_EMOTE = true, | 80 CHAT_MSG_TEXT_EMOTE = true, |
91 if Degaine_isAuto and not InCombatLockdown() then | 96 if Degaine_isAuto and not InCombatLockdown() then |
92 t_left = delay | 97 t_left = delay |
93 DegaineFrame:SetScript("OnUpdate", Degaine_OnUpdate) | 98 DegaineFrame:SetScript("OnUpdate", Degaine_OnUpdate) |
94 end | 99 end |
95 end | 100 end |
101 | |
96 | 102 |
97 --------------------------------------------------------------- | 103 --------------------------------------------------------------- |
98 -- Activation functions | 104 -- Activation functions |
99 --------------------------------------------------------------- | 105 --------------------------------------------------------------- |
100 local activate = function() | 106 local activate = function() |
132 | 138 |
133 | 139 |
134 --------------------------------------------------------------- | 140 --------------------------------------------------------------- |
135 -- Event/hooks functions | 141 -- Event/hooks functions |
136 --------------------------------------------------------------- | 142 --------------------------------------------------------------- |
137 local Degaine_OnEvent = function(self,event, arg1, arg2, ...) | 143 local Degaine_OnEvent = function(self,event, arg1, arg2, _, _, arg5, ...) |
138 --@debug@ | 144 --@debug@ |
139 if debug then | 145 if debug then |
140 DEFAULT_CHAT_FRAME:AddMessage(event) | 146 DEFAULT_CHAT_FRAME:AddMessage(event) |
141 if arg1 then DEFAULT_CHAT_FRAME:AddMessage("arg1 = "..arg1) end | 147 if arg1 then DEFAULT_CHAT_FRAME:AddMessage("arg1 = "..arg1) end |
142 if arg2 then DEFAULT_CHAT_FRAME:AddMessage("arg2 = "..arg2) end | 148 if arg2 then DEFAULT_CHAT_FRAME:AddMessage("arg2 = "..arg2) end |
143 end | 149 end |
144 --@end-debug@ | 150 --@end-debug@ |
145 | 151 |
146 if ((events[event] and (type(events[event])~="function" or events[event]())) | 152 if events[event] then |
147 or (events1player[event] and arg1=="player") | 153 if type(events[event])~="function" or events[event]() then |
148 or (events2playername[event] and arg2==playername)) then | 154 start() |
149 start() | 155 end |
156 elseif events1player[event] then | |
157 if arg1=="player" then | |
158 if not SpellBlackList[arg5] then -- arg5 is SpellID | |
159 start() | |
160 end | |
161 end | |
162 elseif events2playername[event] then | |
163 if arg2==playername then | |
164 start() | |
165 end | |
150 | 166 |
151 elseif event == "PLAYER_REGEN_ENABLED" then | 167 elseif event == "PLAYER_REGEN_ENABLED" then |
152 desactivate() | 168 desactivate() |
153 elseif event == "PLAYER_REGEN_DISABLED" then | 169 elseif event == "PLAYER_REGEN_DISABLED" then |
154 activate() | 170 activate() |
189 -- Global events | 205 -- Global events |
190 DegaineFrame:RegisterEvent("PLAYER_REGEN_ENABLED") | 206 DegaineFrame:RegisterEvent("PLAYER_REGEN_ENABLED") |
191 DegaineFrame:RegisterEvent("PLAYER_REGEN_DISABLED") | 207 DegaineFrame:RegisterEvent("PLAYER_REGEN_DISABLED") |
192 DegaineFrame:RegisterEvent("ADDON_LOADED") | 208 DegaineFrame:RegisterEvent("ADDON_LOADED") |
193 activate() | 209 activate() |
210 |