PHP Code:
-- Courtesy of Wopak - http://www.ownedcore.com/forums/members/309249-wopak.html
-- IF THE CODE IS TO COMPLEX, GO FIX YOUR PROGRAMMING SKILLS
-- This function doesn't require any PLUA unlocker or any other kind of hack
-- Searches bags for a Shield and usable 1 hander and equips them if they are found.
-- Signature
---- fawEquipOneHandAndShield(mode, goBack)
-- Arguments:
---- mode: If "PVP" is passed as an argument, it will prioritize 1 hander & Shield with PVPPower stats
---- goBack: If true is passed, it will equip the previously used Main-Hand and Off-Hand
-- Returns:
---- Nothing
function fawEquipOneHandAndShield(mode, goBack)
if mode == nil then mode = "PVP"; end
if goBack == nil then goBack = false; end
local onehandBagNum, onehandSlotNum, onehandItemID = fawGetItemBagSlot("One-Hand", mode);
local shieldBagNum, shieldSlotNum, shieldItemID = fawGetItemBagSlot("Shields", mode);
if goBack then
EquipItemByName(fawMainHandItemID);
EquipItemByName(fawOffHandItemID);
else
-- Check if a Shield is found, otherwise this is useless
if shieldBagNum then
-- Store currently equipped MainHand ItemID & OffHand ItemID
fawMainHandItemID = GetInventoryItemID("player", 16);
fawOffHandItemID = GetInventoryItemID("player", 17)
-- First Equip 1hander, because you can't equip a Sheild when you have a 2hander equipped
if IsEquippedItem(onehandItemID) ~= 1 then
PickupContainerItem(onehandBagNum, onehandSlotNum)
AutoEquipCursorItem()
end
-- Now equip Shield
if IsEquippedItem(shieldItemID) ~= 1 then
PickupContainerItem(shieldBagNum, shieldBagNum)
AutoEquipCursorItem()
end
end
end
end
-- No documentation, because i don't feel like it.
-- Besides, this function is called by the function above
function fawGetItemBagSlot(itemSubType, mode)
local myBagNum, mySlotNum, myItemID = nil;
for thisBagNum = 0, NUM_BAG_SLOTS do
for thisSlotNum = 1, GetContainerNumSlots(thisBagNum) do
local thisItemID = GetContainerItemID(thisBagNum, thisSlotNum)
if thisItemID then
local thisItemName, _, _, _, thisMinLevel, thisItemType, thisItemSubType, _, thisItemEquipSlot, _, _ = GetItemInfo(thisItemID)
-- if (thisMinLevel == 0 or thisMinLevel <= UnitLevel("player")) and thisItemSubType == itemSubType then
if (thisMinLevel == 0 or thisMinLevel <= UnitLevel("player")) and string.find(thisItemSubType, string.gsub(itemSubType, "-", "%%-")) then
if mode == "PVP" then
local thisItemStats = GetItemStats((select(2, GetItemInfo(thisItemID))));
if thisItemStats["ITEM_MOD_RESILIENCE_RATING_SHORT"] and thisItemStats["ITEM_MOD_RESILIENCE_RATING_SHORT"] > 0 then
return thisBagNum, thisSlotNum, thisItemID;
end
end
myBagNum, mySlotNum, myItemID = thisBagNum, thisSlotNum, thisItemID;
end
end
end
end
return myBagNum, mySlotNum, myItemID;
end