vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | assert( oRA, "oRA not found!") |
2 | |||
3 | ------------------------------ |
||
4 | -- Are you local? -- |
||
5 | ------------------------------ |
||
6 | |||
7 | local L = AceLibrary("AceLocale-2.2"):new("oRAPResurrection") |
||
8 | local BS = AceLibrary("Babble-Spell-2.2") |
||
9 | local G = AceLibrary("Gratuity-2.0") |
||
10 | |||
11 | local spells = { |
||
12 | [BS["Rebirth"]] = true, |
||
13 | [BS["Resurrection"]] = true, |
||
14 | [BS["Redemption"]] = true, |
||
15 | [BS["Ancestral Spirit"]] = true, |
||
16 | [BS["Reincarnation"]] = true, |
||
17 | } |
||
18 | |||
19 | ---------------------------- |
||
20 | -- Localization -- |
||
21 | ---------------------------- |
||
22 | |||
23 | L:RegisterTranslations("enUS", function() return { |
||
24 | ["resurrection"] = true, |
||
25 | ["resurrectionparticipant"] = true, |
||
26 | ["Participant/Resurrection"] = true, |
||
27 | ["Options for resurrection."] = true, |
||
28 | ["Toggle"] = true, |
||
29 | ["toggle"] = true, |
||
30 | ["^Corpse of (.+)$"] = true, |
||
31 | } end ) |
||
32 | |||
33 | L:RegisterTranslations("koKR", function() return { |
||
34 | |||
35 | ["Participant/Resurrection"] = "부분/부활", |
||
36 | ["Options for resurrection."] = "부활 설정", |
||
37 | ["Toggle"] = "토글", |
||
38 | ["^Corpse of (.+)$"] = "^([^%s]+)의 시체", |
||
39 | } end ) |
||
40 | |||
41 | L:RegisterTranslations("zhCN", function() return { |
||
42 | ["resurrection"] = "复活术", |
||
43 | ["resurrectionparticipant"] = "resurrectionparticipant", |
||
44 | ["Participant/Resurrection"] = "Participant/Resurrection", |
||
45 | ["Options for resurrection."] = "复活的选项", |
||
46 | ["Toggle"] = "显示", |
||
47 | ["toggle"] = "显示", |
||
48 | ["^Corpse of (.+)$"] = "^([^%s]+)的尸体", |
||
49 | } end ) |
||
50 | |||
51 | L:RegisterTranslations("zhTW", function() return { |
||
52 | ["resurrection"] = "復活", |
||
53 | ["resurrectionparticipant"] = "resurrectionparticipant", |
||
54 | ["Participant/Resurrection"] = "隊員/復活", |
||
55 | ["Options for resurrection."] = "復活選項", |
||
56 | ["Toggle"] = "顯示", |
||
57 | ["toggle"] = "顯示", |
||
58 | ["^Corpse of (.+)$"] = "^(.+)的屍體", |
||
59 | } end ) |
||
60 | |||
61 | L:RegisterTranslations("frFR", function() return { |
||
62 | --["resurrection"] = true, |
||
63 | --["resurrectionparticipant"] = true, |
||
64 | ["Participant/Resurrection"] = "Participant/R\195\169surrection", |
||
65 | ["Options for resurrection."] = "Options concernant les r\195\169surrections", |
||
66 | ["Toggle"] = "Afficher", |
||
67 | --["toggle"] = true, |
||
68 | ["^Corpse of (.+)$"] = "^Cadavre de (.+)$", |
||
69 | } end ) |
||
70 | |||
71 | ---------------------------------- |
||
72 | -- Module Declaration -- |
||
73 | ---------------------------------- |
||
74 | |||
75 | oRAPResurrection = oRA:NewModule(L["resurrectionparticipant"], "AceHook-2.1") |
||
76 | oRAPResurrection.defaults = { |
||
77 | } |
||
78 | oRAPResurrection.participant = true |
||
79 | oRAPResurrection.name = L["Participant/Resurrection"] |
||
80 | -- oRAPResurrection.consoleCmd = L["resurrection"] |
||
81 | -- oRAPResurrection.consoleOptions = { |
||
82 | -- type = "group", |
||
83 | -- desc = L["Options for resurrection."], |
||
84 | -- args = { |
||
85 | -- } |
||
86 | -- } |
||
87 | |||
88 | ------------------------------ |
||
89 | -- Initialization -- |
||
90 | ------------------------------ |
||
91 | |||
92 | function oRAPResurrection:OnEnable() |
||
93 | self.spell = nil |
||
94 | self.target = nil |
||
95 | self.enabled = nil |
||
96 | self:HookAndRegister() |
||
97 | end |
||
98 | |||
99 | function oRAPResurrection:OnDisable() |
||
100 | self:UnregisterAllEvents() |
||
101 | self:UnhookAll() |
||
102 | end |
||
103 | |||
104 | function oRAPResurrection:HookAndRegister() |
||
105 | self:RegisterEvent("oRA_JoinedRaid") |
||
106 | self:RegisterEvent("oRA_LeftRaid") |
||
107 | end |
||
108 | |||
109 | ------------------------ |
||
110 | -- Event Handlers -- |
||
111 | ------------------------ |
||
112 | |||
113 | function oRAPResurrection:oRA_JoinedRaid() |
||
114 | if not self.enabled then |
||
115 | self.enabled = true |
||
116 | local _, c = UnitClass("player") |
||
117 | if c == "DRUID" or c == "PRIEST" or c == "SHAMAN" or c == "PALADIN" then |
||
118 | self:RegisterEvent("SPELLCAST_START") |
||
119 | self:RegisterEvent("SPELLCAST_INTERRUPTED", "SpellFailed") |
||
120 | self:RegisterEvent("SPELLCAST_FAILED", "SpellFailed") |
||
121 | self:RegisterEvent("SPELLCAST_STOP", "SpellFailed") |
||
122 | self:Hook("CastSpell", true) |
||
123 | self:Hook("CastSpellByName", true) |
||
124 | self:Hook("UseAction", true) |
||
125 | self:Hook("SpellTargetUnit", true) |
||
126 | self:Hook("SpellStopTargeting", true) |
||
127 | self:Hook("TargetUnit", true) |
||
128 | self:HookScript(WorldFrame, "OnMouseDown", "WorldFrameOnMouseDown") |
||
129 | end |
||
130 | self:Hook(StaticPopupDialogs["DEATH"], "OnShow", function() |
||
131 | self.hooks[StaticPopupDialogs["DEATH"]].OnShow() |
||
132 | if HasSoulstone() then self:SendMessage("CANRES") end end, true ) |
||
133 | |||
134 | self:Hook(StaticPopupDialogs["RESURRECT"], "OnShow", function() |
||
135 | self.hooks[StaticPopupDialogs["RESURRECT"]].OnShow() |
||
136 | self:SendMessage("RESSED") end, true ) |
||
137 | |||
138 | self:Hook(StaticPopupDialogs["RESURRECT_NO_SICKNESS"], "OnShow", function() |
||
139 | self.hooks[StaticPopupDialogs["RESURRECT_NO_SICKNESS"]].OnShow() |
||
140 | self:SendMessage("RESSED") end, true ) |
||
141 | |||
142 | self:Hook(StaticPopupDialogs["RESURRECT_NO_TIMER"], "OnShow", function() |
||
143 | self.hooks[StaticPopupDialogs["RESURRECT_NO_TIMER"]].OnShow() |
||
144 | self:SendMessage("RESSED") end, true ) |
||
145 | |||
146 | -- hrmf we can't hook the OnHide's normally, since they are not there. But |
||
147 | -- blizzard will fire the OnHide if it finds it. |
||
148 | -- so some more magic to get this working. And be friendly if someone else created |
||
149 | -- an OnHide already. |
||
150 | |||
151 | if not StaticPopupDialogs["RESURRECT"].OnHide then |
||
152 | StaticPopupDialogs["RESURRECT"].OnHide = function() self:SendMessage("NORESSED") end |
||
153 | else |
||
154 | self:Hook(StaticPopupDialogs["RESURRECT"], "OnHide", function() |
||
155 | self.hooks[StaticPopupDialogs["RESURRECT"]].OnHide() |
||
156 | self:SendMessage("NORESSED") end, true ) |
||
157 | end |
||
158 | if not StaticPopupDialogs["RESURRECT_NO_SICKNESS"].OnHide then |
||
159 | StaticPopupDialogs["RESURRECT_NO_SICKNESS"].OnHide = function() self:SendMessage("NORESSED") end |
||
160 | else |
||
161 | self:Hook(StaticPopupDialogs["RESURRECT_NO_SICKNESS"], "OnHide", function() |
||
162 | self.hooks[StaticPopupDialogs["RESURRECT_NO_SICKNESS"]].OnHide() |
||
163 | self:SendMessage("NORESSED") end, true ) |
||
164 | end |
||
165 | if not StaticPopupDialogs["RESURRECT_NO_TIMER"].OnHide then |
||
166 | StaticPopupDialogs["RESURRECT_NO_TIMER"].OnHide = function() |
||
167 | if not StaticPopup_FindVisible("DEATH") then self:SendMessage("NORESSED") end |
||
168 | end |
||
169 | else |
||
170 | self:Hook(StaticPopupDialogs["RESURRECT_NO_TIMER"], "OnHide", function() |
||
171 | self.hooks[StaticPopupDialogs["RESURRECT_NO_TIMER"]].OnHide() |
||
172 | if not StaticPopup_FindVisible("DEATH") then self:SendMessage("NORESSED") end end, true ) |
||
173 | end |
||
174 | end |
||
175 | end |
||
176 | |||
177 | function oRAPResurrection:oRA_LeftRaid() |
||
178 | self:DisableSpellHooking() |
||
179 | end |
||
180 | |||
181 | function oRAPResurrection:SPELLCAST_START(spell) |
||
182 | if spells[spell] and self.spell == spell and self.target then |
||
183 | self:SendMessage("RES " .. self.target ) |
||
184 | end |
||
185 | end |
||
186 | |||
187 | function oRAPResurrection:SpellFailed() |
||
188 | if self.spell and self.target and spells[self.spell] then |
||
189 | self:SendMessage("RESNO") |
||
190 | self.spell = nil |
||
191 | self.target = nil |
||
192 | end |
||
193 | end |
||
194 | |||
195 | -------------- |
||
196 | -- Disabler -- |
||
197 | -------------- |
||
198 | |||
199 | function oRAPResurrection:DisableSpellHooking() |
||
200 | self:UnhookAll() |
||
201 | self:UnregisterAllEvents() |
||
202 | -- register our old stuff again |
||
203 | self:HookAndRegister() |
||
204 | end |
||
205 | |||
206 | ------------- |
||
207 | -- HOOKS -- |
||
208 | ------------- |
||
209 | |||
210 | function oRAPResurrection:CastSpell(id, tab) |
||
211 | self.hooks["CastSpell"](id, tab) |
||
212 | G:Erase() |
||
213 | G:SetSpell(id, tab) |
||
214 | local spellname = G:GetLine(1) |
||
215 | |||
216 | if spellname then |
||
217 | if SpellIsTargeting() then |
||
218 | self.spell = spellname |
||
219 | elseif UnitExists("target") then |
||
220 | self.spell = spellname |
||
221 | self.target = UnitName("target") |
||
222 | end |
||
223 | end |
||
224 | end |
||
225 | |||
226 | function oRAPResurrection:CastSpellByName( a1, a2) |
||
227 | self.hooks["CastSpellByName"](a1,a2) |
||
228 | local _,_,spell = string.find(a1, "^([^%(]+)") |
||
229 | if spell then |
||
230 | if SpellIsTargeting() then |
||
231 | self.spell = spell |
||
232 | elseif UnitExists("target") then |
||
233 | self.spell = spell |
||
234 | self.target = UnitName("target") |
||
235 | end |
||
236 | end |
||
237 | end |
||
238 | |||
239 | function oRAPResurrection:UseAction( a1, a2, a3) |
||
240 | self.hooks["UseAction"](a1, a2, a3) |
||
241 | |||
242 | G:Erase() |
||
243 | G:SetAction(a1) |
||
244 | local spellname = G:GetLine(1) |
||
245 | |||
246 | self.spell = spellname |
||
247 | -- Test to see if this is a macro |
||
248 | if GetActionText(a1) or not self.spell then |
||
249 | return |
||
250 | end |
||
251 | |||
252 | if SpellIsTargeting() then |
||
253 | -- Spell is waiting for a target |
||
254 | return |
||
255 | elseif a3 then |
||
256 | -- Spell is being cast on the player |
||
257 | self.target = UnitName("player") |
||
258 | elseif UnitExists("target") then |
||
259 | -- Spell is being cast on the current target |
||
260 | self.target = UnitName("target") |
||
261 | end |
||
262 | end |
||
263 | |||
264 | function oRAPResurrection:SpellTargetUnit( a1 ) |
||
265 | local shallTargetUnit |
||
266 | if SpellIsTargeting() then |
||
267 | shallTargetUnit = true |
||
268 | end |
||
269 | |||
270 | self.hooks["SpellTargetUnit"](a1) |
||
271 | |||
272 | if shallTargetUnit and self.spell and not SpellIsTargeting() then |
||
273 | self.target = UnitName(a1) |
||
274 | end |
||
275 | end |
||
276 | |||
277 | function oRAPResurrection:SpellStopTargeting() |
||
278 | self.hooks["SpellStopTargeting"]() |
||
279 | self.spell = nil |
||
280 | self.target = nil |
||
281 | end |
||
282 | |||
283 | function oRAPResurrection:TargetUnit( a1 ) |
||
284 | self.hooks["TargetUnit"](a1) |
||
285 | |||
286 | if self.spell and UnitExists(a1) then |
||
287 | self.target = UnitName(a1) |
||
288 | end |
||
289 | end |
||
290 | |||
291 | function oRAPResurrection:WorldFrameOnMouseDown() |
||
292 | if self.spell and UnitName("mouseover") then |
||
293 | self.target = UnitName("mouseover") |
||
294 | elseif self.spell and GameTooltipTextLeft1:IsVisible() then |
||
295 | local _, _, name = string.find(GameTooltipTextLeft1:GetText(), L["^Corpse of (.+)$"]) |
||
296 | if ( name ) then |
||
297 | self.target = name; |
||
298 | end |
||
299 | end |
||
300 | self.hooks[WorldFrame]["OnMouseDown"]() |
||
301 | end |
||
302 |