-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathequipmentManager.lua
More file actions
663 lines (624 loc) · 30.4 KB
/
equipmentManager.lua
File metadata and controls
663 lines (624 loc) · 30.4 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
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
local colorDebug1 = CreateColor(1, 0.84, 0) -- yellow
local colorDebug2 = CreateColor(1, 0.91, 0.49) -- pale yellow
local colorDebug3 = CreateColor(1, 1, 0) -- lemon yellow
local function getItemLink(itemID)
if not itemID then return end
local name, link = C_Item.GetItemInfo(itemID)
return link
end
function Angleur_EquipmentManager()
if not Angleur_SwapoutItemsSaved then
Angleur_SwapoutItemsSaved = {}
end
if not AngleurCharacter.angleurSet then
AngleurCharacter.angleurSet = false
end
Angleur_CreateSetAndAdd_UpdateState()
Angleur_CreateWeaponSwapFrames()
end
function Angleur_CreateSetAndAdd_UpdateState()
if AngleurCharacter.angleurSet == true then
Angleur.configPanel.tab2.contents.createSetAndAdd.defaultTexture:Hide()
Angleur.configPanel.tab2.contents.createSetAndAdd.defaultText:Hide()
Angleur.configPanel.tab2.contents.createSetAndAdd.checkedTexture:Show()
Angleur.configPanel.tab2.contents.createSetAndAdd.checkedText:Show()
Angleur.configPanel.tab2.contents.createSetAndAdd.disableAndDelete:Show()
elseif AngleurCharacter.angleurSet == false then
Angleur_SwapoutItemsSaved = {}
Angleur.configPanel.tab2.contents.createSetAndAdd.checkedTexture:Hide()
Angleur.configPanel.tab2.contents.createSetAndAdd.checkedText:Hide()
Angleur.configPanel.tab2.contents.createSetAndAdd.defaultTexture:Show()
Angleur.configPanel.tab2.contents.createSetAndAdd.defaultText:Show()
Angleur.configPanel.tab2.contents.createSetAndAdd.disableAndDelete:Hide()
end
end
---------------------------
--Needed for Classic(Era)--
---------------------------
local function deleteAngleurSet()
AngleurCharacter.angleurSet = false
Angleur_CreateSetAndAdd_UpdateState()
local setID = C_EquipmentSet.GetEquipmentSetID("Angleur")
if setID ~= nil then
C_EquipmentSet.DeleteEquipmentSet(C_EquipmentSet.GetEquipmentSetID("Angleur"))
end
if not Angleur_CreateSetAndAdd:IsEnabled() then
Angleur_CreateSetAndAdd:Enable()
end
updatingSet = false
Angleur_BetaPrint(colorDebug1:WrapTextInColorCode("deleteAngleurSet ") .. ": Deleted Angleur set due to the lack of equippable slotted items.")
Angleur_BetaPrint("This is a limitation of Classic(not the case for Cata and Retail), since it lacks a proper built-in Equipment Manager, allowing you to slot passive items to your Angleur Set.")
end
---------------------------
---------------------------
---------------------------
local function checkSlottedExtraItems()
for i, slot in pairs(Angleur_SlottedExtraItems) do
if slot.itemID ~= 0 then
if C_Item.IsEquippableItem(slot.itemID) then
---------------------------
--Needed for Classic(Era)--
---------------------------
if not (C_Item.GetItemCount(slot.itemID) >= 1) then
Angleur_BetaPrint(colorDebug1:WrapTextInColorCode("checkSlottedExtraItems ") .. ": not in bags")
else
return true
end
---------------------------
---------------------------
---------------------------
end
elseif slot.macroItemID ~= 0 then
if C_Item.IsEquippableItem(slot.macroItemID) then
---------------------------
--Needed for Classic(Era)--
---------------------------
if not (C_Item.GetItemCount(slot.macroItemID) >= 1) then
Angleur_BetaPrint(colorDebug1:WrapTextInColorCode("checkSlottedExtraItems ") .. ": not in bags")
else
return true
end
---------------------------
---------------------------
---------------------------
end
end
end
return false
end
function Angleur_CreateEquipmentSet()
---------------------------
--Needed for Classic(Era)--
---------------------------
if checkSlottedExtraItems() == false then
print("Can't create Equipment Set without any equippable slotted items. Slot a usable and equippable item to your Extra Items slots first.")
print("This is a limitation of Classic(not the case for Cata and Retail), since it lacks a proper built-in Equipment Manager, allowing you to slot passive items to your Angleur Set.")
deleteAngleurSet()
return
end
---------------------------
---------------------------
---------------------------
local setID
if not C_EquipmentSet.GetEquipmentSetID("Angleur") then
C_EquipmentSet.CreateEquipmentSet("Angleur", 136245)
for i = 1, 19, 1 do
C_EquipmentSet.IgnoreSlotForSave(i)
end
setID = C_EquipmentSet.GetEquipmentSetID("Angleur")
C_EquipmentSet.SaveEquipmentSet(setID)
C_EquipmentSet.ClearIgnoredSlotsForSave()
Angleur_BetaPrint(colorDebug1:WrapTextInColorCode("Angleur_CreateEquipmentSet ") .. ": Ignored Slots:")
Angleur_BetaTableToString(C_EquipmentSet.GetIgnoredSlots(setID))
local colorBlu = CreateColor(0.61, 0.85, 0.92)
local colorYellow = CreateColor(1.0, 0.82, 0.0)
print("Created equipment set for " .. colorBlu:WrapTextInColorCode("Angleur" ) .. ". ID is : ", setID)
print("All unslotted items in the set have been set to <ignore slot>.")
print("Adding passive items is currently disabled on the Classic Era version of Angleur due to a lack of proper equipment manager UI.")
AngleurCharacter.angleurSet = true
end
Angleur_AddToEquipmentSet()
end
-- Sets all item slots in the Equipment Manager to ignore
local function setIgnores(setID)
local isIgnored = C_EquipmentSet.GetIgnoredSlots(setID)
if not isIgnored then
print("setIgnores: Angleur error: Equip set ID not found")
return
end
local Debug_Ignores = ""
for i, ignore in pairs(isIgnored) do
if ignore == true then
C_EquipmentSet.IgnoreSlotForSave(i)
Debug_Ignores = Debug_Ignores .. " | " .. i
end
end
Angleur_BetaPrint(colorDebug1:WrapTextInColorCode("setIgnores "), ": ", Debug_Ignores, " are ignored")
end
local function isSetEquipped(setID)
if next(C_EquipmentSet.GetItemIDs(setID)) == nil then
Angleur_BetaPrint(colorDebug1:WrapTextInColorCode("isSetEquipped ") .. ": EMPTY SET")
return true
end
local _, _, _, equipped = C_EquipmentSet.GetEquipmentSetInfo(setID)
Angleur_BetaPrint(colorDebug1:WrapTextInColorCode("isSetEquipped ") .. ": EQUIPPED: ", equipped)
return equipped
end
--**********************[1]************************
--* Automatically adding slotted items to the set *
--**********************[1]************************
local function showAndPlayAnimation()
if not CharacterFrame:IsShown() then
ToggleCharacter("PaperDollFrame")
end
end
-- When player manually changes items, add them to the 'Angleur_SwapoutItemsSaved' regardless of sleep state
local updatingSet = false
local equipmentChangeTrackFrame = CreateFrame("Frame")
equipmentChangeTrackFrame:RegisterEvent("PLAYER_EQUIPMENT_CHANGED")
equipmentChangeTrackFrame:SetScript("OnEvent", function(self, event, slot, empty)
if AngleurCharacter.angleurSet == false then return end
if event == "PLAYER_EQUIPMENT_CHANGED" then
if empty == true then
elseif empty == false then
local newItem = GetInventoryItemID("player", slot)
local angleurSetItemIDs = C_EquipmentSet.GetItemIDs(C_EquipmentSet.GetEquipmentSetID("Angleur"))
local setItem = angleurSetItemIDs[slot]
if not setItem or setItem == -1 then
Angleur_BetaPrint(colorDebug1:WrapTextInColorCode("EquipmentChangeTrack ") .. ": No set counterpart in the slot, not overwriting")
return
end
Angleur_BetaPrint(colorDebug1:WrapTextInColorCode("EquipmentChangeTrack ") .. ": Newly Equipped Item: ", getItemLink(newItem))
Angleur_BetaPrint(colorDebug1:WrapTextInColorCode("EquipmentChangeTrack ") .. ": Angleur Set Counterpart: ", getItemLink(setItem))
if newItem == setItem then
Angleur_BetaPrint(colorDebug1:WrapTextInColorCode("EquipmentChangeTrack ") .. ": The new item is the set item...")
elseif updatingSet == false then
Angleur_SwapoutItemsSaved[slot] = newItem
Angleur_BetaPrint(colorDebug1:WrapTextInColorCode("EquipmentChangeTrack ") .. ": OVERWRITTEN: ", getItemLink(Angleur_SwapoutItemsSaved[slot]))
end
end
end
end)
-- Will periodically call 'Equip Item' for items in wantToEquip until it's empty(all items have been equipped)
local wantToEquip = {}
local equipFrame = CreateFrame("Frame")
local erapusuThreshold = 0.3
local erapusuCounter = 0
local function OnUpdate_AttemptEquip(self, elapsed)
erapusuCounter = erapusuCounter + elapsed
if erapusuCounter < erapusuThreshold then
return
end
if InCombatLockdown() then
wantToEquip = {}
self:SetScript("OnUpdate", nil)
print("Couldn't equip slotted item in time before combat")
return
end
erapusuCounter = 0
local setID = C_EquipmentSet.GetEquipmentSetID("Angleur")
if not setID then
Angleur_BetaPrint("OnUpdate_AttemptEquip: Angleur Set not found")
self:SetScript("OnUpdate", nil)
AngleurCharacter.angleurSet = false
Angleur_CreateSetAndAdd_UpdateState()
Angleur.configPanel.tab2.contents.createSetAndAdd:Enable()
if not Angleur_CreateSetAndAdd:IsEnabled() then
Angleur_CreateSetAndAdd:Enable()
end
return
end
Angleur_BetaPrint(colorDebug1:WrapTextInColorCode("OnUpdate_AttemptEquip ") .. ": Item IDs from Set ID:")
Angleur_BetaTableToString(C_EquipmentSet.GetItemIDs(setID))
if not isSetEquipped(setID) then
-- empty for now
end
-- Checks for each item in 'wantToEquip' if they are equipped. If not, call 'C_Item.EquipItemByName()' again.
for location, itemID in pairs(wantToEquip) do
Angleur_BetaPrint(colorDebug1:WrapTextInColorCode("OnUpdate_AttemptEquip ") .. ": Location:", location, ", itemID:", itemID, ", link:", getItemLink(itemID))
if itemID then
if C_Item.IsEquippedItem(itemID) then
C_EquipmentSet.UnignoreSlotForSave(location)
C_EquipmentSet.SaveEquipmentSet(setID)
wantToEquip[location] = nil
Angleur_BetaPrint(colorDebug1:WrapTextInColorCode("OnUpdate_AttemptEquip ") .. ": Item equipped succesfully, saving to equipment set")
else
C_Item.EquipItemByName(itemID)
Angleur_BetaPrint(colorDebug1:WrapTextInColorCode("OnUpdate_AttemptEquip ") .. ": Set equipped, trying to equip item")
end
else
wantToEquip[location] = nil
end
end
-- Equipping process is complete, finish up
if next(wantToEquip) == nil then
self:SetScript("OnUpdate", nil)
if AngleurCharacter.sleeping == true then
Angleur_UnequipAngleurSet(true)
end
local colorBlu = CreateColor(0.61, 0.85, 0.92)
local colorYellow = CreateColor(1.0, 0.82, 0.0)
local colorRed = CreateColor(1, 0, 0)
local colorGrae = CreateColor(0.85, 0.85, 0.85)
if checkSlottedExtraItems() == true then
print("Slotted items successfully updated for your " .. colorYellow:WrapTextInColorCode("Angleur Equipment Set."))
elseif checkSlottedExtraItems() == false then
print(colorBlu:WrapTextInColorCode("----------------------------------------------------------------------------------------------------"))
print(" The " .. colorYellow:WrapTextInColorCode("Update/Create Set ") .. "Button automatically adds equippable items in your "
.. colorYellow:WrapTextInColorCode"Extra Items " .. "slots to your " .. colorBlu:WrapTextInColorCode("Angleur Set")
.. ", and creates one if there isn't already.\n\nIf you want to " .. colorRed:WrapTextInColorCode("remove ")
.. "previously saved slotted items, you need to click the " .. colorRed:WrapTextInColorCode("Delete ")
.. "Button to the top right, and then re-create the set - or manually change the item set.\n\nYou may also assign "
.. colorGrae:WrapTextInColorCode("- Passive Items - ") .. "to your "
.. colorBlu:WrapTextInColorCode("Angleur Set ") .. "manually, and Angleur will swap them in and out like the rest.")
print(colorBlu:WrapTextInColorCode("----------------------------------------------------------------------------------------------------"))
end
Angleur_BetaPrint(colorDebug1:WrapTextInColorCode("OnUpdate_AttemptEquip ") .. ": item table empty, removing script")
AngleurCharacter.angleurSet = true
Angleur_CreateSetAndAdd_UpdateState()
Angleur.configPanel.tab2.contents.createSetAndAdd:Enable()
updatingSet = false
showAndPlayAnimation()
end
end
local function isEligible(itemID)
if not C_Item.IsEquippableItem(itemID) then return false end
if not (C_Item.GetItemCount(itemID) >= 1) then
print("ITEM NOT FOUND IN BAGS. TO USE FOR EQUIPMENT SWAP, EITHER ADD IT MANUALLY TO ANGLEUR SET OR RE-DRAG THE MACRO.")
return false
end
return true
end
-- First called when player clicks the 'Create/Update Set' button
function Angleur_AddToEquipmentSet()
local setID = C_EquipmentSet.GetEquipmentSetID("Angleur")
setIgnores(setID)
updatingSet = true
for index, item in pairs(Angleur_SlottedExtraItems) do
local itemID
if item.itemID ~= 0 and item.itemID ~= nil then
itemID = item.itemID
elseif item.macroItemID ~= 0 and item.macroItemID ~= nil then
itemID = item.macroItemID
end
if itemID and isEligible(itemID) == true and item.equipLoc ~= 0 and item.equipLoc ~= nil then
local location = item.equipLoc
if type(location) == "table" then location = location[1] end
if C_EquipmentSet.IsSlotIgnoredForSave(location) then
C_EquipmentSet.UnignoreSlotForSave(location)
end
Angleur_BetaPrint(colorDebug1:WrapTextInColorCode("AddToEquipmentSet ") .. ": Slotted item detected: ", C_Item.GetItemNameByID(itemID))
wantToEquip[location] = itemID
local currentlyEquipped = GetInventoryItemID("player", location)
if itemID ~= currentlyEquipped then
Angleur_SwapoutItemsSaved[location] = currentlyEquipped
Angleur_BetaPrint(colorDebug1:WrapTextInColorCode("AddToEquipmentSet ") .. ": This is the item to re-equip(swapout list): ", getItemLink(Angleur_SwapoutItemsSaved[location]))
else
Angleur_BetaPrint(colorDebug1:WrapTextInColorCode("AddToEquipmentSet ") .. ": Equipped item same as new, not overwriting Swapout.")
end
end
end
---------------------------
--Needed for Classic(Era)--
---------------------------
if next(wantToEquip) == nil then
deleteAngleurSet()
return
end
---------------------------
---------------------------
---------------------------
Angleur_BetaPrint(colorDebug1:WrapTextInColorCode("AddToEquipmentSet ") .. ": The items that will be equipped:")
Angleur_BetaTableToString(wantToEquip)
local _, _, _, equipped = C_EquipmentSet.GetEquipmentSetInfo(setID)
-- Will kick off the perpetual calling of 'OnUpdate_AttemptEquip' after making sure the Set is active
if not equipped then
Angleur_EquipAngleurSet(AngleurCharacter.sleeping)
equipFrame:RegisterEvent("EQUIPMENT_SWAP_FINISHED")
equipFrame:SetScript("OnEvent", function(self, event, result, listenedSetID)
if event == "EQUIPMENT_SWAP_FINISHED" and result == true and listenedSetID == setID then
Angleur_BetaPrint(colorDebug1:WrapTextInColorCode("AddToEquipmentSet ") .. ": Set equip finished.")
Angleur_BetaTableToString(C_EquipmentSet.GetItemIDs(setID))
equipFrame:SetScript("OnEvent", nil)
equipFrame:SetScript("OnUpdate", OnUpdate_AttemptEquip)
elseif event == "EQUIPMENT_SWAP_FINISHED" and result == false then
Angleur_BetaPrint(colorDebug1:WrapTextInColorCode("AddToEquipmentSet ") .. ": Failed to equip set: ", listenedSetID)
end
end)
else
equipFrame:SetScript("OnUpdate", OnUpdate_AttemptEquip)
end
end
--**********************[1]************************
--|||||||||||||||||||||||||||||||||||||||||||||||||
--**********************[1]************************
--**********************[2]************************
--************** Combat Weapon Swap ***************
--**********************[2]************************
local combatSwapped = false
local swapWepTable = {}
local erapusuThreshold3 = 0.05
local erapusuCounter3 = 0
local function swapCombatWeapons_OnUpdate(self, elapsed)
erapusuCounter3 = erapusuCounter3 + elapsed
if erapusuCounter3 < erapusuThreshold3 then
return
end
erapusuCounter3 = 0
if InCombatLockdown() then
self:SetScript("OnUpdate", nil)
Angleur_BetaPrint(colorDebug2:WrapTextInColorCode("swapCombatWeapons_OnUpdate ") .. ": Couldn't equip combat weapon in time")
return
end
for location, itemID in pairs(swapWepTable) do
Angleur_BetaPrint(colorDebug2:WrapTextInColorCode("swapCombatWeapons_OnUpdate ") .. ": Weapon Location ", location)
if C_Item.IsEquippedItem(itemID) then
Angleur_BetaPrint(colorDebug2:WrapTextInColorCode("swapCombatWeapons_OnUpdate ") .. ": equipped weapon slot successfully: ", itemID)
swapWepTable[location] = nil
elseif not IsInventoryItemLocked(location) then
C_Item.EquipItemByName(itemID, location)
Angleur_BetaPrint(colorDebug2:WrapTextInColorCode("swapCombatWeapons_OnUpdate ") .. ": trying to equip item")
Angleur_BetaPrint(itemID, location)
end
end
if next(swapWepTable) == nil then
self:SetScript("OnUpdate", nil)
Angleur_BetaPrint(colorDebug2:WrapTextInColorCode("swapCombatWeapons_OnUpdate ") .. ": weapon swap complete, removing script")
end
end
local function swapCombatWeapons_Single()
for location, itemID in pairs(swapWepTable) do
Angleur_BetaPrint(colorDebug2:WrapTextInColorCode("swapCombatWeapons_Single ") .. ": Weapon Location ", location)
if C_Item.IsEquippedItem(itemID) then
Angleur_BetaPrint(itemID, colorDebug2:WrapTextInColorCode("swapCombatWeapons_Single ") .. ": equipped weapon slot successfully")
swapWepTable[location] = nil
elseif not IsInventoryItemLocked(location) then
local GUID = C_TooltipInfo.GetOwnedItemByID(itemID).guid
if GUID then
local lokasyon = C_Item.GetItemLocation(GUID)
C_Item.UnlockItem(lokasyon)
end
C_Item.EquipItemByName(itemID, location)
Angleur_BetaPrint(colorDebug2:WrapTextInColorCode("swapCombatWeapons_Single ") .. ": trying to equip item")
else
Angleur_BetaPrint(colorDebug2:WrapTextInColorCode("swapCombatWeapons_Single ") .. ": LOCKEDLOCKEDLOCKEDLOCKED")
end
end
end
local function wepSwapFrame_OnEvent(self, event, unit, ...)
if AngleurCharacter.sleeping == true then return end
local arg4, arg5 = ...
local children = {self:GetChildren()}
if event == "PLAYER_REGEN_DISABLED" then
swapWepTable[16] = Angleur_SwapoutItemsSaved[16]
swapWepTable[17] = Angleur_SwapoutItemsSaved[17]
Angleur_RepositionWeaponSwapFrames()
for i, child in pairs(children) do
child:setMacro(swapWepTable)
end
self:Show()
elseif event == "PLAYER_REGEN_ENABLED" then
self:Hide()
local setID = C_EquipmentSet.GetEquipmentSetID("Angleur")
if not setID then
return
end
local setItems = C_EquipmentSet.GetItemIDs(setID)
if setItems[16] and setItems[16] ~= -1 then
swapWepTable[16] = setItems[16]
end
if setItems[17] and setItems[17] ~= -1 then
swapWepTable[17] = setItems[17]
end
swapCombatWeapons_Single()
if next(swapWepTable) ~= nil then
self:SetScript("OnUpdate", swapCombatWeapons_OnUpdate)
end
elseif event == "PLAYER_EQUIPMENT_CHANGED" then
if next(swapWepTable) == nil then return end
if swapWepTable[unit] then
if C_Item.IsEquippedItem(swapWepTable[unit]) then
swapWepTable[unit] = nil
end
end
if next(swapWepTable) == nil then
for i, child in pairs(children) do
child.icon:SetTexture(nil)
child.equipArrow:Hide()
child.success:Show()
end
end
end
end
local weaponSwapFrames = CreateFrame("Frame")
weaponSwapFrames:SetFrameStrata("HIGH")
weaponSwapFrames:RegisterEvent("PLAYER_REGEN_ENABLED")
weaponSwapFrames:RegisterEvent("PLAYER_REGEN_DISABLED")
weaponSwapFrames:RegisterEvent("PLAYER_EQUIPMENT_CHANGED")
weaponSwapFrames:SetScript("OnEvent", wepSwapFrame_OnEvent)
-- Creates hidden overlay force-equip macro secureactionbuttons onto the minimap button and visual
function Angleur_CreateWeaponSwapFrames()
if weaponSwapFrames.visual == nil then Angleur_BetaPrint(colorDebug2:WrapTextInColorCode("CreateWeaponSwapFrames ") .. ": it do be nil") end
if Angleur.visual:IsShown() and weaponSwapFrames.visual == nil then
weaponSwapFrames.visual = CreateFrame("Button", "Angleur_WeaponSwapFrame1", weaponSwapFrames, "CombatWeaponSwapButtonTemplate")
end
if weaponSwapFrames.minimap == nil then Angleur_BetaPrint(colorDebug2:WrapTextInColorCode("CreateWeaponSwapFrames ") .. ": it do be nil") end
if LibDBIcon10_AngleurMap then
if LibDBIcon10_AngleurMap:IsShown() then
weaponSwapFrames.minimap = CreateFrame("Button", "Angleur_WeaponSwapFrame2", weaponSwapFrames, "CombatWeaponSwapButtonTemplate")
end
end
end
function Angleur_RepositionWeaponSwapFrames()
if weaponSwapFrames.visual ~= nil and Angleur.visual:IsShown() then
local frameX, frameY = Angleur.visual:GetSize()
local selfX, selfY = weaponSwapFrames.visual:GetSize()
weaponSwapFrames.visual:SetScale(Angleur.visual:GetEffectiveScale())
weaponSwapFrames.visual:ClearAllPoints()
weaponSwapFrames.visual:SetPoint("BOTTOMLEFT", UIParent, Angleur.visual:GetLeft(), Angleur.visual:GetBottom())
else
Angleur_BetaPrint(colorDebug2:WrapTextInColorCode("RepositionWeaponSwapFrames ") .. ": it do be nil")
end
if weaponSwapFrames.minimap ~= nil and LibDBIcon10_AngleurMap and LibDBIcon10_AngleurMap:IsShown() then
local frameX, frameY = LibDBIcon10_AngleurMap:GetSize()
local selfX, selfY = weaponSwapFrames.minimap:GetSize()
local minimapScaler = 0.7
weaponSwapFrames.minimap:SetScale(LibDBIcon10_AngleurMap:GetEffectiveScale() * minimapScaler)
weaponSwapFrames.minimap:ClearAllPoints()
weaponSwapFrames.minimap:SetPoint("BOTTOMLEFT", UIParent, LibDBIcon10_AngleurMap:GetLeft() / minimapScaler, LibDBIcon10_AngleurMap:GetBottom() / minimapScaler)
else
Angleur_BetaPrint(colorDebug2:WrapTextInColorCode("RepositionWeaponSwapFrames ") .. ": it do be nil")
end
end
--**********************[2]************************
--|||||||||||||||||||||||||||||||||||||||||||||||||
--**********************[2]************************
--**********************[3]************************
--****************** Equip Set ********************
--**********************[3]************************
--
local equipFrameSet = CreateFrame("Frame")
equipFrameSet:RegisterEvent("EQUIPMENT_SWAP_FINISHED")
local function fillSwapoutTable(setID)
itemIDs = C_EquipmentSet.GetItemIDs(setID)
Angleur_BetaPrint(colorDebug2:WrapTextInColorCode("fillSwapoutTable ") .. ": Table ItemIDs:")
Angleur_BetaTableToString(itemIDs)
for location = 1, 19 do
if itemIDs[location] ~= nil and itemIDs[location] ~= -1 then
Angleur_BetaPrint(colorDebug2:WrapTextInColorCode("fillSwapoutTable ") .. ": Slot is set to equip item: ", itemIDs[location])
local inventoryItemID = GetInventoryItemID("player", location)
Angleur_BetaPrint(inventoryItemID)
if inventoryItemID then
if inventoryItemID == itemIDs[location] then
Angleur_BetaPrint(colorDebug2:WrapTextInColorCode("fillSwapoutTable ") .. ": Set item was previously equipped, not overriding previous re-requip table.")
elseif Angleur_SwapoutItemsSaved[location] ~= nil and Angleur_SwapoutItemsSaved[location] ~= -1 then
local _, itemLink = GetItemInfo(Angleur_SwapoutItemsSaved[location])
Angleur_BetaPrint(location, itemLink)
end
end
end
end
end
-- Starts off the periodical calling of 'Equip Set' until player enters combat or set is succesfully equipped
function Angleur_EquipAngleurSet(overrideSwapoutItems)
local setID = C_EquipmentSet.GetEquipmentSetID("Angleur")
if not setID then
Angleur_BetaPrint(colorDebug2:WrapTextInColorCode("EquipAngleurSet ") .. ": No Angleur set found, can't swap")
return
end
---------------------------
--Needed for Classic(Era)--
---------------------------
if checkSlottedExtraItems() == false then
print("Angleur Set without equippable items detected. Deleting Set.")
print("This is a limitation of Classic(not the case for Cata and Retail)")
deleteAngleurSet()
return
end
---------------------------
---------------------------
---------------------------
if overrideSwapoutItems == true then
setIgnores(setID)
fillSwapoutTable(setID)
end
local erapusuThresholdSet = 0.3
local erapusuCounterSet = 0
equipFrameSet:SetScript("OnUpdate", function(self, elapsed)
erapusuCounterSet = erapusuCounterSet + elapsed
if erapusuCounterSet < erapusuThresholdSet then
return
end
erapusuCounterSet = 0
if InCombatLockdown() then
print("Equipping of the Angleur set disrupted due to sudden combat")
self:SetScript("OnUpdate", nil)
self:SetScript("OnEvent", nil)
return
end
C_EquipmentSet.UseEquipmentSet(setID)
end)
equipFrameSet:SetScript("OnEvent", function(self, event, result, equippedSet)
if event == "EQUIPMENT_SWAP_FINISHED" then
if result == true and equippedSet == setID then
self:SetScript("OnEvent", nil)
self:SetScript("OnUpdate", nil)
Angleur_BetaPrint(colorDebug2:WrapTextInColorCode("Angleur_EquipAngleurSet ") .. ": Angleur set equipped successfully")
for location, itemID in pairs(Angleur_SwapoutItemsSaved) do
local _, itemLink = GetItemInfo(Angleur_SwapoutItemsSaved[location])
Angleur_BetaPrint(colorDebug2:WrapTextInColorCode("Angleur_EquipAngleurSet ") .. ": Swapout: ", location, itemLink)
end
end
end
end)
end
--**********************[3]************************
--|||||||||||||||||||||||||||||||||||||||||||||||||
--**********************[3]************************
--**********************[4]************************
--***************** Unequip Set *******************
--**********************[4]************************
local erapusuThreshold3 = 0.3
local erapusuCounter3 = 0
local swapoutsTemporary = {}
local function copyTableToTemp()
for i, v in pairs(Angleur_SwapoutItemsSaved) do
swapoutsTemporary[i] = v
end
end
-- Attempts to unequip until the temporary copied table is emptied
local function unequipSet_OnUpdate(self, elapsed)
erapusuCounter3 = erapusuCounter3 + elapsed
if erapusuCounter3 < erapusuThreshold3 then
return
end
erapusuCounter3 = 0
copyTableToTemp()
if InCombatLockdown() then
Angleur_BetaPrint(colorDebug3:WrapTextInColorCode("unequipSet_OnUpdate ") .. ": Couldn't re-equip all items before combat in time.")
Angleur_BetaTableToString(swapoutsTemporary)
self:SetScript("OnUpdate", nil)
return
end
for location, itemID in pairs(swapoutsTemporary) do
Angleur_BetaPrint(colorDebug3:WrapTextInColorCode("unequipSet_OnUpdate ") .. ": Location ", location)
if C_Item.IsEquippedItem(itemID) then
Angleur_BetaPrint(colorDebug3:WrapTextInColorCode("unequipSet_OnUpdate ") .. ": " , itemID, "equipped back successfully")
swapoutsTemporary[location] = nil
else
C_Item.EquipItemByName(itemID)
Angleur_BetaPrint(colorDebug3:WrapTextInColorCode("unequipSet_OnUpdate ") .. ": trying to equip item")
end
end
if next(swapoutsTemporary) == nil then
self:SetScript("OnUpdate", nil)
Angleur_BetaPrint(colorDebug3:WrapTextInColorCode("unequipSet_OnUpdate ") .. ": swapback complete, removing script")
end
end
local function unequipSet_Single()
for location, itemID in pairs(swapoutsTemporary) do
C_Item.EquipItemByName(itemID)
Angleur_BetaPrint(colorDebug3:WrapTextInColorCode("unequipSet_Single ") .. ": trying to equip item(first attempt)")
if C_Item.IsEquippedItem(itemID) then
swapoutsTemporary[location] = nil
end
end
end
-- Main unequip function, kicks off periodical calling of unequipSet
function Angleur_UnequipAngleurSet(secondary)
equipFrameSet:SetScript("OnEvent", nil)
equipFrameSet:SetScript("OnUpdate", nil)
unequipSet_Single()
if next(Angleur_SwapoutItemsSaved) == nil then
Angleur_BetaPrint(colorDebug3:WrapTextInColorCode("Angleur_UnequipAngleurSet ") .. ": Swapped back successfully on the first attempt")
return
end
if not secondary then return end
Angleur_BetaPrint(colorDebug3:WrapTextInColorCode("Angleur_UnequipAngleurSet ") .. ": SwapoutItems Table remaining from first(singular) attempt:")
Angleur_BetaTableToString(Angleur_SwapoutItemsSaved)
Angleur_BetaPrint(colorDebug3:WrapTextInColorCode("Angleur_UnequipAngleurSet ") .. ": Starting secondary swapback process")
equipFrameSet:SetScript("OnUpdate", unequipSet_OnUpdate)
end
--**********************[4]************************
--|||||||||||||||||||||||||||||||||||||||||||||||||
--**********************[4]************************