Thread Tools Display Modes
07-17-14, 09:25 PM   #1
morpheusxeno
A Flamescale Wyrmkin
 
morpheusxeno's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 126
Tired of trolls...

I am looking for some help for modifying a small bit of code I found on MMO-Champions

It was originally for announcing who lusted. Well I figure I could also use this to announce who is also being a jack ass and trolling in the raid. I have found the amount of trolling in LFR these days to excessive and annoying.

I have this code so far

-- This file is loaded from "NoTroll.toc"

local spellIds = {
[2825] = "Bloodlust",
[32182] = "Heroism",
[80353] = "Time Warp",
[13159] = "Aspect of Fail",
[41450] = "Blessing of Piss me off",
[73325] = "Leap of Fail",
[34477] = "MD",
[20736] = "Distracting Shot",
[62124] = "Reckoning * paladin",
[56222] = "Dark Command",
[49576] = "Death Grip",
[2649] = "Generic hunter growl",
[39270] = "main target growl",
[103128] = "suffering",
};


local f = CreateFrame("Frame");
f:SetScript("OnEvent", function(self, event, ...) self[event](self, ...); end);
f:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED");


f.COMBAT_LOG_EVENT_UNFILTERED = function(self, _, logEvent, _, _, sourceLogName, _, _, _, _, _, _, spellId, spellName)
if ( logEvent == "SPELL_CAST_SUCCESS" and spellIds[spellId] ~= nil ) then
print(sourceLogName, "used", spellName);
end
end;
I am looking to do a little bit more with it though. I would like it to have toggles with a GUI and simple check boxes that allow it to announce to raid chat or none for each item listed.

I would also like it to announce when the boss is pulled and by who. I know there is an addon called WhoPulled but I wasnt exactly looking to steal work. I would just like it it announce with a yell %t PULLED!!!
__________________
My mother-in-law fell down a wishing well. I was amazed; I never knew they worked...

Last edited by morpheusxeno : 07-18-14 at 08:14 AM.
  Reply With Quote
07-18-14, 03:00 PM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
For simple cast detection like that, I'd recommend using UNIT_SPELLCAST_SUCCEEDED instead of CLEU -- it fires a lot less often. Your event processing is also overkill for an addon handling a single event. Finally, if you're planning to publish this, I'd suggest using localized spell names instead of cutesy euphemisms or abbreviations.

This doesn't incorporate any "who pulled" announcement but it does add toggles for each spell:

Code:
local ADDON,  = ...

local db = {
	[2825]   = true, -- Bloodlust
	[32182]  = true, -- Heroism
	[80353]  = true, -- Time Warp
	[13159]  = true, -- Aspect of Fail
	[41450]  = true, -- Blessing of Piss me off
	[73325]  = true, -- Leap of Fail
	[34477]  = true, -- MD
	[20736]  = true, -- Distracting Shot
	[62124]  = true, -- Reckoning * paladin
	[56222]  = true, -- Dark Command
	[49576]  = true, -- Death Grip
	[2649]   = true, -- Generic hunter growl
	[39270]  = true, -- main target growl
	[103128] = true, -- suffering
}

local f = CreateFrame("Frame", "NoTroll", InterfaceOptionsFramePanelContainer)

-- Main addon logic

f:RegisterEvent("PLAYER_LOGIN")
f:SetScript("OnEvent", function(self, event)
	NoTrollDB = NoTrollDB or db
	db = NoTrollDB
	self:UnregisterEvent("PLAYER_LOGIN")

	self:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED")
	self:SetScript("OnEvent", function(self, event, unit, spellName, _, _, spellID)
		if db[spellID] then
			local name = GetUnitName(unit, false) -- Use true to show the realm name
			print("|cffffff9a[NoTroll]|r", name, "used", spellName)
		end
	end)
end)

-- Options panel

