vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 TheoryCraft_Data.EquipEffects = {}
2 local _, class = UnitClass("player")
3  
4 local function findpattern(text, pattern, start)
5 if (text and pattern and (string.find(text, pattern, start))) then
6 return string.sub(text, string.find(text, pattern, start))
7 else
8 return ""
9 end
10 end
11  
12 local function TheoryCraft_AddEquipEffect (slotname, test, data, equippedsets)
13 if (test ~= "test") then
14 TheoryCraftTooltip:SetOwner(UIParent,"ANCHOR_NONE")
15 TheoryCraftTooltip:SetInventoryItem ("player", GetInventorySlotInfo(slotname.."Slot"))
16 end
17 if (getglobal("TheoryCraftTooltipTextLeft1") == nil) then
18 return
19 end
20 local ltext = getglobal(TheoryCraftTooltip:GetName().."TextLeft1"):GetText()
21 if (data["name"] == ltext) and (data["numlines"] == TheoryCraftTooltip:NumLines()) then
22 return
23 end
24 for k,v in pairs(data) do
25 data[k] = nil
26 end
27 if data["procs"] == nil then data["procs"] = {} end
28 for k,v in pairs(equippedsets) do
29 equippedsets[k] = nil
30 end
31 data["name"] = ltext
32 data["numlines"] = TheoryCraftTooltip:NumLines()
33 local index = 2
34 ltext = getglobal("TheoryCraftTooltipTextLeft"..index)
35 if ltext then
36 ltext = ltext:GetText()
37 end
38 rtext = getglobal("TheoryCraftTooltipTextRight"..index)
39 if rtext then
40 if (not getglobal("TheoryCraftTooltipTextRight"..index):IsVisible()) then
41 rtext = nil
42 else
43 rtext = rtext:GetText()
44 end
45 end
46 local s2 = 1
47 local is = 1
48 local i2 = 1
49 local ignoreline = false
50 local startpos, endpos, found, foundme
51 while (ltext ~= nil) do
52 if strfind(ltext, TheoryCraft_Locale.Set) then
53 local numpieces = tonumber(findpattern(findpattern(ltext, TheoryCraft_Locale.Set), "%d+"))
54 while (string.len(ltext) > 0) and (string.sub(ltext, string.len(ltext), string.len(ltext)) == " ") do
55 ltext = string.sub(ltext, 1, string.len(ltext)-1)
56 end
57 while (string.len(ltext) > 0) and (string.sub(ltext, string.len(ltext), string.len(ltext)) ~= " ") do
58 ltext = string.sub(ltext, 1, string.len(ltext)-1)
59 end
60 while (string.len(ltext) > 0) and (string.sub(ltext, string.len(ltext), string.len(ltext)) == " ") do
61 ltext = string.sub(ltext, 1, string.len(ltext)-1)
62 end
63 local setname = ltext
64 equippedsets[setname] = (equippedsets[setname] or 0)+1
65 if TheoryCraft_SetBonuses[setname] == nil then
66 TheoryCraft_SetBonuses[setname] = {}
67 end
68 local foundbonuses = {}
69 local idx = 1
70 index = index + 1
71 ltext = getglobal(TheoryCraftTooltip:GetName().."TextLeft"..index)
72 while (ltext ~= nil) do
73 ltext = ltext:GetText()
74 if ltext == nil then break end
75 if strfind(string.sub(ltext, 1, 4), "%d+") then
76 foundbonuses[idx] = {}
77 foundbonuses[idx]["pieces"] = tonumber(findpattern(ltext, "%d+"))
78 ltext = string.sub(ltext, 5+string.len(TheoryCraft_Locale.ID_Set))
79 foundbonuses[idx]["text"] = ltext
80 idx = idx + 1
81 end
82 index = index + 1
83 ltext = getglobal(TheoryCraftTooltip:GetName().."TextLeft"..index)
84 end
85 local newbonuses = {}
86 i = 1
87 for k,v in TheoryCraft_SetBonuses[setname] do
88 if (v["pieces"] <= numpieces) then
89 newbonuses[i] = v
90 i = i + 1
91 end
92 end
93 for k,v in pairs(foundbonuses) do
94 newbonuses[i] = v
95 i = i + 1
96 end
97 TheoryCraft_SetBonuses[setname] = newbonuses
98 break
99 end
100 if (strfind(ltext, "^"..TheoryCraft_Locale.ID_Equip)) then
101 foundme = false
102 for k, v in pairs(TheoryCraft_Equips) do
103 if (v.slot == nil) or (v.slot == slotname) then
104 if ((foundme == false) or (v.me == nil)) then
105 _, start, found = strfind(ltext, v.text)
106 if _ then
107 if v.proc then
108 i2 = 1
109 if data["procs"] == nil then
110 data["procs"] = {}
111 end
112 while data["procs"][i2] do i2 = i2 + 1 end
113 data["procs"][i2] = {}
114 data["procs"][i2].amount = v.amount
115 data["procs"][i2].proc = v.proc
116 data["procs"][i2].duration = v.duration
117 data["procs"][i2].exact = v.exact
118 data["procs"][i2].type = v.type
119 else
120 if (v.amount) then
121 data[v.type] = (data[v.type] or 0) + v.amount
122 else
123 data[v.type] = (data[v.type] or 0) + tonumber(found)
124 end
125 if (v.me) then
126 foundme = true
127 end
128 end
129 end
130 end
131 end
132 end
133 else
134 foundme = false
135 if rtext then
136 for k, v in pairs(TheoryCraft_EquipEveryRight) do
137 if (v.slot == nil) or (v.slot == slotname) then
138 if (foundme == false) or (v.me == nil) then
139 _, start, found = strfind(rtext, v.text)
140 if _ then
141 if (v.amount) then
142 data[v.type] = (data[v.type] or 0) + v.amount
143 else
144 data[v.type] = (data[v.type] or 0) + found
145 end
146 if (v.me) then foundme = true end
147 end
148 end
149 end
150 end
151 end
152 ignoreline = false
153 for k, v in pairs(TheoryCraft_IgnoreLines) do
154 if strfind(ltext, v) then
155 ignoreline = true
156 break
157 end
158 end
159 if not ignoreline then
160 foundme = false
161 for k, v in pairs(TheoryCraft_EquipEveryLine) do
162 if (v.slot == nil) or (v.slot == slotname) then
163 if (not foundme) or (not v.me) then
164 _, start, found = strfind(ltext, v.text)
165 if _ then
166 if (v.amount) then
167 data[v.type] = (data[v.type] or 0) + v.amount
168 else
169 data[v.type] = (data[v.type] or 0) + found
170 end
171 if (v.me) then foundme = true end
172 end
173 end
174 end
175 end
176 end
177 end
178  
179 index = index + 1
180 ltext = getglobal("TheoryCraftTooltipTextLeft"..index)
181 rtext = getglobal("TheoryCraftTooltipTextRight"..index)
182 if ltext then
183 ltext = ltext:GetText()
184 end
185 if rtext then
186 if (not getglobal("TheoryCraftTooltipTextRight"..index):IsVisible()) then
187 rtext = nil
188 else
189 rtext = rtext:GetText()
190 end
191 end
192 end
193 TheoryCraftTooltip:ClearLines()
194 return true
195 end
196  
197 function TheoryCraft_CombineTables(tab1, tab2)
198 if tab2 == nil then tab2 = tab1 return end
199 for k,v in pairs(tab1) do
200 if type(v) == "table" then
201 tab2[k] = TheoryCraft_CombineTables(v, tab2[k])
202 elseif tonumber(v) and tonumber(tab2[k] or 0) then
203 tab2[k] = v + (tab2[k] or 0)
204 end
205 end
206 end
207  
208 local function TheoryCraft_AddAllEquips(outfit, force)
209 local i2 = 1
210 local resetall = true
211 if not force and UnitAffectingCombat("player") then
212 resetall = false
213 end
214 if (TheoryCraft_Outfits[outfit]) == nil then
215 outfit = 1
216 end
217 if TheoryCraft_Data["SlotData"] == nil then
218 TheoryCraft_Data["SlotData"] = {}
219 TheoryCraft_Data["SetData"] = {}
220 end
221 TheoryCraft_Data.OldOutfit = outfit
222 if TheoryCraft_Data.StatsToDo == nil then
223 TheoryCraft_Data.StatsToDo = {}
224 end
225 TheoryCraft_DeleteTable(TheoryCraft_Data.StatsToDo)
226 for k, v in pairs(TheoryCraft_Outfits[outfit].wear) do
227 TheoryCraft_Data.StatsToDo[v] = true
228 if TheoryCraft_Data["SlotData"][v] == nil then
229 TheoryCraft_Data["SlotData"][v] = {}
230 TheoryCraft_Data["SlotData"][v]["procs"] = {}
231 end
232 if TheoryCraft_Data["SetData"][v] == nil then
233 TheoryCraft_Data["SetData"][v] = {}
234 end
235 if (v == "MainHand") or (v == "SecondaryHand") or (v == "Ranged") or (v == "Ammo") then
236 changed = TheoryCraft_AddEquipEffect(v, nil, TheoryCraft_Data["SlotData"][v], TheoryCraft_Data["SetData"][v])
237 elseif (resetall) then
238 changed = TheoryCraft_AddEquipEffect(v, nil, TheoryCraft_Data["SlotData"][v], TheoryCraft_Data["SetData"][v])
239 end
240 end
241 if not TheoryCraft_Data.EquipEffects then
242 TheoryCraft_Data.EquipEffects = {}
243 end
244 if not TheoryCraft_Data.EquipedSets then
245 TheoryCraft_Data.EquippedSets = {}
246 end
247 TheoryCraft_DeleteTable(TheoryCraft_Data.EquipEffects)
248 TheoryCraft_DeleteTable(TheoryCraft_Data.EquippedSets)
249 for k, v in pairs(TheoryCraft_Data.StatsToDo) do
250 TheoryCraft_CombineTables(TheoryCraft_Data.SlotData[k], TheoryCraft_Data.EquipEffects)
251 TheoryCraft_CombineTables(TheoryCraft_Data.SetData[k], TheoryCraft_Data.EquippedSets)
252 end
253 data = TheoryCraft_Data.EquipEffects
254 local i = 1
255 if (outfit == 2) then
256 TheoryCraft_Outfits[outfit].meleecritchance = 0
257 TheoryCraft_Outfits[outfit].formattackpower = 0
258 TheoryCraft_Outfits[outfit].rangedattackpower = 0
259 TheoryCraft_Outfits[outfit].attackpower = 0
260 TheoryCraft_Outfits[outfit].strength = 0
261 TheoryCraft_Outfits[outfit].agility = 0
262 TheoryCraft_Outfits[outfit].stamina = 0
263 TheoryCraft_Outfits[outfit].intellect = 0
264 TheoryCraft_Outfits[outfit].spirit = 0
265 TheoryCraft_Outfits[outfit].totalmana = 0
266 TheoryCraft_Outfits[outfit].totalhealth = 0
267 if (TheoryCraft_Settings["CustomOutfit"] == nil) then
268 TheoryCraft_Settings["CustomOutfit"] = TheoryCraft_Outfits[outfit]
269 TheoryCraft_Settings["CustomOutfit"].slots = {}
270 end
271 local k, v
272 while (TheoryCraft_SlotNames[i]) do
273 if ((TheoryCraft_SlotNames[i-1] == nil) or (TheoryCraft_SlotNames[i].slot ~= TheoryCraft_SlotNames[i-1].slot)) and (TheoryCraft_Settings["CustomOutfit"].slots[TheoryCraft_SlotNames[i].slot]) then
274 if TheoryCraft_Settings["CustomOutfit"].slots[TheoryCraft_SlotNames[i].slot] == nil then
275 TheoryCraft_Settings["CustomOutfit"].slots[TheoryCraft_SlotNames[i].slot] = {}
276 end
277 if TheoryCraft_Settings["CustomOutfit"].slots[TheoryCraft_SlotNames[i].slot]["stats"] == nil then TheoryCraft_Settings["CustomOutfit"].slots[TheoryCraft_SlotNames[i].slot]["stats"] = {} end
278 local a = TheoryCraft_Settings["CustomOutfit"].slots[TheoryCraft_SlotNames[i].slot]["stats"]
279 TheoryCraft_Outfits[outfit].meleecritchance = TheoryCraft_Outfits[outfit].meleecritchance+(a.meleecritchance or 0)
280 TheoryCraft_Outfits[outfit].formattackpower = TheoryCraft_Outfits[outfit].formattackpower+(a.formattackpower or 0)
281 TheoryCraft_Outfits[outfit].rangedattackpower = TheoryCraft_Outfits[outfit].rangedattackpower+(a.rangedattackpower or 0)
282 TheoryCraft_Outfits[outfit].attackpower = TheoryCraft_Outfits[outfit].attackpower+(a.attackpower or 0)
283 TheoryCraft_Outfits[outfit].strength = TheoryCraft_Outfits[outfit].strength+(a.strength or 0)
284 TheoryCraft_Outfits[outfit].agility = TheoryCraft_Outfits[outfit].agility+(a.agility or 0)
285 TheoryCraft_Outfits[outfit].stamina = TheoryCraft_Outfits[outfit].stamina+(a.stamina or 0)
286 TheoryCraft_Outfits[outfit].intellect = TheoryCraft_Outfits[outfit].intellect+(a.intellect or 0)
287 TheoryCraft_Outfits[outfit].spirit = TheoryCraft_Outfits[outfit].spirit+(a.spirit or 0)
288 TheoryCraft_Outfits[outfit].totalmana = TheoryCraft_Outfits[outfit].totalmana+(a.totalmana or 0)
289 TheoryCraft_Outfits[outfit].totalhealth = TheoryCraft_Outfits[outfit].totalhealth+(a.totalhealth or 0)
290 if a.settype then
291 TheoryCraft_Data.EquippedSets[a.settype] = (TheoryCraft_Data.EquippedSets[a.settype] or 0) + 1
292 end
293 a = TheoryCraft_Settings["CustomOutfit"].slots[TheoryCraft_SlotNames[i].slot]["data"]
294 if type(a) == "table" then
295 for k,v in pairs(a) do
296 if k ~= "procs" then
297 if tonumber(v) then
298 data[k] = (tonumber(data[k]) or 0)+v
299 end
300 else
301 for k,v in pairs(a["procs"]) do
302 i2 = 1
303 if data["procs"] == nil then
304 data["procs"] = {}
305 end
306 while data["procs"][i2] do i2 = i2 + 1 end
307 data["procs"][i2] = {}
308 data["procs"][i2].amount = v.amount
309 data["procs"][i2].proc = v.proc
310 data["procs"][i2].duration = v.duration
311 data["procs"][i2].exact = v.exact
312 data["procs"][i2].type = v.type
313 end
314 end
315 end
316 end
317 end
318 i = i + 1
319 end
320  
321 local returndata
322 for k,count in pairs(TheoryCraft_Data.EquippedSets) do
323 if TheoryCraft_SetBonuses[k] then
324 for k,v in pairs(TheoryCraft_SetBonuses[k]) do
325 if (v["pieces"] <= count) then
326 returndata = {}
327 returndata = TheoryCraft_DequipLine(v["text"], returndata)
328 for k,v in pairs(returndata) do
329 TheoryCraft_Outfits[outfit][k] = (TheoryCraft_Outfits[outfit][k] or 0) - v
330 end
331 returndata = {}
332 returndata = TheoryCraft_DequipSpecial(v["text"], returndata)
333 for k,v in pairs(returndata) do
334 data[k] = (data[k] or 0) - v
335 end
336 end
337 end
338 end
339 end
340 else
341 while (TheoryCraft_Outfits[outfit].newstat[i]) do
342 if TheoryCraft_Outfits[outfit].newstat[i].proc then
343 i2 = 1
344 if data["procs"] == nil then
345 data["procs"] = {}
346 end
347 while data["procs"][i2] do i2 = i2 + 1 end
348 data["procs"][i2] = {}
349 data["procs"][i2].amount = TheoryCraft_Outfits[outfit].newstat[i].amount
350 data["procs"][i2].proc = TheoryCraft_Outfits[outfit].newstat[i].proc
351 data["procs"][i2].duration = TheoryCraft_Outfits[outfit].newstat[i].duration
352 data["procs"][i2].exact = TheoryCraft_Outfits[outfit].newstat[i].exact
353 data["procs"][i2].type = TheoryCraft_Outfits[outfit].newstat[i].type
354 else
355 data[TheoryCraft_Outfits[outfit].newstat[i].type] = (data[TheoryCraft_Outfits[outfit].newstat[i].type] or 0) + TheoryCraft_Outfits[outfit].newstat[i].amount
356 end
357 i = i + 1
358 end
359 for k,v in pairs(TheoryCraft_Locale.SetTranslator) do
360 if v.id == TheoryCraft_Outfits[outfit].name then
361 if TheoryCraft_SetBonuses[v.translated] then
362 local returndata
363 TheoryCraft_Data.EquippedSets[v.translated] = 100
364 for k,v in pairs(TheoryCraft_SetBonuses[v.translated]) do
365 returndata = {}
366 returndata = TheoryCraft_DequipSpecial(v["text"], returndata)
367 for k,v in pairs(returndata) do
368 data[k] = (data[k] or 0) - v
369 end
370 end
371 end
372 break
373 end
374 end
375 end
376 local i2, ltext, _, start, found, foundme
377 for k,count in pairs(TheoryCraft_Data.EquippedSets) do
378 if TheoryCraft_SetBonuses[k] then
379 foundme = false
380 for k,v in pairs(TheoryCraft_SetBonuses[k]) do
381 if (v["pieces"] <= count) then
382 ltext = v["text"]
383 foundme = false
384 for k, v in pairs(TheoryCraft_Equips) do
385 if (v.slot == nil) or (v.slot == slotname) then
386 if ((foundme == false) or (v.me == nil)) then
387 _, start, found = strfind(ltext, v.text)
388 if _ then
389 if v.proc then
390 i2 = 1
391 if data["procs"] == nil then
392 data["procs"] = {}
393 end
394 while data["procs"][i2] do i2 = i2 + 1 end
395 data["procs"][i2] = {}
396 data["procs"][i2].amount = v.amount
397 data["procs"][i2].proc = v.proc
398 data["procs"][i2].duration = v.duration
399 data["procs"][i2].exact = v.exact
400 data["procs"][i2].type = v.type
401 else
402 if (v.amount) then
403 data[v.type] = (data[v.type] or 0) + v.amount
404 else
405 data[v.type] = (data[v.type] or 0) + tonumber(found)
406 end
407 if (v.me) then
408 foundme = true
409 end
410 end
411 end
412 end
413 end
414 end
415 foundme = false
416 for k, v in pairs(TheoryCraft_Sets) do
417 if (v.slot == nil) or (v.slot == slotname) then
418 if ((foundme == false) or (v.me == nil)) then
419 _, start, found = strfind(ltext, v.text)
420 if _ then
421 if v.proc then
422 i2 = 1
423 if data["procs"] == nil then
424 data["procs"] = {}
425 end
426 while data["procs"][i2] do i2 = i2 + 1 end
427 data["procs"][i2] = {}
428 data["procs"][i2].amount = v.amount
429 data["procs"][i2].proc = v.proc
430 data["procs"][i2].duration = v.duration
431 data["procs"][i2].exact = v.exact
432 data["procs"][i2].type = v.type
433 else
434 if (v.amount) then
435 if v.amount == "n/100" then
436 data[v.type] = (data[v.type] or 0) + tonumber(found)/100
437 else
438 data[v.type] = (data[v.type] or 0) + v.amount
439 end
440 else
441 data[v.type] = (data[v.type] or 0) + tonumber(found)
442 end
443 if (v.me) then
444 foundme = true
445 end
446 end
447 end
448 end
449 end
450 end
451 end
452 end
453 end
454 end
455 end
456  
457 local old = {}
458 local old2 = {}
459  
460 function TheoryCraft_UpdateGear(arg1, dontgen, force)
461 if TheoryCraft_SetBonuses == nil then
462 TheoryCraft_SetBonuses = {}
463 end
464 if (arg1 ~= "player") then return end
465 if not force then
466 if UnitAffectingCombat("player") then
467 TheoryCraft_Data.regenaftercombat = true
468 end
469 end
470 TheoryCraft_DeleteTable(old)
471 TheoryCraft_CopyTable(TheoryCraft_Data.EquipEffects, old)
472 TheoryCraft_AddAllEquips(TheoryCraft_Data["outfit"], force)
473 if TheoryCraft_Data.EquipEffects["MeleeAPMult"] == nil then
474 TheoryCraft_Data.EquipEffects["MeleeAPMult"] = 1
475 end
476 if (dontgen == nil) then
477 TheoryCraft_DeleteTable(old2)
478 TheoryCraft_CopyTable(TheoryCraft_Data.Stats, old2)
479 TheoryCraft_DeleteTable(TheoryCraft_Data.Stats)
480 TheoryCraft_LoadStats()
481 if (TheoryCraft_IsDifferent(old, TheoryCraft_Data.EquipEffects)) or (TheoryCraft_IsDifferent(old2, TheoryCraft_Data.Stats)) then
482 TheoryCraft_GenerateAll()
483 end
484 end
485 end
486  
487  
488 function TheoryCraft_DequipLine(line, returndata)
489 local _, start, found
490 for k, v in pairs(TheoryCraft_Dequips) do
491 if strfind(line, TheoryCraft_Locale.Set) then
492 return returndata
493 end
494 _, start, found = strfind(line, v.text)
495 if found then
496 if v.type == "all" then
497 returndata["strength"] = (returndata["strength"] or 0)-found
498 returndata["agility"] = (returndata["agility"] or 0)-found
499 returndata["stamina"] = (returndata["stamina"] or 0)-found
500 returndata["intellect"] = (returndata["intellect"] or 0)-found
501 returndata["spirit"] = (returndata["spirit"] or 0)-found
502 elseif v.type == "formattackpower" then
503 returndata[v.type] = (returndata[v.type] or 0)-found
504 break
505 elseif v.type == "attackpower" then
506 returndata[v.type] = (returndata[v.type] or 0)-found
507 returndata["rangedattackpower"] = (returndata["rangedattackpower"] or 0)-found
508 break
509 else
510 returndata[v.type] = (returndata[v.type] or 0)-found
511 end
512 end
513 end
514 return returndata
515 end
516  
517 local b = TheoryCraft_SetsDequipOnly
518  
519 function TheoryCraft_DequipSpecial(line, returndata)
520 local i = 1
521 local amount
522 while (b[i]) do
523 if strfind(line, TheoryCraft_Locale.Set) then
524 return returndata
525 end
526 if string.find(line, b[i].text) then
527 if b[i].amount == "n" then
528 amount = tonumber(findpattern(findpattern(line, b[i].text), "%d+"))
529 elseif b[i].amount == "n/100" then
530 amount = tonumber(findpattern(findpattern(line, b[i].text), "%d+"))/100
531 else
532 amount = b[i].amount
533 end
534 returndata[b[i].type] = (returndata[b[i].type] or 0)-amount
535 end
536 i = i + 1
537 end
538 return returndata
539 end
540  
541 function TheoryCraft_DequipEffect (slotname, returndata, equippedsets)
542 if (slotname ~= "test") then
543 TheoryCraftTooltip:SetOwner(UIParent,"ANCHOR_NONE")
544 TheoryCraftTooltip:SetInventoryItem ("player", GetInventorySlotInfo(slotname.."Slot"))
545 end
546 local index = 1
547 local i, found
548 local ltext
549 while (getglobal("TheoryCraftTooltipTextLeft"..index) ~= nil) do
550 ltext = getglobal("TheoryCraftTooltipTextLeft"..index):GetText();
551 if (ltext == nil) then
552 break
553 end
554 if strfind(ltext, TheoryCraft_Locale.Set) then
555 if equippedsets then
556 ltext = string.sub(ltext, 1, string.find(ltext, TheoryCraft_Locale.Set)-2)
557 equippedsets[ltext] = (equippedsets[ltext] or 0)+1
558 end
559 break
560 else
561 returndata = TheoryCraft_DequipLine(ltext, returndata)
562 end
563 index = index + 1
564 end
565 TheoryCraftTooltip:ClearLines()
566 return returndata
567 end
568  
569 function TheoryCraft_AddToCustom(linkid)
570 if (TheoryCraft_Settings["CustomOutfit"] == nil) then
571 TheoryCraft_Settings["CustomOutfit"] = TheoryCraft_Outfits[3]
572 end
573 if (TheoryCraft_Settings["CustomOutfit"].slots == nil) then
574 TheoryCraft_Settings["CustomOutfit"].slots = {}
575 end
576 if (linkid == nil) or (string.find(linkid, "item:%d+:%d+:%d+:%d+") == nil) then
577 return
578 end
579 linkid = string.sub(linkid, string.find(linkid, "item:%d+:%d+:%d+:%d+"))
580 if linkid == nil then
581 return
582 end
583 TheoryCraftTooltip:SetOwner(UIParent,"ANCHOR_NONE")
584 TheoryCraftTooltip:SetHyperlink(linkid)
585 if (getglobal(TheoryCraftTooltip:GetName().."TextLeft1") == nil) then
586 return
587 end
588 local itemname, itemlink, itemrarity = GetItemInfo(linkid)
589 local r, g, b, hex = GetItemQualityColor(itemrarity)
590 itemname = hex.."|H"..itemlink.."|h["..itemname.."]|h|r"
591 local index = 1
592 local ltext = getglobal(TheoryCraftTooltip:GetName().."TextLeft"..index):GetText()
593 if ltext == nil then
594 return
595 end
596 local found = false
597 local realslot = false
598 local both = false
599 while (ltext ~= nil) and (found == false) do
600 local i = 1
601 while (TheoryCraft_SlotNames[i]) do
602 if (ltext == TheoryCraft_SlotNames[i].text) then
603 if (found) then
604 if TheoryCraft_Settings["CustomOutfit"].slots[found] then
605 TheoryCraft_Settings["CustomOutfit"].slots[TheoryCraft_SlotNames[i].slot] = TheoryCraft_Settings["CustomOutfit"].slots[found]
606 end
607 else
608 found = TheoryCraft_SlotNames[i].slot
609 realslot = TheoryCraft_SlotNames[i].realslot
610 both = TheoryCraft_SlotNames[i].both
611 end
612 end
613 i = i + 1
614 end
615 ltext = getglobal(TheoryCraftTooltip:GetName().."TextLeft"..index):GetText()
616 index = index + 1
617 end
618 if found == false then
619 return
620 end
621 if both then
622 TheoryCraft_Settings["CustomOutfit"].slots["Off HandItemName"] = nil
623 TheoryCraft_Settings["CustomOutfit"].slots["Off Hand"] = nil
624 end
625 local itemdata = {}
626 local equippedsets = {}
627 TheoryCraft_AddEquipEffect (realslot, "test", itemdata, equippedsets)
628 TheoryCraft_Settings["CustomOutfit"].slots[found] = {}
629 TheoryCraft_Settings["CustomOutfit"].slots[found]["data"] = itemdata
630 TheoryCraft_Settings["CustomOutfit"].slots[found]["name"] = itemname
631 TheoryCraftTooltip:SetOwner(UIParent,"ANCHOR_NONE")
632 TheoryCraftTooltip:SetHyperlink(linkid)
633 if (getglobal(TheoryCraftTooltip:GetName().."TextLeft1") == nil) then
634 return
635 end
636 local returndata = {}
637 returndata = TheoryCraft_DequipEffect ("test", returndata)
638 TheoryCraft_Settings["CustomOutfit"].slots[found]["stats"] = {}
639 local a = TheoryCraft_Settings["CustomOutfit"].slots[found]["stats"]
640 for k,v in pairs(equippedsets) do
641 a.settype = k
642 end
643 if returndata["meleecritchance"] then a.meleecritchance = -returndata["meleecritchance"] end
644 if returndata["formattackpower"] then a.formattackpower = -returndata["formattackpower"] end
645 if returndata["rangedattackpower"] then a.rangedattackpower = -returndata["rangedattackpower"] end
646 if returndata["attackpower"] then a.attackpower = -returndata["attackpower"] end
647 if returndata["strength"] then a.strength = -returndata["strength"] end
648 if returndata["agility"] then a.agility = -returndata["agility"] end
649 if returndata["stamina"] then a.stamina = -returndata["stamina"] end
650 if returndata["intellect"] then a.intellect = -returndata["intellect"] end
651 if returndata["spirit"] then a.spirit = -returndata["spirit"] end
652 if returndata["totalmana"] then a.totalmana = -returndata["totalmana"] end
653 if returndata["totalhealth"] then a.totalhealth = -returndata["totalhealth"] end
654 end