forked from kakaZzzz/AutoEquip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.lua
693 lines (521 loc) · 21.9 KB
/
main.lua
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
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
local _, SELFAQ = ...
local debug = SELFAQ.debug
local clone = SELFAQ.clone
local diff = SELFAQ.diff
local L = SELFAQ.L
local initSV = SELFAQ.initSV
local loopSlots = SELFAQ.loopSlots
local chatInfo = SELFAQ.chatInfo
local chatInfo = SELFAQ.chatInfo
local popupInfo = SELFAQ.popupInfo
-- 主函数 --
-- 小地图按钮
local icon = LibStub("LibDBIcon-1.0")
local MiniIconLDB = LibStub("LibDataBroker-1.1"):NewDataObject("AutoEquip", {
type = "data source",
text = "AutoEquip",
icon = 136115,
OnClick = function()
InterfaceOptionsFrame_OpenToCategory(SELFAQ.top);
InterfaceOptionsFrame_OpenToCategory(SELFAQ.top);
end,
OnEnter = function(owner)
local anchor = owner:GetBottom() < GetScreenHeight() / 2 and 'ANCHOR_TOP' or 'ANCHOR_BOTTOM'
GameTooltip:SetOwner(owner, anchor)
GameTooltip:SetText(L["AutoEquip "]..SELFAQ.version)
GameTooltip:AddDoubleLine("|cffffffffClick: Open settings|r")
GameTooltip:Show()
end,
OnLeave = GameTooltip_Hide,
})
icon:Register("MiniIcon", MiniIconLDB)
-- 注入按键设置页面
for k,v in pairs(SELFAQ.gearSlots) do
_G["BINDING_NAME_AUTOEQUIP_BUTTON"..v] = SELFAQ.slotToName[v]
end
for i=1,9 do
_G["BINDING_NAME_AUTOEQUIP_SUIT"..i] = L["Suit "]..i
end
_G["BINDING_NAME_AUTOEQUIP_TAKEOFF"] = L["Takeoff"]
-- _G.BINDING_NAME_AUTOEQUIP_BUTTON14 = L['Trinket Slot ']..2
_G.BINDING_HEADER_AUTOEQUIP_INVENTORYBAR_BUTTON = L["Equipment Bar Button"]
_G.BINDING_HEADER_AUTOEQUIP_SUPER_EQUIP = L["Super Equip"]
-- 注册事件
SELFAQ.main = CreateFrame("Frame")
-- 计数器
SELFAQ.main.TimeSinceLastUpdate = 0
-- 函数执行间隔时间
SELFAQ.main.Interval = 0.5
SELFAQ.main.garbageCount = 0
SELFAQ.onMainUpdate = function(self, elapsed)
self.TimeSinceLastUpdate = self.TimeSinceLastUpdate + elapsed;
-- 每秒执行执行一次
if (self.TimeSinceLastUpdate > self.Interval) then
-- 重新计时
self.TimeSinceLastUpdate = 0;
self.garbageCount = self.garbageCount + 1
if self.garbageCount > 5 then
-- collectgarbage("collect")
self.garbageCount = 0
end
-- 以能读取到物品信息为基准,开始执行
-- 尝试过在ADDON_LOADED等事件中初始化,发现无法读取物品信息,所以改为现在这个逻辑
if GetItemInfo(12930) == nil then
debug("not ready")
return
end
-- 插件初始化,包括构建选项菜单
if not SELFAQ.init then
-- 初始化全局变量
SUITAQ = initSV(SUITAQ, {})
-- for i=1,9 do
-- SUITAQ[i] = initSV(SUITAQ[i], {})
-- end
AQSV = initSV(AQSV, {})
AQSV.usableItems = initSV(AQSV.usableItems, SELFAQ.usable)
AQSV.usableChests = initSV(AQSV.usableChests, SELFAQ.usableChests)
AQSV.enable = initSV(AQSV.enable, true)
AQSV.enableBattleground = initSV(AQSV.enableBattleground, true)
AQSV.disableSlot14 = initSV(AQSV.disableSlot14, false)
AQSV.enableCarrot = initSV(AQSV.enableCarrot, true)
AQSV.enableSwim = initSV(AQSV.enableSwim, true)
AQSV.slot13 = initSV(AQSV.slot13, 0)
AQSV.slot14 = initSV(AQSV.slot14, 0)
AQSV.queue13 = initSV(AQSV.queue13, {})
AQSV.queue14 = initSV(AQSV.queue14, {})
AQSV.x = initSV(AQSV.x, 200)
AQSV.y = initSV(AQSV.y, 0)
AQSV.point = initSV(AQSV.point, "CENTER")
AQSV.locked = initSV(AQSV.locked, false)
AQSV.enableItemBar = initSV(AQSV.enableItemBar, true)
AQSV.enableItemBarSlot = initSV(AQSV.enableItemBarSlot, {})
AQSV.raidTrinkets = initSV(AQSV.raidTrinkets, {})
AQSV.pveTrinkets = initSV(AQSV.pveTrinkets, {})
AQSV.pvpTrinkets = initSV(AQSV.pvpTrinkets, {})
AQSV.pvpMode = initSV(AQSV.pvpMode, false)
AQSV.reverseCooldownUnit = initSV(AQSV.reverseCooldownUnit, true)
AQSV.carrotBackup = initSV(AQSV.carrotBackup, 0)
AQSV.backup8 = initSV(AQSV.backup8, 0)
AQSV.backup10 = initSV(AQSV.backup10, 0)
AQSV.backup1 = initSV(AQSV.backup1, 0)
AQSV.backup6 = initSV(AQSV.backup6, 0)
AQSV.backup16 = initSV(AQSV.backup16, 0)
AQSV.backup17 = initSV(AQSV.backup17, 0)
AQSV.slot13Locked = initSV(AQSV.slot13Locked, false)
AQSV.slot14Locked = initSV(AQSV.slot14Locked, false)
AQSV.slot13LockedCD = initSV(AQSV.slot13LockedCD, false)
AQSV.slot14LockedCD = initSV(AQSV.slot14LockedCD, false)
AQSV.slot13LockedTime = initSV(AQSV.slot13LockedTime, 0)
AQSV.slot14LockedTime = initSV(AQSV.slot14LockedTime, 0)
AQSV.slot13LockedTime = 0
AQSV.slot14LockedTime = 0
AQSV.xBuff = initSV(AQSV.xBuff, 200)
AQSV.yBuff = initSV(AQSV.yBuff, 80)
AQSV.pointBuff = initSV(AQSV.pointBuff, "CENTER")
AQSV.enableBuff = initSV(AQSV.enableBuff, true)
AQSV.buffLocked = initSV(AQSV.buffLocked, false)
AQSV.forcePriority = initSV(AQSV.forcePriority, false)
AQSV.buffNames = initSV(AQSV.buffNames, L["Unstable Power, Mind Quickening"])
AQSV.additionItems = initSV(AQSV.additionItems, "14023/0")
AQSV.blockItems = initSV(AQSV.blockItems, "6219,5956")
AQSV.ignoreBoss = initSV(AQSV.ignoreBoss, "")
AQSV.barZoom = initSV(AQSV.barZoom, 1)
AQSV.buffZoom = initSV(AQSV.buffZoom, 1)
AQSV.hideBackdrop = initSV(AQSV.hideBackdrop, false)
AQSV.suit = initSV(AQSV.suit, {})
AQSV.suit[73] = initSV(AQSV.suit[73], {})
AQSV.suit[74] = initSV(AQSV.suit[74], {})
AQSV.suit[70] = initSV(AQSV.suit[70], {})
AQSV.currentSuit = initSV(AQSV.currentSuit, 0)
AQSV.enableSuit = initSV(AQSV.enableSuit, false)
AQSV.enableAutoSuit70 = initSV(AQSV.enableAutoSuit70, false)
AQSV.enableTargetSuit70 = initSV(AQSV.enableTargetSuit70, false)
AQSV.itemsPerColumn = initSV(AQSV.itemsPerColumn, 4)
AQSV.customSlots = initSV(AQSV.customSlots, {})
AQSV.hideItemQueue = initSV(AQSV.hideItemQueue, false)
AQSV.hideTooltip = initSV(AQSV.hideTooltip, false)
AQSV.shiftLeftShowDropdown = initSV(AQSV.shiftLeftShowDropdown, false)
AQSV.buttonSpacing = initSV(AQSV.buttonSpacing, 3)
AQSV.buttonSpacingNew = initSV(AQSV.buttonSpacingNew, 0)
AQSV.cloakBackup = initSV(AQSV.cloakBackup, 0)
AQSV.simpleTooltip = initSV(AQSV.simpleTooltip, false)
AQSV.disableMouseover = initSV(AQSV.disableMouseover, false)
AQSV.hidePopupInfo = initSV(AQSV.hidePopupInfo, false)
AQSV.hideQuickButton = initSV(AQSV.hideQuickButton, false)
AQSV.hideTakeoffButton = initSV(AQSV.hideTakeoffButton, false)
AQSV.popupX = initSV(AQSV.popupX, 0)
AQSV.popupY = initSV(AQSV.popupY, 320)
AQSV.enableMembersTarget = initSV(AQSV.enableMembersTarget, false)
AQSV.raidTargetThreshold = initSV(AQSV.raidTargetThreshold, 1)
AQSV.enableRaidQueue = initSV(AQSV.enableRaidQueue, false)
AQSV.enableFixedPosition = initSV(AQSV.enableFixedPosition, false)
AQSV.enableAccInstance = initSV(AQSV.enableAccInstance, false)
AQSV.forceAcc = initSV(AQSV.forceAcc, true)
AQSV.pauseAccWhenTarget = initSV(AQSV.pauseAccWhenTarget, true)
AQSV.pauseAccWhenTargetFriend = initSV(AQSV.pauseAccWhenTargetFriend, true)
AQSV.pauseAccWhenTargetMember = initSV(AQSV.pauseAccWhenTargetMember, true)
AQSV.quickButtonZoom = initSV(AQSV.quickButtonZoom, 1)
AQSV.quickButtonLocked = initSV(AQSV.quickButtonLocked, false)
AQSV.splitQuickButton = initSV(AQSV.splitQuickButton, false)
AQSV.quickButtonX = initSV(AQSV.quickButtonX, 0)
AQSV.quickButtonY = initSV(AQSV.quickButtonY, 0)
AQSV.quickButtonPosition = initSV(AQSV.quickButtonPosition, "CENTER")
AQSV.enableLR = initSV(AQSV.enableLR, false)
AQSV.enableQuickEquip = initSV(AQSV.enableQuickEquip, true)
AQSV.hideItemLevel = initSV(AQSV.hideItemLevel, false)
AQSV.enableMinimapIcon = initSV(AQSV.enableMinimapIcon, true)
AQSV.enableTargetUndead = initSV(AQSV.enableTargetUndead, true)
AQSV.enableInUndeadInstance = initSV(AQSV.enableInUndeadInstance, true)
AQSV.undeadPosition = initSV(AQSV.undeadPosition, 1)
if not AQSV.enableMinimapIcon then
icon:Hide("MiniIcon")
end
if AQSV.slotStatus == nil then
AQSV.slotStatus = {}
for k,v in pairs(SELFAQ.slotToName) do
AQSV.slotStatus[k] = {
["backup"] = 0,
["locked"] = false,
["lockedCD"] = false,
["lockedTime"] = 0,
}
end
end
SELFAQ.addonInit()
SELFAQ.createItemBar()
SELFAQ.createBuffIcon()
SELFAQ.mainInit( )
chatInfo(L["Loaded"])
SELFAQ.init = true
end
-- 记录装备栏位置
if SELFAQ.bar then
local point, relativeTo, relativePoint, xOfs, yOfs = SELFAQ.bar:GetPoint()
AQSV.x = xOfs
AQSV.y = yOfs
AQSV.point = point
end
-- 记录快捷按钮位置
-- 已经分离才记录位置
if SELFAQ.quickButton and SELFAQ.quickButton.split then
local point, relativeTo, relativePoint, xOfs, yOfs = SELFAQ.quickButton:GetPoint()
AQSV.quickButtonX = xOfs
AQSV.quickButtonY = yOfs
AQSV.quickButtonPosition = point
end
-- 记录buff提醒位置
if SELFAQ.buff then
local point, relativeTo, relativePoint, xOfs, yOfs = SELFAQ.buff:GetPoint()
AQSV.xBuff = xOfs
AQSV.yBuff = yOfs
AQSV.pointBuff = point
end
-- collectgarbage("collect")
-- UpdateAddOnMemoryUsage()
-- print(string.format("%.2f mb", (GetAddOnMemoryUsage("AutoEquip") / 1024)))
-- 装备栏队列应该不受开关影响
-- 角色处在战斗状态或跑尸状态,不进行换饰品逻辑,退出函数
if not SELFAQ.playerCanEquip() then
return
end
SELFAQ.checkAllWait()
SELFAQ.checkSuperSuit()
SELFAQ.checkSelfTarget()
-- 插件整体开关,以角色为单位
if not AQSV.enable then
return
end
-- 战场开关
if UnitInBattleground("player") and not AQSV.enableBattleground then
return
end
SELFAQ.changeSuit()
-- 整合团队目标处理
SELFAQ.runTargetMemberRules()
-- 自动更换饰品
loopSlots(function(slot_id)
if slot_id == 13 then
SELFAQ.changeTrinket()
else
SELFAQ.changeItem(slot_id)
end
end)
end
end
function SELFAQ.mainInit()
SLASH_AQCMD1 = "/aq";
SLASH_AQCMD2 = "/autoequip";
SLASH_AQCMD2 = "/ae";
function SlashCmdList.AQCMD(msg)
debug(msg)
local number = tonumber(msg)
if number and number >= 0 and number <= 9 then
SELFAQ.superEquipSuit(number)
end
if msg == "" then
SELFAQ.enableAutoEuquip()
elseif msg == "settings" then
InterfaceOptionsFrame_OpenToCategory(SELFAQ.top);
InterfaceOptionsFrame_OpenToCategory(SELFAQ.top);
elseif msg == "pvp" then
SELFAQ. enablePvpMode()
elseif msg == "takeoff" then
for k,v in pairs(AQSV.slotStatus) do
SELFAQ.setLocker(k)
end
SELFAQ.takeoffAll()
chatInfo(L["|cFF00FF00Takeoff|r all equipments"])
popupInfo(L["|cFF00FF00Takeoff|r all equipments"])
elseif msg == "unlock" then
for k,v in pairs(AQSV.slotStatus) do
SELFAQ.cancelLocker(k)
end
chatInfo(L["|cFF00FF00Unlocked|r all equipment buttons"])
popupInfo(L["|cFF00FF00Unlocked|r all equipment buttons"])
elseif msg == "lock" then
for k,v in pairs(AQSV.slotStatus) do
SELFAQ.setLocker(k)
end
chatInfo(L["|cFF00FF00Locked|r all equipment buttons"])
popupInfo(L["|cFF00FF00Locked|r all equipment buttons"])
elseif msg == "70" or msg == "73" or msg == "74" then
-- EquipItemByName(19891, 17)
if SELFAQ.playerCanEquip() then
SELFAQ.needSuit = tonumber(msg)
else
chatInfo(L["|cFF00FF00In combat|r"])
end
elseif strfind(msg, "ipc") then
-- items per column
local n = tonumber(strmatch(msg, "%d+"))
if n > 0 then
AQSV.itemsPerColumn = n
end
elseif strfind(msg, "bs") then
-- equipment button spacing
local n = tonumber(strmatch(msg, "%d+"))
if n >= 0 then
AQSV.buttonSpacingNew = n
chatInfo(L["Set Equipment button spacing to "]..SELFAQ.color("00FF00", n).."."..L[" Please reload UI manually (/reload)."])
end
elseif strfind(msg, "rm") then
-- equipment button spacing
local n = tonumber(strmatch(msg, "%d+"))
if n > 0 then
AQSV.raidTargetThreshold = n
chatInfo(L["Set threshold of member's target to "]..AQSV.raidTargetThreshold)
end
elseif strfind(msg, "dm") then
if strfind(msg, "1") then
AQSV.disableMouseover = true
chatInfo(L["|cFFFF0000Disable|r the display of item list when moseover"])
elseif strfind(msg, "0") then
AQSV.disableMouseover = false
chatInfo(L["|cFF00FF00Enable|r the display of item list when moseover"])
end
elseif strfind(msg, "ceb") then
local _, str = strsplit(" ", msg)
if tonumber(str) == 0 then
chatInfo(L["Custom equipment bar was |cFFFF0000CANCELED|r."]..L[" Please reload UI manually (/reload)."])
AQSV.customSlots = {}
return
end
str = string.gsub(str,",", ",")
local t = {strsplit(",", strtrim(str))}
local new = {}
for k,v in pairs(t) do
v = tonumber(v)
if v and v >= 1 and v <= 18 and v~= 4 and not tContains(new, v) then
table.insert(new, v)
end
end
if #new > 0 then
chatInfo(L["Custom equipment bar |cFF00FF00SUCCESS|r."]..L[" Please reload UI manually (/reload)."])
AQSV.customSlots = new
end
elseif strfind(msg, "pp") then
local _, str = strsplit(" ", msg)
str = string.gsub(str,",", ",")
local x,y = strsplit(",", strtrim(str))
x = tonumber(x)
y = tonumber(y)
if x and y then
AQSV.popupX = x
AQSV.popupY = y
chatInfo(L["Set popup info to a new position"])
popupInfo(L["Set popup info to a new position"])
end
elseif strfind(msg, "hiq") then
if strfind(msg, "1") then
AQSV.hideItemQueue = true
chatInfo(L["|cFFFF0000Hide|r item queue"])
elseif strfind(msg, "0") then
AQSV.hideItemQueue = false
chatInfo(L["|cFF00FF00Show|r item queue"])
end
elseif strfind(msg, "resetp") then
AQSV.x = 200
AQSV.y = 0
AQSV.point = "CENTER"
C_UI.Reload()
elseif strfind(msg, "resetpb") then
AQSV.quickButtonX = 0
AQSV.quickButtonY = 0
AQSV.quickButtonPosition = "CENTER"
C_UI.Reload()
end
end
SELFAQ.main:RegisterEvent("UNIT_INVENTORY_CHANGED")
SELFAQ.main:RegisterEvent("UPDATE_BINDINGS")
SELFAQ.main:RegisterEvent("PLAYER_REGEN_ENABLED")
SELFAQ.main:RegisterEvent("PLAYER_ALIVE") -- 未释放复活
SELFAQ.main:RegisterEvent("PLAYER_UNGHOST") -- 从鬼混复活
SELFAQ.main:RegisterEvent("PLAYER_TARGET_CHANGED")
-- SELFAQ.main:RegisterEvent("UNIT_TARGET")
SELFAQ.main:RegisterEvent("BAG_UPDATE")
SELFAQ.main:RegisterEvent("PLAYER_ENTERING_WORLD")
-- SELFAQ.main:RegisterEvent("ZONE_CHANGED_NEW_AREA")
-- SELFAQ.main:RegisterEvent("ZONE_CHANGED_INDOORS")
-- SELFAQ.main:RegisterEvent("ZONE_CHANGED")
SELFAQ.main:SetScript("OnEvent", function( self, event, arg1 )
if event == "UNIT_INVENTORY_CHANGED" and arg1 == "player" then
for k,v in pairs(SELFAQ.slots) do
SELFAQ.updateItemButton( v )
end
if SELFAQ.playerCanEquip() then
-- 战斗中毒药减少会触发该事件
SELFAQ.runEquipmentRules()
end
-- if SELFAQ.showingSlot then
-- SELFAQ.showDropdown(SELFAQ.showingSlot, SELFAQ.showingPosition, true)
-- end
end
if event == "UPDATE_BINDINGS" then
SELFAQ.bindingSlot()
end
if event == "ZONE_CHANGED_NEW_AREA" or event == "ZONE_CHANGED_INDOORS" or event == "ZONE_CHANGED" then
local zonetext = GetSubZoneText() == "" and GetZoneText() or GetSubZoneText()
debug(GetSubZoneText())
debug(GetZoneText())
-- local uiMapID = C_Map.GetBestMapForUnit("player")
-- debug(uiMapID)
-- print(UnitPosition("player"))
end
-- 脱离战斗的事件
-- 复活也是脱战事件
if event == "PLAYER_REGEN_ENABLED" or event == "PLAYER_ALIVE" or event == "PLAYER_UNGHOST" then
-- 脱战也要判断一下其他状态
if not SELFAQ.playerCanEquip() then
return
end
SELFAQ.checkAllWait()
if not AQSV.enable then
return
end
SELFAQ.runLeaveCombatRules()
-- 避免每次脱离战斗都触发
if AQSV.enableSuit and AQSV.enableAutoSuit70 and AQSV.currentSuit > 70 and SELFAQ.inInstance() then
SELFAQ.needSuit = 70
end
-- 执行一系列更换逻辑
SELFAQ.changeSuit()
-- 自动更换饰品
loopSlots(function(slot_id)
if slot_id == 13 then
SELFAQ.changeTrinket()
else
SELFAQ.changeItem(slot_id)
end
end)
end
-- if event == "UNIT_TARGET" then
-- -- debug(arg1)
-- if not SELFAQ.playerCanEquip() then
-- return
-- end
-- if not AQSV.enableSuit then
-- return
-- end
-- if arg1 == "player" then
-- else
-- SELFAQ.checkAndFireChangeSuit(arg1.."target")
-- end
-- end
if event == "PLAYER_ENTERING_WORLD" then
SELFAQ.runEnterRules()
end
if event == "BAG_UPDATE" then
SELFAQ.updateAllItems( )
end
if event == "PLAYER_TARGET_CHANGED" then
if not SELFAQ.playerCanEquip() then
return
end
SELFAQ.checkSelfTarget()
end
end)
end
SELFAQ.checkSelfTarget = function()
-- 自动骑乘判断
if AQSV.pauseAccWhenTarget then
if not UnitIsDead("target") and not UnitIsFriend("player", "target") then
SELFAQ.targetEnemy = true
else
SELFAQ.targetEnemy = false
end
if GetUnitName("target") == nil then
SELFAQ.targetEnemy = false
end
else
SELFAQ.targetEnemy = false
end
if AQSV.pauseAccWhenTargetFriend then
if not UnitIsDead("target") and UnitIsFriend("player", "target") then
SELFAQ.targetFriend = true
else
SELFAQ.targetFriend = false
end
if GetUnitName("target") == nil then
SELFAQ.targetFriend = false
end
else
SELFAQ.targetFriend = false
end
-- 目标是亡灵
if true then
if not UnitIsDead("target") and (UnitCreatureType("target") == "亡灵" or UnitCreatureType("target") == "恶魔") then
SELFAQ.targetUndead = true
else
SELFAQ.targetUndead = false
end
if GetUnitName("target") == nil then
SELFAQ.targetUndead = false
end
end
-- 目标不是亡灵
if true then
-- 目标活着,并且不是友善的,不是亡灵
if not UnitIsDead("target") and not UnitIsFriend("player", "target") and not (UnitCreatureType("target") == "亡灵" or UnitCreatureType("target") == "恶魔") then
SELFAQ.targetNotUndead = true
else
SELFAQ.targetNotUndead = false
end
if GetUnitName("target") == nil then
SELFAQ.targetNotUndead = false
end
end
-- 超级换装
local number = SELFAQ.checkTargetRules("target")
if number then
SELFAQ.superEquipSuit(number)
end
-- 73+套装
if not AQSV.enable then
return
end
if not SELFAQ.inInstance() then
return
end
SELFAQ.checkAndFireChangeSuit("target")
end
SELFAQ.main:SetScript("OnUpdate", SELFAQ.onMainUpdate)