|
7 | 7 | // Configuration object |
8 | 8 | const CONFIG = { |
9 | 9 | filterDiscovered: true, // Set to false to show all items regardless of discovery status |
| 10 | + gameMode: [], // Possible values: 'base', 'td', 'aod', 'cr' (for base game, Throne of the Herald, Astrology of Dragons, Crimson Reborn) |
10 | 11 | showDropSources: true, // Set to false to hide drop source information |
| 12 | + showDungeonInfo: true, // Set to false to hide dungeon information |
11 | 13 | showItemIds: true, // Set to false to hide item IDs |
12 | 14 | showSlayerInfo: true, // Set to false to hide slayer task information |
13 | 15 | sortByCombatLevel: true, // Set to false to keep default sort |
|
25 | 27 |
|
26 | 28 | // Loop through all game items |
27 | 29 | game.items.allObjects.forEach((item) => { |
| 30 | + // Check item game mode |
| 31 | + if (CONFIG.gameMode && CONFIG.gameMode.length > 0) { |
| 32 | + const itemGameMode = item.gamemode; |
| 33 | + const isValidGameMode = CONFIG.gameMode.some( |
| 34 | + (mode) => |
| 35 | + (mode === 'base' && itemGameMode === 'melvorBase') || |
| 36 | + (mode === 'td' && itemGameMode === 'melvorTotH') || |
| 37 | + (mode === 'aod' && itemGameMode === 'melvorAoD') || |
| 38 | + (mode === 'cr' && itemGameMode === 'melvorCR') |
| 39 | + ); |
| 40 | + if (!isValidGameMode) { |
| 41 | + return; // Skip items not from selected game modes |
| 42 | + } |
| 43 | + } |
| 44 | + |
28 | 45 | // Check if item has been discovered |
29 | 46 | const isDiscovered = game.stats.itemFindCount(item) > 0; |
30 | 47 | // Check if it's not in inventory |
|
57 | 74 | if ((!CONFIG.filterDiscovered || isDiscovered) && !isInInventory && !isEquipped) { |
58 | 75 | // Get drop sources for this item |
59 | 76 | const dropSources = []; |
| 77 | + const dungeonSources = []; // Array for dungeon sources |
60 | 78 |
|
61 | 79 | game.monsters.allObjects.forEach((monster) => { |
62 | 80 | const drops = monster.lootTable.drops; |
|
86 | 104 | }); |
87 | 105 | }); |
88 | 106 |
|
| 107 | + // Function to get dungeon combat level |
| 108 | + const getDungeonLevel = (dungeon) => { |
| 109 | + // Use the highest level monster in the dungeon as reference |
| 110 | + return dungeon.monsters |
| 111 | + ? Math.max(...dungeon.monsters.map((monster) => monster.combatLevel)) |
| 112 | + : dungeon.combinedModifiers?.decreasedMinimumCombatLevel || dungeon.recommendedBaseCombatLevel || 0; |
| 113 | + }; |
| 114 | + |
| 115 | + // Modify dungeon sources collection to include max monster level |
| 116 | + game.dungeons.allObjects.forEach((dungeon) => { |
| 117 | + if (dungeon._rewards) { |
| 118 | + const dungeonLevel = getDungeonLevel(dungeon); |
| 119 | + dungeon._rewards.forEach((reward) => { |
| 120 | + if (reward.type === 'Item' && reward.name === item.name) { |
| 121 | + dungeonSources.push({ |
| 122 | + dungeon: dungeon.name, |
| 123 | + chance: 100, |
| 124 | + type: 'completion', |
| 125 | + level: dungeonLevel, |
| 126 | + }); |
| 127 | + } else if (reward.type === 'Chest' && reward.dropTable && reward.dropTable.drops) { |
| 128 | + reward.dropTable.drops.forEach((drop) => { |
| 129 | + if (drop.item === item) { |
| 130 | + dungeonSources.push({ |
| 131 | + dungeon: dungeon.name, |
| 132 | + chance: (drop.weight / reward.dropTable.totalWeight) * 100, |
| 133 | + type: 'chest', |
| 134 | + level: dungeonLevel, |
| 135 | + }); |
| 136 | + } |
| 137 | + }); |
| 138 | + } |
| 139 | + }); |
| 140 | + } |
| 141 | + }); |
| 142 | + |
89 | 143 | // Sort drop sources by chance (highest to lowest) |
90 | 144 | dropSources.sort((a, b) => b.chance - a.chance); |
91 | 145 |
|
92 | 146 | missingItems.push({ |
93 | 147 | item: item, |
94 | 148 | dropSources: dropSources, |
| 149 | + dungeonSources: dungeonSources, // Add dungeon sources |
95 | 150 | }); |
96 | 151 | } |
97 | 152 | } |
|
115 | 170 |
|
116 | 171 | const aHasSlayer = hasSlayerDrops(a); |
117 | 172 | const bHasSlayer = hasSlayerDrops(b); |
| 173 | + const aHasDrops = a.dropSources.length > 0; |
| 174 | + const bHasDrops = b.dropSources.length > 0; |
| 175 | + const aHasDungeon = a.dungeonSources.length > 0; |
| 176 | + const bHasDungeon = b.dungeonSources.length > 0; |
118 | 177 |
|
119 | | - // First sort by whether the item has slayer drops |
| 178 | + // Slayer first |
120 | 179 | if (aHasSlayer !== bHasSlayer) { |
121 | | - return bHasSlayer - aHasSlayer; // Slayer items first |
| 180 | + return bHasSlayer - aHasSlayer; |
122 | 181 | } |
123 | 182 |
|
124 | 183 | // If both have slayer drops, sort by slayer combat level |
125 | 184 | if (aHasSlayer && bHasSlayer) { |
126 | 185 | return getMinSlayerCombatLevel(a) - getMinSlayerCombatLevel(b); |
127 | 186 | } |
128 | 187 |
|
129 | | - // If neither have slayer drops, sort by non-slayer combat level |
130 | | - const aHasDrops = a.dropSources.length > 0; |
131 | | - const bHasDrops = b.dropSources.length > 0; |
| 188 | + if (aHasDrops !== bHasDrops) { |
| 189 | + return bHasDrops - aHasDrops; |
| 190 | + } |
132 | 191 |
|
133 | 192 | if (aHasDrops && bHasDrops) { |
134 | 193 | return getMinNonSlayerCombatLevel(a) - getMinNonSlayerCombatLevel(b); |
135 | 194 | } |
136 | 195 |
|
137 | | - // Put items without drops at the end |
138 | | - return aHasDrops ? -1 : bHasDrops ? 1 : 0; |
| 196 | + // Add check for dungeon sources |
| 197 | + if (aHasDungeon !== bHasDungeon) { |
| 198 | + return bHasDungeon - aHasDungeon; |
| 199 | + } |
| 200 | + |
| 201 | + // Then dungeons |
| 202 | + if (aHasDungeon && bHasDungeon) { |
| 203 | + // First sort by dungeon level |
| 204 | + const aMinLevel = Math.min(...a.dungeonSources.map((source) => source.level)); |
| 205 | + const bMinLevel = Math.min(...b.dungeonSources.map((source) => source.level)); |
| 206 | + if (aMinLevel !== bMinLevel) { |
| 207 | + return aMinLevel - bMinLevel; |
| 208 | + } |
| 209 | + // If same level, sort by name |
| 210 | + return a.dungeonSources[0].dungeon.localeCompare(b.dungeonSources[0].dungeon); |
| 211 | + } |
| 212 | + |
| 213 | + return 0; |
139 | 214 | }); |
140 | 215 | } |
141 | 216 |
|
|
146 | 221 | itemsToShow.length > 0 |
147 | 222 | ? '\n' + |
148 | 223 | itemsToShow |
149 | | - .map(({ item, dropSources }) => { |
| 224 | + .map(({ item, dropSources, dungeonSources }) => { |
150 | 225 | const itemInfo = `- ${item.name}${CONFIG.showItemIds ? ` [ID: ${item.id}]` : ''}`; |
151 | 226 |
|
152 | | - if (!CONFIG.showDropSources || dropSources.length === 0) return itemInfo; |
| 227 | + if (!CONFIG.showDropSources || (dropSources.length === 0 && dungeonSources.length === 0)) return itemInfo; |
153 | 228 |
|
154 | 229 | const dropInfo = dropSources |
155 | 230 | .map((source) => { |
156 | 231 | const slayerInfo = CONFIG.showSlayerInfo && source.canSlayer ? ` [${source.taskDifficulty} Task]` : ''; |
157 | 232 | return `\n-- Drops from ${source.monster} (${source.combatLevel})${slayerInfo} (${source.chance.toFixed(2)}%)`; |
158 | 233 | }) |
159 | 234 | .join(''); |
160 | | - return `${itemInfo}${dropInfo}`; |
| 235 | + |
| 236 | + const dungeonInfo = |
| 237 | + CONFIG.showDungeonInfo && dungeonSources.length > 0 |
| 238 | + ? dungeonSources |
| 239 | + .map((source) => { |
| 240 | + const levelInfo = source.level > 0 ? ` (Level ${source.level})` : ''; |
| 241 | + const sourceType = source.type === 'chest' ? 'Chest' : 'Completion'; |
| 242 | + return `\n-- Found in ${source.dungeon}${levelInfo} (${sourceType}) (${source.chance.toFixed(2)}%)`; |
| 243 | + }) |
| 244 | + .join('') |
| 245 | + : ''; |
| 246 | + |
| 247 | + return `${itemInfo}${dropInfo}${dungeonInfo}`; |
161 | 248 | }) |
162 | 249 | .filter(Boolean) |
163 | 250 | .join('\n') |
|
0 commit comments