Alert Rework (2.1.0)

This commit is contained in:
mikx
2020-11-30 11:41:27 -05:00
parent c67d374828
commit 6111ec4c2d
11 changed files with 192 additions and 64 deletions

View File

@@ -10,6 +10,7 @@ local L = LibStub("AceLocale-3.0"):GetLocale("MxW");
local numItems
local iLink
local value
local by = 300
local LOOT_OPENED_Frame = CreateFrame("Frame")
LOOT_OPENED_Frame:RegisterEvent("LOOT_OPENED")
@@ -22,59 +23,21 @@ LOOT_OPENED_Frame:SetScript("OnEvent",
numItems = GetNumLootItems()
-- loop each loot slot
for i = 1, numItems do
-- get lootslotinfo to get item stack size
lootIcon, lootName, lootQuantity, currencyID, lootQuality, locked, isQuestItem, questID, isActive = GetLootSlotInfo(i)
-- get loot slot link to get iteminfo, we can't use item name due to API limitation
iLink = GetLootSlotLink(i)
-- get the iteminfo and continue only if the itemlink is not empty (EXEMPLE: money in a slot = empty)
if (iLink ~= nil) then
-- get the iteminfo using the slot itemlink
name, link, quality, iLevel, reqLevel, class, subclass, maxStack, equipSlot, texture, vendorPrice = GetItemInfo(iLink)
name, link, quality, iLevel, reqLevel, class, subclass, stack, equipSlot, texture, vendorPrice = GetItemInfo(iLink)
-- get the item value using the link, return nil if the item has no value
local itemId = MX:ToItemID(link);
if (itemId ~= nil) then
value = MX.TSM:GetItemValue(itemId, "DBMinBuyout");
end
-- MINIMUM QUALITY SETTINGS ------
local eq = 2 -- equipable quality
local mq = 1 -- mats quality
local cq = 1 -- consumable quality
local oq = 1 -- other quality
local rq = 1 -- recipe quality
----------------------------------
-- if value is nil, the object is not BoE/not known by TSM & Looter is the player
-- we use locales because the item class is localized by the client
if (value ~= nil and Settings_Alert_Enabled) then
if(class == L["Alert_Class_Armor"]) then
if (value >= Farmer_Logic_MinAlert and quality >= eq) then
MX:SendAlert(link,value);
MX:ChatGuildLootMessage(link,value);
end
elseif(class == L["Alert_Class_Weapon"]) then
if (value >= Farmer_Logic_MinAlert and quality >= eq) then
MX:SendAlert(link,value);
MX:ChatGuildLootMessage(link,value);
end
elseif(class == L["Alert_Class_TradeGoods"]) then
if (value >= Farmer_Logic_MinAlert and quality >= mq) then
MX:SendAlert(link,value);
MX:ChatGuildLootMessage(link,value);
end
elseif(class == L["Alert_Class_Consumable"]) then
if (value >= Farmer_Logic_MinAlert and quality >= cq) then
MX:SendAlert(link,value);
MX:ChatGuildLootMessage(link,value);
end
elseif(class == L["Alert_Class_Misc"]) then
if (value >= Farmer_Logic_MinAlert and quality >= oq) then
MX:SendAlert(link,value);
MX:ChatGuildLootMessage(link,value);
end
elseif(class == "Recipe") then
if (value >= Farmer_Logic_MinAlert and quality >= rq) then
MX:SendAlert(link,value);
MX:ChatGuildLootMessage(link,value);
end
end
MX:SendAlert(iLink,lootQuantity,value,by)
by = by - 85
end
if (value ~= nil) then
Farmer_Money_LootSession = Farmer_Money_LootSession + value;
@@ -82,8 +45,54 @@ LOOT_OPENED_Frame:SetScript("OnEvent",
value = nil
iLink = nil
end
end
end
by = 300
end
end)
function MX:SendAlert(link,lootQuantity,value,y)
-- get the iteminfo using the slot itemlink
name, link, quality, iLevel, reqLevel, class, subclass, stack, equipSlot, texture, vendorPrice = GetItemInfo(link)
-- MINIMUM QUALITY SETTINGS ------
local eq = 2 -- equipable quality
local mq = 1 -- mats quality
local cq = 1 -- consumable quality
local oq = 1 -- other quality
local rq = 1 -- recipe quality
----------------------------------
-- if value is nil, the object is not BoE/not known by TSM & Looter is the player
-- we use locales because the item class is localized by the client
if (value ~= nil and Settings_Alert_Enabled) then
if(class == L["Alert_Class_Armor"]) then
if (value >= Farmer_Logic_MinAlert and quality >= eq) then
MX:ShowAlert(link,lootQuantity,value,y);
MX:ChatGuildLootMessage(link,value);
end
elseif(class == L["Alert_Class_Weapon"]) then
if (value >= Farmer_Logic_MinAlert and quality >= eq) then
MX:ShowAlert(link,lootQuantity,value,y);
MX:ChatGuildLootMessage(link,value);
end
elseif(class == L["Alert_Class_TradeGoods"]) then
if (value >= Farmer_Logic_MinAlert and quality >= mq) then
MX:ShowAlert(link,lootQuantity,value,y);
MX:ChatGuildLootMessage(link,value);
end
elseif(class == L["Alert_Class_Consumable"]) then
if (value >= Farmer_Logic_MinAlert and quality >= cq) then
MX:ShowAlert(link,lootQuantity,value,y);
MX:ChatGuildLootMessage(link,value);
end
elseif(class == L["Alert_Class_Misc"]) then
if (value >= Farmer_Logic_MinAlert and quality >= oq) then
MX:ShowAlert(link,lootQuantity,value,y);
MX:ChatGuildLootMessage(link,value);
end
elseif(class == "Recipe") then
if (value >= Farmer_Logic_MinAlert and quality >= rq) then
MX:ShowAlert(link,lootQuantity,value,y);
MX:ChatGuildLootMessage(link,value);
end
end
end)
end
end