vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 function IMBA_RaidInCombat()
2 if GetNumRaidMembers()==0 then
3 return false
4 end
5 NumInCombat=0;
6 for i = 1, GetNumRaidMembers() do
7 if UnitAffectingCombat("raid"..i)~=nil then
8 NumInCombat=NumInCombat+UnitAffectingCombat("raid"..i);
9 end
10 end
11 if NumInCombat>2 then
12 return true;
13 end
14 return false;
15 end
16  
17 function IMBA_BossAggroed(BossName)
18 if UnitName("target")==BossName then
19 return true;
20 end
21  
22 if GetNumRaidMembers()==0 then
23 return false
24 end
25 for i = 1, GetNumRaidMembers() do
26 if UnitName("raid"..i.."target")==BossName then
27 if UnitAffectingCombat("raid"..i.."target")~=nil then
28 return true;
29 end
30 end
31 end
32 return false;
33 end
34  
35 --Don't call this before UI has finished loading
36 function IMBA_SetLogDistance(Dist)
37 if not Dist then
38 Dist=200;
39 end
40 SetCVar("CombatDeathLogRange", Dist);
41 SetCVar("CombatLogRangeParty", Dist);
42 SetCVar("CombatLogRangePartyPet", Dist);
43 SetCVar("CombatLogRangeFriendlyPlayers", Dist);
44 SetCVar("CombatLogRangeFriendlyPlayersPets", Dist);
45 SetCVar("CombatLogRangeHostilePlayers", Dist);
46 SetCVar("CombatLogRangeHostilePlayersPets", Dist);
47 SetCVar("CombatLogRangeCreature", Dist);
48 end
49  
50  
51 --This Function is From AllInOneInventory
52 function IMBA_ExtractNextParam(msg)
53 local params = msg;
54 local command = params;
55 local index = strfind(command, " ");
56 if ( index ) then
57 command = strsub(command, 1, index-1);
58 params = strsub(params, index+1);
59 else
60 params = "";
61 end
62 return command, params;
63 end
64  
65 function IMBA_FindBuffCountAndDuration(name)
66 local j, buff, buffApplications, buffTime;
67 for j=1,16 do
68 buff = GetPlayerBuffTexture(GetPlayerBuff(j - 1, "HELPFUL"));
69 if string.find(string.upper(buff),string.upper(name)) then
70 buffApplications = GetPlayerBuffApplications(GetPlayerBuff(j - 1, "HELPFUL"));
71 buffTime = GetPlayerBuffTimeLeft(GetPlayerBuff(j - 1, "HELPFUL"));
72 return buffApplications, buffTime;
73 end
74 end
75 return 0, 0;
76 end
77 function IMBA_FindDebuffCountAndDuration(name)
78 local j, buff, debuffApplications, debuffTime;
79 for j=1,16 do
80 buff = GetPlayerBuffTexture(GetPlayerBuff(j - 1, "HARMFUL"));
81 if buff~=nil and string.find(string.upper(buff),string.upper(name)) then
82 debuffApplications = GetPlayerBuffApplications(GetPlayerBuff(j - 1, "HARMFUL"));
83 debuffTime = GetPlayerBuffTimeLeft(GetPlayerBuff(j - 1, "HARMFUL"));
84 return debuffApplications, debuffTime;
85 end
86 end
87 return 0, 0;
88 end
89  
90 function IMBA_GetRaidIconUnitID(raidtargetindex)
91 if GetNumRaidMembers()==0 then
92 return nil
93 end
94 for i=1,GetNumRaidMembers() do
95 if UnitExists("raid"..i) and GetRaidTargetIndex("raid"..i) == raidtargetindex then
96 return "raid"..i
97 elseif UnitExists("raid"..i.."target") and GetRaidTargetIndex("raid"..i.."target") == raidtargetindex then
98 return "raid"..i.."target"
99 elseif UnitExists("raid"..i.."targettarget") and GetRaidTargetIndex("raid"..i.."targettarget") == raidtargetindex then
100 return "raid"..i.."targettarget"
101 elseif UnitExists("raidpet"..i) and GetRaidTargetIndex("raidpet"..i) == raidtargetindex then
102 return "raidpet"..i
103 end
104 end
105 return nil;
106 end
107  
108 function IMBA_GetRaidIconName(raidtargetindex)
109 if raidtargetindex==1 then
110 return "Star";
111 elseif raidtargetindex==2 then
112 return "Circle";
113 elseif raidtargetindex==3 then
114 return "Diamond";
115 elseif raidtargetindex==4 then
116 return "Triangle";
117 elseif raidtargetindex==5 then
118 return "Moon";
119 elseif raidtargetindex==6 then
120 return "Square";
121 elseif raidtargetindex==7 then
122 return "Cross";
123 elseif raidtargetindex==8 then
124 return "Skull";
125 end
126 end
127  
128 function IMBA_FindPlayerUnitByName(name)
129 if UnitExists("player") and (UnitName("player")==name) then
130 return "player";
131 end
132 if GetNumRaidMembers()==0 then
133 return nil
134 end
135 for i=1,GetNumRaidMembers() do
136 if UnitExists("raid"..i) and (UnitName("raid"..i)==name) then
137 return "raid"..i;
138 end
139 end
140 return nil;
141 end
142  
143 function IMBA_FindUnitByName(name)
144 if UnitExists("player") and (UnitName("player")==name) then
145 return "player";
146 end
147 if UnitExists("playertarget") and (UnitName("playertarget")==name) then
148 return "playertarget";
149 end
150 if GetNumRaidMembers()==0 then
151 return nil
152 end
153 for i=1,GetNumRaidMembers() do
154 if UnitExists("raid"..i) and (UnitName("raid"..i)==name) then
155 return "raid"..i;
156 elseif UnitExists("raid"..i.."target") and (UnitName("raid"..i.."target")==name) then
157 return "raid"..i.."target";
158 end
159 end
160 return nil;
161 end
162  
163 function IMBA_SendEvent(event)
164 local frame
165  
166 -- first let's find all the frames
167 local hasonevent
168  
169 while true do
170  
171 -- get next frame
172 frame = EnumerateFrames(frame)
173 if frame == nil then
174 break
175 end
176  
177  
178 hasonevent = frame:GetScript("OnEvent")
179  
180 if hasonevent then
181 hasonevent(event,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9);
182 end
183 end
184 end
185  
186 function IMBA_CheckIfCanActivate(Addon)
187 return (IMBA_Addons[Addon].RegenActivator~=nil) or (IMBA_Addons[Addon].YellActivator~=nil);
188 end
189  
190 function IMBA_IsPlayerALeader()
191 return IsPartyLeader() or IsRaidLeader() or IsRaidOfficer()
192 end
193  
194 --Function from gatherer though slightly changed to be more correctly named
195 function IMBA_isMinimapInsideWMO()
196 local tempzoom = 0;
197 local InsideWMO = 0;
198 if (GetCVar("minimapZoom") == GetCVar("minimapInsideZoom")) then
199 if (GetCVar("minimapInsideZoom")+0 >= 3) then
200 Minimap:SetZoom(Minimap:GetZoom() - 1);
201 tempzoom = 1;
202 else
203 Minimap:SetZoom(Minimap:GetZoom() + 1);
204 tempzoom = -1;
205 end
206 end
207 if (GetCVar("minimapInsideZoom")+0 == Minimap:GetZoom()) then InsideWMO = 1; end
208 Minimap:SetZoom(Minimap:GetZoom() + tempzoom);
209 return InsideWMO;
210 end
211  
212 function IMBA_Flash_Warning()
213 UIFrameFlash(LowHealthFrame, 0.5, 0.5, 5);
214 LowHealthFrame.flashing = 1;
215 end
216  
217 --Just some fun function I made to traverse all the children of a frame
218 --Help me find about screen flashing :)
219 --UIFrameFlash(LowHealthFrame, 0.5, 0.5, 5); LowHealthFrame.flashing = 1;
220 function TraverseChildren(TheFrame,msg)
221 local i, smsg;
222 if not msg then
223 msg="";
224 end
225  
226 local children = {TheFrame:GetChildren()};
227 for i=1,getn(children) do
228 if not children[i]:GetName() then
229 DEFAULT_CHAT_FRAME:AddMessage(msg.."Child "..i);
230 smsg=msg.."Child "..i.."->"
231  
232 else
233 DEFAULT_CHAT_FRAME:AddMessage(msg..children[i]:GetName());
234 smsg=msg..children[i]:GetName().."->"
235 end
236 TraverseChildren(children[i],smsg)
237 end
238 end