vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | -- |
2 | -- MI2_ConvDropRate.lua |
||
3 | -- |
||
4 | -- author: NakorNH |
||
5 | -- this converter was written and submitted by NakorNH |
||
6 | -- |
||
7 | -- DropRate data converter for the MobInfo2 AddOn |
||
8 | -- This converter will convert all Mobs found in the DropRate database |
||
9 | -- and convert them into entries for the MobInfo2 database. Item data |
||
10 | -- can only be converted if the item can be found in either the |
||
11 | -- ItemSync or KC_Items or LootLink databases (thus either of these |
||
12 | -- AddOns must be installed as well). |
||
13 | -- |
||
14 | -- Using LootLink is recommended for the conversion because AddOns sites |
||
15 | -- like "http://ui.worldofwar.net" host huge LootLink item databases |
||
16 | -- that ensure a high conversion success rate. After successful |
||
17 | -- conversion LootLink can be uninstalled. |
||
18 | -- |
||
19 | |||
20 | |||
21 | local MI_CONVERTER = mifontLightBlue.."<MobInfo DR Convert>"..mifontWhite.." " |
||
22 | local MI_MOBSFOUND = " Mobs found in DropRate data," |
||
23 | local MI_NEWMOBSFOUND = " new Mobs added to database," |
||
24 | local MI_EXISTINGMOBS = " existing Mobs expanded," |
||
25 | local MI_PARTIALMOBS = " Mobs partially converted," |
||
26 | local MI_SKIPPEDITEMS = " unknown items skipped," |
||
27 | local MI_ADDEDITEMS = " items added to database," |
||
28 | |||
29 | |||
30 | ----------------------------------------------------------------------------- |
||
31 | -- MI2_StartDropRateConversion() |
||
32 | -- |
||
33 | -- Scans the DropRate database. Then converts the data and adds it to MobInfo2 database |
||
34 | ----------------------------------------------------------------------------- |
||
35 | function MI2_StartDropRateConversion() |
||
36 | local totalMobs = 0 |
||
37 | local newMobsFound = 0 |
||
38 | local mobsExtended = 0 |
||
39 | local partialMobs = 0 |
||
40 | local itemsSkipped = 0 |
||
41 | local itemsFound = 0 |
||
42 | |||
43 | chattext( MI_CONVERTER.."DropRate conversion started ..." ) |
||
44 | |||
45 | if not drdb then |
||
46 | chattext( "DropRate database not found" ) |
||
47 | return |
||
48 | end |
||
49 | |||
50 | for mobName, value in drdb do |
||
51 | local notCompleteMob = 0 |
||
52 | local newMobData = {} |
||
53 | local drMobLevel |
||
54 | for index , value2 in value do |
||
55 | if index == "level" then |
||
56 | drMobLevel = value2 |
||
57 | totalMobs = totalMobs + 1 |
||
58 | end |
||
59 | end |
||
60 | |||
61 | if drMobLevel then |
||
62 | for index, value2 in value do |
||
63 | local drItemID = -1 |
||
64 | if index == "level" then |
||
65 | drMobLevel = value2 |
||
66 | elseif index == "looted" then |
||
67 | newMobData.loots = value2 |
||
68 | drdb[mobName][index] = nil |
||
69 | elseif index == "skinned" then |
||
70 | newMobData.skinCount = value2 |
||
71 | notItem = 1 |
||
72 | drdb[mobName][index] = nil |
||
73 | elseif index == "money" then |
||
74 | newMobData.copper = value2 |
||
75 | drdb[mobName][index] = nil |
||
76 | else |
||
77 | drItemID = (MI2_drFindItemID(index) or 0) |
||
78 | end |
||
79 | |||
80 | -- process all item data antries where an item ID code could be found |
||
81 | if drItemID > 0 then |
||
82 | -- process item quality for item quality overview |
||
83 | local drQuality = dritems[index] |
||
84 | if drQuality == 0 then |
||
85 | newMobData.r1 = (newMobData.r1 or 0) + 1 |
||
86 | elseif drQuality == 1 then |
||
87 | newMobData.r2 = (newMobData.r2 or 0) + 1 |
||
88 | elseif drQuality == 2 then |
||
89 | newMobData.r3 = (newMobData.r3 or 0) + 1 |
||
90 | elseif drQuality == 3 then |
||
91 | newMobData.r4 = (newMobData.r4 or 0) + 1 |
||
92 | elseif drQuality == 4 then |
||
93 | newMobData.r5 = (newMobData.r5 or 0) + 1 |
||
94 | elseif drQuality == -1 then |
||
95 | drQuality = 1 |
||
96 | end |
||
97 | |||
98 | -- process item value |
||
99 | local drItemValue = MI2_FindItemValue( index, drItemID ) |
||
100 | newMobData.itemValue = (newMobData.itemValue or 0) + drItemValue |
||
101 | |||
102 | -- add item to MobInfo items table |
||
103 | if MobInfoConfig.SaveItems == 1 and (drQuality + 1) >= MobInfoConfig.ItemsQuality then |
||
104 | if not newMobData.itemList then newMobData.itemList = {} end |
||
105 | newMobData.itemList[drItemID] = value2 |
||
106 | if not MI2_ItemNameTable[drItemID] then |
||
107 | MI2_ItemNameTable[drItemID] = index.."/"..(drQuality + 1) |
||
108 | end |
||
109 | end |
||
110 | |||
111 | drdb[mobName][index] = nil |
||
112 | itemsFound = itemsFound + 1 |
||
113 | |||
114 | elseif drItemID == 0 then |
||
115 | notCompleteMob = 1 |
||
116 | itemsSkipped = itemsSkipped + 1 |
||
117 | end |
||
118 | end -- for |
||
119 | |||
120 | -- add converted DropRate Mob data to existing MobInfo data |
||
121 | -- (creates new MobInfo database entry if Mob does not exist) |
||
122 | local origMobData = MI2_GetMobData(mobName,drMobLevel) |
||
123 | if origMobData.loots then |
||
124 | mobsExtended = mobsExtended + 1 |
||
125 | else |
||
126 | newMobsFound = newMobsFound + 1 |
||
127 | end |
||
128 | MI2_AddTwoMobs(newMobData, origMobData) |
||
129 | MI2x_StoreMobData( newMobData, mobName, drMobLevel, MI2_PlayerName ) |
||
130 | |||
131 | -- check if entire DropRate Mob entry has been converted |
||
132 | local remainingEntries = 0 |
||
133 | for index in drdb[mobName] do |
||
134 | if index ~= "level" then |
||
135 | remainingEntries = remainingEntries + 1 |
||
136 | end |
||
137 | end |
||
138 | if remainingEntries == 0 then |
||
139 | drdb[mobName] = nil |
||
140 | end |
||
141 | end |
||
142 | if notCompleteMob > 0 then |
||
143 | partialMobs = partialMobs + 1 |
||
144 | end |
||
145 | |||
146 | end |
||
147 | |||
148 | MI2_BuildXRefItemTable() |
||
149 | |||
150 | chattext(MI_CONVERTER..totalMobs..MI_MOBSFOUND) |
||
151 | chattext(MI_CONVERTER..mobsExtended..MI_EXISTINGMOBS) |
||
152 | chattext(MI_CONVERTER..newMobsFound..MI_NEWMOBSFOUND) |
||
153 | chattext(MI_CONVERTER..partialMobs..MI_PARTIALMOBS) |
||
154 | chattext(MI_CONVERTER..itemsFound..MI_ADDEDITEMS) |
||
155 | chattext(MI_CONVERTER..itemsSkipped..MI_SKIPPEDITEMS) |
||
156 | end |
||
157 | |||
158 | ----------------------------------------------------------------------------- |
||
159 | -- MI2_StartDropRateConversion() |
||
160 | -- |
||
161 | -- Find the itemID for each item in the database |
||
162 | ----------------------------------------------------------------------------- |
||
163 | function MI2_drFindItemID(index) |
||
164 | -- Find item code from ItemSync |
||
165 | if ISyncDB_Names then |
||
166 | for ISItemID, ISItemName in ISyncDB_Names do |
||
167 | if ISItemName == index then |
||
168 | return ISItemID |
||
169 | end |
||
170 | end |
||
171 | end |
||
172 | |||
173 | -- Find item code from KC_Items (potentially dangerous : might cause disconnect |
||
174 | -- when calling "GetItemInfo()" with item ID not known on server) |
||
175 | if KC_ItemsDB then |
||
176 | for itemCode, itemInfo in KC_ItemsDB do |
||
177 | local itemName, itemLink = GetItemInfo(itemCode) |
||
178 | if itemName then |
||
179 | if itemName == index then |
||
180 | return itemCode, itemLink |
||
181 | end |
||
182 | end |
||
183 | end |
||
184 | end |
||
185 | |||
186 | -- Find item code from LootLink |
||
187 | if ItemLinks then |
||
188 | if ItemLinks[index] then |
||
189 | local lootLinkData = ItemLinks[index].i |
||
190 | local a,b,itemCode,CDRenchantCode,CDRbonusCode,CDRmiscCode = string.find(lootLinkData, "(%d*):(%d*):(%d*):(%d*)") |
||
191 | return tonumber(itemCode) |
||
192 | end |
||
193 | end |
||
194 | |||
195 | return nil |
||
196 | end -- of MI2_drFindItemID |
||
197 |