forked from liyunfan1223/unbot-addon
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathExecuteCommand.lua
More file actions
340 lines (313 loc) · 9.49 KB
/
ExecuteCommand.lua
File metadata and controls
340 lines (313 loc) · 9.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
function CommandBotCharEquipmentManagerFrame(index)
BotEquippmentManagerMainFrame()
end
function CommandUnBotSetting(index)
UnBotHideAllSubFrame();
UnBotCloseAllBagsFrame();
OnlineFrame:Hide();
NPCFrame:Hide();
if (InspectFrame and InspectFrame:IsShown()) then
DisplayInfomation("InspectFrame_Show " .. UnitName(InspectFrame.unit) .. ", Name " .. InspectFrame:GetName());
end
end
function CommandShowOnlineFrame(index)
if (OnlineFrame:IsShown()) then
OnlineFrame:Hide();
else
OnlineFrame:Show();
end
end
function CommandShowNPCFrame(index)
if (NPCFrame:IsShown()) then
NPCFrame:Hide();
else
NPCFrame:Show();
end
end
function CommandShowStrategyFrame(index)
local targetClass = UnitClass("target");
local targetName = UnitName("target");
local isParty = UnitInParty("target");
local isRaid = UnitInRaid("target");
if (targetName == nil or targetName == "") then
DisplayInfomation("You have no target.");
return;
end
if (not UnitIsPlayer("target")) then
DisplayInfomation("A bot needs to be targetted.");
return;
end
if (isParty == nil and isRaid == nil) then
DisplayInfomation("The target is not in your group.");
return;
end
-- if (not IsRealPartyLeader()) then
-- DisplayInfomation("你当前不是队伍领袖。");
-- return;
-- end
UnBotShowStrategyFrame(targetName, targetClass);
end
function CommandFriendsOnline(index)
local num = GetNumFriends();
if num > 0 then
for x = 1, num, 1 do
local name, level, className, un2, online, un4 = GetFriendInfo(x);
if (name ~= nil) then
SendChatMessage(".playerbot bot add " .. name, "SAY");
end
end
else
DisplayInfomation("You have no friends.");
end
end
function CommandFriendsInvite(index)
local num = GetNumFriends();
if num > 0 then
local partyCount = GetNumPartyMembers();
local raidCount = GetNumRaidMembers();
for x = 1, num, 1 do
local name, level, className, un2, online, un4 = GetFriendInfo(x);
if (name ~= nil) then
local isParty = UnitInParty(name);
local isRaid = UnitInRaid(name);
if (isParty == nil and isRaid == nil) then
if (partyCount == 4 and raidCount == 0) then
ConvertToRaid();
end
InviteUnit(name);
end
end
end
else
DisplayInfomation("You have no friends.");
end
end
function CommandListIcons(index)
local iconsList = {};
for i = 1, #UnBotCommandIconsPath do iconsList[i] = { [1] = i } end
CreateIconsByUnBotBagsFrame(0, "UnBotBagsFrameIcon", 0, false, iconsList, UnitName("player"), UnitClass("player"),
"Icons", nil, nil, GetIconFunc);
end
function CommandInspectFrame(index)
local targetClass = UnitClass("target");
local targetName = UnitName("target");
local isParty = UnitInParty("target");
local isRaid = UnitInRaid("target");
if (targetName == nil or targetName == "") then
DisplayInfomation("You have no target.");
return;
end
if (not UnitIsPlayer("target")) then
DisplayInfomation("A bot needs to be targetted.");
return;
end
if (isParty == nil and isRaid == nil) then
DisplayInfomation("The target is not in your group.");
return;
end
InspectFrame_Show("target");
end
function CommandInitForLevel(index)
local targetName = UnitName("target");
if (targetName == nil or targetName == "") then
DisplayInfomation("You have no target.");
return;
end
if (not UnitIsPlayer("target")) then
DisplayInfomation("A bot needs to be targetted.");
return;
end
local lv = UnitLevel("player");
SendChatMessage(UnBotExecuteCommand[index] .. tostring(lv), "SAY");
end
function CommandReadyCheck(index)
DoReadyCheck();
end
function CommandCombatStop(index)
if (UnitInRaid("player") ~= nil) then
if (GetNumRaidMembers() > 0) then
for i = 1, GetNumRaidMembers(), 1 do
local name = (UnitName("raid" .. i));
if (name) then
DisplayInfomation("In the group " .. name .. " out of combat"); -- Needs correction
SendChatMessage(UnBotExecuteCommand[index] .. name, "PARTY");
end
end
end
else
SendChatMessage(UnBotExecuteCommand[index] .. UnitName("player"), "PARTY");
if (GetNumPartyMembers() > 0) then
for i = 1, GetNumPartyMembers(), 1 do
local name = (UnitName("party" .. i));
if (name) then
DisplayInfomation("In the group " .. name .. " out of combat"); -- Needs correction
SendChatMessage(UnBotExecuteCommand[index] .. name, "PARTY");
end
end
end
end
end
function CommandUninvite(index)
SendChatMessage("nc +grind", "PARTY");
SendChatMessage("stay", "PARTY");
if (UnitInRaid("player") ~= nil) then
if (GetNumRaidMembers() > 0) then
for i = 1, GetNumRaidMembers(), 1 do
local name = (UnitName("raid" .. i));
if (name and name ~= UnitName("player")) then
UninviteUnit(name);
end
end
end
else
if (GetNumPartyMembers() > 0) then
for i = 1, GetNumPartyMembers(), 1 do
local name = (UnitName("party" .. i));
if (name and name ~= UnitName("player")) then
UninviteUnit(name);
end
end
end
end
end
function CommandUnBotItemList(index)
local targetClass = UnitClass("target");
local targetName = UnitName("target");
local isParty = UnitInParty("target");
local isRaid = UnitInRaid("target");
if (targetName == nil or targetName == "") then
DisplayInfomation("You have no target.");
return;
end
if (not UnitIsPlayer("target")) then
DisplayInfomation("A bot needs to be targetted.");
return;
end
if (isParty == nil and isRaid == nil) then
DisplayInfomation("The target is not in your group.");
return;
end
CreateIconsByUnBotBagsFrame(1, "UnBotItemList" .. targetName, 1, false, {}, targetName, targetClass, "View items",
FlushItemsToBags, nil, GetItemFunc);
end
function CommandUnBotDestroyItem(index)
local targetClass = UnitClass("target");
local targetName = UnitName("target");
local isParty = UnitInParty("target");
local isRaid = UnitInRaid("target");
if (targetName == nil or targetName == "") then
DisplayInfomation("You have no target.");
return;
end
if (not UnitIsPlayer("target")) then
DisplayInfomation("A bot needs to be targetted.");
return;
end
if (isParty == nil and isRaid == nil) then
DisplayInfomation("The target is not in your group.");
return;
end
CreateIconsByUnBotBagsFrame(3, "UnBotDestroyItem" .. targetName, 1, true, {}, targetName, targetClass,
"Discard items", FlushItemsToBags, UnBotExecuteCommand[index], GetItemFunc);
end
function CommandUnBotEquipItem(index)
local targetClass = UnitClass("target");
local targetName = UnitName("target");
local isParty = UnitInParty("target");
local isRaid = UnitInRaid("target");
if (targetName == nil or targetName == "") then
DisplayInfomation("You have no target.");
return;
end
if (not UnitIsPlayer("target")) then
DisplayInfomation("A bot needs to be targetted.");
return;
end
if (isParty == nil and isRaid == nil) then
DisplayInfomation("The target is not in your group.");
return;
end
CreateIconsByUnBotBagsFrame(2, "UnBotEquipItem" .. targetName, 1, true, {}, targetName, targetClass, "Equip items",
FlushItemsToBags, UnBotExecuteCommand[index], GetItemFunc);
end
function CommandUnBotSellItem(index)
local targetClass = UnitClass("target");
local targetName = UnitName("target");
local isParty = UnitInParty("target");
local isRaid = UnitInRaid("target");
if (targetName == nil or targetName == "") then
DisplayInfomation("You have no target.");
return;
end
if (not UnitIsPlayer("target")) then
DisplayInfomation("A bot needs to be targetted.");
return;
end
if (isParty == nil and isRaid == nil) then
DisplayInfomation("The target is not in your group.");
return;
end
CreateIconsByUnBotBagsFrame(4, "UnBotSellItem" .. targetName, 1, true, {}, targetName, targetClass, "Sell items",
FlushItemsToBags, UnBotExecuteCommand[index], GetItemFunc);
end
function CommandUnBotUseItem(index)
local targetClass = UnitClass("target");
local targetName = UnitName("target");
local isParty = UnitInParty("target");
local isRaid = UnitInRaid("target");
if (targetName == nil or targetName == "") then
DisplayInfomation("You have no target.");
return;
end
if (not UnitIsPlayer("target")) then
DisplayInfomation("A bot needs to be targetted.");
return;
end
if (isParty == nil and isRaid == nil) then
DisplayInfomation("The target is not in your group.");
return;
end
CreateIconsByUnBotBagsFrame(5, "UnBotUseItem" .. targetName, 1, true, {}, targetName, targetClass, "Use items",
FlushItemsToBags, UnBotExecuteCommand[index], GetItemFunc);
end
function CommandUnBotSpells(index)
local targetClass = UnitClass("target");
local targetName = UnitName("target");
local isParty = UnitInParty("target");
local isRaid = UnitInRaid("target");
if (targetName == nil or targetName == "") then
DisplayInfomation("You have no target.");
return;
end
if (not UnitIsPlayer("target")) then
DisplayInfomation("A bot needs to be targetted.");
return;
end
if (isParty == nil and isRaid == nil) then
DisplayInfomation("The target is not in your group.");
return;
end
CreateIconsByUnBotBagsFrame(0, "UnBotSpells" .. targetName, 2, false, {}, targetName, targetClass, "Spells",
FlushItemsToBags, UnBotExecuteCommand[index], GetItemFunc);
end
function CommandAddFriends(index)
if (UnitInRaid("player") ~= nil) then
if (GetNumRaidMembers() > 0) then
for i = 1, GetNumRaidMembers(), 1 do
local name = (UnitName("raid" .. i));
if (name and name ~= UnitName("player")) then
AddFriend(name);
end
end
end
else
if (GetNumPartyMembers() > 0) then
for i = 1, GetNumPartyMembers(), 1 do
local name = (UnitName("party" .. i));
if (name and name ~= UnitName("player")) then
AddFriend(name);
end
end
end
end
end