Skip to content

Commit

Permalink
allow bags to work correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
insunaa committed Dec 2, 2022
1 parent 1949b61 commit a4c4423
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 27 deletions.
17 changes: 14 additions & 3 deletions QEGearImporter/questionablyepic_enhanced.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -112,7 +111,6 @@ function scanGear()

end


local ammoID = GetInventoryItemID("player", 0);
if (ammoID ~= nil) then
addPrint("ammo=,id=" .. ammoID)
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions src/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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');")
Expand Down
77 changes: 53 additions & 24 deletions src/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit a4c4423

Please sign in to comment.