Zadrot KillSound

09.07.2020 - Zadrot

Zadrot KillSound

Очередной аддон для World of Warcraft

Zadrot KillSound - Проигрывает звуки (и соотвтествующие эмоции) из Unreal Tournament при убийстве игроков.

Весит 5 килобайт + 500 килобайт звуки (17 штук).

Убирает кнопку выхода из окна телепорта на БГшку (чтобы случайно не нажать), а так же добавляет оставшееся время на кнопку входа

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
local playerName = UnitName("player")
local playerGUID = UnitGUID("player")
local DeathsTable = {}
local KillsTable = {}

local ToEnemy
local FromEnemy
local FromMyPets

local LastKill = nil
local Kills = 0
local Streak = 0

local PlayedIndex = 0
local ButtonText = PVPReadyDialogEnterBattleButton:GetText() .. " "

local function Play(file)
	PlaySoundFile(file, "Master")
	PlaySoundFile(file, "SFX")
end

local function Emote(str)
	SendChatMessage(str, "EMOTE")
end

PVPReadyDialogLeaveQueueButton:Hide()
PVPReadyDialogLeaveQueueButton.Show = function() end
PVPReadyDialog:HookScript("OnUpdate", function(self)
	if self.activeIndex then
		PVPReadyDialogEnterBattleButton:SetText(ButtonText .. GetBattlefieldPortExpiration(self.activeIndex))
	end
end)

hooksecurefunc("PVPReadyDialog_Update", function(self, index)
	local status = GetBattlefieldStatus(index);
	if PlayedIndex == 0 and status == "confirm" then
		PlayedIndex = index
		Play("Interface/AddOns/Zadrot KillSound/Timer/Play.ogg")
	elseif PlayedIndex == index and (status == "queued" or status == "active" or status == "none") then
		PlayedIndex = 0
	end
end)

