Thread Tools Display Modes
09-30-15, 09:40 AM   #1
ramzax
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 10
Mount drop message & sound

Hello, I'm trying to make an addon to announce when a rare mount drops, since I almost never pay attention when looting the corpses and I'm using a fast loot addon so I don't see the loot window.

Code:
-- Mount drop message & sound

local mounts = {
	[71665] = true,		-- Flametalon of Alysrazor
	[69224] = true,		-- Smoldering Egg of Millagazor
	[68824] = true,		-- Swift Zulian Panther
	[43959] = true,		-- Grand Black War Mammoth
	[63041] = true,		-- Drake of the South Wind
	[78919] = true,		-- Experiment 12-B
	[77067] = true,		-- Blazing Drake
	[77069] = true,		-- Life-Binder's Handmaiden
	[50818] = true,		-- Invincible
	[45693] = true		-- Mimiron's Head
}

local function OnEvent(self, event, ...)
	for i = 0, GetNumLootItems(), 1 do
		local _, mountID = C_MountJournal.GetMountInfo(i)
	    	if mounts[mountID] then
	    		SendChatMessage("Mount dropped!", RAID_WARNING)
	    		PlaySoundFile("Sound\\Creature\\Ragnaros\\RagnarosSpecialAttack01.wav")
	    	end
    end
end

local mountDrop = CreateFrame("Frame")
mountDrop:RegisterEvent("LOOT_OPENED")
mountDrop:SetScript("OnEvent", OnEvent)
mountDrop:UnregisterEvent("LOOT_OPENED")
  Reply With Quote
09-30-15, 10:28 AM   #2
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
You didn't mention what the problem was! But I'm guessing that the mount ID returned from C_MountJournal.GetMountInfo is not the same as the item ID.
__________________
Grab your sword and fight the Horde!
  Reply With Quote
09-30-15, 12:44 PM   #3
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
Originally Posted by Lombra View Post
I'm guessing that the mount ID returned from C_MountJournal.GetMountInfo is not the same as the item ID.
He's not even getting the item id, he's just making a loop from 0 to GetNumLootItems and calling C_MountJournal.GetMountInfo on the iteration.

The loop should be starting at 1, not 0.

You can get the hyperlink for the item in the loot window via GetLootSlotLink(i), pull the item ID out of that with strsplit(':', link) or something and compare them to a table of item IDs for the mounts.

The event is also being unregistered, so the OnEvent script is never going to run.

Last edited by semlar : 09-30-15 at 02:54 PM.
  Reply With Quote
10-02-15, 05:29 AM   #4
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
There's no way to get item IDs from the mount journal. C_MountJournal.GetMountInfo takes an index (eg. 1 is the 1st mount listed, 52 is that 52nd mount listed, and so on), not an itemID, item name, mount name, or loot slot index (which is what you're passing it). Searching by name would not be effective either, since many mount items have different names than the mounts they teach.

It would be way more efficient to just check if any mount dropped. Are there even any mounts that drop from mobs that aren't rare?

lua Code:
  1. local c = { r = 1, g = 1, b = 1 } -- change values to use some color other than white
  2.  
  3. local f = CreateFrame("Frame")
  4. f:RegisterEvent("LOOT_OPENED")
  5. f:SetScript("OnEvent", function()
  6.     for i = 1, GetNumLootItems() do
  7.         local link = GetLootSlotLink(i)
  8.         local _, _, _, _, _, _, subtype, _, _, icon = GetItemInfo(link)
  9.         if subtype == "Mount" then -- change if you're not playing in English
  10.             PlaySoundFile("Sound\\Creature\\Ragnaros\\RagnarosSpecialAttack01.wav")
  11.             RaidNotice_AddMessage(RaidWarningFrame, "|T"..icon..":0|t "..link.." mount dropped!", c)
  12.             return -- no need to keep looking
  13.         end
  14.     end
  15. end)
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.

Last edited by Phanx : 10-02-15 at 05:33 AM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Mount drop message & sound


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off