From 32bc2bf83c742db976f1e7660dc58d82a8a92da3 Mon Sep 17 00:00:00 2001 From: FlaminSarge Date: Mon, 29 Apr 2024 05:30:24 -0700 Subject: [PATCH 1/4] Add dummy-catalyst-mapping.json for mapping dummy catalyst items to actual catalyst items This affects any of the older exotics that used to have "Upgrade Masterwork" and now have dummy items for the catalyst sockets. Bungie uses reinitializationPossiblePlugHashes to autoapply the actual catalyst item once it's completed, but the values available to be socketed in do not include the actual catalyst item, so this mapping is needed for D2 tools to be able to automatically grab the real catalyst item based on the dummy item present in the socket options for a given exotic. --- README.md | 1 + output/dummy-catalyst-mapping.json | 32 ++++++++++++++++++++++++++++++ src/generate-catalyst-data.ts | 17 ++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 output/dummy-catalyst-mapping.json diff --git a/README.md b/README.md index 0cdbd835..5cbde6b3 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,7 @@ If your pre-commit hook fails, please run the following `pnpm dlx husky install` | d2-trials-objectives.json | a mapping containing trials objective hashes and trials passage hashes | | deprecated-mods.json | an array containing all deprecated mod hashes | | DestinySymbols.woff2 | woff containing Destiny Glyphs, refer to d2-font-glyphs for enums | +| dummy-catalyst-mapping.json | a mapping from dummy catalyst to actual catalyst hashes for items with the older catalyst socket system (where catalysts auto-apply to the gun once completed) | | empty-plug-hashes.ts | a set containing a listing of all "empty" plugs (e.g. No Shader, No Mod Inserted) | | energy-mods-change.json | table for looking up energy capacity mods for Armor 2.0 to change between elements | | energy-mods.json | table for looking up energy capacity mods for Armor 2.0 staying the same element | diff --git a/output/dummy-catalyst-mapping.json b/output/dummy-catalyst-mapping.json new file mode 100644 index 00000000..e4ad8176 --- /dev/null +++ b/output/dummy-catalyst-mapping.json @@ -0,0 +1,32 @@ +{ + "354293076": 1824496861, + "354293077": 1824496860, + "390807531": 1864989992, + "544137184": 1249968539, + "544137185": 1249968538, + "680163197": 658317088, + "800074992": 3466057365, + "854868710": 769440797, + "1340292993": 2732814938, + "1620506138": 615063267, + "1620506139": 615063266, + "1637046321": 2674202880, + "1678902463": 2409031770, + "1772382457": 1496699324, + "1891148055": 920755188, + "2101754671": 3459475454, + "2142466730": 136852797, + "2282260620": 2085058763, + "2282260621": 2085058762, + "2408641879": 4067652714, + "2626423393": 1733620422, + "2790377728": 1783582993, + "2858348496": 924149235, + "2858348497": 924149234, + "3384861888": 1758592809, + "3804992459": 1149703256, + "3815768596": 484491717, + "3867277431": 1684153732, + "4233905576": 456628589, + "4233905577": 456628588 +} diff --git a/src/generate-catalyst-data.ts b/src/generate-catalyst-data.ts index 21280d85..02a78a23 100644 --- a/src/generate-catalyst-data.ts +++ b/src/generate-catalyst-data.ts @@ -116,6 +116,15 @@ const pretty = `const exoticWeaponHashesWithCatalyst = new Set([\n${uniq .join('')}]);\n\nexport default exoticWeaponHashesWithCatalyst;`; const annotatedExoticHashes = annotate(pretty); +// Get all Dummy Catalyst items, figure out their PCHs, and map them to the reinitializationPossiblePlugHashes items if available +// This will create a mapping of dummy catalyst -> actual catalyst for all guns that 'auto-apply' catalyst when pulled from collections +const dummyCatalystMapping = Object.fromEntries(getAllDefs('InventoryItem').filter( + (i) => i.itemType === 20 && i.plug?.uiPlugLabel === 'masterwork_interactable', +).filter((i) => i.plug?.plugCategoryHash && i.hash) + .map((i) => [i.hash, findAutoAppliedCatalystForCatalystPCH(i.plug!.plugCategoryHash!)]) + .filter(([hash, catalyst]) => hash && catalyst).map(([hash, catalyst]) => [hash, catalyst!])); + +writeFile('./output/dummy-catalyst-mapping.json', dummyCatalystMapping); writeFile('./output/catalyst-triumph-icons.json', triumphData); writeFile('./output/exotics-with-catalysts.ts', annotatedExoticHashes); writeFile('./output/exotic-to-catalyst-record.json', exoticWeaponHashToCatalystRecord); @@ -156,3 +165,11 @@ function findDummyItemWithSpecificName(DummyItemName: string) { i.itemCategoryHashes?.includes(ItemCategoryHashes.Dummies), ); } + +function findAutoAppliedCatalystForCatalystPCH(catalystPCH: number) { + const socket = allsockets.find( + (sockets) => sockets.plugWhitelist?.find((plug) => plug.categoryHash === catalystPCH), + ); + + return socket?.plugWhitelist?.find((plug) => plug.categoryHash === catalystPCH)?.reinitializationPossiblePlugHashes?.[0]; +} From 1a44c3671eeed71c048d126b16bb95ae88192741 Mon Sep 17 00:00:00 2001 From: FlaminSarge Date: Sat, 4 May 2024 15:31:55 -0700 Subject: [PATCH 2/4] Apply pnpm pretty --- src/generate-catalyst-data.ts | 158 +++++++++++++++++----------------- 1 file changed, 79 insertions(+), 79 deletions(-) diff --git a/src/generate-catalyst-data.ts b/src/generate-catalyst-data.ts index 02a78a23..a8c98fe4 100644 --- a/src/generate-catalyst-data.ts +++ b/src/generate-catalyst-data.ts @@ -37,75 +37,73 @@ const craftableExotics = getAllDefs('InventoryItem') // (more interesting than the all-identical icons on catalyst triumphs) const triumphData: any = { icon: String, source: String }; -getDef('PresentationNode', catalystPresentationNodeHash)?.children.presentationNodes.forEach( - (p) => - getDef('PresentationNode', p.presentationNodeHash)?.children.records.forEach((r) => { - const recordName = getDef('Record', r.recordHash)?.displayProperties.name; - catalystRecordNames.push(recordName ?? ''); - }), +getDef('PresentationNode', catalystPresentationNodeHash)?.children.presentationNodes.forEach((p) => + getDef('PresentationNode', p.presentationNodeHash)?.children.records.forEach((r) => { + const recordName = getDef('Record', r.recordHash)?.displayProperties.name; + catalystRecordNames.push(recordName ?? ''); + }), ); // loop the catalyst section of triumphs -getDef('PresentationNode', catalystPresentationNodeHash)?.children.presentationNodes.forEach( - (p) => - getDef('PresentationNode', p.presentationNodeHash)?.children.records.forEach((r) => { - const record = getDef('Record', r.recordHash); - const recordName = record?.displayProperties.name; - if (!record || !recordName) { - return; - } - - // look for an inventoryItem with the same name, and plugStyle 1 (should find the catalyst for that gun) - let itemWithSameName = inventoryItems.find( - (i) => i.displayProperties.name === recordName && i.plug?.plugStyle === 1, +getDef('PresentationNode', catalystPresentationNodeHash)?.children.presentationNodes.forEach((p) => + getDef('PresentationNode', p.presentationNodeHash)?.children.records.forEach((r) => { + const record = getDef('Record', r.recordHash); + const recordName = record?.displayProperties.name; + if (!record || !recordName) { + return; + } + + // look for an inventoryItem with the same name, and plugStyle 1 (should find the catalyst for that gun) + let itemWithSameName = inventoryItems.find( + (i) => i.displayProperties.name === recordName && i.plug?.plugStyle === 1, + ); + + // Work around for weirdly named catalysts + if (recordName === 'Two-Tailed Fox Catalyst') { + itemWithSameName = inventoryItems.find( + (i) => i.displayProperties.name === 'Third Tail' && i.plug?.plugStyle === 1, + ); + } + + // Work around for exotic quest craftables + // still no good icon for osteo striga catalyst + switch (recordName) { + case 'Revision Zero Catalyst': + itemWithSameName = findDummyItemWithSpecificName('4-Timer Refit'); + break; + case 'Immovable Refit': + itemWithSameName = findDummyItemWithSpecificName('Immovable Refit'); + break; + case 'Wish-Keeper Catalyst': + itemWithSameName = findDummyItemWithSpecificName('Hatchling Refit'); + break; + } + + const matchingExotic = + (itemWithSameName && + (findWeaponViaCatalystPlug(itemWithSameName.hash) ?? + findWeaponViaCatalystPCH(itemWithSameName.plug?.plugCategoryHash))) ?? + craftableExotics.find((i) => + record.displayProperties.description.includes(i!.displayProperties.name), ); - // Work around for weirdly named catalysts - if (recordName === 'Two-Tailed Fox Catalyst') { - itemWithSameName = inventoryItems.find( - (i) => i.displayProperties.name === 'Third Tail' && i.plug?.plugStyle === 1, - ); - } - - // Work around for exotic quest craftables - // still no good icon for osteo striga catalyst - switch (recordName) { - case 'Revision Zero Catalyst': - itemWithSameName = findDummyItemWithSpecificName('4-Timer Refit'); - break; - case 'Immovable Refit': - itemWithSameName = findDummyItemWithSpecificName('Immovable Refit'); - break; - case 'Wish-Keeper Catalyst': - itemWithSameName = findDummyItemWithSpecificName('Hatchling Refit'); - break; - } - - const matchingExotic = - (itemWithSameName && - (findWeaponViaCatalystPlug(itemWithSameName.hash) ?? - findWeaponViaCatalystPCH(itemWithSameName.plug?.plugCategoryHash))) ?? - craftableExotics.find((i) => - record.displayProperties.description.includes(i!.displayProperties.name), - ); - - if (matchingExotic) { - exoticWeaponHashToCatalystRecord[matchingExotic.hash] = r.recordHash; - exoticWeaponHashesWithCatalyst.push(matchingExotic.hash); - } + if (matchingExotic) { + exoticWeaponHashToCatalystRecord[matchingExotic.hash] = r.recordHash; + exoticWeaponHashesWithCatalyst.push(matchingExotic.hash); + } - // and get its icon image - const icon = itemWithSameName?.displayProperties?.icon; + // and get its icon image + const icon = itemWithSameName?.displayProperties?.icon; - // this "if" check is because of classified data situations - if (icon) { - triumphData[r.recordHash] = icon; - } else { - if (!IGNORED_CATALYSTS_NAMES.some((term) => recordName?.includes(term))) { - console.log(`no catalyst image found for ${r.recordHash} ${recordName}`); - } + // this "if" check is because of classified data situations + if (icon) { + triumphData[r.recordHash] = icon; + } else { + if (!IGNORED_CATALYSTS_NAMES.some((term) => recordName?.includes(term))) { + console.log(`no catalyst image found for ${r.recordHash} ${recordName}`); } - }), + } + }), ); // Generate List of Sorted Exotic Weapons Hashes with Catalysts @@ -118,11 +116,14 @@ const annotatedExoticHashes = annotate(pretty); // Get all Dummy Catalyst items, figure out their PCHs, and map them to the reinitializationPossiblePlugHashes items if available // This will create a mapping of dummy catalyst -> actual catalyst for all guns that 'auto-apply' catalyst when pulled from collections -const dummyCatalystMapping = Object.fromEntries(getAllDefs('InventoryItem').filter( - (i) => i.itemType === 20 && i.plug?.uiPlugLabel === 'masterwork_interactable', -).filter((i) => i.plug?.plugCategoryHash && i.hash) - .map((i) => [i.hash, findAutoAppliedCatalystForCatalystPCH(i.plug!.plugCategoryHash!)]) - .filter(([hash, catalyst]) => hash && catalyst).map(([hash, catalyst]) => [hash, catalyst!])); +const dummyCatalystMapping = Object.fromEntries( + getAllDefs('InventoryItem') + .filter((i) => i.itemType === 20 && i.plug?.uiPlugLabel === 'masterwork_interactable') + .filter((i) => i.plug?.plugCategoryHash && i.hash) + .map((i) => [i.hash, findAutoAppliedCatalystForCatalystPCH(i.plug!.plugCategoryHash!)]) + .filter(([hash, catalyst]) => hash && catalyst) + .map(([hash, catalyst]) => [hash, catalyst!]), +); writeFile('./output/dummy-catalyst-mapping.json', dummyCatalystMapping); writeFile('./output/catalyst-triumph-icons.json', triumphData); @@ -139,22 +140,20 @@ function getCatalystPresentationNodeHash(): number | undefined { } function findWeaponViaCatalystPlug(catalystPlugHash: number) { - return inventoryItems.find( - (item) => - item.sockets?.socketEntries.find( - (socket) => socket.reusablePlugItems[0]?.plugItemHash === catalystPlugHash, - ), + return inventoryItems.find((item) => + item.sockets?.socketEntries.find( + (socket) => socket.reusablePlugItems[0]?.plugItemHash === catalystPlugHash, + ), ); } function findWeaponViaCatalystPCH(catalystPCH: number | undefined) { - const socketTypeHash = allsockets.find( - (sockets) => sockets.plugWhitelist?.find((plug) => plug.categoryHash === catalystPCH), + const socketTypeHash = allsockets.find((sockets) => + sockets.plugWhitelist?.find((plug) => plug.categoryHash === catalystPCH), )?.hash; - return inventoryItems.find( - (item) => - item.sockets?.socketEntries.find((socket) => socket.socketTypeHash === socketTypeHash), + return inventoryItems.find((item) => + item.sockets?.socketEntries.find((socket) => socket.socketTypeHash === socketTypeHash), ); } @@ -167,9 +166,10 @@ function findDummyItemWithSpecificName(DummyItemName: string) { } function findAutoAppliedCatalystForCatalystPCH(catalystPCH: number) { - const socket = allsockets.find( - (sockets) => sockets.plugWhitelist?.find((plug) => plug.categoryHash === catalystPCH), + const socket = allsockets.find((sockets) => + sockets.plugWhitelist?.find((plug) => plug.categoryHash === catalystPCH), ); - return socket?.plugWhitelist?.find((plug) => plug.categoryHash === catalystPCH)?.reinitializationPossiblePlugHashes?.[0]; + return socket?.plugWhitelist?.find((plug) => plug.categoryHash === catalystPCH) + ?.reinitializationPossiblePlugHashes?.[0]; } From 734abecced35e1503d90b3a16be40e3c4e04767f Mon Sep 17 00:00:00 2001 From: FlaminSarge Date: Sat, 4 May 2024 15:54:26 -0700 Subject: [PATCH 3/4] pnpm lint --- src/generate-catalyst-data.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/generate-catalyst-data.ts b/src/generate-catalyst-data.ts index a8c98fe4..b794dacb 100644 --- a/src/generate-catalyst-data.ts +++ b/src/generate-catalyst-data.ts @@ -120,7 +120,7 @@ const dummyCatalystMapping = Object.fromEntries( getAllDefs('InventoryItem') .filter((i) => i.itemType === 20 && i.plug?.uiPlugLabel === 'masterwork_interactable') .filter((i) => i.plug?.plugCategoryHash && i.hash) - .map((i) => [i.hash, findAutoAppliedCatalystForCatalystPCH(i.plug!.plugCategoryHash!)]) + .map((i) => [i.hash, findAutoAppliedCatalystForCatalystPCH(i.plug!.plugCategoryHash)]) .filter(([hash, catalyst]) => hash && catalyst) .map(([hash, catalyst]) => [hash, catalyst!]), ); From 1cd6ec319a77f45b9b61113f618469cf4bf6a8d2 Mon Sep 17 00:00:00 2001 From: FlaminSarge Date: Sat, 4 May 2024 17:11:14 -0700 Subject: [PATCH 4/4] Reduce redundant call for readability --- src/generate-catalyst-data.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/generate-catalyst-data.ts b/src/generate-catalyst-data.ts index b794dacb..e3c02386 100644 --- a/src/generate-catalyst-data.ts +++ b/src/generate-catalyst-data.ts @@ -166,10 +166,9 @@ function findDummyItemWithSpecificName(DummyItemName: string) { } function findAutoAppliedCatalystForCatalystPCH(catalystPCH: number) { - const socket = allsockets.find((sockets) => - sockets.plugWhitelist?.find((plug) => plug.categoryHash === catalystPCH), - ); + const plug = allsockets + .flatMap((socket) => socket.plugWhitelist || []) + .find((plug) => plug.categoryHash === catalystPCH); - return socket?.plugWhitelist?.find((plug) => plug.categoryHash === catalystPCH) - ?.reinitializationPossiblePlugHashes?.[0]; + return plug?.reinitializationPossiblePlugHashes?.[0]; }