From a4c4423143b87149fa4535e784dda93ad2cbcf84 Mon Sep 17 00:00:00 2001 From: insunaa Date: Sat, 3 Dec 2022 00:43:21 +0100 Subject: [PATCH] allow bags to work correctly --- QEGearImporter/questionablyepic_enhanced.lua | 17 ++++- src/constants.py | 18 +++++ src/parser.py | 77 ++++++++++++++------ 3 files changed, 85 insertions(+), 27 deletions(-) diff --git a/QEGearImporter/questionablyepic_enhanced.lua b/QEGearImporter/questionablyepic_enhanced.lua index 7c46be8..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 @@ -112,7 +111,6 @@ function scanGear() end - local ammoID = GetInventoryItemID("player", 0); if (ammoID ~= nil) then addPrint("ammo=,id=" .. ammoID) @@ -138,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 @@ -181,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]) .. ",buckle=" .. tostring(hasBuckle)) + 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 9b83b79..ce1d01e 100644 --- a/src/constants.py +++ b/src/constants.py @@ -1191,6 +1191,24 @@ def fill(self, **kwds: object) -> str: """ ) +pdumpTemplate2 = Template( + """IMPORTANT NOTE: THIS DUMPFILE IS MADE FOR USE WITH THE 'PDUMP' COMMAND ONLY - EITHER THROUGH INGAME CHAT OR ON CONSOLE! +IMPORTANT NOTE: DO NOT apply it directly - it will irreversibly DAMAGE and CORRUPT your database! You have been warned! + +$characters_row +$achievements +$actions +$glyphs +INSERT INTO `character_homebind` (`guid`, `mapId`, `zoneId`, `posX`, `posY`, `posZ`) VALUES ('$char_guid', '$start_map', '3703', '$pos_x', '$pos_y', '$pos_z'); +$inventory_list$pet_list +$factions +$skills +$spells +$talents +$instance_list +""" +) + instanceEnchantTemplate = 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 0 0 0 ") charactersTemplateAcore = Template("INSERT INTO `characters` (`guid`, `account`, `name`, `race`, `class`, `gender`, `level`, `xp`, `money`, `skin`, `face`, `hairStyle`, `hairColor`, `facialStyle`, `bankSlots`, `restState`, `playerFlags`, `position_x`, `position_y`, `position_z`, `map`, `instance_id`, `instance_mode_mask`, `orientation`, `taximask`, `online`, `cinematic`, `totaltime`, `leveltime`, `logout_time`, `is_logout_resting`, `rest_bonus`, `resettalents_cost`, `resettalents_time`, `trans_x`, `trans_y`, `trans_z`, `trans_o`, `transguid`, `extra_flags`, `stable_slots`, `at_login`, `zone`, `death_expire_time`, `taxi_path`, `arenaPoints`, `totalHonorPoints`, `todayHonorPoints`, `yesterdayHonorPoints`, `totalKills`, `todayKills`, `yesterdayKills`, `chosenTitle`, `knownCurrencies`, `watchedFaction`, `drunk`, `health`, `power1`, `power2`, `power3`, `power4`, `power5`, `power6`, `power7`, `latency`, `talentGroupsCount`, `activeTalentGroup`, `exploredZones`, `equipmentCache`, `ammoId`, `knownTitles`, `actionBars`, `grantableLevels`, `order`, `creation_date`, `deleteInfos_Account`, `deleteInfos_Name`, `deleteDate`, `innTriggerId`) VALUES ('$char_guid', '5', '$char_name', '$char_race', '$char_class', '$char_gender', '$char_level', '0', '300000000', '0', '0', '0', '0', '0', '0', '0', '0', '$pos_x', '$pos_y', '$pos_z', '$start_map', '0', '0', '4.54661', '32 0 0 8 0 0 1048576 0 0 0 0 0 0 0 ', '1', '1', '109', '109', '1665606973', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '876', '0', 'NULL', '0', '0', '0', '0', '0', '0', '0', '0', '0', '4294967295', '0', '14206', '15246', '0', '0', '100', '0', '0', '0', '89', '2', '0', '0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8 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 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 ', '37684 3820 40680 0 37673 3810 0 0 39497 3832 40696 0 37854 3719 44202 3826 37361 2332 39500 3246 37694 0 43253 0 40682 0 37873 0 41610 3831 37360 3854 0 0 37177 0 0 0 23162 0 23162 0 23162 0 23162 0 ', '0', '0 0 0 0 0 0 ', '0', '0', 'NULL', '2022-10-12 22:34:21', 'NULL', 'NULL', 'NULL', '0');") diff --git a/src/parser.py b/src/parser.py index d70fcd9..bdf4614 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, buckle, 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 = "" @@ -137,7 +161,7 @@ def parse_slots_base(): item_entry = ( f[i + equip_offset].split("=")[2].split(",")[0].replace("\n", "") ) - add_to_itemlists(slotMap[slot], item_entry, suffix, enchant, gems, buckle[0].rstrip()) + add_to_itemlists(slotMap[slot], item_entry, suffix, enchant, gems, buckle[0].rstrip(), worn=True) slots = [ "head", @@ -228,37 +252,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) == 9: 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]] buckle = [item_data[8].split("=")[1]] - if len(item_data) == 7: - enchant = item_data[2].split("=")[1] - gems = [item_data[3].split("=")[1], item_data[4].split("=")[1], item_data[5].split("=")[1]] - buckle = [item_data[6].split("=")[1]] - slotID = firstSlot % 28 - bagID = int(firstSlot / 28) + 216 + 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 += 1 - firstSlot = 23 + 14 - bagID = 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 @@ -436,7 +465,7 @@ def write_pdump(char_info): start_map=startPos[3]) textIns=", ''" - result = pdumpTemplate.fill( + result = pdumpTemplate2.fill( bag_id=bagId, characters_row=charactersRow, enchantments=enchantments,