Go to Page... |
Thread Tools | Display Modes |
02-27-21, 06:31 PM | #1 |
Arena ClassSpec-Icons appear/mirror friendly/neutral nameplates
Hello,
I use alot of scripts for pvp and one of the codes is giving me trouble since Shadowlands. Code:
local U = UnitIsUnit; local GetNamePlate = C_NamePlate.GetNamePlateForUnit; local frame = CreateFrame("frame"); local data = {}; function NamePlate_Added(...) local nameplateId = ...; local nameplate = GetNamePlate(nameplateId).UnitFrame; for i=1,5 do if UnitIsUnit(nameplateId, "arena"..i) then addIcon(data[i], nameplate); end end end function NamePlate_Removed(...) local nameplateId = ...; local nameplate = GetNamePlate(nameplateId).UnitFrame; if (nameplate.iconClass) then nameplate.iconClass:Hide(); end end function SetupIcons() for i = 1, GetNumArenaOpponentSpecs() do local specID = GetArenaOpponentSpec(i) if specID > 0 then local id, name, description, icon, role, class = GetSpecializationInfoByID(specID); data[i] = icon; end end end function addIcon (icon, frame) local button = CreateFrame("Button", "ClassIcon", frame); local txt = button:CreateTexture(); txt:SetTexture(icon); txt:SetAllPoints(); button:SetNormalTexture(txt); button:SetWidth(20); button:SetHeight(20); button:SetPoint("RIGHT", 10, -5); frame.iconClass = button; end frame:RegisterEvent('NAME_PLATE_UNIT_ADDED'); frame:RegisterEvent('NAME_PLATE_UNIT_REMOVED'); frame:RegisterEvent('ARENA_PREP_OPPONENT_SPECIALIZATIONS'); frame:SetScript('OnEvent', function (self, event, ...) if (event == "ARENA_PREP_OPPONENT_SPECIALIZATIONS") then SetupIcons(); elseif (event == 'NAME_PLATE_UNIT_ADDED') then NamePlate_Added(...) elseif (event == 'NAME_PLATE_UNIT_REMOVED') then NamePlate_Removed(...); end end) Also I get lua.errors which I couldnt fix myself but I dont think it is related to this problem itself: Code:
Message: Interface\AddOns\RulezPvPScripts\core.lua:21: attempt to index local 'nameplate' (a nil value) Time: Sun Feb 28 00:59:43 2021 Count: 2 Stack: Interface\AddOns\RulezPvPScripts\core.lua:21: attempt to index local 'nameplate' (a nil value) [string "@Interface\AddOns\RulezPvPScripts\core.lua"]:21: in function `NamePlate_Removed' [string "@Interface\AddOns\RulezPvPScripts\core.lua"]:60: in function <Interface\AddOns\RulezPvPScripts\core.lua:54> Locals: nameplateId = "nameplate1" nameplate = nil (*temporary) = "nameplate1" (*temporary) = NamePlate1 { OnSizeChanged = <function> defined @Interface\AddOns\Blizzard_NamePlates\Blizzard_NamePlates.lua:485 GetPreferredInsets = <function> defined @Interface\AddOns\Blizzard_NamePlates\Blizzard_NamePlates.lua:466 GetAdditionalInsetPadding = <function> defined @Interface\AddOns\Blizzard_NamePlates\Blizzard_NamePlates.lua:455 NCIconsCount = 0 ApplyOffsets = <function> defined =[C]:-1 NCIcons = <table> { } OnRemoved = <function> defined @Interface\AddOns\Blizzard_NamePlates\Blizzard_NamePlates.lua:424 OnAdded = <function> defined @Interface\AddOns\Blizzard_NamePlates\Blizzard_NamePlates.lua:413 template = "NamePlateUnitFrameTemplate" 0 = <userdata> OnOptionsUpdated = <function> defined @Interface\AddOns\Blizzard_NamePlates\Blizzard_NamePlates.lua:431 } (*temporary) = "attempt to index local 'nameplate' (a nil value)" GetNamePlate = <function> defined =[C]:-1 It is not my own code so it would be really kind if someone is able to fix it up. For friendly nameplates I use a different code because I need different positioning and Iconsize (smaller nameplates): Code:
local frame = CreateFrame("Frame") frame:SetScript("OnEvent", function(self, event, unit) local namePlate = GetNamePlateForUnit(unit) if event == "NAME_PLATE_UNIT_ADDED" and UnitIsFriend("player", unit) then local _, class = UnitClass(unit) if iconTexture[class] then local icon = namePlate[iconKey] if not icon then icon = namePlate:CreateTexture(nil, "OVERLAY") icon:SetPoint('CENTER', 0, 29.46) icon:SetSize(24, 24) namePlate[iconKey] = icon end icon:SetTexture(iconTexture[class]) icon:Show() return end end if namePlate[iconKey] then namePlate[iconKey]:Hide() end end) frame:RegisterEvent("NAME_PLATE_UNIT_ADDED") frame:RegisterEvent("NAME_PLATE_UNIT_REMOVED") local f = CreateFrame("Frame") f:RegisterEvent("PLAYER_LOGIN") f:RegisterEvent("PLAYER_ENTERING_WORLD") f:SetScript("OnEvent", function() nameplateSize() end) function nameplateSize() and to rewrite the second code with friendly_units but to show spec-icons instead of class-icons (see example) in arenas? Basically friendly and enemy nameplate class-icons outside of arena/pvp (or when :GetSpec isnt working) and turn to friendly/enemy specialization-icons inside arena/pvp (if possible). I know its a mess and alot of work but I usually just put all the stuff mixed together in one addon and I dont have alot of expierence with lua. It would be really helpful and maybe its possible to create a small addon with both functions/codes (friendly, enemy) with the possibility to seperate edit friendly icons from enemy icons in sizes/positioning (no ingame config just simple lua-code). I would also like to share the result to the community if someone get this to work. Thank you for reading. Attachments: Issues (wrong/discplacement_example), Friendly_Nameplates (default_ like usually), Enemy_Nameplates (default_ like usually) The icon on the top of the first image is from BigDebuffs which is bugged too but addon related (already reportet). Last edited by rulezyx : 03-01-21 at 06:49 AM. |
|
03-01-21, 07:27 AM | #2 |
I don't pvp so I didn't get to test the enemy nameplate part but here is a start:
Lua Code:
|
|
03-01-21, 01:03 PM | #3 |
Seems to work perfectly without any issues.
Thank you so much! |
|
03-01-21, 07:28 PM | #4 |
So it works fine for friendly nameplates but I noticed that enemy spec-icons doesn't show/switch up in arenas.
I can only see the class-icons for enemy players. Is there a way to fix that? Friendly is fine even in Openworld when warmode is on. I mean with the first code the spec-icons worked fine except the errors and buggs but I dont understand the issue since you put up both friendly and enemy triggers the same way. Gladius and GladiusEx (Addons) have a similar way to detect that. Does that do anything: local isInArena = false Last edited by rulezyx : 03-01-21 at 07:40 PM. |
|
03-01-21, 07:31 PM | #5 |
Spec info for enemy players is not available. All you get is their class, what they look like, and the spells they cast.
__________________
|
|
03-01-21, 07:49 PM | #6 |
I am sure it is available at least in closed pvp: arenas and battlegrounds.
You can also get Talents/CD's of Opponents, here some examples from my UI: https://imgur.com/a/EQDNHZZ (GladiusEx and before the game started) https://imgur.com/a/fOeEjvf (old Code in Arenafight) Last edited by rulezyx : 03-01-21 at 07:55 PM. |
|
03-02-21, 12:15 AM | #7 |
Like I said I don't do arenas so I couldn't test that part. I can change it to do the arena opponent specs the original way when I get some time but it may be a few days.
|
|
03-02-21, 05:11 AM | #8 |
Ty, you already helped alot
I was just confused because it worked for friendly units but I noticed for enemys it is a bit more tricky. Blizzard gives opportunities to detect specialization in closed PvP areas (skrims, rated arena, normal-, epic-bgs, rated bgs). Something like this worked well with friendly units and some Tooltip Addons use this and Inspect for friendly player specs too: Code:
local specID = GetInspectSpecialization(unit) if specID then local _, _, _, icon = GetSpecializationInfoByID(specID) texture = icon Code:
for i=1,5 do if UnitIsUnit(nameplateId, "arena"..i) then addIcon(data[i], nameplate); end end end ----------------------------------------------------------------------------------- function SetupIcons() for i = 1, GetNumArenaOpponentSpecs() do local specID = GetArenaOpponentSpec(i) if specID > 0 then local id, name, description, icon, role, class = GetSpecializationInfoByID(specID); data[i] = icon; end end end Last edited by rulezyx : 03-02-21 at 05:23 AM. |
|
03-05-21, 01:19 PM | #9 |
Most of the extra code is for showing friendly specs and the arena code has still not been tested:
Lua Code:
|
|
03-05-21, 02:53 PM | #10 |
Ok I tested it openworld and in arenas (friendly&enemy).
Friendly nameplates show random race-like icons/frame(?) before spec shows up: https://imgur.com/a/GKtbccl Enemy nameplates too but no spec-icon will show up/appear and it looks like this: https://imgur.com/a/8MvPpSG Basically friendly icons will work openworld and in preparation-room(pvp) aside from the race-frame/thing but when the pvp game starts they end up looking like this too: https://imgur.com/a/sCliDLA Also when I inspect players their whole profile/gear-slots appear empty. No errors/other issues. Hope that helps a bit. Last edited by rulezyx : 03-11-21 at 10:51 AM. |
|
03-29-21, 04:12 AM | #11 |
At the moment I use the first code (Vrul/#2) which works fine.
It shows friendly spec-icons and enemie class-icons in closed pvp. Maybe theres a solution for the enemy-specs in the future but the only Addon I found is Plater Nameplates. And since Plater is somehow in correlation with Details it is probably much easier to have these functions working but apart from this I prefer default nameplates. Last edited by rulezyx : 03-29-21 at 04:17 AM. |
|
WoWInterface » Developer Discussions » Lua/XML Help » Arena ClassSpec-Icons appear/mirror friendly/neutral nameplates |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|