vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | function DUF_Get_ClassColor(unit, defaultcolor) |
2 | local index; |
||
3 | local class = UnitClass(unit); |
||
4 | if (class == DUF_TEXT.Druid) then |
||
5 | index = "classcolorDruid"; |
||
6 | elseif (class == DUF_TEXT.Hunter) then |
||
7 | index = "classcolorHunter"; |
||
8 | elseif (class == DUF_TEXT.Mage) then |
||
9 | index = "classcolorMage"; |
||
10 | elseif (class == DUF_TEXT.Paladin) then |
||
11 | index = "classcolorPaladin"; |
||
12 | elseif (class == DUF_TEXT.Priest) then |
||
13 | index = "classcolorPriest"; |
||
14 | elseif (class == DUF_TEXT.Rogue) then |
||
15 | index = "classcolorRogue"; |
||
16 | elseif (class == DUF_TEXT.Shaman) then |
||
17 | index = "classcolorShaman"; |
||
18 | elseif (class == DUF_TEXT.Warlock) then |
||
19 | index = "classcolorWarlock"; |
||
20 | elseif (class == DUF_TEXT.Warrior) then |
||
21 | index = "classcolorWarrior"; |
||
22 | end |
||
23 | if (UnitIsTapped(unit) and (not UnitIsTappedByPlayer(unit))) then |
||
24 | return DUF_Settings[DUF_INDEX].reactioncolor6.r, DUF_Settings[DUF_INDEX].reactioncolor6.g, DUF_Settings[DUF_INDEX].reactioncolor6.b; |
||
25 | elseif (index) then |
||
26 | return DUF_Settings[DUF_INDEX][index].r, DUF_Settings[DUF_INDEX][index].g, DUF_Settings[DUF_INDEX][index].b; |
||
27 | elseif (defaultcolor) then |
||
28 | return defaultcolor.r, defaultcolor.g, defaultcolor.b; |
||
29 | end |
||
30 | end |
||
31 | |||
32 | function DUF_Get_DifficultyColor(unit, defaultcolor) |
||
33 | local diff = UnitLevel(unit) - UnitLevel("player"); |
||
34 | local difficulty; |
||
35 | if (UnitLevel(unit) == -1) then |
||
36 | difficulty = 6; |
||
37 | elseif (diff < -GetQuestGreenRange()) then |
||
38 | difficulty = 1; |
||
39 | elseif (diff < -2) then |
||
40 | difficulty = 2; |
||
41 | elseif (diff < 3) then |
||
42 | difficulty = 3; |
||
43 | elseif (diff < 5) then |
||
44 | difficulty = 4; |
||
45 | elseif (diff < 11) then |
||
46 | difficulty = 5; |
||
47 | else |
||
48 | difficulty = 6; |
||
49 | end |
||
50 | if (UnitIsTapped(unit) and (not UnitIsTappedByPlayer(unit))) then |
||
51 | return DUF_Settings[DUF_INDEX].reactioncolor6.r, DUF_Settings[DUF_INDEX].reactioncolor6.g, DUF_Settings[DUF_INDEX].reactioncolor6.b; |
||
52 | elseif (difficulty) then |
||
53 | return DUF_Settings[DUF_INDEX]["lvlcolor"..difficulty].r, DUF_Settings[DUF_INDEX]["lvlcolor"..difficulty].g, DUF_Settings[DUF_INDEX]["lvlcolor"..difficulty].b; |
||
54 | elseif (defaultcolor) then |
||
55 | return defaultcolor.r, defaultcolor.g, defaultcolor.b; |
||
56 | end |
||
57 | end |
||
58 | |||
59 | function DUF_Get_ElementName(index, subindex) |
||
60 | if (index == "StatusBar") then |
||
61 | if (subindex == 1) then |
||
62 | return "_HealthBar"; |
||
63 | elseif (subindex == 2) then |
||
64 | return "_ManaBar"; |
||
65 | elseif (subindex == 3) then |
||
66 | return "_XPBar"; |
||
67 | elseif (subindex == 4) then |
||
68 | return "_TargetHealthBar"; |
||
69 | elseif (subindex == 5) then |
||
70 | return "_TargetManaBar"; |
||
71 | elseif (subindex == 6) then |
||
72 | return "_HonorBar"; |
||
73 | end |
||
74 | elseif (index == "TextBox") then |
||
75 | return "_TextBox_"..subindex; |
||
76 | else |
||
77 | return "_"..index; |
||
78 | end |
||
79 | end |
||
80 | |||
81 | function DUF_Get_Health(unit) |
||
82 | local health; |
||
83 | if (unit == "target" and MobHealth_GetTargetCurHP) then |
||
84 | health = MobHealth_GetTargetCurHP(); |
||
85 | if ((not health) or health == 0) then health = UnitHealth(unit); end |
||
86 | elseif (string.find(unit, "target") and MobHealth_PPP) then |
||
87 | if (UnitName(unit) and UnitLevel(unit)) then |
||
88 | local mhindex = UnitName(unit)..":"..UnitLevel(unit); |
||
89 | local ppp = MobHealth_PPP(mhindex); |
||
90 | health = math.floor(UnitHealth(unit) * ppp + 0.5); |
||
91 | end |
||
92 | if (health == 0 or (not health)) then health = UnitHealth(unit); end |
||
93 | else |
||
94 | health = UnitHealth(unit); |
||
95 | end |
||
96 | return health; |
||
97 | end |
||
98 | |||
99 | function DUF_Get_HealthColor(unit, defaultcolor) |
||
100 | if (not defaultcolor) then |
||
101 | return; |
||
102 | end |
||
103 | local percent; |
||
104 | if (UnitHealth(unit) and UnitHealthMax(unit)) then |
||
105 | percent = UnitHealth(unit)/UnitHealthMax(unit); |
||
106 | else |
||
107 | return defaultcolor.r, defaultcolor.g, defaultcolor.b; |
||
108 | end |
||
109 | local r, g, b, diff; |
||
110 | if (percent <= DUF_Settings[DUF_INDEX].healththreshold2) then |
||
111 | r = DUF_Settings[DUF_INDEX].healthcolor2.r; |
||
112 | g = DUF_Settings[DUF_INDEX].healthcolor2.g; |
||
113 | b = DUF_Settings[DUF_INDEX].healthcolor2.b; |
||
114 | elseif (percent <= DUF_Settings[DUF_INDEX].healththreshold1) then |
||
115 | diff = 1 - (percent - DUF_Settings[DUF_INDEX].healththreshold2) / (DUF_Settings[DUF_INDEX].healththreshold1 - DUF_Settings[DUF_INDEX].healththreshold2); |
||
116 | r = DUF_Settings[DUF_INDEX].healthcolor1.r - (DUF_Settings[DUF_INDEX].healthcolor1.r - DUF_Settings[DUF_INDEX].healthcolor2.r) * diff; |
||
117 | g = DUF_Settings[DUF_INDEX].healthcolor1.g - (DUF_Settings[DUF_INDEX].healthcolor1.g - DUF_Settings[DUF_INDEX].healthcolor2.g) * diff; |
||
118 | b = DUF_Settings[DUF_INDEX].healthcolor1.b - (DUF_Settings[DUF_INDEX].healthcolor1.b - DUF_Settings[DUF_INDEX].healthcolor2.b) * diff; |
||
119 | elseif (percent < 1) then |
||
120 | diff = 1 - (percent - DUF_Settings[DUF_INDEX].healththreshold1) / (1 - DUF_Settings[DUF_INDEX].healththreshold1); |
||
121 | r = defaultcolor.r - (defaultcolor.r - DUF_Settings[DUF_INDEX].healthcolor1.r) * diff; |
||
122 | g = defaultcolor.g - (defaultcolor.g - DUF_Settings[DUF_INDEX].healthcolor1.g) * diff; |
||
123 | b = defaultcolor.b - (defaultcolor.b - DUF_Settings[DUF_INDEX].healthcolor1.b) * diff; |
||
124 | else |
||
125 | return defaultcolor.r, defaultcolor.g, defaultcolor.b; |
||
126 | end |
||
127 | if (r < 0) then r = 0; end |
||
128 | if (r > 1) then r = 1; end |
||
129 | if (g < 0) then g = 0; end |
||
130 | if (g > 1) then g = 1; end |
||
131 | if (b < 0) then b = 0; end |
||
132 | if (b > 1) then b = 1; end |
||
133 | if (UnitIsTapped(unit) and (not UnitIsTappedByPlayer(unit))) then |
||
134 | return DUF_Settings[DUF_INDEX].reactioncolor6.r, DUF_Settings[DUF_INDEX].reactioncolor6.g, DUF_Settings[DUF_INDEX].reactioncolor6.b; |
||
135 | else |
||
136 | return r, g, b; |
||
137 | end |
||
138 | end |
||
139 | |||
140 | function DUF_Get_HealthDamage(unit) |
||
141 | local healthmax = DUF_Get_MaxHealth(unit); |
||
142 | local health = DUF_Get_Health(unit); |
||
143 | local damage = healthmax - health; |
||
144 | if (healthmax == 0) then |
||
145 | damage = 0; |
||
146 | end |
||
147 | return damage; |
||
148 | end |
||
149 | |||
150 | function DUF_Get_ManaColor(unit, defaultcolor) |
||
151 | if (UnitPowerType(unit) and (not DUF_Settings[DUF_INDEX]["usefor"..UnitPowerType(unit)])) then |
||
152 | return defaultcolor.r, defaultcolor.g, defaultcolor.b; |
||
153 | end |
||
154 | local percent; |
||
155 | if (UnitMana(unit) and UnitManaMax(unit)) then |
||
156 | percent = UnitMana(unit)/UnitManaMax(unit); |
||
157 | else |
||
158 | return defaultcolor.r, defaultcolor.g, defaultcolor.b; |
||
159 | end |
||
160 | local r, g, b, diff; |
||
161 | if (percent <= DUF_Settings[DUF_INDEX].manathreshold2) then |
||
162 | r = DUF_Settings[DUF_INDEX].manacolor2.r; |
||
163 | g = DUF_Settings[DUF_INDEX].manacolor2.g; |
||
164 | b = DUF_Settings[DUF_INDEX].manacolor2.b; |
||
165 | elseif (percent <= DUF_Settings[DUF_INDEX].manathreshold1) then |
||
166 | diff = 1 - (percent - DUF_Settings[DUF_INDEX].manathreshold2) / (DUF_Settings[DUF_INDEX].manathreshold1 - DUF_Settings[DUF_INDEX].manathreshold2); |
||
167 | r = DUF_Settings[DUF_INDEX].manacolor1.r - (DUF_Settings[DUF_INDEX].manacolor1.r - DUF_Settings[DUF_INDEX].manacolor2.r) * diff; |
||
168 | g = DUF_Settings[DUF_INDEX].manacolor1.g - (DUF_Settings[DUF_INDEX].manacolor1.g - DUF_Settings[DUF_INDEX].manacolor2.g) * diff; |
||
169 | b = DUF_Settings[DUF_INDEX].manacolor1.b - (DUF_Settings[DUF_INDEX].manacolor1.b - DUF_Settings[DUF_INDEX].manacolor2.b) * diff; |
||
170 | elseif (percent < 1) then |
||
171 | diff = 1 - (percent - DUF_Settings[DUF_INDEX].manathreshold1) / (1 - DUF_Settings[DUF_INDEX].manathreshold1); |
||
172 | r = defaultcolor.r - (defaultcolor.r - DUF_Settings[DUF_INDEX].manacolor1.r) * diff; |
||
173 | g = defaultcolor.g - (defaultcolor.g - DUF_Settings[DUF_INDEX].manacolor1.g) * diff; |
||
174 | b = defaultcolor.b - (defaultcolor.b - DUF_Settings[DUF_INDEX].manacolor1.b) * diff; |
||
175 | else |
||
176 | return defaultcolor.r, defaultcolor.g, defaultcolor.b; |
||
177 | end |
||
178 | if (r < 0) then r = 0; end |
||
179 | if (r > 1) then r = 1; end |
||
180 | if (g < 0) then g = 0; end |
||
181 | if (g > 1) then g = 1; end |
||
182 | if (b < 0) then b = 0; end |
||
183 | if (b > 1) then b = 1; end |
||
184 | if (UnitIsTapped(unit) and (not UnitIsTappedByPlayer(unit))) then |
||
185 | return DUF_Settings[DUF_INDEX].reactioncolor6.r, DUF_Settings[DUF_INDEX].reactioncolor6.g, DUF_Settings[DUF_INDEX].reactioncolor6.b; |
||
186 | else |
||
187 | return r, g, b; |
||
188 | end |
||
189 | end |
||
190 | |||
191 | function DUF_Get_MaxHealth(unit) |
||
192 | local healthmax; |
||
193 | if (unit == "target" and MobHealth_GetTargetMaxHP and UnitHealth(unit) > 0) then |
||
194 | healthmax = MobHealth_GetTargetMaxHP(); |
||
195 | if ((not healthmax) or healthmax == 0) then healthmax = UnitHealthMax(unit); end |
||
196 | elseif (string.find(unit, "target") and MobHealth_PPP) then |
||
197 | if (UnitName(unit) and UnitLevel(unit)) then |
||
198 | local mhindex = UnitName(unit)..":"..UnitLevel(unit); |
||
199 | local ppp = MobHealth_PPP(mhindex); |
||
200 | healthmax = math.floor(100 * ppp + 0.5); |
||
201 | end |
||
202 | if (healthmax == 0 or (not healthmax)) then healthmax = UnitHealthMax(unit); end |
||
203 | else |
||
204 | healthmax = UnitHealthMax(unit); |
||
205 | end |
||
206 | if (not healthmax) then healthmax = 0; end |
||
207 | return healthmax; |
||
208 | end |
||
209 | |||
210 | function DUF_Get_Reaction(unit) |
||
211 | local index; |
||
212 | if (UnitIsPlayer(unit)) then |
||
213 | if (UnitIsPVP(unit)) then |
||
214 | if (UnitCanAttack("player", unit)) then |
||
215 | index = 1; |
||
216 | else |
||
217 | index = 5; |
||
218 | end |
||
219 | else |
||
220 | if (UnitCanAttack("player", unit) or UnitFactionGroup(unit) ~= UnitFactionGroup("player")) then |
||
221 | index = 2; |
||
222 | else |
||
223 | index = 4; |
||
224 | end |
||
225 | end |
||
226 | elseif (UnitIsTapped(unit) and (not UnitIsTappedByPlayer(unit))) then |
||
227 | index = 6; |
||
228 | else |
||
229 | local reaction = UnitReaction(unit, "player"); |
||
230 | if (reaction) then |
||
231 | if (reaction < 4) then |
||
232 | index = 1; |
||
233 | elseif (reaction == 4) then |
||
234 | index = 2; |
||
235 | else |
||
236 | index = 3; |
||
237 | end |
||
238 | end |
||
239 | end |
||
240 | return index; |
||
241 | end |
||
242 | |||
243 | function DUF_Get_ReactionColor(unit, defaultcolor) |
||
244 | local index = DUF_Get_Reaction(unit); |
||
245 | if (index) then |
||
246 | return DUF_Settings[DUF_INDEX]["reactioncolor"..index].r, DUF_Settings[DUF_INDEX]["reactioncolor"..index].g, DUF_Settings[DUF_INDEX]["reactioncolor"..index].b; |
||
247 | elseif (defaultcolor) then |
||
248 | return defaultcolor.r, defaultcolor.g, defaultcolor.b; |
||
249 | end |
||
250 | end |