diff --git a/QEGearImporter/questionablyepic_enhanced.lua b/QEGearImporter/questionablyepic_enhanced.lua index d394bce..a6b3600 100644 --- a/QEGearImporter/questionablyepic_enhanced.lua +++ b/QEGearImporter/questionablyepic_enhanced.lua @@ -75,7 +75,6 @@ function scanGear() local equipID = GetInventoryItemID("player", i); local itemLink = GetInventoryItemLink('player', i) - if (equipID ~= nil) then local itemSplit = GetItemSplit(itemLink) local suffix = itemSplit[7] * -1 @@ -83,7 +82,7 @@ function scanGear() local unique = bit.band(itemSplit[8], 65535) suffix = ",suffix=" .. suffix .. ",unique=" .. unique else suffix = "" end - + local hasBuckle = false --local _, enchantId, gem1, gem2, gem3, gem4 = string.match(itemLink, "item:(%d+):(%d+):(%d+):(%d+):(%d+):(%d+)") local enchantId = itemSplit[2] local gem1 = itemSplit[3] @@ -92,13 +91,19 @@ function scanGear() SocketInventoryItem(i) gemColors = {nil, nil, nil} for j=1, GetNumSockets() do + _, _, _, _, _, _, _, _, equipLoc = GetItemInfo(itemLink) + if (equipLoc ~= nil and equipLoc == "INVTYPE_WAIST") then + if (GetSocketTypes(j) ~= nil and GetSocketTypes(j) == "Prismatic") then + hasBuckle = true + end + end _, _, gemColors[j] = GetExistingSocketInfo(j) end CloseSocketInfo() local itemName, _, _, _, _, _, _, _, _, _, _, classID, subclassID = GetItemInfo(equipID); --print(classID) if (classID == 2 or classID == 4) then - addPrint(slotNames[i] .. "=,id=" .. equipID .. suffix .. ",enchantId=" .. enchantId .. ",gem1=" .. gem1 ..":" .. tostring(gemColors[1]) .. ",gem2=" .. gem2 ..":" .. tostring(gemColors[2]) .. ",gem3=" .. gem3 ..":" .. tostring(gemColors[3])) + addPrint(slotNames[i] .. "=,id=" .. equipID .. suffix .. ",enchantId=" .. enchantId .. ",gem1=" .. gem1 ..":" .. tostring(gemColors[1]) .. ",gem2=" .. gem2 ..":" .. tostring(gemColors[2]) .. ",gem3=" .. gem3 ..":" .. tostring(gemColors[3]) .. ",buckle=" .. tostring(hasBuckle)) --print(itemName .. "(" .. itemType .. ")"); end @@ -106,7 +111,6 @@ function scanGear() end - local ammoID = GetInventoryItemID("player", 0); if (ammoID ~= nil) then addPrint("ammo=,id=" .. ammoID) @@ -132,6 +136,15 @@ function scanGear() addPrint("") addPrint("### GEAR FROM BAGS ###") + if (true) then + for i=20, 23, 1 do + local equipID = GetInventoryItemID("player", i); + if equipID ~= nil then + addPrint(i .. "," .. equipID) + end + end + end + for bag=0, (NUM_BAG_SLOTS + GetNumBankSlots()) do if (GetContainerNumSlots(bag) ~= 0) then for bagSlots=1, GetContainerNumSlots(bag) do @@ -144,6 +157,7 @@ function scanGear() local itemLink = GetContainerItemLink(bag, bagSlots) local itemSplit = GetItemSplit(itemLink) local suffix = itemSplit[7] * -1 + local hasBuckle = false local enchantId = itemSplit[2] local gem1 = itemSplit[3] local gem2 = itemSplit[4] @@ -157,6 +171,12 @@ function scanGear() SocketContainerItem(bag, bagSlots) gemColors = {nil, nil, nil} for j=1, GetNumSockets() do + _, _, _, _, _, _, _, _, equipLoc = GetItemInfo(itemLink) + if (equipLoc ~= nil and equipLoc == "INVTYPE_WAIST") then + if (GetSocketTypes(j) ~= nil and GetSocketTypes(j) == "Prismatic") then + hasBuckle = true + end + end _, _, gemColors[j] = GetExistingSocketInfo(j) end CloseSocketInfo() @@ -168,7 +188,11 @@ function scanGear() --addPrint("# " .. convertSlot(itemEquipLoc) .. "=,id=" .. itemID .. suffix) local _, itemCount = GetContainerItemInfo(bag, bagSlots) --addPrint(itemName) - addPrint("id=" .. itemID .. suffix .. ",count=" .. itemCount .. ",enchantId=" .. enchantId .. ",gem1=" .. gem1 ..":" .. tostring(gemColors[1]) .. ",gem2=" .. gem2 ..":" .. tostring(gemColors[2]) .. ",gem3=" .. gem3 ..":" .. tostring(gemColors[3])) + if (true) then + addPrint("bag=" .. bag .. ",slot=" .. bagSlots ..",id=" .. itemID .. suffix .. ",count=" .. itemCount .. ",enchantId=" .. enchantId .. ",gem1=" .. gem1 ..":" .. tostring(gemColors[1]) .. ",gem2=" .. gem2 ..":" .. tostring(gemColors[2]) .. ",gem3=" .. gem3 ..":" .. tostring(gemColors[3]) .. ",buckle=" .. tostring(hasBuckle)) + else + addPrint("id=" .. itemID .. suffix .. ",count=" .. itemCount .. ",enchantId=" .. enchantId .. ",gem1=" .. gem1 ..":" .. tostring(gemColors[1]) .. ",gem2=" .. gem2 ..":" .. tostring(gemColors[2]) .. ",gem3=" .. gem3 ..":" .. tostring(gemColors[3]) .. ",buckle=" .. tostring(hasBuckle)) + end --print(itemName .. "(" .. itemType .. ")"); end diff --git a/src/constants.py b/src/constants.py index 5f69182..31fcf2a 100644 --- a/src/constants.py +++ b/src/constants.py @@ -1175,20 +1175,10 @@ def fill(self, **kwds: object) -> str: $achievements $glyphs INSERT INTO `character_homebind` VALUES ('$char_guid', '$start_map', '3703', '$pos_x', '$pos_y', '$pos_z'); -INSERT INTO `character_inventory` VALUES ('$char_guid', '0', '24', '184', '6948'); -- Hearthstone -INSERT INTO `character_inventory` VALUES ('$char_guid', '0', '19', '217', '$bag_id'); -- Large Bag -INSERT INTO `character_inventory` VALUES ('$char_guid', '0', '22', '218', '$bag_id'); -- Large Bag -INSERT INTO `character_inventory` VALUES ('$char_guid', '0', '21', '219', '$bag_id'); -- Large Bag -INSERT INTO `character_inventory` VALUES ('$char_guid', '0', '20', '220', '$bag_id'); -- Large Bag $inventory_list$pet_list $skills $spells $talents -INSERT INTO `item_instance` VALUES ('184', '$char_guid', '6948', '0', '0', '1', '0', '0 0 0 0 0 ', '1', '$enchantments', '0', '100', '0'$text); -INSERT INTO `item_instance` VALUES ('217', '$char_guid', '$bag_id', '0', '0', '1', '0', '0 0 0 0 0 ', '1', '$enchantments', '0', '100', '0'$text); -INSERT INTO `item_instance` VALUES ('218', '$char_guid', '$bag_id', '0', '0', '1', '0', '0 0 0 0 0 ', '1', '$enchantments', '0', '100', '0'$text); -INSERT INTO `item_instance` VALUES ('219', '$char_guid', '$bag_id', '0', '0', '1', '0', '0 0 0 0 0 ', '1', '$enchantments', '0', '100', '0'$text); -INSERT INTO `item_instance` VALUES ('220', '$char_guid', '$bag_id', '0', '0', '1', '0', '0 0 0 0 0 ', '1', '$enchantments', '0', '100', '0'$text); $instance_list $actions $factions @@ -1199,7 +1189,7 @@ def fill(self, **kwds: object) -> str: instanceEnchantTemplateTBC = Template("$main_enchant 0 0 0 0 0 $gem1 0 0 $gem2 0 0 $gem3 0 0 $socket_bonus 0 0 $enchant_1 0 0 $enchant_2 0 0 $enchant_3 0 0 0 0 0 0 0 0 ") instanceEnchantTemplateVan = Template("$main_enchant 0 0 0 0 0 0 0 0 $enchant_1 0 0 $enchant_2 0 0 $enchant_3 0 0 0 0 0 ") -charactersTemplateWOTLK = Template("INSERT INTO `characters` VALUES ('$char_guid', '5', '$char_name', '$char_race', '$char_class', '$char_gender', '$char_level', '0', '300000000', '0', '0', '65568', '$pos_x', '$pos_y', '$pos_z', '$start_map', '0', '4.13832', '2 0 0 8 0 0 1048576 0 0 0 0 0 0 0 ', '0', '1', '200', '175', '1669632358', '1', '0', '0', '0', '0', '0', '0', '0', '0', '8', '0', '0', '4395', '0', '', '5000', '75000', '0', '0', '0', '0', '0', '0', '0', '4294967295', '0', '$char_health', '$char_power', '0', '0', '100', '0', '0', '0', '1', '0', '0 0 0 0 0 0 1048576 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 512 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4194304 256 0 0 0 0 0 0 0 0 67108864 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ', NULL, '0', '0 0 0 0 0 0 ', '0', '0', '0', NULL, NULL, NULL);") +charactersTemplateWOTLK = Template("INSERT INTO `characters` VALUES ('$char_guid', '5', '$char_name', '$char_race', '$char_class', '$char_gender', '$char_level', '0', '300000000', '0', '0', '65568', '$pos_x', '$pos_y', '$pos_z', '$start_map', '0', '4.13832', '2 0 0 8 0 0 1048576 0 0 0 0 0 0 0 ', '0', '1', '200', '175', '1669632358', '1', '0', '0', '0', '0', '0', '0', '0', '0', '8', '0', '8', '4395', '0', '', '5000', '75000', '0', '0', '0', '0', '0', '0', '0', '4294967295', '0', '$char_health', '$char_power', '0', '0', '100', '0', '0', '0', '1', '0', '0 0 0 0 0 0 1048576 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 512 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4194304 256 0 0 0 0 0 0 0 0 67108864 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ', NULL, '0', '0 0 0 0 0 0 ', '0', '0', '0', NULL, NULL, NULL);") charactersTemplateTBC = Template("INSERT INTO `characters` VALUES ('$char_guid', '5', '$char_name', '$char_race', '$char_class', '$char_gender', '$char_level', '0', '300000000', '0', '0', '65568', '$pos_x', '$pos_y', '$pos_z', '$start_map', '0', '1.86449', '2 0 0 8 0 0 1048576 0 0 0 0 0 0 0 0 0 ', '0', '1', '200', '175', '1642414101', '1', '0', '0', '0', '0', '0', '0', '0', '0', '10', '0', '0', '3703', '0', '', '0', '0', '0', '0', '0', '0', '0', '0', '2147483647', '0', '5594', '0', '0', '0', '100', '0', '4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 ', NULL, '0', '0 0 ', '0', '0', '0', NULL, NULL, NULL);") charactersTemplateVan = Template("INSERT INTO `characters` VALUES ('$char_guid', '5', '$char_name', '$char_race', '$char_class', '$char_gender', '$char_level', '0', '300000000', '0', '0', '0', '$pos_x', '$pos_y', '$pos_z', '$start_map', '2.70526', '1024 0 0 0 0 0 0 0 ', '0', '1', '0', '0', '1642834034', '1', '0', '0', '0', '0', '0', '0', '0', '0', '2', '0', '32', '0', '0', '', '0', '0', '0', '0', '0', '0', '0', '63', '79', '0', '0', '100', '0', '4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 ', NULL, '0', '0', '0', '0', NULL, NULL, NULL);") diff --git a/src/parser.py b/src/parser.py index 4aa1ce7..3d35e8f 100644 --- a/src/parser.py +++ b/src/parser.py @@ -46,15 +46,39 @@ def get_char_info(): return result - def add_to_itemlists(slot_id, item_entry, suffix, enchant, gems, bag_id=0, item_count=1): + def add_to_itemlists(slot_id, item_entry, suffix, enchant, gems, buckle, bag_id="0", item_count=1, bagno=5, worn=False): global inventory_list, instance_list, itemguiditr + bagMap = {"0":0, "1":10036, "2":10038, "3":10040, "4":10042} + slot_id = int(slot_id) socketBonus = 0 - inventory_list += wornTemplate.fill( - slot_id=slot_id, - item_guid=itemguiditr, - item_entry=item_entry, - bag_id=bag_id, - ) + if bag_id != "0" and bagno>3 and not worn: + inventory_list += wornTemplate.fill( + slot_id=slot_id, + item_guid=itemguiditr, + item_entry=item_entry, + bag_id = bagMap[bag_id], + ) + elif bag_id=="0" and bagno <= 3 and worn: + inventory_list += wornTemplate.fill( + slot_id=slot_id - 1, + item_guid=itemguiditr, + item_entry=item_entry, + bag_id=bag_id, + ) + elif bag_id=="0" and bagno > 3 and not worn: + inventory_list += wornTemplate.fill( + slot_id=((slot_id - 1) + 23), + item_guid=itemguiditr, + item_entry=item_entry, + bag_id=bag_id, + ) + else: + inventory_list += wornTemplate.fill( + slot_id=slot_id, + item_guid=itemguiditr, + item_entry=item_entry, + bag_id=bag_id, + ) sockets = [gems[0].split(":")[1], gems[1].split(":")[1], gems[2].split(":")[1]] suffix = abs(int(suffix)) enchantments = "" @@ -86,26 +110,33 @@ def add_to_itemlists(slot_id, item_entry, suffix, enchant, gems, bag_id=0, item_ socketBonus = itemSocketBonusMapWotlk[int(item_entry)] if str(suffix) not in suffixTable: suffix = 0 - enchantments = instanceEnchantTemplateWOTLK.fill( - main_enchant=enchant, - gem1=gemPropertyMapWotLK[gemIDPropertyMapWotlk[int(gems[0].split(":")[0])]], - gem2=gemPropertyMapWotLK[gemIDPropertyMapWotlk[int(gems[1].split(":")[0])]], - gem3=gemPropertyMapWotLK[gemIDPropertyMapWotlk[int(gems[2].split(":")[0])]], - socket_bonus=socketBonus, - enchant_1=suffixTable[str(suffix)][0], - enchant_2=suffixTable[str(suffix)][1], - enchant_3=suffixTable[str(suffix)][2], - ) - if exp != 2: - instance_list += instanceTemplate.fill( - item_guid=itemguiditr, - item_entry=item_entry, - item_count=item_count, - item_suffix=-suffix, - enchantments=enchantments, - ) - itemguiditr += 2 - else: + if buckle == "false": + enchantments = instanceEnchantTemplateWOTLK.fill( + main_enchant=enchant, + gem1=gemPropertyMapWotLK[gemIDPropertyMapWotlk[int(gems[0].split(":")[0])]], + gem2=gemPropertyMapWotLK[gemIDPropertyMapWotlk[int(gems[1].split(":")[0])]], + gem3=gemPropertyMapWotLK[gemIDPropertyMapWotlk[int(gems[2].split(":")[0])]], + socket_bonus=socketBonus, + enchant_1=suffixTable[str(suffix)][0], + enchant_2=suffixTable[str(suffix)][1], + enchant_3=suffixTable[str(suffix)][2], + ) + else: + enchantments = instanceEnchantTemplateWOTLK.fill( + main_enchant=enchant, + gem1=gemPropertyMapWotLK[gemIDPropertyMapWotlk[int(gems[0].split(":")[0])]], + gem2=gemPropertyMapWotLK[gemIDPropertyMapWotlk[int(gems[1].split(":")[0])]], + gem3=gemPropertyMapWotLK[gemIDPropertyMapWotlk[int(gems[2].split(":")[0])]], + socket_bonus=socketBonus, + enchant_1=3729, + enchant_2=suffixTable[str(suffix)][1], + enchant_3=suffixTable[str(suffix)][2], + ) + if exp == 0: + pass + elif exp == 1: + pass + elif exp == 2: instance_list += instanceTemplateWotLK.fill( item_guid=itemguiditr, item_entry=item_entry, @@ -113,7 +144,7 @@ def add_to_itemlists(slot_id, item_entry, suffix, enchant, gems, bag_id=0, item_ item_suffix=-suffix, enchantments=enchantments, ) - itemguiditr += 2 + itemguiditr += 2 def parse_slots_equipped(): def parse_slots_base(): @@ -121,18 +152,21 @@ def parse_slots_base(): suffix = "0" enchant = "0" gems = [] - if len(item_info) == 8: + buckle = "false" + if len(item_info) == 9: suffix = item_info[2].split("=")[1] enchant = item_info[4].split("=")[1] gems = [item_info[5].split("=")[1], item_info[6].split("=")[1], item_info[7].split("=")[1]] - elif len(item_info) == 6: + buckle = [item_info[8].split("=")[1]] + elif len(item_info) == 7: enchant = item_info[2].split("=")[1] gems = [item_info[3].split("=")[1], item_info[4].split("=")[1], item_info[5].split("=")[1]] + buckle = [item_info[6].split("=")[1]] item_entry = ( f[i + equip_offset].split("=")[2].split(",")[0].replace("\n", "") ) - add_to_itemlists(slotMap[slot], item_entry, suffix, enchant, gems) + add_to_itemlists(slotMap[slot], item_entry, suffix, enchant, gems, buckle[0].rstrip(), worn=True) slots = [ "head", @@ -223,34 +257,42 @@ def get_all_items(): def parse_bag(all_items): def parse_bag_base(): - nonlocal firstSlot, bagID +# nonlocal firstSlot, bagID suffix = "0" enchant = "0" gems = [] + buckle = "false" item_data = item.split(",") item_count = "" - item_entry = item_data[0].split("=") + item_entry = item_data[2].split("=") if len(item_entry) > 1: item_entry = item_entry[1] if len(item_data) > 1: - item_count = clean(item_data[1].split("=")[1]) - if len(item_data) == 8: item_count = clean(item_data[3].split("=")[1]) - suffix = item_data[1].split("=")[1] + if len(item_data) == 11: + item_count = clean(item_data[5].split("=")[1]) + suffix = item_data[3].split("=")[1] + enchant = item_data[6].split("=")[1] + gems = [item_data[7].split("=")[1], item_data[8].split("=")[1], item_data[9].split("=")[1]] + buckle = [item_data[10].split("=")[1]] + if len(item_data) == 9: enchant = item_data[4].split("=")[1] gems = [item_data[5].split("=")[1], item_data[6].split("=")[1], item_data[7].split("=")[1]] - if len(item_data) == 6: - enchant = item_data[2].split("=")[1] - gems = [item_data[3].split("=")[1], item_data[4].split("=")[1], item_data[5].split("=")[1]] - slotID = firstSlot % 28 - bagID = int(firstSlot / 28) + 216 - add_to_itemlists(slotID, item_entry, suffix, enchant, gems, bagID, item_count=item_count) - firstSlot += 1 - - firstSlot = 23 + 14 - bagID = 1 + buckle = [item_data[8].split("=")[1]] + slotID = str(int(item_data[1].split("=")[1]) - 1) + bagID = item_data[0].split("=")[1] + add_to_itemlists(slotID, item_entry, suffix, enchant, gems, buckle[0], bagID, item_count=item_count) +# firstSlot += 1 + +# firstSlot = 23 + 14 +# bagID = 1 for item in all_items["gear"][3]: - parse_bag_base() + if "=" not in item and "," in item: + slot = int(item.split(",")[0]) - 1 + iid = item.split(",")[1] + add_to_itemlists(slot, iid, suffix=0, enchant=0, bag_id=0, gems=["0:nil", "0:nil", "0:nil"], buckle="false", bagno=0) + else: + parse_bag_base() def parse_spells(all_items): global skills, spells, action_list, faction_list, talents @@ -387,13 +429,14 @@ def parse_glyphs(): def parse_achievements(): global achievements for achievement in all_items["achievements"][3]: - achId = achievement.split(",")[0] - year = int(achievement.split(",")[1]) - month = int(achievement.split(",")[2]) - day = int(achievement.split(",")[3]) - date_time = datetime.datetime(year+2000, month, day, 0, 0) - timestamp = time.mktime(date_time.timetuple()) - achievements += achievementTemplate.fill(achievement_id=achId,timestamp=timestamp) + if "," in achievement: + achId = achievement.split(",")[0] + year = int(achievement.split(",")[1]) + month = int(achievement.split(",")[2]) + day = int(achievement.split(",")[3]) + date_time = datetime.datetime(year+2000, month, day, 0, 0) + timestamp = time.mktime(date_time.timetuple()) + achievements += achievementTemplate.fill(achievement_id=achId,timestamp=timestamp) def write_pdump(char_info): startPos = startPosMap[exp][factions[clean(f[5].split("=")[1])]]