local function OnEvent(self, event)
	if event == "COMBAT_LOG_EVENT_UNFILTERED" then
		local timestamp, type, _,  sourceGUID, sourceName, sourceFlags, _, destGUID, destName, destFlags, _, _, swingOverkill, _, _, spellOverkill = CombatLogGetCurrentEventInfo()

		local FILTER_MY_PETS = bit.bor(COMBATLOG_OBJECT_AFFILIATION_MINE, COMBATLOG_OBJECT_REACTION_FRIENDLY, COMBATLOG_OBJECT_CONTROL_PLAYER, COMBATLOG_OBJECT_TYPE_OBJECT, COMBATLOG_OBJECT_TYPE_GUARDIAN, COMBATLOG_OBJECT_TYPE_PET)
		local FILTER_ENEMY_PLAYERS = bit.bor(COMBATLOG_OBJECT_AFFILIATION_MASK, COMBATLOG_OBJECT_REACTION_MASK, COMBATLOG_OBJECT_CONTROL_PLAYER, COMBATLOG_OBJECT_TYPE_PLAYER) --COMBATLOG_OBJECT_CONTROL_NPC, COMBATLOG_OBJECT_TYPE_NPC

		if destName and not CombatLog_Object_IsA(destFlags, COMBATLOG_OBJECT_NONE) then
			ToEnemy = CombatLog_Object_IsA(destFlags, FILTER_ENEMY_PLAYERS)
		end

		if sourceName and not CombatLog_Object_IsA(sourceFlags, COMBATLOG_OBJECT_NONE) then
			FromMyPets = CombatLog_Object_IsA(sourceFlags, FILTER_MY_PETS)
			FromEnemy = CombatLog_Object_IsA(sourceFlags, FILTER_ENEMY_PLAYERS)
		end

		if (type == "PARTY_KILL" and sourceGUID == playerGUID and ToEnemy)
		or (type == "SWING_DAMAGE" and destGUID ~= playerGUID and FromMyPets and ToEnemy and swingOverkill >= 0)
		or ((type == "RANGE_DAMAGE" or type == "SPELL_DAMAGE" or type == "SPELL_PERIODIC_DAMAGE") and destGUID ~= playerGUID and FromMyPets and ToEnemy and spellOverkill >= 0) then

			if LastKill and (timestamp - LastKill < 17) then
				Streak = Streak + 1
			else
				Streak = 1
				Kills = Kills + 1
			end

			if Streak == 2 then
				Play("Interface/AddOns/Zadrot KillSound/Multikill/DoubleKill.ogg")
				Emote("Double Kill")
			elseif Streak == 3 then
				Play("Interface/AddOns/Zadrot KillSound/Multikill/MultiKill.ogg")
				Emote("Multi Kill")
			elseif Streak == 4 then
				Play("Interface/AddOns/Zadrot KillSound/Multikill/MegaKill.ogg")
				Emote("Mega Kill")
			elseif Streak == 5 then
				Play("Interface/AddOns/Zadrot KillSound/Multikill/UltraKill.ogg")
				Emote("Ultra Kill")
			elseif Streak == 6 then
				Play("Interface/AddOns/Zadrot KillSound/Multikill/MonsterKill.ogg")
				Emote("Monster Kill")
			elseif Streak == 7 then
				Play("Interface/AddOns/Zadrot KillSound/Multikill/LudicrousKill.ogg")
				Emote("Ludicrous Kill")
			elseif Streak >= 8 then
				Play("Interface/AddOns/Zadrot KillSound/Multikill/HolyShit.ogg")
				Emote("Holy Shit")

			elseif Streak <= 1 then
				KillsTable[destName] = timestamp
				if (DeathsTable[destName] and (timestamp - DeathsTable[destName]) < 90) then
					DeathsTable[destName] = nil
					Play("Interface/AddOns/Zadrot KillSound/Revenge/Retribution.ogg")
					Emote("Retribution")
				elseif Kills == 1 then
					Play("Interface/AddOns/Zadrot KillSound/Kill/FirstBlood.ogg")
					Emote("First Blood")
				elseif Kills == 2 then
					Play("Interface/AddOns/Zadrot KillSound/Kill/KillingSpree.ogg")
					Emote("Killing Spree")
				elseif Kills == 3 then
					Play("Interface/AddOns/Zadrot KillSound/Kill/Rampage.ogg")
					Emote("Rampage")
				elseif Kills == 4 then
					Play("Interface/AddOns/Zadrot KillSound/Kill/Dominating.ogg")
					Emote("Dominating")
				elseif Kills == 5 then
					Play("Interface/AddOns/Zadrot KillSound/Kill/Unstoppable.ogg")
					Emote("Unstoppable")
				elseif Kills == 6 then
					Play("Interface/AddOns/Zadrot KillSound/Kill/GodLike.ogg")
					Emote("GodLike")
				elseif Kills >= 7 then
					Play("Interface/AddOns/Zadrot KillSound/Kill/WhickedSick.ogg")
					Emote("Whicked Sick")
				end
			end

			LastKill = timestamp

		elseif (type == "SWING_DAMAGE" and FromEnemy and destGUID == playerGUID and swingOverkill >= 0)
		or ((type == "RANGE_DAMAGE" or type == "SPELL_DAMAGE" or type == "SPELL_PERIODIC_DAMAGE") and FromEnemy and destGUID == playerGUID and spellOverkill>= 0) then
			if sourceName ~= nil and sourceName ~= playerName then
				DeathsTable[sourceName] = timestamp
				if KillsTable[sourceName] and (timestamp - KillsTable[sourceName]) < 90 then
					KillsTable[sourceName] = nil
					Play("Interface/AddOns/Zadrot KillSound/Revenge/Denied.ogg")
					Emote("Denied")
				end
			end
		end

	elseif event == "ZONE_CHANGED_NEW_AREA" or event == "PLAYER_DEAD" then
		LastKill = nil
		Kills = 0
		Streak = 0
	end
end

local f = CreateFrame("Frame")
f:SetScript("OnEvent", OnEvent)
f:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
f:RegisterEvent("ZONE_CHANGED_NEW_AREA")
f:RegisterEvent("PLAYER_DEAD")