Skip to content

Commit

Permalink
Add support for shattering
Browse files Browse the repository at this point in the history
  • Loading branch information
p3lim committed Sep 9, 2024
1 parent fbd9e0d commit afb4167
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/scrape_retail.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ jobs:
disenchantable: disenchantable
scrappable: scrappable
crushable: crushable
shatterable: shatterable
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ The following "salvaging" is supported:
- [Engineering picks](https://www.wowhead.com/items/consumables?filter=107:99;0:5;lock:0#0+2+18)
- [Scrapping](https://www.wowhead.com/spell=382374)
- [Crushing](https://www.wowhead.com/spell=395696)
- [Shattering](https://www.wowhead.com/spell=391302)

In addition, Molinari also works for lockpicking in the trade window.

Expand Down
13 changes: 13 additions & 0 deletions api/items.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ function addon:IsScrappable(itemID)
end
end

function addon:IsShatterable(itemID)
if addon:IsRetail() then
local info = addon.data.shatterable[itemID]
if info then
return info[1], addon.colors.disenchantable, info[2]
end
end
end

function addon:NonDisenchantable(itemID)
return not not addon.data.nondisenchantable[itemID]
end
Expand Down Expand Up @@ -119,6 +128,10 @@ function addon:IsSalvagable(itemID)
if spellID then
return spellID, color, numItems
end
spellID, color, numItems = addon:IsShatterable(itemID)
if spellID then
return spellID, color, numItems
end
spellID, color = addon:IsDisenchantable(itemID)
if spellID then
return spellID, color
Expand Down
58 changes: 58 additions & 0 deletions scripts/shatterable.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/env python3

from utils import *

itemSparse = CSVReader(open('dbc/itemsparse.csv', 'r'))
itemSalvageLoot = CSVReader(open('dbc/itemsalvageloot.csv', 'r'))
spellEffect = CSVReader(open('dbc/spelleffect.csv', 'r'))

recipeSpellIDs = {
44: 391302, # Crystalline Shatter (Dragon Isles)
45: 391304, # Elemental Shatter (Dragon Isles)
86: 445466, # Shatter Essence (Khaz Algar)
# TODO: add new shatter recipe for Gleaming Shard
}

# figure out how many items are needed to perform the salvage
spellItemsRequired = {}
for _, spellID in recipeSpellIDs.items():
spellItemsRequired[spellID] = 0

for row in spellEffect:
if row.SpellID in spellItemsRequired:
spellItemsRequired[row.SpellID] = row.EffectBasePointsF

# iterate through ItemSalvageLoot for items that can be shattered
items = {}
for row in itemSalvageLoot:
if row.ItemSalvageID in recipeSpellIDs:
items[row.SalvagedItemID] = {
'itemID': row.SalvagedItemID,
'recipeSpellID': recipeSpellIDs[row.ItemSalvageID],
'numItems': spellItemsRequired[recipeSpellIDs[row.ItemSalvageID]],
}

# shatterable items somehow not in ItemSalvageLoot
items[124441] = { # Leylight Shard
'itemID': 124441,
'recipeSpellID': 224199, # Ley Shatter (Legion)
'numItems': 1,
}
items[124442] = { # Chaos Crystal
'itemID': 124442,
'recipeSpellID': 252106, # Chaos Shatter (Legion)
'numItems': 1,
}

# iterate through ItemSparse for shatterable items and add their names to the dict
for row in itemSparse:
if row.ID in items:
if (getattr(row, 'Flags[0]') & 0x10) != 0:
# deprecated item
del items[row.ID]
continue

items[row.ID]['name'] = row.Display_lang

# print data file structure
templateLuaTable('shatterable', '\t[{itemID}] = {{{recipeSpellID}, {numItems}}}, -- {name}', items)

0 comments on commit afb4167

Please sign in to comment.