WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Legion Beta archived threads (https://www.wowinterface.com/forums/forumdisplay.php?f=177)
-   -   Equipment Manager and Legion legendaries (https://www.wowinterface.com/forums/showthread.php?t=54889)

p3lim 12-04-16 01:26 AM

Equipment Manager and Legion legendaries
 
Legion legendaries are unique-equipped up to two at the same time, but the UseEquipmentSet API is stupid, it will fail should you try to swap to a different legendary without unequipping a previous one first (fails with the "Too many legendaries equipped" error).

Here is a dirty fix to the EquipmentManager_EquipSet function:
Lua Code:
  1. function EquipmentManager_EquipSet(name)
  2.     if(EquipmentSetContainsLockedItems(name) or UnitCastingInfo('player')) then
  3.         UIErrorsFrame:AddMessage(ERR_CLIENT_LOCKED_OUT, 1, 0.1, 0.1, 1)
  4.         return
  5.     end
  6.  
  7.     -- BUG: legion legendaries will halt the set equipping if the user is swapping
  8.     -- different slotted legendaries beyond the 1/2 equipped limit
  9.     local locations = GetEquipmentSetLocations(name)
  10.     for inventoryID = 1, 17 do
  11.         local itemLink = GetInventoryItemLink('player', inventoryID)
  12.         if(itemLink) then
  13.             local rarity = GetInventoryItemQuality('player', inventoryID)
  14.             if(rarity == 5) then
  15.                 -- legendary item found, manually replace it with the item from the new set
  16.                 local action = EquipmentManager_EquipItemByLocation(locations[inventoryID], inventoryID)
  17.                 if(action) then
  18.                     EquipmentManager_RunAction(action)
  19.                 end
  20.             end
  21.         end
  22.     end
  23.  
  24.     UseEquipmentSet(name)
  25. end

Non-blocking version:
Lua Code:
  1. function EquipmentManager_EquipSet(name)
  2.     if(EquipmentSetContainsLockedItems(name) or UnitCastingInfo('player')) then
  3.         UIErrorsFrame:AddMessage(ERR_CLIENT_LOCKED_OUT, 1, 0.1, 0.1, 1)
  4.         return
  5.     end
  6.  
  7.     -- BUG: legion legendaries will halt the set equipping if the user is swapping
  8.     -- different slotted legendaries beyond the 1/2 equipped limit
  9.     local locations = GetEquipmentSetLocations(name)
  10.     for inventoryID = 1, 17 do
  11.         local itemLink = GetInventoryItemLink('player', inventoryID)
  12.         if(itemLink) then
  13.             local rarity = GetInventoryItemQuality('player', inventoryID)
  14.             if(rarity == 5) then
  15.                 -- legendary item found, manually replace it with the item from the new set
  16.                 local action = EquipmentManager_EquipItemByLocation(locations[inventoryID], inventoryID)
  17.                 if(action) then
  18.                     EquipmentManager_RunAction(action)
  19.                     locations[inventoryID] = nil
  20.                 end
  21.             end
  22.         end
  23.     end
  24.  
  25.     -- Equip remaining items through _RunAction to avoid blocking from UseEquipmentSet
  26.     for inventoryID, location in next, locations do
  27.         local action = EquipmentManager_EquipItemByLocation(location, inventoryID)
  28.         if(action) then
  29.             EquipmentManager_RunAction(action)
  30.         end
  31.     end
  32. end

p3lim 01-22-17 02:20 AM

Fixed on the 7.2 PTR, build 23436.


All times are GMT -6. The time now is 04:15 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI