vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 FORMS_EN = {"Bear Form", "Cat Form", "Moonkin Form", "Travel Form", "Aquatic Form"}
2 PROWL_EN = "Prowl"
3 CHARG_EN = "Feral Charge"
4  
5 FORMS_FR = {"Forme d\226\128\153ours", "Forme de f\195\169lin", "Forme de s\195\169l\195\169nien", "Forme de voyage", "Forme aquatique"}
6 PROWL_FR = "R\195\180der"
7 CHARG_FR = "Charge farouche"
8  
9 FORMS_DE = {"B\195\164rengestalt", "Katzengestalt", "Moonkingestalt", "Reisegestalt", "Wassergestalt"}
10 PROWL_DE = "Schleichen"
11 CHARG_DE = "Wilde Attacke"
12  
13 Human = "human"
14  
15 PROWL = "\Ability_Ambush"
16  
17 Prowler_Forms = {}
18  
19 local maxspells
20 local prowl_id
21 local charg_id
22 local prev_ab
23 local locked
24 local charg_toggle
25  
26 function SearchForm(form)
27 form = string.lower(form)
28 local bear = string.lower(Bear)
29 if (GetLocale() == 'frFR') then
30 if string.find(bear, form) then
31 form = bear
32 end
33 else
34 if string.find(form, bear) then
35 form = bear
36 end
37 end
38 return Prowler_Forms[form].pos
39 end
40  
41 function CurrentForm()
42 return Prowler_Forms["current"]
43 end
44  
45 local function ActiveForm()
46 local i = 1
47 while (i <= GetNumShapeshiftForms()) do
48 local _, name, active, castable = GetShapeshiftFormInfo(i)
49 if active then
50 return name
51 end
52 i = i + 1
53 end
54 return Human
55 end
56  
57 local function Init_Forms_Table()
58 for i = 1, getn(FORMS) do
59 local form = string.lower(FORMS[i])
60 Prowler_Forms[form] = {name = "", pos = 0}
61 end
62 end
63  
64 local function Create_Forms_Table()
65 local i = 1;
66 Prowler_Forms["current"] = string.lower(Human)
67 while (i <= GetNumShapeshiftForms()) do
68 local _, name1, active1 = GetShapeshiftFormInfo(i);
69 name1 = string.lower(name1)
70 local j = 0
71 if (GetLocale() == 'frFR') then
72 repeat
73 j = j + 1
74 form = string.lower(FORMS[j])
75 until (string.find(form,name1) or j >= getn(FORMS))
76 if (string.find(form,name1)) then
77 Prowler_Forms[form] = {name = form, pos = i}
78 if (active1) then
79 Prowler_Forms["current"] = form
80 end
81 end
82 else
83 repeat
84 j = j + 1
85 form = string.lower(FORMS[j])
86 until (string.find(name1,form) or j >= getn(FORMS))
87 if (string.find(name1,form)) then
88 Prowler_Forms[form] = {name = form, pos = i}
89 if (active1) then
90 Prowler_Forms["current"] = form
91 end
92 end
93 end
94 i = i + 1
95 end
96 end
97  
98 local function Update_Forms_Table()
99 form = string.lower(ActiveForm())
100 local bear = string.lower(Bear)
101 if (GetLocale() == 'frFR') then
102 if string.find(bear, form) then
103 form = bear
104 end
105 else
106 if string.find(form, bear) then
107 form = bear
108 end
109 end
110 Prowler_Forms["current"] = string.lower(form);
111 end
112  
113 local function FindProwl()
114 local i = 0
115 while GetPlayerBuffTexture(i) do
116 local icon = GetPlayerBuffTexture(i)
117 if (string.find(icon,PROWL) )then
118 return true
119 end
120 i = i + 1
121 if i > 50 then break end
122 end
123 return false
124 end
125  
126 local function GetNumBuffs()
127 local i = 0
128 while GetPlayerBuffTexture(i) do
129 i = i + 1
130 end
131 return i
132 end
133  
134 local function MaxSpells()
135 local i = 1
136 local total_spells = 0
137 local num_tabs = GetNumSpellTabs()
138 while (i <= num_tabs) do
139 local _,_,_,numSpells = GetSpellTabInfo(i)
140 total_spells = total_spells + numSpells
141 i = i + 1;
142 end
143 return total_spells
144 end
145  
146 local function SearchBestSpell(msg)
147 local i = 0
148 local found = false
149 while (not found) do
150 i = i + 1
151 name = GetSpellName(i,'spell')
152 if (name == msg) then
153 found = true
154 end
155 if (i > maxspells) then
156 break
157 end
158 end
159 if (not found) then
160 return -1
161 end
162 local j = i
163 local best_spell = false
164 while (not best_spell) do
165 local name2,_ = GetSpellName(j+1,'spell')
166 if (msg == name2) then
167 j = j + 1
168 else
169 best_spell = true
170 end
171 end
172 return j
173 end
174  
175 local function Prowl_Print(msg)
176 if (not DEFAULT_CHAT_FRAME) then
177 return
178 end
179 DEFAULT_CHAT_FRAME:AddMessage(msg)
180 end
181  
182 function Prowler_OnLoad()
183 _,lclass = UnitClass("player")
184 if (lclass ~= "DRUID") then
185 return
186 end
187  
188 Prowl = PROWL_EN
189 Charg = CHARG_EN
190 Bear = string.lower(FORMS_EN[1])
191 Cat = string.lower(FORMS_EN[2])
192 Moon = string.lower(FORMS_EN[3])
193 Travel = string.lower(FORMS_EN[4])
194 Aqua = string.lower(FORMS_EN[5])
195 FORMS = FORMS_EN
196 if (GetLocale() == 'frFR') then
197 Prowl = PROWL_FR
198 Charg = CHARG_FR
199 Bear = string.lower(FORMS_FR[1])
200 Cat = string.lower(FORMS_FR[2])
201 Moon = string.lower(FORMS_FR[3])
202 Travel = string.lower(FORMS_FR[4])
203 Aqua = string.lower(FORMS_FR[5])
204 FORMS = FORMS_FR
205 elseif (GetLocale() == 'deDE') then
206 Prowl = PROWL_DE
207 Charg = CHARG_DE
208 Bear = string.lower(FORMS_DE[1])
209 Cat = string.lower(FORMS_DE[2])
210 Moon = string.lower(FORMS_DE[3])
211 Travel = string.lower(FORMS_DE[4])
212 Aqua = string.lower(FORMS_DE[5])
213 FORMS = FORMS_DE
214 end
215  
216 BINDING_HEADER_Prowler = 'Prowler'
217 BINDING_NAME_Prowler_Aquatic = 'Aquatic Form'
218 BINDING_NAME_Prowler_Bear = 'Bear & Charge'
219 BINDING_NAME_Prowler_Prowl = 'Cat & Prowl'
220 BINDING_NAME_Prowler_Moon = 'Moonkin Form'
221 BINDING_NAME_Prowler_Human = 'Humanoid'
222 BINDING_NAME_Prowler_Travel = 'Travel Form'
223 BINDING_NAME_Prowler_Best = 'Best From'
224  
225 this:RegisterEvent("VARIABLES_LOADED");
226 this:RegisterEvent("PLAYER_AURAS_CHANGED");
227 this:RegisterEvent('SPELLS_CHANGED');
228  
229 SLASH_PROWLER1 = "/Prowler"
230 SlashCmdList["PROWLER"] = function(msg)
231 Prowler_Cmd(msg);
232 end
233  
234 maxspells = MaxSpells()
235 prowl_id = SearchBestSpell(Prowl);
236 charg_id = SearchBestSpell(Charg);
237 Init_Forms_Table()
238 Create_Forms_Table()
239 Update_Forms_Table()
240  
241 tinsert(UISpecialFrames,"Prowler1");
242 end
243  
244 function Prowler_OnClick1(arg1)
245 if (Prowler1_CheckButton1:GetChecked()) then
246 toggle = true;
247 Prowler1_CheckButton1Text:SetText("Prowler Enabled")
248 Prowler1_CheckButton1Text:SetTextColor(0,1,0)
249 else
250 toggle = false;
251 Prowler1_CheckButton1Text:SetText("Prowler Disabled")
252 Prowler1_CheckButton1Text:SetTextColor(1,0,0)
253 end
254 end
255  
256 function Prowler_OnClick2(arg1)
257 local frame = getglobal("Prowler1")
258 if (Prowler1_CheckButton2:GetChecked()) then
259 frame.isLocked = 1;
260 locked = 1;
261 Prowler1_CheckButton2Text:SetText("Prowler Locked")
262 Prowler1_CheckButton2Text:SetTextColor(0,1,0)
263 else
264 frame.isLocked = 0;
265 locked = 0;
266 Prowler1_CheckButton2Text:SetText("Prowler Unlocked")
267 Prowler1_CheckButton2Text:SetTextColor(1,0,0)
268 end
269 end
270  
271 function Prowler_OnClick3(arg1)
272 if (Prowler1_CheckButton3:GetChecked()) then
273 prev = true
274 Prowler1_CheckButton3Text:SetText("Using Last AB")
275 Prowler1_CheckButton3Text:SetTextColor(0,1,0)
276 else
277 prev = false
278 Prowler1_CheckButton3Text:SetText("Using Main AB")
279 Prowler1_CheckButton3Text:SetTextColor(1,0,0)
280 end
281 end
282  
283 function Prowler_OnClick4(arg1)
284 if (Prowler1_CheckButton4:GetChecked()) then
285 MA_toggle = true
286 Prowler1_CheckButton4Text:SetText("MoveAnything! Fix on")
287 Prowler1_CheckButton4Text:SetTextColor(0,1,0)
288 else
289 MA_toggle = false
290 Prowler1_CheckButton4Text:SetText("MoveAnything! Fix off")
291 Prowler1_CheckButton4Text:SetTextColor(1,0,0)
292 end
293 end
294  
295 function Prowler_OnClick5(arg1)
296 if (Prowler1_CheckButton5:GetChecked()) then
297 charg_toggle = true
298 Prowler1_CheckButton5Text:SetText("Bear & Charge")
299 Prowler1_CheckButton5Text:SetTextColor(0,1,0)
300 else
301 charg_toggle = false
302 Prowler1_CheckButton5Text:SetText("Only Bear")
303 Prowler1_CheckButton5Text:SetTextColor(1,0,0)
304 end
305 end
306  
307 function Prowler_InitSlider1(slider,num)
308 sl = getglobal(slider)
309 if (sl:GetName() == "Prowler1_Slider1") then
310 sl.tooltipText = "Set the Main Actionbar";
311 elseif (sl:GetName() == "Prowler1_Slider2") then
312 sl.tooltipText = "Set the Prowl Actionbar";
313 end
314 getglobal(slider .. "Low"):SetText("1");
315 getglobal(slider .. "High"):SetText("7");
316 getglobal(sl:GetName()):SetValue(num);
317 getglobal(slider .. "Text"):SetText(sl:GetValue());
318 end
319  
320 function Prowler_InitSlider2(slider,num)
321 sl = getglobal(slider)
322 if (sl:GetName() == "Prowler1_Slider3") then
323 sl.tooltipText = "Set how the Cat Keybind will work";
324 end
325 getglobal(slider .. "Low"):SetText("");
326 getglobal(slider .. "High"):SetText("");
327 getglobal(sl:GetName()):SetValue(num);
328 if (cat_mode == 1) then
329 getglobal(sl:GetName().."Text"):SetText("Cat Only");
330 elseif (cat_mode == 2) then
331 getglobal(sl:GetName().."Text"):SetText("Prowl Only");
332 elseif (cat_mode == 3) then
333 getglobal(sl:GetName().."Text"):SetText("Prowl and Unprowl");
334 end
335 end
336  
337 function Prowler_Prowl()
338 if CurrentForm() == string.lower(Cat) then
339 if (cat_mode == 2) then
340 if (GetSpellCooldown(prowl_id,1) == 0) and (not FindProwl()) then
341 CastSpell(prowl_id,1)
342 end
343 elseif (cat_mode == 3) then
344 if (GetSpellCooldown(prowl_id,1) == 0) or FindProwl() then
345 CastSpell(prowl_id,1)
346 end
347 end
348 else
349 Shapeshift(Cat)
350 end
351 end
352  
353 function Prowler_Bear()
354 if CurrentForm() == string.lower(Bear) then
355 if (charg_id ~= -1) then
356 if (GetSpellCooldown(charg_id,1) == 0) and (charg_toggle == true) then
357 CastSpell(charg_id,1)
358 end
359 end
360 else
361 Shapeshift(Bear)
362 end
363 end
364  
365 function Shapeshift(form)
366 local i = 1
367 local thing
368 form = string.lower(form)
369 local current = string.lower(CurrentForm())
370 if (UnitIsMounted("player")) then
371 Dismount()
372 else
373 if (not string.find(current,form)) then
374 if (CurrentForm() == Human) then
375 thing = SearchForm(form)
376 if (thing ~= 0) then
377 CastShapeshiftForm(thing)
378 else
379 Prowl_Print(form .. ' not found')
380 end
381 else
382 CastShapeshiftForm(SearchForm(CurrentForm()))
383 end
384 end
385 end
386 end
387  
388 function Prowler_BestForm()
389 if (MirrorTimer1:IsVisible()) then
390 if (CurrentForm() ~= Aqua) then
391 Shapeshift(Aqua)
392 end
393 else
394 if (CurrentForm() ~= Travel) then
395 Shapeshift(Travel)
396 end
397 end
398 end
399  
400 local function Shapeshifted()
401 local active = string.lower(ActiveForm())
402 local bear = string.lower(Bear)
403 local current = string.lower(CurrentForm())
404 if (GetLocale() == 'frFR') then
405 if string.find(bear, active) then
406 active = bear
407 end
408 else
409 if string.find(active, bear) then
410 active = bear
411 end
412 end
413  
414 if (active ~= current) then
415 return true
416 else
417 return false
418 end
419 end
420  
421 function Prowler_OnEvent(arg1)
422 if (event == 'VARIABLES_LOADED') then
423 if (not main_ab) then
424 main_ab = 1
425 end
426 if (not prowl_ab) then
427 prowl_ab = 2
428 end
429 if (not locked) then
430 locked = 1
431 end
432 if (not prev) then
433 prev = false;
434 end
435 if (not MA_toggle) then
436 MA_toggle = false
437 end
438 if (not charg_toggle) then
439 charg_toggle = true
440 end
441 if (not cat_mode) then
442 cat_mode = 3
443 end
444 prev_ab = main_ab
445 Prowler_InitSlider1("Prowler1_Slider1",main_ab);
446 Prowler_InitSlider1("Prowler1_Slider2",prowl_ab);
447 Prowler_InitSlider2("Prowler1_Slider3",cat_mode);
448 if (locked == 1) then
449 Prowler1.isLocked = 1;
450 Prowler1_CheckButton2Text:SetText("Prowler Locked")
451 Prowler1_CheckButton2Text:SetTextColor(0,1,0)
452 else
453 Prowler1.isLocked = 0;
454 Prowler1_CheckButton2Text:SetText("Prowler Unlocked")
455 Prowler1_CheckButton2Text:SetTextColor(1,0,0)
456 end
457 if (prev == true) then
458 Prowler1_CheckButton3Text:SetText("Using Last AB")
459 Prowler1_CheckButton3Text:SetTextColor(0,1,0)
460 else
461 Prowler1_CheckButton3Text:SetText("Using Main AB")
462 Prowler1_CheckButton3Text:SetTextColor(1,0,0)
463 end
464 if (toggle == true) then
465 Prowler1_CheckButton1Text:SetText("Prowler Enabled")
466 Prowler1_CheckButton1Text:SetTextColor(0,1,0)
467 else
468 Prowler1_CheckButton1Text:SetText("Prowler Disabled")
469 Prowler1_CheckButton1Text:SetTextColor(1,0,0)
470 end
471 if (MA_toggle == true) then
472 Prowler1_CheckButton4Text:SetText("MoveAnything! Fix on")
473 Prowler1_CheckButton4Text:SetTextColor(0,1,0)
474 else
475 Prowler1_CheckButton4Text:SetText("MoveAnything! Fix off")
476 Prowler1_CheckButton4Text:SetTextColor(1,0,0)
477 end
478 if (charg_toggle == true) then
479 Prowler1_CheckButton5Text:SetText("Bear & Charge")
480 Prowler1_CheckButton5Text:SetTextColor(0,1,0)
481 else
482 Prowler1_CheckButton5Text:SetText("Bear Only")
483 Prowler1_CheckButton5Text:SetTextColor(1,0,0)
484 end
485  
486 Prowler1_CheckButton1:SetChecked(toggle);
487 Prowler1_CheckButton2:SetChecked(locked);
488 Prowler1_CheckButton3:SetChecked(prev);
489 Prowler1_CheckButton4:SetChecked(MA_toggle);
490 Prowler1_CheckButton5:SetChecked(charg_toggle);
491 Prowl_Print('Prowler Loaded. Main bar = ' .. main_ab .. ' Prowling bar = ' .. prowl_ab)
492 end
493 if (event == 'PLAYER_AURAS_CHANGED') then
494 num_buff_1 = GetNumBuffs()
495 if (num_buff_1 == num_buff_2) then
496 buffed = true
497 end
498 if (Shapeshifted() == true) then
499 Update_Forms_Table()
500 shifted = true
501 if (CurrentForm() == string.lower(Cat)) or (CurrentForm() == string.lower(Bear)) then
502 prev_ab = CURRENT_ACTIONBAR_PAGE
503 end
504 end
505 if (toggle == true) then
506 if (CurrentForm() == string.lower(Cat)) then
507 if (FindProwl()) then
508 if (CURRENT_ACTIONBAR_PAGE ~= prowl_ab) then
509 CURRENT_ACTIONBAR_PAGE = prowl_ab;
510 ChangeActionBarPage();
511 end
512 else
513 if (CURRENT_ACTIONBAR_PAGE ~= 1) then
514 CURRENT_ACTIONBAR_PAGE = 1;
515 ChangeActionBarPage();
516 end
517 end
518 elseif (CurrentForm() == Human) then
519 if (prev == true) then
520 if (CURRENT_ACTIONBAR_PAGE ~= prev_ab) and (shifted) then
521 CURRENT_ACTIONBAR_PAGE = prev_ab;
522 ChangeActionBarPage();
523 end
524 else
525 if (CURRENT_ACTIONBAR_PAGE ~= main_ab) and (shifted) then
526 CURRENT_ACTIONBAR_PAGE = main_ab;
527 ChangeActionBarPage();
528 end
529 end
530 if (MA_toggle == true) and buffed then
531 ChangeActionBarPage()
532 end
533 shifted = false
534 elseif (CurrentForm() == string.lower(Bear)) then
535 if (CURRENT_ACTIONBAR_PAGE ~= 1) then
536 CURRENT_ACTIONBAR_PAGE = 1;
537 ChangeActionBarPage();
538 end
539 end
540 end
541 num_buff_2 = GetNumBuffs()
542 buffed = false
543 end
544 if (event == 'SPELLS_CHANGED') then
545 maxspells = MaxSpells();
546 prowl_id = SearchBestSpell(Prowl);
547 charg_id = SearchBestSpell(Charg);
548 Create_Forms_Table()
549 Update_Forms_Table()
550 end
551 end
552  
553 function Prowler_Cmd(msg)
554 local frame = getglobal("Prowler1")
555 if (frame) then
556 if( frame:IsVisible() ) then
557 frame:Hide();
558 else
559 frame:Show();
560 end
561 end
562 end