Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add super subclass plugs. #627

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions output/subclass-plug-category-hashes.json
Original file line number Diff line number Diff line change
@@ -1,36 +1,54 @@
[
39076551,
81856188,
144959979,
180411040,
185594100,
204703343,
227647633,
379285521,
404070091,
511532732,
605941486,
641408223,
826897697,
900498880,
902963970,
1080622901,
1191502208,
1197336009,
1281712906,
1308084083,
1387605624,
1422809918,
1458470025,
1662395848,
1681184239,
1684765285,
1763298974,
1774026300,
1861253111,
1929408791,
1943502171,
1960796738,
1970675705,
1979332108,
2101241798,
2111409167,
2139679542,
2200902275,
2285394316,
2415307576,
2430016289,
2434874031,
2480042224,
2552562702,
2613010961,
2789335173,
2822977079,
2831653331,
2850085618,
2883193222,
2905530840,
2997411645,
3052104375,
Expand All @@ -39,12 +57,24 @@
3205146347,
3287837048,
3324969927,
3339135424,
3369359206,
3460332466,
3468785159,
3530064820,
3538316507,
3693308166,
3711066169,
3728449707,
3752921107,
3777887553,
3820930681,
3826855743,
3873313773,
3904090216,
3956119552,
3990226434,
4031311265,
4141244538,
4145425829,
4225254304
Expand Down
17 changes: 17 additions & 0 deletions output/subclass-super-plug-category-hashes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

README.md documents these output files in a table, wouldn't hurt to add this one too.

144959979,
180411040,
902963970,
1080622901,
1684765285,
1774026300,
1861253111,
2285394316,
2613010961,
2850085618,
2997411645,
3151809860,
3468785159,
4141244538,
4145425829
]
4 changes: 3 additions & 1 deletion src/generate-subclass-plug-category-hashes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ function findAllSubclassPlugs() {
for (const plugItem of plugItems) {
const plugCategoryHash = plugItem?.plug?.plugCategoryHash;
if (plugCategoryHash) {
plugTracker[plugItem.displayProperties.name] = plugCategoryHash;
plugTracker[
`${plugItem.plug.plugCategoryIdentifier} - ${plugItem.displayProperties.name}`
] = plugCategoryHash;
}
}
}
Expand Down
65 changes: 65 additions & 0 deletions src/generate-subclass-super-plug-category-hashes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/**
* Collect all the subclass super plug plugCategoryHashes.
*/
import { getAllDefs, getDef } from '@d2api/manifest-node';
import { uniqAndSortArray, writeFile } from './helpers.js';
import { infoLog, infoTable } from './log.js';

const TAG = 'SUBCLASS-PLUG';
const DEBUG = false;

const getItem = (hash: number) => getDef('InventoryItem', hash);
const getPlugSet = (hash: number) => getDef('PlugSet', hash);

const allItems = getAllDefs('InventoryItem');

const classBucketHash = 3284755031;

const superSocketCategoryHash = 457473665;

function findAllSubclassSuperPlugs() {
const plugTracker: Record<string, number> = {};

for (const item of allItems) {
if (item.inventory?.bucketTypeHash === classBucketHash && item.sockets) {
const indexes: number[] = [];

// get all the socket indexes that have the right category hash
for (const socketCategory of item.sockets.socketCategories) {
if (socketCategory.socketCategoryHash === superSocketCategoryHash) {
for (const index of socketCategory.socketIndexes) {
indexes.push(index);
}
}
}

for (const socketIndex of indexes) {
const socket = item.sockets.socketEntries[socketIndex];
const plugSet = socket.reusablePlugSetHash
? getPlugSet(socket.reusablePlugSetHash)
: undefined;
const plugItems =
plugSet?.reusablePlugItems.map(({ plugItemHash }) => getItem(plugItemHash)) || [];
for (const plugItem of plugItems) {
const plugCategoryHash = plugItem?.plug?.plugCategoryHash;
if (plugCategoryHash) {
plugTracker[
`${plugItem.plug.plugCategoryIdentifier} - ${plugItem.displayProperties.name}`
] = plugCategoryHash;
}
}
}
}
}

// Log this to make debugging easier
if (DEBUG) {
infoLog(TAG, 'Subclass super plugs found');
infoTable(plugTracker);
}
return Array.from(new Set(Object.values(plugTracker)));
}

const subclassPlugs = uniqAndSortArray(findAllSubclassSuperPlugs());

writeFile('./output/subclass-super-plug-category-hashes.json', subclassPlugs);