digitorum.ru

Как меня найти

Профиль

icq: 4415944

Простой аддон для World of Warcraft: нотификация о [де]бафах

Games, World of Warcraft, lua

В те недавние времена, когда я еще пропадал в рейдах, во время очередного вайпа нервы не выдержали, и на коленке был написан плагин (именно на коленке, оно даже отдаленно не претендует на красоту кода ).

Делает он очень простую вещь - оповещает членов рейда о том, что хантер опять вляпался в дебаф...

Состоит из 2х файлов, которые нужно положить в папку "World of Warcraft\Interface\AddOns\di" (где di - название аддона).

файл di.toc :

## Interface: 40300 
## Title: di
## Version: 1.0.0
## Notes: Dddon for listen [de]buffs
## Author: digitorum
di.lua

 

файл di.lua :

-- table with current buffs
di_BuffsList = {};

-- table with current debuffs
di_DebuffsList = {};

-- get buffs list
function di_getPlayerBuffs()
	local buffs, i = { }, 1;
	local buff = UnitBuff("player", i);
	while buff do
		buffs[#buffs + 1] = buff;
		i = i + 1;
		buff = UnitBuff("player", i);
	end;
	return buffs
end

-- get debuffs list
function di_getPlayerDebuffs()
	local debuffs, i = { }, 1;
	local debuff = UnitDebuff("player", i);
	while debuff do
		debuffs[#debuffs + 1] = debuff;
		i = i + 1;
		debuff = UnitDebuff("player", i);
	end;
	return debuffs
end

-- is buff in buff list
function di_isInList(buff, list)
	for i = 1, table.getn(list), 1 do
		if list[i] == buff then
			return true
		end
	end
	return false
end

-- nitificate raid members
function di_say(text)
	SendChatMessage(text, "SAY", nil, nil);
end

-- event handler
local function di_eventHandler(self, event, ...)
	-- get bufs
	--local list = di_getPlayerBuffs();
	-- check expired buff
	--for j = 1, table.getn(di_BuffsList), 1 do
	--	if di_isInList(di_BuffsList[j], list) == false then
	--		di_say("На мне больше нет бафа: " .. di_BuffsList[j]);
	--	end
	--end
	-- check new buff
	--for j = 1, table.getn(list), 1 do
	--	if di_isInList(list[j], di_BuffsList) == false then
	--		di_say("На мне новый баф: " .. list[j]);
	--	end
	--end
	--di_BuffsList = list;
	-- get debuffs
	list = di_getPlayerDebuffs();
	-- check expired debuff
	for j = 1, table.getn(di_DebuffsList), 1 do
		if di_isInList(di_DebuffsList[j], list) == false then
			di_say("На мне больше нет дебафа: " .. di_DebuffsList[j]);
		end
	end
	-- check new debuff
	for j = 1, table.getn(list), 1 do
		if di_isInList(list[j], di_DebuffsList) == false then
			di_say("На мне новый дебаф: " .. list[j]);
		end
	end
	di_DebuffsList = list;
end

-- default frame
local di_frame = CreateFrame("FRAME", "diAddonFrame");

-- register all events
di_frame:RegisterAllEvents();

-- listen all events
di_frame:SetScript("OnEvent", di_eventHandler);

 

Собственно и все. После его подключения в основной игровой чат будет поступать огромное количество флуда на тему новых дебафоф.