@@ -52,6 +52,7 @@ local TimerTick = 0
5252local NextScanTime = 0 ;
5353local lastBuffTarget = " " ;
5454local lastBuffStatus = " " ;
55+ local lastBuffFired = nil ;
5556
5657local Buffalo_GroupBuffProperties = { }; -- Array of buff properties for the group UI: { buffname, iconid, bitmask, priority }
5758local Buffalo_SelfBuffProperties = { };
@@ -1259,19 +1260,15 @@ function Buffalo_UpdateBuffButton(unitid, spellname, textureId)
12591260 end ;
12601261end ;
12611262
1263+ function Buffalo_OnBeforeBuffClick (self , ...)
1264+ lastBuffFired = BuffButton :GetAttribute (" spell" );
1265+ end ;
1266+
12621267function Buffalo_OnAfterBuffClick (self , ...)
12631268 local buttonName = ... ;
12641269
12651270 if buttonName == " RightButton" then
12661271 Buffalo_OpenConfigurationDialogue ();
1267- else
1268- if CONFIG_AnnounceCompletedBuff and not UnitAffectingCombat (" player" ) then
1269- local unitid = BuffButton :GetAttribute (" unit" );
1270- local spellID = BuffButton :GetAttribute (" spell" );
1271- if unitid and spellID then
1272- Buffalo_Echo (string.format (" %s was buffed with %s." , Buffalo_GetPlayerAndRealm (unitid ) or " nil" , GetSpellInfo (spellID )));
1273- end ;
1274- end ;
12751272 end ;
12761273end ;
12771274
@@ -1740,6 +1737,34 @@ function Buffalo_OnEvent(self, event, ...)
17401737 elseif (event == " CHAT_MSG_ADDON" ) then
17411738 Buffalo_OnChatMsgAddon (event , ... )
17421739
1740+ elseif (event == " UNIT_SPELLCAST_STOP" ) then
1741+ local caster = ... ;
1742+ if caster == " player" then
1743+ lastBuffFired = nil ;
1744+ end ;
1745+
1746+ elseif (event == " UNIT_SPELLCAST_FAILED" ) then
1747+ local caster = ... ;
1748+ if caster == " player" then
1749+ lastBuffFired = nil ;
1750+ end ;
1751+
1752+ elseif (event == " UNIT_SPELLCAST_SUCCEEDED" ) then
1753+ local caster , _ , spellId = ... ;
1754+
1755+ if caster == " player" then
1756+ local buffName = GetSpellInfo (spellId );
1757+ if buffName and buffName == lastBuffFired then
1758+ lastBuffFired = nil ;
1759+ if CONFIG_AnnounceCompletedBuff and not UnitAffectingCombat (" player" ) then
1760+ local unitid = BuffButton :GetAttribute (" unit" );
1761+ if unitid then
1762+ Buffalo_Echo (string.format (" %s was buffed with %s." , Buffalo_GetPlayerAndRealm (unitid ) or " nil" , buffName ));
1763+ end ;
1764+ end ;
1765+ end ;
1766+ end ;
1767+
17431768 else
17441769 if (debug ) then
17451770 echo (" **DEBUG**: Other event: " .. event );
@@ -1772,6 +1797,9 @@ function Buffalo_OnLoad()
17721797
17731798 BuffaloEventFrame :RegisterEvent (" ADDON_LOADED" );
17741799 BuffaloEventFrame :RegisterEvent (" CHAT_MSG_ADDON" );
1800+ BuffaloEventFrame :RegisterEvent (" UNIT_SPELLCAST_STOP" );
1801+ BuffaloEventFrame :RegisterEvent (" UNIT_SPELLCAST_FAILED" );
1802+ BuffaloEventFrame :RegisterEvent (" UNIT_SPELLCAST_SUCCEEDED" );
17751803
17761804 BuffaloConfigFrame :SetBackdrop (BUFFALO_BACKDROP_FRAME );
17771805 BuffaloGeneralConfigFrame :SetBackdrop (BUFFALO_BACKDROP_FRAME );
0 commit comments