vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | -------------------------------------------------- |
2 | -- This is a cut version on BonusScanner |
||
3 | -- Healbot only cares about heals and although BonusScanner is a great addon, it lags when everts are fired. |
||
4 | -- |
||
5 | -- Original BonusScanner here: |
||
6 | -- http://www.curse-gaming.com/mod.php?addid=2384 |
||
7 | -------------------------------------------------- |
||
8 | |||
9 | HB_BONUSSCANNER_PATTERN_SETNAME = "^(.*) %(%d/%d%)$"; |
||
10 | HB_BONUSSCANNER_PATTERN_GENERIC_PREFIX = "^%+(%d+)%%?(.*)$"; |
||
11 | HB_BONUSSCANNER_PATTERN_GENERIC_SUFFIX = "^(.*)%+(%d+)%%?$"; |
||
12 | |||
13 | HealBot_BonusScanner = { |
||
14 | bonuses = 0; |
||
15 | IsUpdating = false; |
||
16 | ShowDebug = false; -- tells when the equipment is scanned |
||
17 | active = nil; |
||
18 | temp = { |
||
19 | sets = {}, |
||
20 | set = "", |
||
21 | slot = "", |
||
22 | bonuses = 0, |
||
23 | details = {} |
||
24 | }; |
||
25 | |||
26 | types = { |
||
27 | "HEAL", -- healing |
||
28 | }; |
||
29 | |||
30 | slots = { |
||
31 | "Head", |
||
32 | "Neck", |
||
33 | "Shoulder", |
||
34 | "Shirt", |
||
35 | "Chest", |
||
36 | "Waist", |
||
37 | "Legs", |
||
38 | "Feet", |
||
39 | "Wrist", |
||
40 | "Hands", |
||
41 | "Finger0", |
||
42 | "Finger1", |
||
43 | "Trinket0", |
||
44 | "Trinket1", |
||
45 | "Back", |
||
46 | "MainHand", |
||
47 | "SecondaryHand", |
||
48 | "Ranged", |
||
49 | "Tabard", |
||
50 | }; |
||
51 | } |
||
52 | |||
53 | function HealBot_BonusScanner:GetBonus() |
||
54 | if(HealBot_BonusScanner.bonuses) then |
||
55 | return HealBot_BonusScanner.bonuses; |
||
56 | end; |
||
57 | return 0; |
||
58 | end |
||
59 | |||
60 | |||
61 | function HealBot_BonusScanner_Update() |
||
62 | |||
63 | if (HealBot_BonusScanner.IsUpdating) then |
||
64 | return; |
||
65 | else |
||
66 | HealBot_BonusScanner.IsUpdating = true; |
||
67 | HealBot_BonusScanner:ScanEquipment(); |
||
68 | end |
||
69 | HealBot_BonusScanner.IsUpdating = false; |
||
70 | end |
||
71 | |||
72 | function HealBot_BonusScanner:ScanEquipment() |
||
73 | local slotid, slotname, hasItem, i; |
||
74 | |||
75 | HealBot_BonusTooltip:SetOwner(HealBot_BonusTooltip, "ANCHOR_NONE"); |
||
76 | HealBot_BonusScanner.temp.bonuses = 0; |
||
77 | HealBot_BonusScanner.temp.sets = {}; |
||
78 | HealBot_BonusScanner.temp.set = ""; |
||
79 | for i, slotname in HealBot_BonusScanner.slots do |
||
80 | slotid, _ = GetInventorySlotInfo(slotname.. "Slot"); |
||
81 | hasItem = HealBot_BonusTooltip:SetInventoryItem("player", slotid); |
||
82 | if ( hasItem ) then |
||
83 | HealBot_BonusScanner.temp.slot = slotname; |
||
84 | HealBot_BonusScanner:ScanTooltip(); |
||
85 | if(HealBot_BonusScanner.temp.set ~= "") then |
||
86 | HealBot_BonusScanner.temp.sets[HealBot_BonusScanner.temp.set] = 1; |
||
87 | end; |
||
88 | end |
||
89 | end |
||
90 | HealBot_BonusScanner.bonuses = HealBot_BonusScanner.temp.bonuses; |
||
91 | end |
||
92 | |||
93 | function HealBot_BonusScanner:ScanTooltip() |
||
94 | local tmpTxt, line; |
||
95 | local lines = HealBot_BonusTooltip:NumLines(); |
||
96 | for i=2, lines, 1 do |
||
97 | tmpText = getglobal("HealBot_BonusTooltipTextLeft"..i); |
||
98 | val = nil; |
||
99 | if (tmpText:GetText()) then |
||
100 | line = tmpText:GetText(); |
||
101 | HealBot_BonusScanner:ScanLine(line); |
||
102 | end |
||
103 | end |
||
104 | end |
||
105 | |||
106 | function HealBot_BonusScanner:AddValue(effect, value) |
||
107 | local i,e; |
||
108 | if(type(effect) == "string") then |
||
109 | if effect=="HEAL" then |
||
110 | if(HealBot_BonusScanner.temp.bonuses) then |
||
111 | HealBot_BonusScanner.temp.bonuses = HealBot_BonusScanner.temp.bonuses + value; |
||
112 | else |
||
113 | HealBot_BonusScanner.temp.bonuses = value; |
||
114 | end |
||
115 | end |
||
116 | else |
||
117 | if(type(value) == "table") then |
||
118 | for i,e in effect do |
||
119 | HealBot_BonusScanner:AddValue(e, value[i]); |
||
120 | end |
||
121 | else |
||
122 | for i,e in effect do |
||
123 | HealBot_BonusScanner:AddValue(e, value); |
||
124 | end |
||
125 | end |
||
126 | end |
||
127 | end; |
||
128 | |||
129 | function HealBot_BonusScanner:ScanLine(line) |
||
130 | local tmpStr, found; |
||
131 | if(string.sub(line,0,string.len(HB_BONUSSCANNER_PREFIX_EQUIP)) == HB_BONUSSCANNER_PREFIX_EQUIP) then |
||
132 | tmpStr = string.sub(line,string.len(HB_BONUSSCANNER_PREFIX_EQUIP)+1); |
||
133 | HealBot_BonusScanner:CheckPassive(tmpStr); |
||
134 | elseif(string.sub(line,0,string.len(HB_BONUSSCANNER_PREFIX_SET)) == HB_BONUSSCANNER_PREFIX_SET |
||
135 | and HealBot_BonusScanner.temp.set ~= "" |
||
136 | and not HealBot_BonusScanner.temp.sets[HealBot_BonusScanner.temp.set]) then |
||
137 | tmpStr = string.sub(line,string.len(HB_BONUSSCANNER_PREFIX_SET)+1); |
||
138 | HealBot_BonusScanner.temp.slot = "Set"; |
||
139 | HealBot_BonusScanner:CheckPassive(tmpStr); |
||
140 | else |
||
141 | _, _, tmpStr = string.find(line, HB_BONUSSCANNER_PATTERN_SETNAME); |
||
142 | if(tmpStr) then |
||
143 | HealBot_BonusScanner.temp.set = tmpStr; |
||
144 | else |
||
145 | found = HealBot_BonusScanner:CheckGeneric(line); |
||
146 | if(not found) then |
||
147 | HealBot_BonusScanner:CheckOther(line); |
||
148 | end; |
||
149 | end |
||
150 | end |
||
151 | end; |
||
152 | |||
153 | function HealBot_BonusScanner:CheckPassive(line) |
||
154 | local i, p, value, found; |
||
155 | |||
156 | found = nil; |
||
157 | for i,p in HB_BONUSSCANNER_PATTERNS_PASSIVE do |
||
158 | _, _, value = string.find(line, "^" .. p.pattern); |
||
159 | if(value) then |
||
160 | HealBot_BonusScanner:AddValue(p.effect, value) |
||
161 | found = 1; |
||
162 | end |
||
163 | end |
||
164 | if(not found) then |
||
165 | HealBot_BonusScanner:CheckGeneric(line); |
||
166 | end |
||
167 | end |
||
168 | |||
169 | function HealBot_BonusScanner:CheckGeneric(line) |
||
170 | local value, token, pos, tmpStr, found; |
||
171 | found = false; |
||
172 | while(string.len(line) > 0) do |
||
173 | pos = string.find(line, "/", 1, true); |
||
174 | if(pos) then |
||
175 | tmpStr = string.sub(line,1,pos-1); |
||
176 | line = string.sub(line,pos+1); |
||
177 | else |
||
178 | tmpStr = line; |
||
179 | line = ""; |
||
180 | end |
||
181 | |||
182 | tmpStr = string.gsub( tmpStr, "^%s+", "" ); |
||
183 | tmpStr = string.gsub( tmpStr, "%s+$", "" ); |
||
184 | tmpStr = string.gsub( tmpStr, "%.$", "" ); |
||
185 | |||
186 | _, _, value, token = string.find(tmpStr, HB_BONUSSCANNER_PATTERN_GENERIC_PREFIX); |
||
187 | if(not value) then |
||
188 | _, _, token, value = string.find(tmpStr, HB_BONUSSCANNER_PATTERN_GENERIC_SUFFIX); |
||
189 | end |
||
190 | if(token and value) then |
||
191 | token = string.gsub( token, "^%s+", "" ); |
||
192 | token = string.gsub( token, "%s+$", "" ); |
||
193 | token = string.gsub( token, "%.$", "" ); |
||
194 | if(HealBot_BonusScanner:CheckToken(token,value)) then |
||
195 | found = true; |
||
196 | end |
||
197 | end |
||
198 | end |
||
199 | return found; |
||
200 | end |
||
201 | |||
202 | function HealBot_BonusScanner:CheckToken(token, value) |
||
203 | local i, p, s1, s2; |
||
204 | |||
205 | if(HB_BONUSSCANNER_PATTERNS_GENERIC_LOOKUP[token]) then |
||
206 | HealBot_BonusScanner:AddValue(HB_BONUSSCANNER_PATTERNS_GENERIC_LOOKUP[token], value); |
||
207 | return true; |
||
208 | end |
||
209 | return false; |
||
210 | end |
||
211 | |||
212 | function HealBot_BonusScanner:CheckOther(line) |
||
213 | local i, p, value, start, found; |
||
214 | |||
215 | for i,p in HB_BONUSSCANNER_PATTERNS_OTHER do |
||
216 | start, _, value = string.find(line, "^" .. p.pattern); |
||
217 | if(start) then |
||
218 | if(p.value) then |
||
219 | HealBot_BonusScanner:AddValue(p.effect, p.value) |
||
220 | elseif(value) then |
||
221 | HealBot_BonusScanner:AddValue(p.effect, value) |
||
222 | end |
||
223 | return true; |
||
224 | end |
||
225 | end |
||
226 | return false; |
||
227 | end |