View Single Post
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