f:Hide()
f:SetScript("OnShow", function(self)
	local title = self:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge")
	title:SetPoint("TOPLEFT", 16, -16)
	title:SetPoint(self.name)

	local notes = Options:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
	notes:SetPoint("TOPLEFT", title, "BOTTOMLEFT", 0, -8)
	notes:SetPoint("RIGHT", -32, 0)
	notes:SetHeight(32)
	notes:SetJustifyH("LEFT")
	notes:SetJustifyV("TOP")
	notes:SetText(GetAddOnMetadata(ADDON, "Notes"))

	local spellNameToID, sortedSpells = {}
	for id in pairs(db) do
		local name = GetSpellInfo(id)
		if name then
			spellNameToID[name] = id
			tinsert(sortedSpells, name)
		end
	end
	sort(sortedSpells)
	
	local boxes = {}
	local breakpoint = 1 + floor(#sortedSpells / 2)
	local function ClickBox(self)
		local checked = not not self:GetChecked()
		PlaySound(checked and "igMainMenuOptionCheckBoxOn" or "igMainmenuOptionCheckBoxOff")
		db[self.id] = checked
	end

	for i = 1, #sortedSpells do
		local spell = sortedSpells[i]
		
		local box = CreateFrame("CheckButton", "$parentCheckbox"..i, self, "InterfaceOptionsCheckButtonTemplate")
		box:SetScript("OnClick", ClickBox)
		box.Text:SetText(spell)
		box:SetHitRectInsets(0, -1 * max(box.Text:GetStringWidth(), 100), 0, 0) -- Make whole label clickable instead only the first 100px
		box.id = spellNameToID[spell]
		
		if i == 1 then
			box:SetPoint("TOPLEFT", notes, "BOTTOMLEFT", 0, -16)
		elseif i == breakpoint then
			box:SetPoint("TOPLEFT", notes, "BOTTOM", 0, -16)
		else
			box:SetPoint("TOPLEFT", boxes[i - 1], "BOTTOMLEFT", 0, -8)
		end
		
		boxes[i] = box
	end
	
	function self:refresh()
		for i = 1, #boxes do
			local box = boxes[i]
			box:SetChecked(db[box.id])
		end
	end
	
	self:SetScript("OnShow", nil)
	self:refresh()
end)

-- Register the options panel:

f.name = GetAddOnMetadata(ADDON, "Title")
InterfaceOptions_AddCategory(f)

-- Create a slash command to open the options panel:

_G["SLASH_"..ADDON.."1"] = "/notroll"
SlashCmdList[ADDON] = function()
	InterfaceOptionsFrame_OpenToCategory(f)
	InterfaceOptionsFrame_OpenToCategory(f)
	-- It's called twice on purpose, to work around the long-standing
	-- Blizzard bug that opens the options window to the wrong panel
	-- under certain conditions.
end
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
07-18-14, 05:02 PM   #3
morpheusxeno
A Flamescale Wyrmkin
 
morpheusxeno's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 126
Thanks Phanx you the man. I remember you helping me before on a few things. I am at work right now so I will be testing this when I get home. Appreciate the work you have done.

I do plan on publicly posting it. You are right I should probably fix the foul lanugage lol! I do want the general population to benifit from the mod and hopefully reduce the raid trolling.
__________________
My mother-in-law fell down a wishing well. I was amazed; I never knew they worked...

Last edited by morpheusxeno : 07-18-14 at 05:08 PM.
  Reply With Quote
07-18-14, 08:29 PM   #4
morpheusxeno
A Flamescale Wyrmkin
 
morpheusxeno's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 126
/notroll isnt working. Something preventing the addon loading properly? I have looked through all the code to see if there was an error of any sort. Couldnt find anything thought I am not that great at LUA...
__________________
My mother-in-law fell down a wishing well. I was amazed; I never knew they worked...

Last edited by morpheusxeno : 07-18-14 at 08:47 PM.
  Reply With Quote
07-18-14, 08:40 PM   #5
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
Originally Posted by morpheusxeno View Post
Thanks Phanx you the man
Fail..


Originally Posted by morpheusxeno View Post
/notroll isnt working. Something preventing the addon loading properly?
Misplaced comma on the first line, turn your error messages on.
  Reply With Quote
07-18-14, 09:25 PM   #6
morpheusxeno
A Flamescale Wyrmkin
 
morpheusxeno's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 126
Wha? Woman?

I removed the comma. Addon now opens the Addon manager UI thinger :P

Doesnt have anything inside it though, The window is empty.
Attached Thumbnails
Click image for larger version

Name:	WoWScrnShot_071814_213020.jpg
Views:	252
Size:	124.0 KB
ID:	8148  
__________________
My mother-in-law fell down a wishing well. I was amazed; I never knew they worked...

Last edited by morpheusxeno : 07-18-14 at 09:36 PM.
  Reply With Quote
07-18-14, 10:03 PM   #7
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Originally Posted by morpheusxeno View Post
Wha? Woman?
Women do exist on the internet.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Search/Requests » Tired of trolls...


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off