All pastes #397681 Raw Edit

Stuff

public lua v1 · immutable
#397681 ·published 2007-03-16 17:45 UTC
rendered paste body
-- Enchanting reagentslocal VOID = 22450local NEXUS = 20725local LPRISMATIC = 22449local LBRILLIANT = 14344local LRADIANT = 11178local LGLOWING = 11139local LGLIMMERING = 11084local SPRISMATIC = 22448local SBRILLIANT = 14343local SRADIANT = 11177local SGLOWING = 11138local SGLIMMERING = 10978local GPLANAR = 22446local GETERNAL = 16203local GNETHER = 11175local GMYSTIC = 11135local GASTRAL = 11082local GMAGIC = 10939local LPLANAR = 22447local LETERNAL = 16202local LNETHER = 11174local LMYSTIC = 11134local LASTRAL = 10998local LMAGIC = 10938local ARCANE = 22445local ILLUSION = 16204local DREAM = 11176local VISION = 11137local SOUL = 11083local STRANGE = 10940-- These are market norm prices.-- Median prices from Allakhazam.com, Mar 15, 2007local baselinePrices = {[20725] = 75000, -- Nexus Crystal[14344] = 110000, -- Large Brilliant Shard[11178] = 87710, -- Large Radiant Shard[11139] = 26125, -- Large Glowing Shard[11084] = 10000, -- Large Glimmering Shard[14343] = 22500, -- Small Brilliant Shard[11177] = 70000, -- Small Radiant Shard[11138] = 5349, -- Small Glowing Shard[10978] = 3500, -- Small Glimmering Shard[16203] = 115000, -- Greater Eternal Essence[11175] = 60000, -- Greater Nether Essence[11135] = 10000, -- Greater Mystic Essence[11082] = 9285, -- Greater Astral Essence[10939] = 5998, -- Greater Magic Essence[16202] = 43500, -- Lesser Eternal Essence[11174] = 23333, -- Lesser Nether Essence[11134] = 5000, -- Lesser Mystic Essence[10998] = 4066, -- Lesser Astral Essence[10938] = 3000, -- Lesser Magic Essence[16204] = 21000, -- Illusion Dust[11176] = 8750, -- Dream Dust[11137] = 5500, -- Vision Dust[11083] = 3453, -- Soul Dust[10940] = 1275, -- Strange Dust[22445] = 20000, -- Arcane Dust[22447] = 22325, -- Lesser Planar Essence[22446] = 68000, -- Greater Planar Essence[22448] = 64600, -- Small Prismatic Shard[22449] = 190000, -- Large Prismatic Shard[22450] = 997500, -- Void Crystal} -- A price adjustment to favour/disfavour particular reagents-- depending on the market.local priceAdjustment = { [VOID]        = 1, [NEXUS]       = 1, [LPRISMATIC]  = 1, [LBRILLIANT]  = 1, [LRADIANT]    = 1, [LGLOWING]    = 1, [LGLIMMERING] = 1, [SPRISMATIC]  = 1, [SBRILLIANT]  = 1, [SRADIANT]    = 1, [SGLOWING]    = 1, [SGLIMMERING] = 1, [GPLANAR]     = 1, [GETERNAL]    = 1, [GNETHER]     = 1, [GMYSTIC]     = 1, [GASTRAL]     = 1, [GMAGIC]      = 1, [LPLANAR]     = 1, [LETERNAL]    = 1, [LNETHER]     = 1, [LMYSTIC]     = 1, [LASTRAL]     = 1, [LMAGIC]      = 1, [ARCANE]      = 1, [ILLUSION]    = 1, [DREAM]       = 1, [VISION]      = 1, [SOUL]        = 0.9, [STRANGE]     = 1,}-- item typeslocal WEAPON = 0local ARMOR = 1-- item qualitieslocal UNCOMMON = 2local RARE = 3local EPIC = 4-- convert an item type string to an integer typelocal typeStringToType = { ["Weapon"] = WEAPON, ["Armor"]  = ARMOR,}-- disenchanting level bracket upper bounds, e.g. an ilevel 52 item-- goes into bracket 55local levelUpperBounds = { 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 85, 99, 120 }-- bad items that look like they should be disenchantable but aren'tlocal badItem = {  [11287] = {}, -- Lesser Magic Wand	  [11288] = {}, -- Greater Magic Wand  [11289] = {}, -- Lesser Mystic Wand  [11290] = {}, -- Greater Mystic Wand  [20406] = {}, -- Twilight Cultist Mantle  [20407] = {}, -- Twilight Cultist Robe  [20408] = {}, -- Twilight Cultist Cowl}-- the big disenchant table, indexed by [quality][type][level bracket]-- and yielding { { reagent type, drop probability, average drop quantity }, ... }-- I would use Enchantrix, but it lacks data for new itemslocal disenchantTable = { [UNCOMMON] = {  [WEAPON] = {   [15]  = { { STRANGE , 0.20, 1.5 }, { LMAGIC  , 0.80, 1.5 }, },   [20]  = { { STRANGE , 0.20, 2.5 }, { GMAGIC  , 0.75, 1.5 }, { SGLIMMERING, 0.05, 1.0 }, },   [25]  = { { STRANGE , 0.15, 5.0 }, { GMAGIC  , 0.75, 1.5 }, { SGLIMMERING, 0.10, 1.0 }, },   [30]  = { { SOUL    , 0.20, 1.5 }, { GMAGIC  , 0.75, 1.5 }, { LGLIMMERING, 0.05, 1.0 }, },   [35]  = { { SOUL    , 0.20, 3.5 }, { LMYSTIC , 0.75, 1.5 }, { SGLOWING   , 0.05, 1.0 }, },   [40]  = { { VISION  , 0.20, 1.5 }, { GMYSTIC , 0.75, 1.5 }, { LGLOWING   , 0.05, 1.0 }, },   [45]  = { { VISION  , 0.15, 3.5 }, { LNETHER , 0.80, 1.5 }, { SRADIANT   , 0.05, 1.0 }, },   [50]  = { { DREAM   , 0.20, 1.5 }, { GNETHER , 0.75, 1.5 }, { LRADIANT   , 0.05, 1.0 }, },   [55]  = { { DREAM   , 0.20, 3.5 }, { LETERNAL, 0.75, 1.5 }, { SBRILLIANT , 0.05, 1.0 }, },   [60]  = { { ILLUSION, 0.20, 1.5 }, { GETERNAL, 0.75, 1.5 }, { LBRILLIANT , 0.05, 1.0 }, },   [65]  = { { ILLUSION, 0.20, 3.5 }, { GETERNAL, 0.75, 2.5 }, { LBRILLIANT , 0.05, 1.0 }, },   [85]  = { { ARCANE  , 0.20, 2.5 }, { LPLANAR , 0.75, 2.5 }, { SPRISMATIC , 0.05, 1.0 }, },   [99]  = { { ARCANE  , 0.20, 2.5 }, { LPLANAR , 0.75, 2.5 }, { SPRISMATIC , 0.05, 1.0 }, },   [120] = { { ARCANE  , 0.20, 3.5 }, { GPLANAR , 0.75, 1.5 }, { LPRISMATIC , 0.05, 1.0 }, },  },  [ARMOR] = {   [15]  = { { STRANGE , 0.80, 1.5 }, { LMAGIC  , 0.20, 1.5 }, },   [20]  = { { STRANGE , 0.75, 2.5 }, { GMAGIC  , 0.20, 1.5 }, { SGLIMMERING, 0.05, 1.0 }, },   [25]  = { { STRANGE , 0.75, 5.0 }, { LASTRAL , 0.15, 1.5 }, { SGLIMMERING, 0.10, 1.0 }, },   [30]  = { { SOUL    , 0.75, 1.5 }, { GASTRAL , 0.20, 1.5 }, { LGLIMMERING, 0.05, 1.0 }, },   [35]  = { { SOUL    , 0.75, 3.5 }, { LMYSTIC , 0.20, 1.5 }, { SGLOWING   , 0.05, 1.0 }, },   [40]  = { { VISION  , 0.75, 1.5 }, { GMYSTIC , 0.20, 1.5 }, { LGLOWING   , 0.05, 1.0 }, },   [45]  = { { VISION  , 0.80, 3.5 }, { LNETHER , 0.15, 1.5 }, { SRADIANT   , 0.05, 1.0 }, },   [50]  = { { DREAM   , 0.75, 1.5 }, { GNETHER , 0.20, 1.5 }, { LRADIANT   , 0.05, 1.0 }, },   [55]  = { { DREAM   , 0.75, 3.5 }, { LETERNAL, 0.20, 1.5 }, { SBRILLIANT , 0.05, 1.0 }, },   [60]  = { { ILLUSION, 0.75, 1.5 }, { GETERNAL, 0.20, 1.5 }, { LBRILLIANT , 0.05, 1.0 }, },   [65]  = { { ILLUSION, 0.75, 3.5 }, { GETERNAL, 0.20, 2.5 }, { LBRILLIANT , 0.05, 1.0 }, },   [85]  = { { ARCANE  , 0.75, 2.5 }, { LPLANAR , 0.20, 2.5 }, { SPRISMATIC , 0.05, 1.0 }, },   [99]  = { { ARCANE  , 0.75, 2.5 }, { LPLANAR , 0.20, 2.5 }, { SPRISMATIC , 0.05, 1.0 }, },   [120] = { { ARCANE  , 0.75, 3.5 }, { GPLANAR , 0.20, 1.5 }, { LPRISMATIC , 0.05, 1.0 }, },  }, }, [RARE] = {  [WEAPON] = {   [20]  = { { SGLIMMERING, 1.00, 1.0 }, }, [25] = { { SGLIMMERING, 1.00, 1.0 }, },   [30]  = { { LGLIMMERING, 1.00, 1.0 }, }, [35] = { { SGLOWING   , 1.00, 1.0 }, },   [40]  = { { LGLOWING   , 1.00, 1.0 }, }, [45] = { { SRADIANT   , 1.00, 1.0 }, },   [50]  = { { LRADIANT   , 1.00, 1.0 }, }, [55] = { { SBRILLIANT , 1.00, 1.0 }, },   [60]  = { { LBRILLIANT , 0.99, 1.0 }, { NEXUS, 0.01, 1.0 }, },   [65]  = { { LBRILLIANT , 0.99, 1.0 }, { NEXUS, 0.01, 1.0 }, },   [85]  = { { SPRISMATIC , 0.99, 1.0 }, { NEXUS, 0.01, 1.0 }, },   [99]  = { { SPRISMATIC , 0.99, 1.0 }, { VOID , 0.01, 1.0 }, },   [120] = { { LPRISMATIC , 0.99, 1.0 }, { VOID , 0.01, 1.0 }, },  },  [ARMOR] = {   [20]  = { { SGLIMMERING, 1.00, 1.0 }, }, [25] = { { SGLIMMERING, 1.00, 1.0 }, },   [30]  = { { LGLIMMERING, 1.00, 1.0 }, }, [35] = { { SGLOWING   , 1.00, 1.0 }, },   [40]  = { { LGLOWING   , 1.00, 1.0 }, }, [45] = { { SRADIANT   , 1.00, 1.0 }, },   [50]  = { { LRADIANT   , 1.00, 1.0 }, }, [55] = { { SBRILLIANT , 1.00, 1.0 }, },   [60]  = { { LBRILLIANT , 0.99, 1.0 }, { NEXUS, 0.01, 1.0 }, },   [65]  = { { LBRILLIANT , 0.99, 1.0 }, { NEXUS, 0.01, 1.0 }, },   [85]  = { { SPRISMATIC , 0.99, 1.0 }, { NEXUS, 0.01, 1.0 }, },   [99]  = { { SPRISMATIC , 0.99, 1.0 }, { VOID , 0.01, 1.0 }, },   [120] = { { LPRISMATIC , 0.99, 1.0 }, { VOID , 0.01, 1.0 }, },  }, }, [EPIC] = {  [WEAPON] = {   [45] = { { SRADIANT  , 1.00, 3.5 }, }, [50]  = { { LRADIANT  , 1.00, 3.5 }, },   [55] = { { SBRILLIANT, 1.00, 3.5 }, }, [60]  = { { NEXUS     , 1.00, 1.0 }, },   [65] = { { NEXUS     , 1.00, 1.0 }, }, [85]  = { { NEXUS     , 1.00, 1.0 }, },   [99] = { { VOID      , 1.00, 1.0 }, }, [120] = { { VOID      , 1.00, 1.5 }, },  },  [ARMOR] = {   [45] = { { SRADIANT  , 1.00, 3.5 }, }, [50]  = { { LRADIANT  , 1.00, 3.5 }, },   [55] = { { SBRILLIANT, 1.00, 3.5 }, }, [60]  = { { NEXUS     , 1.00, 1.0 }, },   [65] = { { NEXUS     , 1.00, 1.0 }, }, [85]  = { { NEXUS     , 1.00, 1.0 }, },   [99] = { { VOID      , 1.00, 1.0 }, }, [120] = { { VOID      , 1.00, 1.5 }, },  }, },}------------------------------------------ calculate value of a stack of reagents based on-- auctioneer data and price tables abovelocal getReagentValue = function(itemID, itemCount)  local base = baselinePrices[itemID]  if not base then return nil end  local adjust = priceAdjustment[itemID] or 1  local historical = nil  local snapshot = nil  local _, link = GetItemInfo(itemID)  if link then    local key = Auctioneer.ItemDB.CreateItemKeyFromLink(link)    if key then      historical = Auctioneer.Statistic.GetItemHistoricalMedianBuyout(key)      snapshot = Auctioneer.Statistic.GetItemSnapshotMedianBuyout(key)    end  end  historical = historical or base  snapshot = snapshot or base  -- arbitrary weighting really. just don't want the snapshot to  -- throw things off too much  local combined = (base * 4 + historical * 4 + snapshot) / 9  return combined * adjust * itemCountend-- take an ilevel and round it up to the corresponding bracketlocal roundupLevel = function(level)  for _, bracket in pairs(levelUpperBounds) do    if bracket >= level then      return bracket    end  end  return nilend-- get entry from disenchant table (or nil if nothing found)local getDisenchants = function(quality, type, level)  if disenchantTable[quality] and disenchantTable[quality][type] and disenchantTable[quality][type][level] then    return disenchantTable[quality][type][level]  end  return nilend-- calculate disenchant value of item based on disenchant table and-- calculated reagent valueslocal getDisenchantValue = function(itemID)  local result = nil  local _, _, quality, level, _, typeString, _, _, _, _ = GetItemInfo(itemID)  if quality >= UNCOMMON and quality <= EPIC and not badItem[itemID] then    local type = typeStringToType[typeString]    if type then      level = roundupLevel(level)      if level then        local disenchants = getDisenchants(quality, type, level)        if disenchants then          result = 0          for _, stats in pairs(disenchants) do            local reagent, chance, count = stats[1], stats[2], stats[3]            result = result + getReagentValue(reagent, chance * count)          end        end      end    end  end  return resultend---------------------------------------------------------------------------------- now decide what to do with the auction-- min profit for bidlocal bidMinProfitRel = 0.70local bidMinProfitAbs = 3000-- min profit for buylocal buyMinProfitRel = 0.70local buyMinProfitAbs = 5000-- if buyout is close enough to low enough bid, just buy it anywaylocal buyMaxBidNear = 0.025-- assume item is worthless until proven otherwiselocal myBasePrice = 0-- prevent equipable greens from showing up for resalelocal _,_, quality, _, _, class, _,_,_ = GetItemInfo(itemID)if (quality==2 and (class =="Weapon" or class == "Armor"))  then  basePrice = 0end-- calculate disenchant value or reagent value depending on the type of itemlocal disenchantValue = getDisenchantValue(itemID)if disenchantValue then  myBasePrice = disenchantValue  reason = "Disenchant"  depositCost = 0  depositRate = 0else  local reagentValue = getReagentValue(itemID, itemCount)  if reagentValue then    myBasePrice = reagentValue    reason = "Reagent"    depositCost = 0    depositRate = 0  endend-- account for AH cutlocal resaleValue = myBasePrice * 0.95-- decide whether or not to buyif     buyPrice ~= 0 and buyPrice <= resaleValue * (1 - buyMinProfitRel) and buyPrice <= resaleValue - buyMinProfitAbs then  action = "buy"  reason = reason .. " (buy)"  basePrice = resaleValueelseif bidPrice ~= 0 and bidPrice <= resaleValue * (1 - bidMinProfitRel) and bidPrice <= resaleValue - bidMinProfitAbs then  if buyPrice ~= 0 and bidPrice >= buyPrice * (1 - buyMaxBidNear) then    action = "buy"    reason = reason .. " (buy near bid)"    basePrice = resaleValue  else    action = "bid"    reason = reason .. " (bid)"    basePrice = resaleValue  endend