mischivin@39
|
1 local ORE = select(7,GetItemInfo(123918)) -- Get Ore Subclass from a known quantity (leystone ore)
|
mischivin@39
|
2 local HERB = select(7,GetItemInfo(128304)) -- Get Herb Subclass from a known quantity (yseralline seed)
|
mischivin@20
|
3
|
mischivin@36
|
4 local Quality = { [0] = "Junk", [1]= "Common", [2] = "Uncommon", [3] = "Rare", [4] = "Epic", }
|
Vynn@0
|
5
|
mischivin@36
|
6 local function Initialize()
|
mischivin@36
|
7 ProspectMe.FormatPrice = function (value)
|
Vynn@0
|
8
|
mischivin@36
|
9 local GSC_GOLD="ffffd100"
|
mischivin@36
|
10 local GSC_SILVER="ffe6e6e6"
|
mischivin@36
|
11 local GSC_COPPER="ffc8602c"
|
Vynn@0
|
12
|
mischivin@36
|
13 local g, s, c
|
mischivin@36
|
14 local digits = 0
|
mischivin@36
|
15 local gsc
|
Vynn@0
|
16
|
mischivin@36
|
17 g = math.floor(value/10000)
|
mischivin@36
|
18 s = math.fmod(math.floor(value/100),100)
|
mischivin@36
|
19 c = math.fmod(value,100)
|
Vynn@0
|
20
|
Vynn@0
|
21
|
mischivin@36
|
22 digits = math.floor(math.log10(value)+1)
|
Vynn@0
|
23
|
mischivin@36
|
24 if ( digits < 3 ) then
|
mischivin@36
|
25 gsc = string.format(" |c%s%2d|r", GSC_COPPER, c)
|
mischivin@36
|
26 elseif ( digits < 5 ) then
|
mischivin@36
|
27 gsc = string.format("|c%s%2d|r |c%s%02d|r", GSC_SILVER, s, GSC_COPPER, c)
|
mischivin@36
|
28 elseif ( digits < 7 ) then
|
mischivin@36
|
29 gsc = string.format("|c%s%2d|r |c%s%02d|r", GSC_GOLD, g, GSC_SILVER, s)
|
mischivin@36
|
30 elseif ( digits < 9 ) then
|
mischivin@36
|
31 gsc = string.format("|c%s%5d|r", GSC_GOLD, g)
|
mischivin@36
|
32 else
|
mischivin@36
|
33 gsc = string.format("|c%s%2.1fk|r", GSC_GOLD, g/1000)
|
mischivin@36
|
34 end
|
mischivin@36
|
35
|
mischivin@36
|
36 return gsc
|
Vynn@0
|
37 end
|
Vynn@0
|
38
|
mischivin@36
|
39 ProspectMe.GetReturn = function (containerID)
|
mischivin@36
|
40 local averageReturn = 0
|
mischivin@36
|
41 if ProspectMe.Results[containerID].TimesProspected > 0 then
|
mischivin@36
|
42 for itemID, num in pairs(ProspectMe.Results[containerID]) do
|
mischivin@36
|
43 if itemID ~= "TimesProspected" then
|
mischivin@36
|
44 averageReturn = averageReturn + ProspectMe.GetItemValue(itemID) * num
|
mischivin@36
|
45 end
|
Vynn@0
|
46 end
|
mischivin@36
|
47 averageReturn = averageReturn/ProspectMe.Results[containerID].TimesProspected
|
Vynn@0
|
48 end
|
mischivin@36
|
49 return tonumber(string.format("%.0f", averageReturn))
|
Vynn@0
|
50 end
|
Vynn@0
|
51 end
|
Vynn@0
|
52
|
Vynn@0
|
53 local cleared = true
|
Vynn@0
|
54 local function OnTooltipCleared(self)
|
Vynn@0
|
55 cleared = true
|
Vynn@0
|
56 end
|
Vynn@0
|
57
|
Vynn@0
|
58 local function OnTooltipSetItem(self)
|
Vynn@0
|
59 if cleared then
|
mischivin@39
|
60 local tooltipLink = select(2, self:GetItem())
|
mischivin@39
|
61 local spellid = select(3, self:GetSpell())
|
mischivin@39
|
62 local item = nil
|
mischivin@39
|
63 if spellid == 225902 then
|
mischivin@39
|
64 item = 123918
|
mischivin@39
|
65 elseif spellid == 225904 then
|
mischivin@39
|
66 item = 123919
|
mischivin@39
|
67 elseif spellid == 210116 then
|
mischivin@39
|
68 item = 128304
|
mischivin@39
|
69 elseif tooltipLink then
|
mischivin@39
|
70 item = tonumber(tooltipLink:match("Hitem:(%d+)"))
|
mischivin@39
|
71 spellid = nil
|
mischivin@39
|
72 else
|
mischivin@39
|
73 item = nil
|
mischivin@39
|
74 spellid = nil
|
mischivin@39
|
75 end
|
mischivin@39
|
76 if item then
|
mischivin@36
|
77 if ProspectMe.Results[item] then
|
mischivin@36
|
78 local price = ProspectMe.GetItemValue(item)
|
mischivin@36
|
79 local lifetimeReturn = ProspectMe.GetReturn(item)
|
mischivin@41
|
80 local subclass = select(7,GetItemInfo(item))
|
Vynn@0
|
81 --NumofEachQuality, Percent of Each Quality
|
Vynn@0
|
82 self:AddLine(" ")
|
Vynn@0
|
83 self:AddLine("Prospect Me",0.5,1,0.5)
|
mischivin@36
|
84 self:AddLine("Times Processed: " .. ProspectMe.Results[item].TimesProspected)
|
mischivin@39
|
85 if spellid then
|
mischivin@39
|
86 ctp = price * 20
|
mischivin@39
|
87 lifetimeReturn = lifetimeReturn * 4
|
mischivin@39
|
88 else
|
mischivin@39
|
89 ctp = price * 5
|
mischivin@39
|
90 end
|
mischivin@39
|
91 if spellid == 225902 or spellid == 225904 then
|
mischivin@39
|
92 self:AddDoubleLine("Cost to Mass Prospect: " .. ProspectMe.FormatPrice(ctp), " Average Return: " .. ProspectMe.FormatPrice(lifetimeReturn))
|
mischivin@39
|
93 elseif spellid == 210116 then
|
mischivin@39
|
94 self:AddDoubleLine("Cost to Mass Mill: " .. ProspectMe.FormatPrice(ctp), " Average Return: " .. ProspectMe.FormatPrice(lifetimeReturn))
|
mischivin@41
|
95 elseif subclass == ORE then
|
mischivin@39
|
96 self:AddDoubleLine("Cost to Prospect: " .. ProspectMe.FormatPrice(ctp), " Average Return: " .. ProspectMe.FormatPrice(lifetimeReturn))
|
mischivin@41
|
97 elseif subclass == HERB then
|
mischivin@39
|
98 self:AddDoubleLine("Cost to Mill: " .. ProspectMe.FormatPrice(ctp), " Average Return: " .. ProspectMe.FormatPrice(lifetimeReturn))
|
mischivin@39
|
99 else
|
mischivin@39
|
100 self:AddDoubleLine("Cost to Process: " .. ProspectMe.FormatPrice(ctp), " Average Return: " .. ProspectMe.FormatPrice(lifetimeReturn))
|
mischivin@39
|
101 end
|
mischivin@39
|
102 if lifetimeReturn-(ctp) > 0 then
|
mischivin@39
|
103 self:AddLine("Estimated Profit: " ..ProspectMe.FormatPrice(lifetimeReturn-(ctp)))
|
Vynn@0
|
104 self:AddLine(" ")
|
Vynn@0
|
105 else
|
Vynn@0
|
106 self:AddLine("No profit to be made",1,0,0)
|
Vynn@0
|
107 self:AddLine(" ")
|
Vynn@0
|
108 end
|
mischivin@36
|
109 local t
|
mischivin@36
|
110 if IsAltKeyDown() == ProspectMe.Config.PerSession then
|
mischivin@36
|
111 t = ProspectMe.Results
|
mischivin@36
|
112 self:AddDoubleLine("Lifetime Results","Hold/Release Alt to toggle",0.5,0.5,1,0.5,0.5,0.5)
|
mischivin@36
|
113 else
|
mischivin@36
|
114 t = ProspectMe.Session
|
mischivin@36
|
115 self:AddDoubleLine("Session Results","Hold/Release Alt to toggle",0.5,0.5,1,0.5,0.5,0.5)
|
mischivin@36
|
116 end
|
mischivin@36
|
117 if t[item] then
|
mischivin@36
|
118 for q = 7, 0, -1 do
|
mischivin@36
|
119 for result, num in pairs(t[item]) do
|
mischivin@36
|
120 if result ~= "TimesProspected" and select(3, GetItemInfo(result)) == q and ProspectMe.Config.ShowQualities[Quality[q]] then
|
mischivin@36
|
121 local p, n = "", ""
|
mischivin@36
|
122 if ProspectMe.Config.ShowPercent then
|
mischivin@36
|
123 p = num/t[item].TimesProspected*100
|
mischivin@36
|
124 if p < 10 then
|
mischivin@36
|
125 p = string.format("[%.1f%%]", p)
|
Vynn@0
|
126 else
|
mischivin@36
|
127 p = string.format("[%.0f%%]", p)
|
Vynn@0
|
128 end
|
mischivin@36
|
129 else
|
mischivin@36
|
130 p = ""
|
Vynn@0
|
131 end
|
mischivin@36
|
132 if ProspectMe.Config.ShowNumber then
|
mischivin@36
|
133 n = "[" .. num .. "]"
|
mischivin@36
|
134 else
|
mischivin@36
|
135 n = ""
|
mischivin@36
|
136 end
|
mischivin@36
|
137 self:AddDoubleLine(p .. select(2, GetItemInfo(result)) .. n, ProspectMe.FormatPrice(ProspectMe.GetItemValue(result)))
|
Vynn@0
|
138 end
|
Vynn@0
|
139 end
|
Vynn@0
|
140 end
|
mischivin@39
|
141 --self:AddLine(" ")
|
Vynn@0
|
142 end
|
Vynn@0
|
143 end
|
Vynn@0
|
144 cleared = true
|
Vynn@0
|
145 end
|
Vynn@0
|
146 end
|
Vynn@0
|
147 end
|
Vynn@0
|
148
|
Vynn@0
|
149 GameTooltip:HookScript("OnTooltipCleared", OnTooltipCleared)
|
mischivin@36
|
150 GameTooltip:HookScript("OnTooltipSetItem", OnTooltipSetItem)
|
mischivin@36
|
151 ItemRefTooltip:HookScript("OnTooltipCleared", OnTooltipCleared)
|
mischivin@36
|
152 ItemRefTooltip:HookScript("OnTooltipSetItem", OnTooltipSetItem)
|
mischivin@36
|
153
|
mischivin@36
|
154 local frame = CreateFrame("FRAME", "ProspectMe_Value")
|
mischivin@36
|
155 frame:RegisterEvent("VARIABLES_LOADED")
|
mischivin@36
|
156 --frame:SetScript("OnEvent", EventHandler)
|
mischivin@36
|
157 frame:SetScript("OnEvent", Initialize) |