Thread Tools Display Modes
10-20-14, 01:05 PM   #1
cokedrivers
A Rage Talon Dragon Guard
 
cokedrivers's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 325
Player Role

Phanx was kind enough to help me with this last time.

Trying to set up a new Statistics Stat for my Datapanel.

So far this is what I have Statisctics.lua

Everything is working good (except that GetVersatility(); is im guessing by the error I get when I use it not in the game yet) but my reason for this thread is I have a playerRoll checker I need some assistance with.

Code:
function nData:UpdatePlayerRole()
	if UnitLevel("player") >= 10 then
		local spec = GetSpecialization()
		local specRole = GetSpecializationRole(spec) -- no need for a giant table that must be maintained by hand
		if specRole == "TANK" then
			playerRole = "Tank"
		elseif specRole == "HEALER" then
			playerRole = "Caster"
		elseif specRole == "DAMAGER" then
			if UnitPowerType("player") == SPELL_POWER_MANA then
				playerRole = "Caster"
			else
				playerRole = "Melee"
			end
		elseif specRole == nil then
			playerRole = nil -- no spec
		end
	else
		return
	end
end
The problem is with DAMAGER the above code marks anyone that is a DAMAGER with mana as a Caster, But Paladins and Shamans have Melee DAMAGER with mana. So everytime I switch to the Melee Mana user it pops up my Spell Stat instead of Melee Stat.

Does this mean im going to add yet another separator and go into specs and not just Rolls?

Thanks for any help in advance.

Coke

PS: I Attached a picture of the tooltip for Statistics.
Attached Thumbnails
Click image for larger version

Name:	Statistics.jpg
Views:	186
Size:	30.7 KB
ID:	8257  

Last edited by cokedrivers : 10-20-14 at 01:12 PM.
  Reply With Quote
10-20-14, 03:05 PM   #2
Mazzop
A Cliff Giant
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 74
try that check, it compare base strength and base attack power

Code:
if UnitStat("unit", 1) == UnitAttackPower("unit") then 
--unit is melee stuff
end
checked on paladin, not sure if that will work same on enhance shamman

Last edited by Mazzop : 10-20-14 at 03:07 PM.
  Reply With Quote
10-20-14, 03:11 PM   #3
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by cokedrivers View Post
Does this mean im going to add yet another separator and go into specs and not just Rolls?
If Mazzop's method doesn't work, just use a table to identify the "weird" specs, like so:

Code:
local meleeMana = {
    PALADIN = 3, -- Retribution
    SHAMAN = 2, -- Enhancement
}
Then:

Code:
		local _, class = UnitClass("player")
		local spec = GetSpecialization()
		local specRole = GetSpecializationRole(spec)
and:

Code:
		elseif specRole == "DAMAGER" then
			if UnitPowerType("player") == SPELL_POWER_MANA and not meleeMana[class] = spec then
				playerRole = "Caster"
			else
				playerRole = "Melee"
			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
10-20-14, 03:50 PM   #4
cokedrivers
A Rage Talon Dragon Guard
 
cokedrivers's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 325
Originally Posted by Mazzop View Post
try that check, it compare base strength and base attack power

Code:
if UnitStat("unit", 1) == UnitAttackPower("unit") then 
--unit is melee stuff
end
checked on paladin, not sure if that will work same on enhance shamman
Ty, yes it worked for the Pally but I had to add a lookup for the shaman for Agi.
Code:
function nData:UpdatePlayerRole()
	
	if UnitLevel("player") >= 10 then
		local spec = GetSpecialization()
		local specRole = GetSpecializationRole(spec) -- no need for a giant table that must be maintained by hand		
		if specRole == "TANK" then
			playerRole = "Tank"
		elseif specRole == "HEALER" then
			playerRole = "Caster"
		elseif specRole == "DAMAGER" then
			if UnitPowerType("player") == SPELL_POWER_MANA then
				if UnitStat("player", 1) == UnitAttackPower("player") or UnitStat("player", 2) == UnitAttackPower("player") then 
					playerRole = "Melee"
				else
					playerRole = "Caster"
				end
			else
				playerRole = "Melee"
			end
		elseif specRole == nil then
			playerRole = nil -- no spec
		end
	else
		return
	end
end
Phanx I tried your table option but the
Code:
meleeMana[class] = spec
kept giving me and error saying that it needed a ")" by the =.

But thank you both for your time and ideas.

Coke

P.S. - Would be awesome if you could be able to look up the Primary Stat after the "TANK", "DAMAGER", or "HEALER" like it shows on the Specialization screen.

Last edited by cokedrivers : 10-20-14 at 03:53 PM.
  Reply With Quote
10-20-14, 03:58 PM   #5
cokedrivers
A Rage Talon Dragon Guard
 
cokedrivers's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 325
Nevermind, It does show the "Melee" stat now but it shows it all the time... grr back to the drawing board
  Reply With Quote
10-20-14, 04:08 PM   #6
cokedrivers
A Rage Talon Dragon Guard
 
cokedrivers's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 325
Combined both methods to get the required result.

Code:
function nData:UpdatePlayerRole()
	
	if UnitLevel("player") >= 10 then
		local _, class = UnitClass("player")
		local spec = GetSpecialization()
		local specRole = GetSpecializationRole(spec) -- no need for a giant table that must be maintained by hand		
		if specRole == "TANK" then
			playerRole = "Tank"
		elseif specRole == "HEALER" then
			playerRole = "Caster"
		elseif specRole == "DAMAGER" then
			if UnitPowerType("player") == SPELL_POWER_MANA then
				if (class == "PALADIN" and spec == 3) or (class == "SHAMAN" and spec == 2) then 
					playerRole = "Melee"
				else
					playerRole = "Caster"
				end
			else
				playerRole = "Melee"
			end
		elseif specRole == nil then
			playerRole = nil -- no spec
		end
	else
		return
	end
end
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Player Role


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