11local Load = select (2 , ... )
22local DataToColor = unpack (Load )
33
4+ local CAST_START = 999998
5+ local CAST_SUCCESS = 999999
6+
47local ignoreErrorList = {
58 " ERR_ABILITY_COOLDOWN" ,
69 " ERR_OUT_OF_RAGE" ,
@@ -23,6 +26,8 @@ local errorList = {
2326 " ERR_SPELL_COOLDOWN" , -- 7 "Spell is not ready yet."
2427 " ERR_SPELL_FAILED_ANOTHER_IN_PROGRESS" , -- 8 "Another action is in progress"
2528 " ERR_SPELL_FAILED_STUNNED" , -- 9 "Can't do that while stunned"
29+ " SPELL_FAILED_INTERRUPTED" , -- 10 "Interrupted"
30+ " SPELL_FAILED_ITEM_NOT_READY" -- 11 "Item is not ready yet"
2631};
2732
2833function DataToColor :RegisterEvents ()
@@ -39,86 +44,144 @@ function DataToColor:RegisterEvents()
3944end
4045
4146function DataToColor :OnUIErrorMessage (event , messageType , message )
42- local errorName = GetGameMessageInfo (messageType )
47+ local code , ignored , foundMessage , message = DataToColor :GetErrorCode (messageType , message )
48+
49+ if ignored then
50+ UIErrorsFrame :AddMessage (message , 0.7 , 0.7 , 0.7 ) -- show as grey messasge
51+ elseif foundMessage and code ~= 0 then
52+ DataToColor .uiErrorMessage = code ;
53+ UIErrorsFrame :AddMessage (message , 0 , 1 , 0 ) -- show as green messasge
54+ else
55+ UIErrorsFrame :AddMessage (message , 0 , 0 , 1 ) -- show as blue message (unknown message)
56+ end
57+ end
58+
59+ function DataToColor :GetErrorCode (messageType , message )
60+
61+ local errorName
62+ local foundMessage = false
63+ local ignored = false
64+ local code = 0
65+
66+ if messageType ~= nil then
67+ errorName = GetGameMessageInfo (messageType )
68+ end
4369
44- local foundMessage = false ;
4570 for i = 1 , table .getn (ignoreErrorList ), 1 do
46- if ignoreErrorList [i ]== errorName then
47- foundMessage = true ;
48- UIErrorsFrame : AddMessage ( message , 0.7 , 0.7 , 0.7 ) -- show as grey messasge
71+ if ignoreErrorList [i ] == errorName then
72+ foundMessage = true ;
73+ ignored = true
4974 end
5075 end
5176
52- if not foundMessage then
77+ if not ignored and not foundMessage then
5378 for i = 1 , table .getn (errorList ), 1 do
54- if errorList [i ]== errorName then
55- DataToColor .uiErrorMessage = i ;
56-
57- if errorName == errorList [2 ] then -- ERR_SPELL_FAILED_S
58- if message == SPELL_FAILED_UNIT_NOT_INFRONT then
59- DataToColor .uiErrorMessage = 1
60- message = message .. " (" .. ERR_BADATTACKFACING .. " )"
61- elseif message == SPELL_FAILED_MOVING then
62- DataToColor .uiErrorMessage = 6
63- elseif message == SPELL_FAILED_STUNNED then
64- DataToColor .uiErrorMessage = 9
65- -- message = message.." ("..SPELL_FAILED_STUNNED..")"
66- -- else
67- -- message = message.." (Spell related)"
68- end
69- end
70-
71- foundMessage = true ;
72- UIErrorsFrame :AddMessage (message , 0 , 1 , 0 ) -- show as green messasge
79+ if errorList [i ] == errorName or
80+ (_G [errorList [i ]] ~= nil and string.find (_G [errorList [i ]], message )) then
81+ code = i ;
82+ foundMessage = true ;
7383 end
7484 end
7585 end
7686
77- if not foundMessage then
78- UIErrorsFrame :AddMessage (message , 0 , 0 , 1 ) -- show as blue message (unknown message)
87+ -- ERR_SPELL_FAILED_S
88+ -- find by message ex combatlog
89+ if not ignored and (not foundMessage or errorName == errorList [2 ]) then
90+ if string.find (message , SPELL_FAILED_UNIT_NOT_INFRONT ) then
91+ code = 1
92+ foundMessage = true
93+ message = message .. " (" .. ERR_BADATTACKFACING .. " )"
94+ elseif string.find (message , SPELL_FAILED_MOVING ) then
95+ foundMessage = true
96+ code = 6
97+ elseif string.find (message , SPELL_FAILED_STUNNED ) then
98+ foundMessage = true
99+ code = 9
100+ end
79101 end
102+
103+ return code , ignored , foundMessage , message
80104end
81105
82106local watchedSpells = {
83107 [DataToColor .C .Spell .AutoShotId ] = function ()
84108 -- DataToColor:Print("Auto Shot detected")
85109 DataToColor .lastAutoShot = DataToColor .globalTime
86- end
110+ end
87111 }
88112
113+ local swing_reset_spells = {
114+ --[[ Maul ]]
115+ [132136 ]= 1 ,
116+ --[[ Raptor Strike ]]
117+ [132223 ]= 1 ,
118+ --[[ Cleave ]]
119+ [132338 ]= 1 ,
120+ --[[ Heroic Strike ]]
121+ [132282 ]= 1 ,
122+ --[[ Slam ]]
123+ [132340 ]= 1
124+ }
125+
89126function DataToColor :OnCombatEvent (...)
90127 local _ , eventType , _ , sourceGUID , sourceName , _ , _ , destGUID , destName , _ , _ , spellId , _ , _ = CombatLogGetCurrentEventInfo ();
91128 -- print(CombatLogGetCurrentEventInfo())
92129 if eventType == " SPELL_PERIODIC_DAMAGE" then
93130 DataToColor .lastCombatCreature = 0 ;
94131 elseif string.find (sourceGUID , " Creature" ) then
95132 DataToColor .lastCombatCreature = DataToColor :getGuidFromUUID (sourceGUID );
96- -- print(CombatLogGetCurrentEventInfo())
97133 else
98134 DataToColor .lastCombatCreature = 0 ;
99- -- print("Other "..eventType);
100135 end
101136
102137 if string.find (sourceGUID , " Creature" ) and (destGUID == DataToColor .playerGUID or destGUID == DataToColor .petGUID ) then
103138 DataToColor .lastCombatDamageTakenCreature = DataToColor :getGuidFromUUID (sourceGUID );
104- -- print(sourceGUID.." "..DataToColor.lastCombatDamageTakenCreature.." "..sourceName);
105139 end
106140
107- if eventType == " SPELL_CAST_SUCCESS" and sourceGUID == DataToColor .playerGUID then
108- if watchedSpells [spellId ] then watchedSpells [spellId ]() end
109- end
141+ if sourceGUID == DataToColor .playerGUID then
142+ if eventType == " SPELL_CAST_SUCCESS" then
143+ if watchedSpells [spellId ] then watchedSpells [spellId ]() end
144+
145+ local _ , _ , icon = GetSpellInfo (spellId )
146+ if swing_reset_spells [icon ] then
147+ -- DataToColor:Print("Special Melee Swing detected")
148+ DataToColor .lastMainHandMeleeSwing = DataToColor .globalTime
149+ end
150+ end
110151
111- if string.find (eventType , " _DAMAGE" ) then
112- if sourceGUID == DataToColor .playerGUID or sourceGUID == DataToColor .petGUID then
152+ if string.find (eventType , " _CAST_START" ) then
153+ DataToColor .lastCastEvent = CAST_START
154+ DataToColor .lastCastSpellId = spellId
155+ -- print(CombatLogGetCurrentEventInfo())
156+ -- print("_CAST_START "..spellId)
157+ end
158+
159+ if string.find (eventType , " _CAST_SUCCESS" ) or string.find (eventType , " _CAST_FAILED" ) then
160+ -- print(CombatLogGetCurrentEventInfo())
161+ DataToColor .lastCastSpellId = spellId
162+
163+ if string.find (eventType , " _CAST_FAILED" ) then
164+ -- local lastCastEvent = DataToColor.lastCastEvent
165+ local failedType = select (15 , CombatLogGetCurrentEventInfo ())
166+ DataToColor .lastCastEvent = DataToColor :GetErrorCode (nil , failedType )
167+ -- print(lastCastEvent.." -> "..DataToColor.lastCastEvent.." "..failedType.." "..spellId)
168+ else
169+ DataToColor .lastCastEvent = CAST_SUCCESS
170+ end
171+ end
172+
173+ -- matches SWING_ RANGE_ SPELL_ but not SPELL_PERIODIC
174+ if not string.find (eventType , " SPELL_PERIODIC" ) and
175+ (string.find (eventType , " _DAMAGE" ) or string.find (eventType , " _MISSED" )) then
113176 DataToColor .lastCombatDamageDoneCreature = DataToColor :getGuidFromUUID (destGUID );
114177 end
115- end
116178
117- if sourceGUID == DataToColor .playerGUID and string.find (eventType , " SWING_" ) then
118- local _ , _ , _ , _ , _ , _ , _ , _ , _ , isOffHand = select (12 , ... )
119- if not isOffHand then
120- -- DataToColor:Print("Melee Swing detected")
121- DataToColor .lastMainHandMeleeSwing = DataToColor .globalTime
179+ if string.find (eventType , " SWING_" ) then
180+ local _ , _ , _ , _ , _ , _ , _ , _ , _ , isOffHand = select (12 , ... )
181+ if not isOffHand then
182+ -- DataToColor:Print("Normal Melee Swing detected")
183+ DataToColor .lastMainHandMeleeSwing = DataToColor .globalTime
184+ end
122185 end
123186 end
124187
0 commit comments