Thread Tools Display Modes
10-09-10, 01:40 PM   #1
Waky
A Cobalt Mageweaver
 
Waky's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2010
Posts: 200
Combat Log issues (again)

I'm trying to make an addon that tracks your mirror images and water elemental as a mage. The only problem I'm having is the fact that I can't register the actual cast of the mirrors/elemental!

Right now this is my code:
Code:
local CLL = CreateFrame("Frame") -- (CombatLogListener)
CLL:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
CLL:SetScript("OnEvent", function(self, event, ...)
	if (event == "COMBAT_LOG_EVENT_UNFILTERED") then
		local timestamp, eventType, sourceGUID, sourceName, sourceFlags, destGUID, destName, destFlags = select(1, ...)
		local spellId, spellName, spellSchool = select(9, ...)
			if (eventType=="SPELL_CAST_SUCCESS") then
				if sourceName == UnitName("player") then
					if (spellId == 55342) then
						mirrorUp = true
						mirrorCastTime = GetTime()
						print("|cff69CCF0Mirror images summoned!")
					end
					if (spellId == 31687) then
						eleUp = true
						eleCastTime = GetTime()
						print("|cff69CCF0Water elemental summoned!")
					end
				end
			end
	end
end)
I'm not receiving any errors in-game, nor am I receiving any sign that it is working. Can anyone look at my code and see what I'm missing here?

Thanks!
  Reply With Quote
10-09-10, 03:20 PM   #2
Waky
A Cobalt Mageweaver
 
Waky's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2010
Posts: 200
Any and all help would be greatly appreciated!
  Reply With Quote
10-09-10, 03:29 PM   #3
Vrul
A Scalebane Royal Guard
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 404
I think you want to check for eventType to be SPELL_SUMMON and not SPELL_CAST_SUCCESS.

A couple suggestions. The name of the player does not change so why call a function each time to check against instead of getting it once and using that? I would also use the player's GUID instead of their name. There is no need to check that event is COMBAT_LOG_EVENT_UNFILTERED each time if that is the only event being registered.

The code:
Code:
local timestamp, eventType, sourceGUID, sourceName, sourceFlags, destGUID, destName, destFlags = select(1, ...)
is the same as:
Code:
local timestamp, eventType, sourceGUID, sourceName, sourceFlags, destGUID, destName, destFlags = ...
but without an unnecessary function call. Also, those first eight arguments are the same for any COMBAT_LOG_EVENT_UNFILTERED eventType so why not just pass them directly in the function declaration and not waste the step/time of reassigning them to new variables? And depending on what you are doing with mirrorCastTime and eleCastTime you may want to switch to using timeStamp instead of calling GetTime().

Something more along the lines of:
Code:
local CLL, playerGUID = CreateFrame('Frame'), UnitGUID('player')
CLL:SetScript('OnEvent', function(self, event, timeStamp, eventType, sourceGUID, sourceName, sourceFlags, destGUID, destName, destFlags, spellID)
	if eventType == 'SPELL_SUMMON' then
		if sourceGUID == playerGUID then
			if spellID == 55342 then
				mirrorUp = true
				mirrorCastTime = GetTime()
				print("|cff69CCF0Mirror images summoned!")
			elseif spellID == 31687 then
				eleUp = true
				eleCastTime = GetTime()
				print("|cff69CCF0Water elemental summoned!")
			end
		end
	end
end)
CLL:RegisterEvent('COMBAT_LOG_EVENT_UNFILTERED')
  Reply With Quote
10-09-10, 03:42 PM   #4
Waky
A Cobalt Mageweaver
 
Waky's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2010
Posts: 200
I took some of your suggestions, and now it's working. All thats left to do now is to make the timer start. Thanks so much for your help!
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Combat Log issues (again)

Thread Tools
Display Modes

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