@@ -177,12 +177,15 @@ function PVPSound:LoadKills()
177177 if not PVPSoundFrameKills then
178178 PVPSoundFrameKills = CreateFrame (" Frame" , nil )
179179 end
180- -- [SAFE MODE] Polling Only. NO RegisterEvent.
180+
181181 if (PS_KillSound == true or PS_MultiKillSound == true or PS_PaybackSound == true ) and PS_EnableAddon == true then
182+ -- WoW 12.0+: some clients can flag Frame:RegisterEvent() as protected for certain scoreboard events.
183+ -- Polling the scoreboard avoids ADDON_ACTION_FORBIDDEN while keeping killing blow detection working.
182184 PVPSoundFrameKills :SetScript (" OnUpdate" , function (_ , elapsed ) PVPSound :KillsOnUpdate (elapsed ) end )
183185 PVPSound :ResetScoreTracking ()
186+ PVPSound :Debug (" Kills poller loaded" )
184187 else
185- PVPSoundFrameKills : SetScript ( " OnUpdate " , nil )
188+ PVPSound : Debug ( " Kills not enabled " )
186189 end
187190end
188191function PVPSound :UnloadKills ()
@@ -1334,37 +1337,108 @@ function PVPSound:TriggerKill(killType, streakNumber)
13341337 end
13351338end
13361339
1340+ -- [FORCE PATCH: PVP STRICT MODE]
1341+ _G [" PVPSound" ] = PVPSound
13371342
1343+ -- 1. DISABLE STAT TRACKING (Stops PvE/Mob Kill Detection)
1344+ function PVPSound :ResetScoreTracking () end
1345+ function PVPSound :HandleScoreUpdate () end
1346+ function PVPSound :HandlePartyKill () end
13381347
1339- -- [FORCE PATCH: VISUALS & SAFETY]
1340- _G [" PVPSound" ] = PVPSound
1348+ -- 2. SAFE STARTUP (Polling Only - No Crashes)
1349+ function PVPSound :LoadKills ()
1350+ if not PVPSoundFrameKills then
1351+ PVPSoundFrameKills = CreateFrame (" Frame" , nil )
1352+ end
1353+ -- Only use polling for background tasks, NOT for event registration
1354+ if PS_EnableAddon == true then
1355+ PVPSoundFrameKills :SetScript (" OnUpdate" , function (_ , elapsed ) PVPSound :KillsOnUpdate (elapsed ) end )
1356+ else
1357+ PVPSoundFrameKills :SetScript (" OnUpdate" , nil )
1358+ end
1359+ end
1360+
1361+ -- 3. SAFE FACTION CHECK (Fixes Secret Value Crash)
1362+ function PVPSound :GetMyScoreInfo () return nil end
1363+
1364+ -- 4. UNLOCKED COMBAT LOG LOGIC
1365+ -- This replaces the original handler. It REMOVES the code that disabled CLEU in BGs.
1366+ function PVPSound :OnEventKills (event , ...)
1367+ if PS_EnableAddon ~= true then return end
1368+
1369+ -- We strictly ignore Scoreboard/PartyKill events because they are Tainted or Noisy.
1370+ -- We ONLY process the Combat Log.
1371+ if event == " COMBAT_LOG_EVENT_UNFILTERED" then
1372+ local _ , eventType , _ , sourceGUID , sourceName , sourceFlags , _ , destGUID , destName , destFlags , _ , _ , swingOverkill , _ , _ , spellOverkill = CombatLogGetCurrentEventInfo ()
1373+
1374+ -- Filter Setup (Crucial for PvP Only)
1375+ local ToEnemy = false
1376+ local ToEnemyPlayer = CombatLog_Object_IsA (destFlags , COMBATLOG_OBJECT_TYPE_PLAYER )
1377+
1378+ -- Enforce PvP Mode Logic
1379+ if PS_Mode == " PVP" then
1380+ ToEnemy = ToEnemyPlayer -- STRICTLY Players Only
1381+ elseif PS_Mode == " PVE" then
1382+ ToEnemy = CombatLog_Object_IsA (destFlags , COMBATLOG_OBJECT_TYPE_NPC )
1383+ else -- PVPandPVE
1384+ ToEnemy = ToEnemyPlayer or CombatLog_Object_IsA (destFlags , COMBATLOG_OBJECT_TYPE_NPC )
1385+ end
1386+
1387+ local FromMyPets = CombatLog_Object_IsA (sourceFlags , COMBATLOG_OBJECT_TYPE_PET ) or CombatLog_Object_IsA (sourceFlags , COMBATLOG_OBJECT_TYPE_GUARDIAN )
1388+
1389+ -- KILL DETECTION
1390+ -- Check 1: Player Kill (Party Kill event inside CLEU is safe)
1391+ if (eventType == " PARTY_KILL" and sourceGUID == UnitGUID (" player" ) and ToEnemy )
1392+ -- Check 2: Pet Kill
1393+ or ((eventType == " SWING_DAMAGE" or eventType == " RANGE_DAMAGE" or eventType == " SPELL_DAMAGE" ) and FromMyPets and ToEnemy and (tonumber (swingOverkill ) or tonumber (spellOverkill ))) then
1394+
1395+ -- Success! It's a valid PvP Kill.
1396+ if PVPSound :CheckRecentlyKilledQueue (destGUID ) ~= true then
1397+ -- Trigger Sound/Text
1398+ local currentT = GetTime ()
1399+ if not LastKill or (currentT - LastKill > ResetTime ) then
1400+ CurrentStreak = 1
1401+ PVPSound :TriggerKill (" Kill" , CurrentStreak )
1402+ elseif (currentT - LastKill <= PS .KillTime ) then
1403+ CurrentStreak = (CurrentStreak or 1 ) + 1
1404+ PVPSound :TriggerKill (" Kill" , CurrentStreak )
1405+ end
1406+ LastKill = currentT
1407+ PVPSound :AddToRecentlyKilledQueue (destGUID )
1408+ end
1409+ end
1410+ end
1411+ end
13411412
1342- -- 1. FORCE SETTINGS (Visuals)
1413+ -- 5. SAFE LISTENER (The "Ears")
1414+ -- Registers the Combat Log on a clean, local frame to avoid Taint Crashes.
1415+ local SafeListener = CreateFrame (" Frame" )
1416+ SafeListener :RegisterEvent (" PLAYER_ENTERING_WORLD" )
1417+ SafeListener :SetScript (" OnEvent" , function (self , event )
1418+ if event == " PLAYER_ENTERING_WORLD" then
1419+ -- Attempt to register CLEU. If blocked, it fails silently (No Crash).
1420+ pcall (function () self :RegisterEvent (" COMBAT_LOG_EVENT_UNFILTERED" ) end )
1421+ elseif event == " COMBAT_LOG_EVENT_UNFILTERED" then
1422+ if PVPSound then PVPSound :OnEventKills (event ) end
1423+ end
1424+ end )
1425+
1426+ -- 6. VISUALS & COMMANDS
13431427local oldDefaultSettings = PVPSound .DefaultSettings
13441428function PVPSound :DefaultSettings ()
1345- if oldDefaultSettings then oldDefaultSettings (self ) end
1346- PS_Emote = true
1347- PS_EmoteMode = false -- Local Print
1429+ if oldDefaultSettings then oldDefaultSettings (self ) end
1430+ PS_Emote = true
1431+ PS_EmoteMode = false -- Console Mode
13481432end
13491433
1350- -- 2. SMART ANNOUNCE (Faction Fix)
13511434SLASH_PSANNOUNCE1 = " /psannounce"
13521435SlashCmdList [" PSANNOUNCE" ] = function (msg )
1353- local info = PVPSound :GetMyScoreInfo ()
1354- local MyFaction = (info and info .faction ) or (UnitFactionGroup (" player" ) == " Alliance" and 1 or 0 )
1355- if MyFaction == 1 then
1356- print (" |cFF00FF00[PVPSound]|r Faction: Alliance -> Blue Team" )
1357- PVPSound :AddToQueue (PS .SoundPackDirectory .. " \\ Eng\\ GameStatus\\ PlayYouAreOnBlue.mp3" )
1358- else
1359- print (" |cFF00FF00[PVPSound]|r Faction: Horde -> Red Team" )
1360- PVPSound :AddToQueue (PS .SoundPackDirectory .. " \\ Eng\\ GameStatus\\ PlayYouAreOnRed.mp3" )
1361- end
1362- end
1363-
1364- -- 3. CRASH SAFETY (Scoreboard)
1365- function PVPSound :GetMyScoreInfo ()
1366- if C_PvP and C_PvP .GetScoreInfoByPlayerGuid then
1367- return C_PvP .GetScoreInfoByPlayerGuid (UnitGUID (" player" ))
1368- end
1369- return nil
1436+ local fGroup = UnitFactionGroup (" player" )
1437+ if fGroup == " Alliance" then
1438+ print (" |cFF00FF00[PVPSound]|r Faction: Alliance -> Blue Team" )
1439+ PVPSound :AddToQueue (PS .SoundPackDirectory .. " \\ Eng\\ GameStatus\\ PlayYouAreOnBlue.mp3" )
1440+ else
1441+ print (" |cFF00FF00[PVPSound]|r Faction: Horde -> Red Team" )
1442+ PVPSound :AddToQueue (PS .SoundPackDirectory .. " \\ Eng\\ GameStatus\\ PlayYouAreOnRed.mp3" )
1443+ end
13701444end
0 commit comments