WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   General Authoring Discussion (https://www.wowinterface.com/forums/forumdisplay.php?f=20)
-   -   Chest loot detection (https://www.wowinterface.com/forums/showthread.php?t=55121)

Nieve 02-11-17 03:20 AM

Chest loot detection
 
Hi,

I'm trying to make a loot assistant addon form my guild, to help our raid master to keep a count of player loots. I'm near to finish it, but i have a problem detecting loot when loot source is not from corpse but from a chest (like krossus). Originaly I try this code for loot detection:

Code:

elseif (event == "LOOT_OPENED") then
                local raidID = UnitInRaid("player")
                local masterID = select(3, GetLootMethod())
                if (raidID and masterID and raidID == masterID) then
                        if (UnitLevel("target") == -1) then
                                RILoot_ManageOpen("inRaid")
                        end
                end

It obviously isn't working for chest, since I am only looking for targeted unit level, and I cant figure out how to detect this situation.

May someone help me a bit with that?

Sorry for my bad english and thanks in advance

semlar 02-12-17 06:06 AM

On LOOT_READY you can iterate from 1 to GetNumLootItems() and call GetLootSourceInfo(index) to get the GUID of the unit being looted.

If you're looting a chest, the GUID will start with the word "GameObject", and will contain a unique identifier for that particular object as the 5th numeric field; for example the Felbound Chest from Krosus has an object ID of 248513, which you can see in wowhead's url, so its GUID will look something like "GameObject-0-0-0-0-248513-0".

I'm not sure whether you want to match loot to a specific boss or just want to know whether a "boss" is being looted, or if any high level boss-like loot has been found, because there are a few different ways to go from there.

Nieve 02-12-17 01:42 PM

Hi, semlar

Yes, the idea is to detect when any high level (raid) boss-like loot has been found, being in raid and in master looter mode.

Since i've posted the original post, i've made a little more investigation and found that BAG_OPEN event refers to lootable objects being opened. So, i have replicated the code under LOOT_OPENED event to see if it can help me:

Code:

elseif (event == "BAG_OPEN") then
                local bagId = (...)
                local raidID = UnitInRaid("player")
                local masterID = select(3, GetLootMethod())
                if (raidID and masterID and raidID == masterID) then
                        if (bagId == 248513) then -- Cofre de vínculo vil, Krossus
                                RILoot_ManageOpen("inRaid")
                        end
                end

I knew about GetLootSourceInfo() but I thought that it was deprecated, I dont know why.

Pittyfully, loot funtions are hard to test since its conditions are hardly repeatable, i have to wait to be in raid, be masterlooter and kill a boss whose loot come from an object. I will try both methods next week, when we kill Krosus again.

Thank you very much!!


All times are GMT -6. The time now is 02:26 AM.

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