WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   (HELP) Dispellable Debuffs Highlighted for non-purge Classes (https://www.wowinterface.com/forums/showthread.php?t=59425)

prev 12-29-22 09:55 AM

(HELP) Dispellable Debuffs Highlighted for non-purge Classes
 
1 Attachment(s)
So prior to Dragonflight I used a script to create the "stealable" glow around dispellable buffs on enemies for classes that don't possess an offensive dispel. With the overhaul of the UI in Dragonflight it no longer works. I attached an image that shows what I mean.



Code that worked before Dragonflight:
Code:

hooksecurefunc('TargetFrame_UpdateAuras', function(self)
        local FrameStealable
        local frameName
        local icon
        local debuffType
        local selfName = self:GetName()
        local isEnemy = UnitIsEnemy(PlayerFrame.unit, self.unit)
        for i = 1, MAX_TARGET_BUFFS do
                _, icon, _, debuffType = UnitBuff(self.unit, i)
                frameName = selfName..'Buff'..i
                if ( icon and ( not self.maxBuffs or i <= self.maxBuffs ) ) then
                        frameStealable = _G[frameName..'Stealable']
                        if ( isEnemy and debuffType == 'Magic' ) then
                                frameStealable:Show()
                        else
                                frameStealable:Hide()
                        end
                end
        end
end)

I don't know alot about LUA but any help is appreciated. Thank you!

watchout 12-31-22 05:58 AM

What does "no longer work" entail?

Anyway, I'd suggest to verify field and frame names, a lot of names changed with the update

P.S: you have a typo in
Lua Code:
  1. local FrameStealable

though that should not affect functionality, only bleed a global variable or two ("_" is a variable name as well, you'll also want to make that local)

SDPhantom 01-01-23 06:21 AM

A lot has changed with how the TargetFrame shows auras.

Lua Code:
  1. local function TargetFrame_UpdateAuras(self)
  2.     if UnitIsEnemy("player",self.unit) then
  3.         for buff in self.auraPools:GetPool("TargetBuffFrameTemplate"):EnumerateActive() do
  4.             local data=C_UnitAuras.GetAuraDataByAuraInstanceID(buff.unit,buff.auraInstanceID);
  5.             buff.Stealable:SetShown(data.isStealable or data.dispelName=="Magic");
  6.         end
  7.     end
  8. end
  9.  
  10. hooksecurefunc(TargetFrame,"UpdateAuras",TargetFrame_UpdateAuras);
  11. hooksecurefunc(FocusFrame,"UpdateAuras",TargetFrame_UpdateAuras);

First to note, most of TargetFrame's functions were moved to a mixin. This is basically a table that is copied when inherited. The buff/debuff frames are now allocated by frame pools that provide a different way to iterate over them. Lastly, using .auraInstanceID, we can use the new C_UnitAuras.GetAuraDataByAuraInstanceID() to query the buff each individual button is assigned to.

Vremon 01-09-23 02:17 PM

Quote:

Originally Posted by SDPhantom (Post 341868)
A lot has changed with how the TargetFrame shows auras.

Lua Code:
  1. local function TargetFrame_UpdateAuras(self)
  2.     if UnitIsEnemy("player",self.unit) then
  3.         for buff in self.auraPools:GetPool("TargetBuffFrameTemplate"):EnumerateActive() do
  4.             local data=C_UnitAuras.GetAuraDataByAuraInstanceID(buff.unit,buff.auraInstanceID);
  5.             buff.Stealable:SetShown(data.isStealable or data.dispelName=="Magic");
  6.         end
  7.     end
  8. end
  9.  
  10. hooksecurefunc("TargetFrame",UpdateAuras,TargetFrame_UpdateAuras);
  11. hooksecurefunc("FocusFrame",UpdateAuras,TargetFrame_UpdateAuras);

First to note, most of TargetFrame's functions were moved to a mixin. This is basically a table that is copied when inherited. The buff/debuff frames are now allocated by frame pools that provide a different way to iterate over them. Lastly, using .auraInstanceID, we can use the new C_UnitAuras.GetAuraDataByAuraInstanceID() to query the buff each individual button is assigned to.

i recive this error on this script Usage: hooksecurefunc([table,] "function", hookfunc)

Fizzlemizz 01-09-23 02:33 PM

Lua Code:
  1. hooksecurefunc(TargetFrame, "UpdateAuras", TargetFrame_UpdateAuras);
  2. hooksecurefunc(FocusFrame, "UpdateAuras" , TargetFrame_UpdateAuras);

SDPhantom 01-09-23 09:42 PM

Don't know how that mistake happened, but I corrected in the original post too.

Vremon 01-09-23 10:18 PM

Quote:

Originally Posted by SDPhantom (Post 341939)
Don't know how that mistake happened, but I corrected in the original post too.

thanks you sir

Vremon 01-09-23 10:19 PM

Quote:

Originally Posted by Fizzlemizz (Post 341938)
Lua Code:
  1. hooksecurefunc(TargetFrame, "UpdateAuras", TargetFrame_UpdateAuras);
  2. hooksecurefunc(FocusFrame, "UpdateAuras" , TargetFrame_UpdateAuras);

thanks you sir

Vremon 01-10-23 02:22 AM

question can thus script be modified instead of enlight magic spells to enlight helpful or harmfull buffs or only one that have above 1min cooldown or buffs that have duration above 10seconds is that possible?

SDPhantom 01-14-23 06:37 AM

There's no way to query cooldown info on just any arbitrary ability. That and not all buffs share the same SpellID as the ability that applies it.

Also, the buff update doesn't continuously happen, so duration tracking will have to be written from scratch. Buff updates only fire when the list changes, usually by a buff (re)applying, gaining or losing stacks, dispelled, or expiration.

Vremon 01-14-23 09:37 AM

Quote:

Originally Posted by SDPhantom (Post 341969)
There's no way to query cooldown info on just any arbitrary ability. That and not all buffs share the same SpellID as the ability that applies it.

Also, the buff update doesn't continuously happen, so duration tracking will have to be written from scratch. Buff updates only fire when the list changes, usually by a buff (re)applying, gaining or losing stacks, dispelled, or expiration.

actualy u can do like this and its really working

buff.Stealable:SetShown(data.duration >= 10 and (data.expirationTime - GetTime()) < 20 );

only buff that have duration above10 and under 20 and its working

SDPhantom 01-15-23 08:30 AM

Quote:

Originally Posted by Vremon (Post 341972)
buff.Stealable:SetShown(data.duration >= 10 and (data.expirationTime - GetTime()) < 20 );

For example, target something that has 20+ seconds remaining on the buff. It may or may not update the highlight immediately when the duration falls below 20 seconds. This isn't "working" when it only updates sometimes.

You're going to need either an OnUpdate script or a C_Timer loop periodically calling the code to get reliable updates when filtering by remaining time.

Lesteryoung 01-18-23 02:31 AM

I've been looking for almost exactly what OP describes since 10.0. My old code showed on all targets though.

Phantom, would it be possible to edit your code above to show the stealable glow on all targets, not just enemies. IE, friendly/enemy/self/npc/everything.

If possible, thanks.

Vremon 01-18-23 03:49 AM

Quote:

Originally Posted by Lesteryoung (Post 341994)
I've been looking for almost exactly what OP describes since 10.0. My old code showed on all targets though.

Phantom, would it be possible to edit your code above to show the stealable glow on all targets, not just enemies. IE, friendly/enemy/self/npc/everything.

If possible, thanks.

u replace this line if UnitIsEnemy("player",self.unit) then
with if UnitIsUnit(self.unit) then

Lesteryoung 01-18-23 05:10 AM

Quote:

Originally Posted by Vremon (Post 341995)
u replace this line if UnitIsEnemy("player",self.unit) then
with if UnitIsUnit(self.unit) then

That didn't work, sorry. Just throwing errors.

SDPhantom 01-18-23 06:13 AM

What are the errors you're getting?

Lesteryoung 01-18-23 07:30 AM

Usage: UnitIsUnit("unit", "otherUnit")
[string "=[C]"]: in function `UnitIsUnit'
[string "@Interface/AddOns/Tweaks/Glow.lua"]:2: in function <Interface/AddOns/Tweaks/Glow.lua:1>
[string "=[C]"]: in function `UpdateAuras'
[string "@Interface/FrameXML/EditModeSystemTemplates.lua"]:989: in function `UpdateSystemSettingBuffsOnTop'
[string "@Interface/FrameXML/EditModeSystemTemplates.lua"]:1141: in function `UpdateSystemSetting'
[string "@Interface/FrameXML/EditModeSystemTemplates.lua"]:219: in function `UpdateSystem'
[string "@Interface/FrameXML/EditModeManager.lua"]:1031: in function `UpdateSystem'
[string "@Interface/FrameXML/EditModeManager.lua"]:1023: in function <Interface/FrameXML/EditModeManager.lua:1022>
[string "=[C]"]: in function `secureexecuterange'
[string "@Interface/FrameXML/EditModeManager.lua"]:1025: in function `UpdateSystems'
[string "@Interface/FrameXML/EditModeManager.lua"]:895: in function `UpdateLayoutInfo'
[string "@Interface/FrameXML/EditModeManager.lua"]:238: in function <Interface/FrameXML/EditModeManager.lua:235>

Locals:
(*temporary) = "target"


Looks like it's Edit Mode related.

SDPhantom 01-19-23 01:49 AM

UnitIsUnit() is expecting two units to compare equality. This is commonly used to check if a firing UNIT_* event is for a script's unitframe. We're already grabbing our unit from the buff frame, there's nothing to compare with here.

If you want to check if a unit exists, you need to use UnitExists(). Considering the hooked function doesn't even fire when the unit doesn't exist, this is also pointless.

This is the updated script without any filtering.

Lua Code:
  1. local function TargetFrame_UpdateAuras(self)
  2.     for buff in self.auraPools:GetPool("TargetBuffFrameTemplate"):EnumerateActive() do
  3.         local data=C_UnitAuras.GetAuraDataByAuraInstanceID(buff.unit,buff.auraInstanceID);
  4.         buff.Stealable:SetShown(data.isStealable or data.dispelName=="Magic");
  5.     end
  6. end
  7.  
  8. hooksecurefunc(TargetFrame,"UpdateAuras",TargetFrame_UpdateAuras);
  9. hooksecurefunc(FocusFrame,"UpdateAuras",TargetFrame_UpdateAuras);

Lesteryoung 01-19-23 04:29 AM

Tyvm for your help, but unfortunately it is still not working.

Now giving this error. I put it into it's own addon folder just to be sure something else wasn't interfering.

Quote:

Usage: hooksecurefunc([table,] "function", hookfunc)
[string "=[C]"]: in function `hooksecurefunc'
[string "@Interface/AddOns/StealableBorder/core.lua"]:8: in main chunk

Locals:
(*temporary) = <table> {
UpdateOnBarHighlightMarksBySpell = <function> defined @Interface/FrameXML/ActionButton.lua:82
ERR_OUT_OF_CHI = "Not enough chi"
DH_HAVOC_CORE_ABILITY_2 = "Strong melee attack that consumes Fury. If it critical strikes, some Fury is refunded."
MultiCastActionButton6Cooldown = MultiCastActionButton6Cooldown {
}
SettingsSliderOptionsMixin = <table> {
}
GetTrainerServiceTypeFilter = <function> defined =[C]:-1
UNIT_NAMES_COMBATLOG_TOOLTIP = "Color unit names."
HUD_EDIT_MODE_SETTING_ACTION_BAR_HIDE_BAR_ART = "Hide Bar Art"
LE_GAME_ERR_CHAT_RAID_RESTRICTED_TRIAL = 774
SPELL_FAILED_CUSTOM_ERROR_71 = "This partygoer wants to dance with you."
LE_GAME_ERR_PET_SPELL_TARGETS_DEAD = 417
ERROR_CLUB_TICKET_COUNT_AT_MAX_COMMUNITY = "Can't create any more invite links for this community."
RecruitAFriendFrame = RecruitAFriendFrame {
}
TutorialFrameLeft19 = TutorialFrameLeft19 {
}
MultiCastActionButton2Cooldown = MultiCastActionButton2Cooldown {
}
ERR_TRADE_EQUIPPED_BAG = "You can't trade equipped bags."
PVP_RANK_6_1 = "Corporal"
MultiBarLeftButton7 = MultiBarLeftButton7 {
}
OPTION_TOOLTIP_SHOW_MULTIBAR4 = "Attached to the left side of Right Action Bar 1 by default"
LE_GAME_ERR_INVALID_FOLLOW_PVP_COMBAT = 371
MerchantItem1AltCurrencyFrameItem1Text = MerchantItem1AltCurrencyFrameItem1Text {
}
PROFESSIONS_COLUMN_REAGENTS_NONE = "None"
OPTION_TOOLTIP_ACTION_BUTTON_USE_KEY_DOWN = "Action button keybinds will respond on key down, rather than on key up."
BINDING_NAME_NAMEPLATES = "Show Enemy Name Plates"
CHAT_HEADER_SUFFIX = ": "
MultiBarBottomRightButton8Shine5 = MultiBarBottomRightButton8Shine5 {
}
COVENANT_MISSIONS_HEALTH = "Health"
MAIL_LETTER_TOOLTIP = "Click to make a permanent
copy of this letter."
UnitFrameManaBar_UnregisterDefaultEvents = <function> defined @Interface/FrameXML/UnitFrame.lua:898
PVPReadyDialogBottomArt = PVPReadyDialogBottomArt {
}
MultiBar6Button4Flash = MultiBar6Button4Flash {
}
DUNGEON_FLOOR_UPPERBLACKROCKSPIRE3 = "Hall of Blackhand"
CHAT_CONFIG_OTHER_COMBAT = <table> {
}
FCFDockOverflowButton_OnClick = <function> defined @Interface/FrameXML/FloatingChatFrame.lua:2398
TutorialFrameRight19 = TutorialFrameRight19 {
}
MoneyFrame_OnEvent = <function> defined @Interface/FrameXML/MoneyFrame.lua:202
BN_UNABLE_TO_RESOLVE_NAME = "Unable to whisper '%s'. Blizzard services may be unavailable."
AutoCompleteEditBox_OnKeyDown = <function> defined @Interface/FrameXML/AutoComplete.lua:368
CompactRaidFrameManagerDisplayFrameHiddenModeToggleTopRight = CompactRaidFrameManagerDisplayFrameHiddenModeToggleTopRight {
}
LFGTeleport = <function> defined =[C]:-1
LE_GAME_ERR_ONLY_ONE_QUIVER = 36
INT_SPELL_DURATION_HOURS = "%d |4hour:hrs;"
ToggleEncounterJournal = <function> defined @Interface/FrameXML/UIParent.lua:1141
LOSS_OF_CONTROL_DISPLAY_FEAR = "Feared"
OverrideActionBarButton6Shine11 = OverrideActionBarButton6Shine11 {
}
ROGUE_COMBAT_CORE_ABILITY_4 = "Melee attack that spends Combo Points."
JoinSkirmish = <function> defined =[C]:-1
MultiBarRightButton7Shine9 = MultiBarRightButton7Shine9 {
}
BankFrameItem17SearchOverlay = BankFrameItem17SearchOverlay {
}
DMG_LCD = "DMG"
ACTION_SPELL_MISSED_POSSESSIVE = "1"
Is64BitClient = <function> defined =[C]:-1
SecureCmdItemParse = <function> defined @Interface/FrameXML/ChatFrame.lua:1156
SLASH_STOPATTACK1 = "/stopattack"
MultiCastActionButton4HotKey = MultiCastActionButton4HotKey {
}
MultiBar5Button11Shine4 = MultiBar5Button11Shine4 {
}
TutorialFrame_OnMouseDown = <function> defined @Interface/FrameXML/TutorialFrame.lua:262
ContainerFrame4Item16Cooldown = ContainerFrame4Item16Cooldown {
}
MINIMAP_TRACKING_TRAINER_CLASS = "Class Trainer"
SLASH_DISMOUNT2 = "/dismount"
DUNGEON_FLOOR_DRAGONBLIGHTCHROMIESCENARIO2 = "Andorhal"
StanceButton8Shine15 = StanceButton8Shine15 {
}
EMOTE69_CMD1 = "/nosepick"
WowTokenRedemptionFrameBg = WowTokenRedemptionFrameBg {
}
SPELL_FAILED_CUSTOM_ERROR_152 = "You must choose a specialization to use Ascendance."
AutoFollowStatus = AutoFollowStatus {
}
ARENA_CASUAL =

Vremon 01-19-23 04:49 AM

Quote:

Originally Posted by Lesteryoung (Post 342015)
Tyvm for your help, but unfortunately it is still not working.

Now giving this error. I put it into it's own addon folder just to be sure something else wasn't interfering.

its cuz u copyed wrong the code check upside posts


All times are GMT -6. The time now is 02:38 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI