mirror of
https://github.com/parnic/LibDogTag-Unit-3.0.git
synced 2025-06-16 21:41:53 -05:00
Compare commits
62 Commits
Author | SHA1 | Date | |
---|---|---|---|
8d7646c83a | |||
4265d57599
|
|||
e970a958ac | |||
bde510f09c | |||
0c66028b9d | |||
7a2e432488 | |||
fc9ba7ac27 | |||
7cf02c9037 | |||
712fef34ae
|
|||
4c4262904d | |||
380bd0f06a
|
|||
e03b5c50cc | |||
aa2817b5db | |||
0217b0ba80 | |||
2641d29079 | |||
b2442ff568 | |||
1c161b436d | |||
9a939cca8b | |||
7f9d5db1e5 | |||
32583d92e0 | |||
05afef899d
|
|||
1ebf467ef4
|
|||
3576a67d39
|
|||
18a36c0cfc
|
|||
9e00585ce1
|
|||
dd28e38868
|
|||
5266af87c8
|
|||
122f129942
|
|||
79b632e7f4
|
|||
93696c41b6
|
|||
95ad2adeeb | |||
4f86740c25 | |||
c862c495f7
|
|||
0097e66d66
|
|||
e53fd70d70
|
|||
2f07b4d995
|
|||
07d6c46c18 | |||
39f70e711c
|
|||
4884525113
|
|||
06bb8d0b18
|
|||
eff831b6ec
|
|||
5deee22437
|
|||
4c5550b244
|
|||
d7e407e965
|
|||
a2b3c73085 | |||
ca58775bc8
|
|||
2602e23927
|
|||
55f27d5496
|
|||
78aa2ec948
|
|||
690bad04bf | |||
cb84320fed | |||
f845e20c05 | |||
3f2505245c
|
|||
f85d5eb088
|
|||
ccea4b3bfb
|
|||
86d49d9e5d | |||
9c59ab23a3
|
|||
de3a5205eb | |||
37d63662fa | |||
7fb0ee06da | |||
bd42fc6339
|
|||
5466a3cfa4
|
61
.github/workflows/release.yml
vendored
Normal file
61
.github/workflows/release.yml
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
# description of this workflow, can be anything you want
|
||||
name: Package and release
|
||||
|
||||
# we need to let GitHub know _when_ we want to release, typically only when we create a new tag.
|
||||
# this will target only tags, and not all pushes to the master branch.
|
||||
# this part can be heavily customized to your liking, like targeting only tags that match a certain word,
|
||||
# other branches or even pullrequests.
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '**'
|
||||
|
||||
# a workflow is built up as jobs, and within these jobs are steps
|
||||
jobs:
|
||||
|
||||
# "release" is a job, you can name it anything you want
|
||||
release:
|
||||
|
||||
# we can run our steps on pretty much anything, but the "ubuntu-latest" image is a safe bet
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
# specify the environment variables used by the packager, matching the secrets from the project on GitHub
|
||||
env:
|
||||
CF_API_KEY: ${{ secrets.CF_API_KEY }}
|
||||
WOWI_API_TOKEN: ${{ secrets.WOWI_API_TOKEN }}
|
||||
GITHUB_OAUTH: ${{ secrets.GITHUB_TOKEN }} # "GITHUB_TOKEN" is a secret always provided to the workflow
|
||||
# for your own token, the name cannot start with "GITHUB_"
|
||||
|
||||
# "steps" holds a list of all the steps needed to package and release our AddOn
|
||||
steps:
|
||||
|
||||
# we first have to clone the AddOn project, this is a required step
|
||||
- name: Clone project
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# once cloned, we just run the GitHub Action for the packager project
|
||||
- name: Package and release
|
||||
uses: BigWigsMods/packager@v2
|
||||
|
||||
# another example where we supply additional arguments, this example is specifically to release
|
||||
# for the Classic version of the game
|
||||
- name: Package and release for Classic
|
||||
uses: BigWigsMods/packager@v2
|
||||
with:
|
||||
args: -g classic -w 0
|
||||
|
||||
- name: Package and release for TBC
|
||||
uses: BigWigsMods/packager@v2
|
||||
with:
|
||||
args: -g bcc -w 0
|
||||
|
||||
- name: Package and release for Wrath
|
||||
uses: BigWigsMods/packager@v2
|
||||
with:
|
||||
args: -g wrath -w 0
|
||||
|
||||
- name: Package and release for Cataclysm
|
||||
uses: BigWigsMods/packager@v2
|
||||
with:
|
||||
args: -g cata -w 0
|
||||
|
@ -1,30 +1,37 @@
|
||||
local MAJOR_VERSION = "LibDogTag-Unit-3.0"
|
||||
local MINOR_VERSION = 90000 + (tonumber(("@file-date-integer@"):match("%d+")) or 33333333333333)
|
||||
local MINOR_VERSION = tonumber(("@project-date-integer@"):match("%d+")) or 33333333333333
|
||||
|
||||
if MINOR_VERSION > _G.DogTag_Unit_MINOR_VERSION then
|
||||
_G.DogTag_Unit_MINOR_VERSION = MINOR_VERSION
|
||||
end
|
||||
|
||||
local select, pairs, rawget, GetTime, setmetatable = select, pairs, rawget, GetTime, setmetatable
|
||||
local GetSpellInfo, UnitAura, UnitIsFriend, UnitClass, UnitPowerType =
|
||||
GetSpellInfo, UnitAura, UnitIsFriend, UnitClass, UnitPowerType
|
||||
local UnitAura, UnitIsFriend, UnitClass, UnitPowerType =
|
||||
UnitAura, UnitIsFriend, UnitClass, UnitPowerType
|
||||
|
||||
if not UnitAura and C_UnitAuras and C_UnitAuras.GetAuraDataByIndex then
|
||||
UnitAura = function(unitToken, index, filter)
|
||||
local auraData = C_UnitAuras.GetAuraDataByIndex(unitToken, index, filter)
|
||||
if not auraData then
|
||||
return nil
|
||||
end
|
||||
|
||||
return AuraUtil.UnpackAuraData(auraData)
|
||||
end
|
||||
end
|
||||
|
||||
-- GetSpellInfo removed in WoW 11.0
|
||||
local GetSpellName = C_Spell and C_Spell.GetSpellName or GetSpellInfo
|
||||
|
||||
DogTag_Unit_funcs[#DogTag_Unit_funcs+1] = function(DogTag_Unit, DogTag)
|
||||
|
||||
local L = DogTag_Unit.L
|
||||
|
||||
local newList = DogTag.newList
|
||||
|
||||
local hasEvent = DogTag.hasEvent
|
||||
|
||||
local IsNormalUnit = DogTag.IsNormalUnit
|
||||
local IsNormalUnit = DogTag_Unit.IsNormalUnit
|
||||
local newList, del = DogTag.newList, DogTag.del
|
||||
|
||||
local currentAuras, currentDebuffTypes, currentAuraTimes, currentNumDebuffs
|
||||
|
||||
-- Parnic: support for cataclysm; Divine Intervention was removed
|
||||
local wow_400 = select(4, GetBuildInfo()) >= 40000
|
||||
local wow_700 = select(4, GetBuildInfo()) >= 70000
|
||||
local wow_800 = select(4, GetBuildInfo()) >= 80000
|
||||
|
||||
local mt = {__index=function(self, unit)
|
||||
@ -91,121 +98,126 @@ currentAuraTimes = setmetatable({}, mt)
|
||||
currentNumDebuffs = setmetatable({}, mt)
|
||||
mt = nil
|
||||
|
||||
local auraQueue = {}
|
||||
local auraQueue
|
||||
DogTag:AddEventHandler("Unit", "EventRequested", function(_, event)
|
||||
if event ~= "Aura" or auraQueue then return end
|
||||
auraQueue = {}
|
||||
|
||||
local nextAuraUpdate = 0
|
||||
local nextWackyAuraUpdate = 0
|
||||
DogTag:AddTimerHandler("Unit", function(num, currentTime)
|
||||
if currentTime >= nextAuraUpdate and hasEvent('Aura') then
|
||||
nextAuraUpdate = currentTime + 0.5
|
||||
if currentTime >= nextWackyAuraUpdate then
|
||||
nextWackyAuraUpdate = currentTime + 2
|
||||
for unit, v in pairs(currentAuras) do
|
||||
if not IsNormalUnit[unit] then
|
||||
currentAuras[unit] = del(v)
|
||||
currentDebuffTypes[unit] = del(currentDebuffTypes[unit])
|
||||
currentAuraTimes[unit] = del(currentAuraTimes[unit])
|
||||
currentNumDebuffs[unit] = nil
|
||||
local nextAuraUpdate = 0
|
||||
local nextWackyAuraUpdate = 0
|
||||
DogTag:AddTimerHandler("Unit", function(num, currentTime)
|
||||
if currentTime >= nextAuraUpdate and DogTag.hasEvent('Aura') then
|
||||
nextAuraUpdate = currentTime + 0.5
|
||||
if currentTime >= nextWackyAuraUpdate then
|
||||
nextWackyAuraUpdate = currentTime + 2
|
||||
for unit, v in pairs(currentAuras) do
|
||||
if not IsNormalUnit[unit] then
|
||||
currentAuras[unit] = del(v)
|
||||
currentDebuffTypes[unit] = del(currentDebuffTypes[unit])
|
||||
currentAuraTimes[unit] = del(currentAuraTimes[unit])
|
||||
currentNumDebuffs[unit] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
for unit in pairs(auraQueue) do
|
||||
auraQueue[unit] = nil
|
||||
local t = newList()
|
||||
local u = newList()
|
||||
local v = newList()
|
||||
for i = 1, 40 do
|
||||
local name, count, expirationTime, _
|
||||
if wow_800 then
|
||||
name, _, count, _, _, expirationTime = UnitAura(unit, i, "HELPFUL")
|
||||
else
|
||||
name, _, _, count, _, _, expirationTime = UnitAura(unit, i, "HELPFUL")
|
||||
end
|
||||
if not name then
|
||||
break
|
||||
end
|
||||
if count == 0 then
|
||||
count = 1
|
||||
end
|
||||
t[name] = (t[name] or 0) + count
|
||||
if expirationTime and expirationTime > 0 and (not v[name] or v[name] > expirationTime) then
|
||||
v[name] = expirationTime
|
||||
end
|
||||
end
|
||||
local numDebuffs = 0
|
||||
local isFriend = UnitIsFriend("player", unit)
|
||||
for i = 1, 40 do
|
||||
local name, count, dispelType, expirationTime, _
|
||||
if wow_800 then
|
||||
name, _, count, dispelType, _, expirationTime = UnitAura(unit, i, "HARMFUL")
|
||||
else
|
||||
name, _, _, count, dispelType, _, expirationTime = UnitAura(unit, i, "HARMFUL")
|
||||
end
|
||||
if not name then
|
||||
break
|
||||
end
|
||||
if count == 0 then
|
||||
count = 1
|
||||
end
|
||||
numDebuffs = numDebuffs + 1
|
||||
t[name] = (t[name] or 0) + count
|
||||
if isFriend and dispelType then
|
||||
u[dispelType] = true
|
||||
end
|
||||
if expirationTime and expirationTime > 0 and (not v[name] or v[name] > expirationTime) then
|
||||
v[name] = expirationTime
|
||||
end
|
||||
end
|
||||
local old = rawget(currentAuras, unit) or newList()
|
||||
local oldType = rawget(currentDebuffTypes, unit) or newList()
|
||||
local oldTimes = rawget(currentAuraTimes, unit) or newList()
|
||||
local changed = false
|
||||
for k, num in pairs(t) do
|
||||
if not old[k] then
|
||||
changed = true
|
||||
break
|
||||
end
|
||||
if num ~= old[k] then
|
||||
changed = true
|
||||
break
|
||||
end
|
||||
old[k] = nil
|
||||
end
|
||||
if not changed then
|
||||
for k in pairs(old) do
|
||||
changed = true
|
||||
break
|
||||
end
|
||||
end
|
||||
currentAuras[unit] = t
|
||||
currentDebuffTypes[unit] = u
|
||||
currentAuraTimes[unit] = v
|
||||
local oldNumDebuffs = rawget(currentNumDebuffs, unit)
|
||||
currentNumDebuffs[unit] = numDebuffs
|
||||
old = del(old)
|
||||
oldType = del(oldType)
|
||||
oldTimes = del(oldTimes)
|
||||
if changed or oldNumDebuffs ~= numDebuffs then
|
||||
DogTag:FireEvent("Aura", unit)
|
||||
end
|
||||
end
|
||||
end
|
||||
for unit in pairs(auraQueue) do
|
||||
auraQueue[unit] = nil
|
||||
local t = newList()
|
||||
local u = newList()
|
||||
local v = newList()
|
||||
for i = 1, 40 do
|
||||
local name, count, expirationTime, _
|
||||
if wow_800 then
|
||||
name, _, count, _, _, expirationTime = UnitAura(unit, i, "HELPFUL")
|
||||
else
|
||||
name, _, _, count, _, _, expirationTime = UnitAura(unit, i, "HELPFUL")
|
||||
end
|
||||
if not name then
|
||||
break
|
||||
end
|
||||
if count == 0 then
|
||||
count = 1
|
||||
end
|
||||
t[name] = (t[name] or 0) + count
|
||||
if expirationTime and expirationTime > 0 and (not v[name] or v[name] > expirationTime) then
|
||||
v[name] = expirationTime
|
||||
end
|
||||
end
|
||||
local numDebuffs = 0
|
||||
local isFriend = UnitIsFriend("player", unit)
|
||||
for i = 1, 40 do
|
||||
local name, count, dispelType, expirationTime, _
|
||||
if wow_800 then
|
||||
name, _, count, dispelType, _, expirationTime = UnitAura(unit, i, "HARMFUL")
|
||||
else
|
||||
name, _, _, count, dispelType, _, expirationTime = UnitAura(unit, i, "HARMFUL")
|
||||
end
|
||||
if not name then
|
||||
break
|
||||
end
|
||||
if count == 0 then
|
||||
count = 1
|
||||
end
|
||||
numDebuffs = numDebuffs + 1
|
||||
t[name] = (t[name] or 0) + count
|
||||
if isFriend and dispelType then
|
||||
u[dispelType] = true
|
||||
end
|
||||
if expirationTime and expirationTime > 0 and (not v[name] or v[name] > expirationTime) then
|
||||
v[name] = expirationTime
|
||||
end
|
||||
end
|
||||
local old = rawget(currentAuras, unit) or newList()
|
||||
local oldType = rawget(currentDebuffTypes, unit) or newList()
|
||||
local oldTimes = rawget(currentAuraTimes, unit) or newList()
|
||||
local changed = false
|
||||
for k, num in pairs(t) do
|
||||
if not old[k] then
|
||||
changed = true
|
||||
break
|
||||
end
|
||||
if num ~= old[k] then
|
||||
changed = true
|
||||
break
|
||||
end
|
||||
old[k] = nil
|
||||
end
|
||||
if not changed then
|
||||
for k in pairs(old) do
|
||||
changed = true
|
||||
break
|
||||
end
|
||||
end
|
||||
currentAuras[unit] = t
|
||||
currentDebuffTypes[unit] = u
|
||||
currentAuraTimes[unit] = v
|
||||
local oldNumDebuffs = rawget(currentNumDebuffs, unit)
|
||||
currentNumDebuffs[unit] = numDebuffs
|
||||
old = del(old)
|
||||
oldType = del(oldType)
|
||||
oldTimes = del(oldTimes)
|
||||
if changed or oldNumDebuffs ~= numDebuffs then
|
||||
DogTag:FireEvent("Aura", unit)
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
DogTag:AddEventHandler("Unit", "UnitChanged", function(event, unit)
|
||||
if rawget(currentAuras, unit) then
|
||||
currentAuras[unit] = del(currentAuras[unit])
|
||||
currentDebuffTypes[unit] = del(currentDebuffTypes[unit])
|
||||
currentAuraTimes[unit] = del(currentAuraTimes[unit])
|
||||
currentNumDebuffs[unit] = nil
|
||||
auraQueue[unit] = true
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
DogTag:AddEventHandler("Unit", "UnitChanged", function(event, unit)
|
||||
if rawget(currentAuras, unit) then
|
||||
currentAuras[unit] = del(currentAuras[unit])
|
||||
currentDebuffTypes[unit] = del(currentDebuffTypes[unit])
|
||||
currentAuraTimes[unit] = del(currentAuraTimes[unit])
|
||||
currentNumDebuffs[unit] = nil
|
||||
end)
|
||||
|
||||
DogTag:AddEventHandler("Unit", "UNIT_AURA", function(event, unit)
|
||||
auraQueue[unit] = true
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
DogTag:AddEventHandler("Unit", "UNIT_AURA", function(event, unit)
|
||||
auraQueue[unit] = true
|
||||
end)
|
||||
|
||||
DogTag:AddTag("Unit", "HasAura", {
|
||||
code = function(aura, unit)
|
||||
@ -302,12 +314,12 @@ DogTag:AddTag("Unit", "RaidStacks", {
|
||||
category = L["Auras"]
|
||||
})
|
||||
|
||||
local MOONKIN_FORM = GetSpellInfo(24858)
|
||||
local AQUATIC_FORM = GetSpellInfo(1066)
|
||||
local FLIGHT_FORM = GetSpellInfo(33943)
|
||||
local SWIFT_FLIGHT_FORM = GetSpellInfo(40120)
|
||||
local TRAVEL_FORM = GetSpellInfo(783)
|
||||
local TREE_OF_LIFE = GetSpellInfo(33891)
|
||||
local MOONKIN_FORM = GetSpellName(24858)
|
||||
local AQUATIC_FORM = GetSpellName(1066)
|
||||
local FLIGHT_FORM = GetSpellName(33943)
|
||||
local SWIFT_FLIGHT_FORM = GetSpellName(40120)
|
||||
local TRAVEL_FORM = GetSpellName(783)
|
||||
local TREE_OF_LIFE = GetSpellName(33891)
|
||||
|
||||
local function DruidForm(unit)
|
||||
local _, c = UnitClass(unit)
|
||||
@ -405,8 +417,8 @@ DogTag:AddTag("Unit", "AuraDuration", {
|
||||
category = L["Auras"],
|
||||
})
|
||||
|
||||
local SHADOWFORM = GetSpellInfo(15473)
|
||||
if not wow_700 then
|
||||
local SHADOWFORM = GetSpellName(15473) or GetSpellName(232698)
|
||||
if SHADOWFORM then
|
||||
DogTag:AddTag("Unit", "IsShadowform", {
|
||||
alias = ("HasAura(aura=%q, unit=unit)"):format(SHADOWFORM),
|
||||
arg = {
|
||||
@ -418,9 +430,13 @@ DogTag:AddTag("Unit", "IsShadowform", {
|
||||
})
|
||||
end
|
||||
|
||||
local STEALTH = GetSpellInfo(1784)
|
||||
local SHADOWMELD = GetSpellInfo(58984) or GetSpellInfo(743) -- 58984 is the ID in BFA, 743 is the ID in Classic.
|
||||
local PROWL = GetSpellInfo(5215)
|
||||
local STEALTH = GetSpellName(1784)
|
||||
local SHADOWMELD =
|
||||
GetSpellName(58984) -- BFA
|
||||
or GetSpellName(20580) -- Classic TBC
|
||||
or GetSpellName(743) -- Classic Vanilla
|
||||
|
||||
local PROWL = GetSpellName(5215)
|
||||
DogTag:AddTag("Unit", "IsStealthed", {
|
||||
alias = ("HasAura(aura=%q, unit=unit) or HasAura(aura=%q, unit=unit) or HasAura(aura=%q, unit=unit)"):format(STEALTH, SHADOWMELD, PROWL),
|
||||
arg = {
|
||||
@ -431,7 +447,7 @@ DogTag:AddTag("Unit", "IsStealthed", {
|
||||
category = L["Auras"]
|
||||
})
|
||||
|
||||
local SHIELD_WALL = GetSpellInfo(871)
|
||||
local SHIELD_WALL = GetSpellName(871)
|
||||
DogTag:AddTag("Unit", "HasShieldWall", {
|
||||
alias = ("HasAura(aura=%q, unit=unit)"):format(SHIELD_WALL),
|
||||
arg = {
|
||||
@ -442,7 +458,7 @@ DogTag:AddTag("Unit", "HasShieldWall", {
|
||||
category = L["Auras"]
|
||||
})
|
||||
|
||||
local LAST_STAND = GetSpellInfo(12975)
|
||||
local LAST_STAND = GetSpellName(12975)
|
||||
DogTag:AddTag("Unit", "HasLastStand", {
|
||||
alias = ("HasAura(aura=%q, unit=unit)"):format(LAST_STAND),
|
||||
arg = {
|
||||
@ -453,7 +469,7 @@ DogTag:AddTag("Unit", "HasLastStand", {
|
||||
category = L["Auras"]
|
||||
})
|
||||
|
||||
local SOULSTONE_RESURRECTION = GetSpellInfo(20707)
|
||||
local SOULSTONE_RESURRECTION = GetSpellName(20707)
|
||||
DogTag:AddTag("Unit", "HasSoulstone", {
|
||||
alias = ("HasAura(aura=%q, unit=unit)"):format(SOULSTONE_RESURRECTION),
|
||||
arg = {
|
||||
@ -464,7 +480,7 @@ DogTag:AddTag("Unit", "HasSoulstone", {
|
||||
category = L["Auras"]
|
||||
})
|
||||
|
||||
local MISDIRECTION = GetSpellInfo(34477)
|
||||
local MISDIRECTION = GetSpellName(34477)
|
||||
if MISDIRECTION then -- WoW Classic compat
|
||||
DogTag:AddTag("Unit", "HasMisdirection", {
|
||||
alias = ("HasAura(aura=%q, unit=unit)"):format(MISDIRECTION),
|
||||
@ -477,7 +493,7 @@ if MISDIRECTION then -- WoW Classic compat
|
||||
})
|
||||
end
|
||||
|
||||
local ICE_BLOCK = GetSpellInfo(27619)
|
||||
local ICE_BLOCK = GetSpellName(27619)
|
||||
DogTag:AddTag("Unit", "HasIceBlock", {
|
||||
alias = ("HasAura(aura=%q, unit=unit)"):format(ICE_BLOCK),
|
||||
arg = {
|
||||
@ -488,7 +504,7 @@ DogTag:AddTag("Unit", "HasIceBlock", {
|
||||
category = L["Auras"]
|
||||
})
|
||||
|
||||
local INVISIBILITY = GetSpellInfo(66)
|
||||
local INVISIBILITY = GetSpellName(66)
|
||||
DogTag:AddTag("Unit", "HasInvisibility", {
|
||||
alias = ("HasAura(aura=%q, unit=unit)"):format(INVISIBILITY),
|
||||
arg = {
|
||||
@ -500,7 +516,7 @@ DogTag:AddTag("Unit", "HasInvisibility", {
|
||||
})
|
||||
|
||||
-- Parnic: DI removed in Cataclysm
|
||||
local DIVINE_INTERVENTION = GetSpellInfo(19752)
|
||||
local DIVINE_INTERVENTION = GetSpellName(19752)
|
||||
if DIVINE_INTERVENTION then
|
||||
DogTag:AddTag("Unit", "HasDivineIntervention", {
|
||||
alias = ("HasAura(aura=%q, unit=unit)"):format(DIVINE_INTERVENTION),
|
||||
|
@ -1,5 +1,5 @@
|
||||
local MAJOR_VERSION = "LibDogTag-Unit-3.0"
|
||||
local MINOR_VERSION = 90000 + (tonumber(("@file-date-integer@"):match("%d+")) or 33333333333333)
|
||||
local MINOR_VERSION = tonumber(("@project-date-integer@"):match("%d+")) or 33333333333333
|
||||
|
||||
if MINOR_VERSION > _G.DogTag_Unit_MINOR_VERSION then
|
||||
_G.DogTag_Unit_MINOR_VERSION = MINOR_VERSION
|
||||
@ -17,185 +17,193 @@ local newList = DogTag.newList
|
||||
local del = DogTag.del
|
||||
local castData = {}
|
||||
local UnitGUID = UnitGUID
|
||||
local IsNormalUnit = DogTag.IsNormalUnit
|
||||
local IsNormalUnit = DogTag_Unit.IsNormalUnit
|
||||
|
||||
local wow_ver = select(4, GetBuildInfo())
|
||||
local wow_classic = WOW_PROJECT_ID and WOW_PROJECT_ID == WOW_PROJECT_CLASSIC
|
||||
local wow_800 = wow_ver >= 80000
|
||||
local cast_api_has_ranks = wow_ver < 80000 and WOW_PROJECT_ID == WOW_PROJECT_MAINLINE
|
||||
|
||||
local playerGuid = nil
|
||||
DogTag:AddEventHandler("Unit", "PLAYER_LOGIN", function()
|
||||
playerGuid = UnitGUID("player")
|
||||
end)
|
||||
|
||||
local nextSpell, nextRank, nextTarget
|
||||
local function updateInfo(event, unit)
|
||||
local guid = UnitGUID(unit)
|
||||
if not guid then
|
||||
return
|
||||
end
|
||||
local data = castData[guid]
|
||||
if not data then
|
||||
data = newList()
|
||||
castData[guid] = data
|
||||
end
|
||||
|
||||
local spell, rank, displayName, icon, startTime, endTime
|
||||
local channeling = false
|
||||
if wow_800 then
|
||||
spell, displayName, icon, startTime, endTime = UnitCastingInfo(unit)
|
||||
rank = nil
|
||||
if not spell then
|
||||
spell, displayName, icon, startTime, endTime = UnitChannelInfo(unit)
|
||||
channeling = true
|
||||
end
|
||||
elseif wow_classic then
|
||||
-- Classic only has an API for player spellcasts. No API for arbitrary units.
|
||||
if unit == "player" then
|
||||
spell, displayName, icon, startTime, endTime = CastingInfo()
|
||||
rank = nil
|
||||
if not spell then
|
||||
spell, displayName, icon, startTime, endTime = ChannelInfo()
|
||||
channeling = true
|
||||
end
|
||||
end
|
||||
else
|
||||
spell, rank, displayName, icon, startTime, endTime = UnitCastingInfo(unit)
|
||||
if not spell then
|
||||
spell, rank, displayName, icon, startTime, endTime = UnitChannelInfo(unit)
|
||||
channeling = true
|
||||
end
|
||||
end
|
||||
|
||||
if spell then
|
||||
data.spell = spell
|
||||
rank = rank and tonumber(rank:match("%d+"))
|
||||
data.rank = rank
|
||||
local oldStart = data.startTime
|
||||
startTime = startTime * 0.001
|
||||
data.startTime = startTime
|
||||
data.endTime = endTime * 0.001
|
||||
if event == "UNIT_SPELLCAST_DELAYED" or event == "UNIT_SPELLCAST_CHANNEL_UPDATE" then
|
||||
data.delay = (data.delay or 0) + (startTime - (oldStart or startTime))
|
||||
else
|
||||
data.delay = 0
|
||||
end
|
||||
if guid == playerGuid and spell == nextSpell and rank == nextRank then
|
||||
data.target = nextTarget
|
||||
end
|
||||
data.casting = not channeling
|
||||
data.channeling = channeling
|
||||
data.fadeOut = false
|
||||
data.stopTime = nil
|
||||
data.stopMessage = nil
|
||||
DogTag:FireEvent("Cast", unit)
|
||||
return
|
||||
end
|
||||
|
||||
if not data.spell then
|
||||
castData[guid] = del(data)
|
||||
DogTag:FireEvent("Cast", unit)
|
||||
return
|
||||
end
|
||||
|
||||
if event == "UNIT_SPELLCAST_FAILED" then
|
||||
data.stopMessage = _G.FAILED
|
||||
elseif event == "UNIT_SPELLCAST_INTERRUPTED" then
|
||||
data.stopMessage = _G.INTERRUPTED
|
||||
end
|
||||
|
||||
data.casting = false
|
||||
data.channeling = false
|
||||
data.fadeOut = true
|
||||
if not data.stopTime then
|
||||
data.stopTime = GetTime()
|
||||
end
|
||||
DogTag:FireEvent("Cast", unit)
|
||||
end
|
||||
|
||||
local guidsToFire, unitsToUpdate = {}, {}
|
||||
local function fixCastData()
|
||||
local frame
|
||||
local currentTime = GetTime()
|
||||
for guid, data in pairs(castData) do
|
||||
if data.casting then
|
||||
if currentTime > data.endTime and playerGuid ~= guid then
|
||||
data.casting = false
|
||||
data.fadeOut = true
|
||||
data.stopTime = currentTime
|
||||
end
|
||||
elseif data.channeling then
|
||||
if currentTime > data.endTime then
|
||||
data.channeling = false
|
||||
data.fadeOut = true
|
||||
data.stopTime = currentTime
|
||||
end
|
||||
elseif data.fadeOut then
|
||||
local alpha = 0
|
||||
local stopTime = data.stopTime
|
||||
if stopTime then
|
||||
alpha = stopTime - currentTime + 1
|
||||
end
|
||||
local castEventIsSetup = false
|
||||
DogTag:AddEventHandler("Unit", "EventRequested", function(_, event)
|
||||
if event ~= "Cast" or castEventIsSetup then return end
|
||||
castEventIsSetup = true
|
||||
|
||||
if alpha <= 0 then
|
||||
castData[guid] = del(data)
|
||||
end
|
||||
else
|
||||
castData[guid] = del(data)
|
||||
local nextSpell, nextRank, nextTarget
|
||||
local function updateInfo(event, unit)
|
||||
local guid = UnitGUID(unit)
|
||||
if not guid then
|
||||
return
|
||||
end
|
||||
local found = false
|
||||
local normal = false
|
||||
for unit in DogTag_Unit.IterateUnitsWithGUID(guid) do
|
||||
found = unit
|
||||
if IsNormalUnit[unit] then
|
||||
normal = true
|
||||
break
|
||||
local data = castData[guid]
|
||||
if not data then
|
||||
data = newList()
|
||||
castData[guid] = data
|
||||
end
|
||||
|
||||
local spell, rank, displayName, icon, startTime, endTime
|
||||
local channeling = false
|
||||
if UnitCastingInfo then
|
||||
if cast_api_has_ranks then
|
||||
spell, rank, displayName, icon, startTime, endTime = UnitCastingInfo(unit)
|
||||
if not spell then
|
||||
spell, rank, displayName, icon, startTime, endTime = UnitChannelInfo(unit)
|
||||
channeling = true
|
||||
end
|
||||
else
|
||||
spell, displayName, icon, startTime, endTime = UnitCastingInfo(unit)
|
||||
rank = nil
|
||||
if not spell then
|
||||
spell, displayName, icon, startTime, endTime = UnitChannelInfo(unit)
|
||||
channeling = true
|
||||
end
|
||||
end
|
||||
elseif CastingInfo then
|
||||
-- Classic only has an API for player spellcasts. No API for arbitrary units.
|
||||
if unit == "player" then
|
||||
spell, displayName, icon, startTime, endTime = CastingInfo()
|
||||
rank = nil
|
||||
if not spell then
|
||||
spell, displayName, icon, startTime, endTime = ChannelInfo()
|
||||
channeling = true
|
||||
end
|
||||
end
|
||||
end
|
||||
if not found then
|
||||
if castData[guid] then
|
||||
castData[guid] = del(data)
|
||||
|
||||
if spell then
|
||||
data.spell = spell
|
||||
rank = rank and tonumber(rank:match("%d+"))
|
||||
data.rank = rank
|
||||
local oldStart = data.startTime
|
||||
startTime = startTime * 0.001
|
||||
data.startTime = startTime
|
||||
data.endTime = endTime * 0.001
|
||||
if event == "UNIT_SPELLCAST_DELAYED" or event == "UNIT_SPELLCAST_CHANNEL_UPDATE" then
|
||||
data.delay = (data.delay or 0) + (startTime - (oldStart or startTime))
|
||||
else
|
||||
data.delay = 0
|
||||
end
|
||||
else
|
||||
if not normal then
|
||||
unitsToUpdate[found] = true
|
||||
if guid == playerGuid and spell == nextSpell and rank == nextRank then
|
||||
data.target = nextTarget
|
||||
end
|
||||
|
||||
guidsToFire[guid] = true
|
||||
end
|
||||
end
|
||||
for unit in pairs(unitsToUpdate) do
|
||||
updateInfo(nil, unit)
|
||||
end
|
||||
wipe(unitsToUpdate)
|
||||
for guid in pairs(guidsToFire) do
|
||||
for unit in DogTag_Unit.IterateUnitsWithGUID(guid) do
|
||||
data.casting = not channeling
|
||||
data.channeling = channeling
|
||||
data.fadeOut = false
|
||||
data.stopTime = nil
|
||||
data.stopMessage = nil
|
||||
DogTag:FireEvent("Cast", unit)
|
||||
return
|
||||
end
|
||||
|
||||
if not data.spell then
|
||||
castData[guid] = del(data)
|
||||
DogTag:FireEvent("Cast", unit)
|
||||
return
|
||||
end
|
||||
|
||||
if event == "UNIT_SPELLCAST_FAILED" then
|
||||
data.stopMessage = _G.FAILED
|
||||
elseif event == "UNIT_SPELLCAST_INTERRUPTED" then
|
||||
data.stopMessage = _G.INTERRUPTED
|
||||
end
|
||||
|
||||
data.casting = false
|
||||
data.channeling = false
|
||||
data.fadeOut = true
|
||||
if not data.stopTime then
|
||||
data.stopTime = GetTime()
|
||||
end
|
||||
DogTag:FireEvent("Cast", unit)
|
||||
end
|
||||
wipe(guidsToFire)
|
||||
end
|
||||
DogTag:AddTimerHandler("Unit", fixCastData)
|
||||
|
||||
DogTag:AddEventHandler("Unit", "UNIT_SPELLCAST_START", updateInfo)
|
||||
DogTag:AddEventHandler("Unit", "UNIT_SPELLCAST_CHANNEL_START", updateInfo)
|
||||
DogTag:AddEventHandler("Unit", "UNIT_SPELLCAST_STOP", updateInfo)
|
||||
DogTag:AddEventHandler("Unit", "UNIT_SPELLCAST_FAILED", updateInfo)
|
||||
DogTag:AddEventHandler("Unit", "UNIT_SPELLCAST_INTERRUPTED", updateInfo)
|
||||
DogTag:AddEventHandler("Unit", "UNIT_SPELLCAST_DELAYED", updateInfo)
|
||||
DogTag:AddEventHandler("Unit", "UNIT_SPELLCAST_CHANNEL_UPDATE", updateInfo)
|
||||
DogTag:AddEventHandler("Unit", "UNIT_SPELLCAST_CHANNEL_STOP", updateInfo)
|
||||
DogTag:AddEventHandler("Unit", "UnitChanged", updateInfo)
|
||||
|
||||
DogTag:AddEventHandler("Unit", "UNIT_SPELLCAST_SENT", function(event, unit, spell, rank, target)
|
||||
|
||||
-- The purpose of this event is to predict the next spell target.
|
||||
-- This seems to be removed in at least wow_800
|
||||
if unit == "player" and not wow_800 then
|
||||
nextSpell = spell
|
||||
nextRank = rank and tonumber(rank:match("%d+"))
|
||||
nextTarget = target ~= "" and target or nil
|
||||
local guidsToFire, unitsToUpdate = {}, {}
|
||||
local function fixCastData()
|
||||
local frame
|
||||
local currentTime = GetTime()
|
||||
for guid, data in pairs(castData) do
|
||||
if data.casting then
|
||||
if currentTime > data.endTime and playerGuid ~= guid then
|
||||
data.casting = false
|
||||
data.fadeOut = true
|
||||
data.stopTime = currentTime
|
||||
end
|
||||
elseif data.channeling then
|
||||
if currentTime > data.endTime then
|
||||
data.channeling = false
|
||||
data.fadeOut = true
|
||||
data.stopTime = currentTime
|
||||
end
|
||||
elseif data.fadeOut then
|
||||
local alpha = 0
|
||||
local stopTime = data.stopTime
|
||||
if stopTime then
|
||||
alpha = stopTime - currentTime + 1
|
||||
end
|
||||
|
||||
if alpha <= 0 then
|
||||
castData[guid] = del(data)
|
||||
end
|
||||
else
|
||||
castData[guid] = del(data)
|
||||
end
|
||||
local found = false
|
||||
local normal = false
|
||||
for unit in DogTag_Unit.IterateUnitsWithGUID(guid) do
|
||||
found = unit
|
||||
if IsNormalUnit[unit] then
|
||||
normal = true
|
||||
break
|
||||
end
|
||||
end
|
||||
if not found then
|
||||
if castData[guid] then
|
||||
castData[guid] = del(data)
|
||||
end
|
||||
else
|
||||
if not normal then
|
||||
unitsToUpdate[found] = true
|
||||
end
|
||||
|
||||
guidsToFire[guid] = true
|
||||
end
|
||||
end
|
||||
for unit in pairs(unitsToUpdate) do
|
||||
updateInfo(nil, unit)
|
||||
end
|
||||
wipe(unitsToUpdate)
|
||||
for guid in pairs(guidsToFire) do
|
||||
for unit in DogTag_Unit.IterateUnitsWithGUID(guid) do
|
||||
DogTag:FireEvent("Cast", unit)
|
||||
end
|
||||
end
|
||||
wipe(guidsToFire)
|
||||
end
|
||||
DogTag:AddTimerHandler("Unit", fixCastData)
|
||||
|
||||
DogTag:AddEventHandler("Unit", "UNIT_SPELLCAST_START", updateInfo)
|
||||
DogTag:AddEventHandler("Unit", "UNIT_SPELLCAST_CHANNEL_START", updateInfo)
|
||||
DogTag:AddEventHandler("Unit", "UNIT_SPELLCAST_STOP", updateInfo)
|
||||
DogTag:AddEventHandler("Unit", "UNIT_SPELLCAST_FAILED", updateInfo)
|
||||
DogTag:AddEventHandler("Unit", "UNIT_SPELLCAST_INTERRUPTED", updateInfo)
|
||||
DogTag:AddEventHandler("Unit", "UNIT_SPELLCAST_DELAYED", updateInfo)
|
||||
DogTag:AddEventHandler("Unit", "UNIT_SPELLCAST_CHANNEL_UPDATE", updateInfo)
|
||||
DogTag:AddEventHandler("Unit", "UNIT_SPELLCAST_CHANNEL_STOP", updateInfo)
|
||||
DogTag:AddEventHandler("Unit", "UnitChanged", updateInfo)
|
||||
|
||||
DogTag:AddEventHandler("Unit", "UNIT_SPELLCAST_SENT", function(event, unit, spell, rank, target)
|
||||
|
||||
-- The purpose of this event is to predict the next spell target.
|
||||
-- This seems to be removed in at least wow_800
|
||||
if unit == "player" and cast_api_has_ranks then
|
||||
nextSpell = spell
|
||||
nextRank = rank and tonumber(rank:match("%d+"))
|
||||
nextTarget = target ~= "" and target or nil
|
||||
end
|
||||
end)
|
||||
|
||||
end)
|
||||
|
||||
local blank = {}
|
||||
|
@ -1,5 +1,5 @@
|
||||
local MAJOR_VERSION = "LibDogTag-3.0"
|
||||
local MINOR_VERSION = 90000 + (tonumber(("@file-date-integer@"):match("%d+")) or 33333333333333)
|
||||
local MINOR_VERSION = tonumber(("@project-date-integer@"):match("%d+")) or 33333333333333
|
||||
|
||||
if MINOR_VERSION > _G.DogTag_Unit_MINOR_VERSION then
|
||||
_G.DogTag_Unit_MINOR_VERSION = MINOR_VERSION
|
||||
@ -17,17 +17,12 @@ DogTag_Unit_funcs[#DogTag_Unit_funcs+1] = function(DogTag_Unit, DogTag)
|
||||
|
||||
local L = DogTag_Unit.L
|
||||
|
||||
-- Pre 3.2.0 compatability support
|
||||
local wow_320 = select(4, GetBuildInfo()) >= 30200
|
||||
local wow_700 = select(4, GetBuildInfo()) >= 70000
|
||||
local wow_800 = select(4, GetBuildInfo()) >= 80000
|
||||
local wow_classic = WOW_PROJECT_ID and WOW_PROJECT_ID == WOW_PROJECT_CLASSIC
|
||||
local GetQuestDifficultyColor
|
||||
if not wow_320 and not wow_classic then
|
||||
GetQuestDifficultyColor = _G.GetDifficultyColor
|
||||
else
|
||||
GetQuestDifficultyColor = _G.GetQuestDifficultyColor
|
||||
end
|
||||
local wow_build = select(4, GetBuildInfo())
|
||||
local wow_800 = wow_build >= 80000
|
||||
-- The mere presence of WOW_PROJECT_ID tells us how "modern" the client is.
|
||||
local WOW_PROJECT_ID = _G.WOW_PROJECT_ID
|
||||
|
||||
local GetQuestDifficultyColor = GetQuestDifficultyColor or GetDifficultyColor
|
||||
|
||||
DogTag:AddTag("Unit", "IsFriend", {
|
||||
code = function(unit)
|
||||
@ -91,7 +86,7 @@ DogTag:AddTag("Unit", "Name", {
|
||||
elseif unit:match("%d*vehicle%d*$") then
|
||||
return VehicleName(unit)
|
||||
end
|
||||
return UnitName(unit) or DogTag.UnitToLocale[unit]
|
||||
return UnitName(unit) or DogTag_Unit.UnitToLocale[unit]
|
||||
end,
|
||||
arg = {
|
||||
'unit', 'string;undef', 'player'
|
||||
@ -108,7 +103,7 @@ DogTag:AddTag("Unit", "SimpleName", {
|
||||
arg = {
|
||||
'unit', 'string;undef', 'player'
|
||||
},
|
||||
ret = "string",
|
||||
ret = "string;nil",
|
||||
events = "UNIT_NAME_UPDATE#$unit",
|
||||
doc = L["Return the name of unit"],
|
||||
example = ('[SimpleName] => %q'):format(UnitName("player")),
|
||||
@ -172,13 +167,14 @@ DogTag:AddTag("Unit", "Level", {
|
||||
category = L["Characteristics"]
|
||||
})
|
||||
|
||||
local maxLevel = GetMaxPlayerLevel and GetMaxPlayerLevel() or _G.MAX_PLAYER_LEVEL
|
||||
DogTag:AddTag("Unit", "IsMaxLevel", {
|
||||
alias = ("Boolean(Level(unit=unit) >= %d)"):format(_G.MAX_PLAYER_LEVEL),
|
||||
alias = ("Boolean(Level(unit=unit) >= %d)"):format(maxLevel),
|
||||
arg = {
|
||||
'unit', 'string;undef', 'player'
|
||||
},
|
||||
doc = L["Return True if the level of unit is %d"]:format(_G.MAX_PLAYER_LEVEL),
|
||||
example = ('[IsMaxLevel] => %q'):format(UnitLevel("player") >= _G.MAX_PLAYER_LEVEL and L["True"] or ""),
|
||||
doc = L["Return True if the level of unit is %d"]:format(maxLevel),
|
||||
example = ('[IsMaxLevel] => %q'):format(UnitLevel("player") >= maxLevel and L["True"] or ""),
|
||||
category = L["Characteristics"],
|
||||
})
|
||||
|
||||
@ -186,11 +182,17 @@ local function Class(unit)
|
||||
if UnitIsPlayer(unit) then
|
||||
return UnitClass(unit) or UNKNOWN
|
||||
else
|
||||
if wow_800 then
|
||||
local classbase, classindex = UnitClassBase(unit)
|
||||
local classbase, classindex = UnitClassBase(unit)
|
||||
if GetClassInfo then
|
||||
return classbase and GetClassInfo(classindex) or UNKNOWN
|
||||
elseif LOCALIZED_CLASS_NAMES_MALE and LOCALIZED_CLASS_NAMES_FEMALE then
|
||||
if UnitSex and UnitSex(unit) == 3 then
|
||||
return LOCALIZED_CLASS_NAMES_FEMALE[classbase] or UNKNOWN
|
||||
else
|
||||
return LOCALIZED_CLASS_NAMES_MALE[classbase] or UNKNOWN
|
||||
end
|
||||
else
|
||||
return UnitClassBase(unit) or UNKNOWN
|
||||
return classbase or UNKNOWN
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -552,7 +554,11 @@ DogTag:AddTag("Unit", "HostileColor", {
|
||||
-- either enemy or friend, no violence
|
||||
r, g, b = unpack(DogTag.__colors.civilian)
|
||||
end
|
||||
elseif (not wow_700 and not wow_classic and UnitIsTapped(unit) and not UnitIsTappedByPlayer(unit)) or ((wow_700 or wow_classic) and UnitIsTapDenied(unit)) or UnitIsDead(unit) then
|
||||
elseif
|
||||
(UnitIsTapDenied and UnitIsTapDenied(unit)) or
|
||||
(UnitIsTapped and UnitIsTapped(unit) and not UnitIsTappedByPlayer(unit)) or
|
||||
UnitIsDead(unit)
|
||||
then
|
||||
r, g, b = unpack(DogTag.__colors.tapped)
|
||||
else
|
||||
local reaction = UnitReaction(unit, "player")
|
||||
|
@ -1,5 +1,5 @@
|
||||
local MAJOR_VERSION = "LibDogTag-Unit-3.0"
|
||||
local MINOR_VERSION = 90000 + (tonumber(("@file-date-integer@"):match("%d+")) or 33333333333333)
|
||||
local MINOR_VERSION = tonumber(("@project-date-integer@"):match("%d+")) or 33333333333333
|
||||
|
||||
if MINOR_VERSION > _G.DogTag_Unit_MINOR_VERSION then
|
||||
_G.DogTag_Unit_MINOR_VERSION = MINOR_VERSION
|
||||
|
@ -1,5 +1,5 @@
|
||||
local MAJOR_VERSION = "LibDogTag-Unit-3.0"
|
||||
local MINOR_VERSION = 90000 + (tonumber(("@file-date-integer@"):match("%d+")) or 33333333333333)
|
||||
local MINOR_VERSION = tonumber(("@project-date-integer@"):match("%d+")) or 33333333333333
|
||||
|
||||
if MINOR_VERSION > _G.DogTag_Unit_MINOR_VERSION then
|
||||
_G.DogTag_Unit_MINOR_VERSION = MINOR_VERSION
|
||||
|
@ -1,5 +1,5 @@
|
||||
local MAJOR_VERSION = "LibDogTag-Unit-3.0"
|
||||
local MINOR_VERSION = 90000 + (tonumber(("@file-date-integer@"):match("%d+")) or 33333333333333)
|
||||
local MINOR_VERSION = tonumber(("@project-date-integer@"):match("%d+")) or 33333333333333
|
||||
|
||||
if MINOR_VERSION > _G.DogTag_Unit_MINOR_VERSION then
|
||||
_G.DogTag_Unit_MINOR_VERSION = MINOR_VERSION
|
||||
@ -69,7 +69,11 @@ end)
|
||||
|
||||
DogTag:AddTimerHandler("Unit", function(num, currentTime)
|
||||
if currentTime > nextGuildRosterUpdate then
|
||||
if IsInGuild() then
|
||||
if IsInGuild()
|
||||
-- CommunitiesFrame check workaround for
|
||||
-- https://github.com/parnic/LibDogTag-Unit-3.0/issues/12
|
||||
and (not CommunitiesFrame or not CommunitiesFrame:IsVisible())
|
||||
then
|
||||
GuildRoster()
|
||||
end
|
||||
nextGuildRosterUpdate = currentTime + 20
|
||||
|
@ -1,5 +1,5 @@
|
||||
local MAJOR_VERSION = "LibDogTag-Unit-3.0"
|
||||
local MINOR_VERSION = 90000 + (tonumber(("@file-date-integer@"):match("%d+")) or 33333333333333)
|
||||
local MINOR_VERSION = tonumber(("@project-date-integer@"):match("%d+")) or 33333333333333
|
||||
|
||||
if MINOR_VERSION > _G.DogTag_Unit_MINOR_VERSION then
|
||||
_G.DogTag_Unit_MINOR_VERSION = MINOR_VERSION
|
||||
@ -9,8 +9,6 @@ local _G, unpack = _G, unpack
|
||||
local UnitHealth, UnitHealthMax, UnitIsGhost, UnitGetTotalAbsorbs =
|
||||
UnitHealth, UnitHealthMax, UnitIsGhost, UnitGetTotalAbsorbs
|
||||
|
||||
-- Support for new UnitGetTotalAbsorbs functionality
|
||||
local wow_502 = select(4, GetBuildInfo()) >= 50200
|
||||
|
||||
DogTag_Unit_funcs[#DogTag_Unit_funcs+1] = function(DogTag_Unit, DogTag)
|
||||
|
||||
@ -94,7 +92,7 @@ DogTag:AddTag("Unit", "IsMaxHP", {
|
||||
category = L["Health"]
|
||||
})
|
||||
|
||||
if wow_502 then
|
||||
if UnitGetTotalAbsorbs then
|
||||
DogTag:AddTag("Unit", "TotalAbsorb", {
|
||||
code = UnitGetTotalAbsorbs,
|
||||
arg = {
|
||||
|
@ -1,5 +1,5 @@
|
||||
local MAJOR_VERSION = "LibDogTag-Unit-3.0"
|
||||
local MINOR_VERSION = 90000 + (tonumber(("@file-date-integer@"):match("%d+")) or 33333333333333)
|
||||
local MINOR_VERSION = tonumber(("@project-date-integer@"):match("%d+")) or 33333333333333
|
||||
|
||||
if MINOR_VERSION > _G.DogTag_Unit_MINOR_VERSION then
|
||||
_G.DogTag_Unit_MINOR_VERSION = MINOR_VERSION
|
||||
@ -37,7 +37,7 @@ DogTag:AddTag("Unit", "Combos", {
|
||||
'target', 'string;undef', '@undef'
|
||||
},
|
||||
ret = "number",
|
||||
events = wow_700 and "UNIT_POWER_FREQUENT#$unit" or "UNIT_COMBO_POINTS",
|
||||
events = (wow_700 or WOW_PROJECT_ID) and "UNIT_POWER_FREQUENT#$unit" or "UNIT_COMBO_POINTS",
|
||||
doc = L["Return the number of combo points you have"],
|
||||
example = '[Combos] => "5"; [Combos("pet"))] => "5"; [Combos("vehicle", "target"))] => "5"',
|
||||
category = L["Miscellaneous"]
|
||||
|
@ -1,5 +1,5 @@
|
||||
local MAJOR_VERSION = "LibDogTag-Unit-3.0"
|
||||
local MINOR_VERSION = 90000 + tonumber(("$Revision: 225 $"):match("%d+")) or 0
|
||||
local MINOR_VERSION = tonumber(("@project-date-integer@"):match("%d+")) or 33333333333333
|
||||
|
||||
if MINOR_VERSION > _G.DogTag_Unit_MINOR_VERSION then
|
||||
_G.DogTag_Unit_MINOR_VERSION = MINOR_VERSION
|
||||
|
@ -1,5 +1,5 @@
|
||||
local MAJOR_VERSION = "LibDogTag-Unit-3.0"
|
||||
local MINOR_VERSION = 90000 + (tonumber(("@file-date-integer@"):match("%d+")) or 33333333333333)
|
||||
local MINOR_VERSION = tonumber(("@project-date-integer@"):match("%d+")) or 33333333333333
|
||||
|
||||
if MINOR_VERSION > _G.DogTag_Unit_MINOR_VERSION then
|
||||
_G.DogTag_Unit_MINOR_VERSION = MINOR_VERSION
|
||||
@ -13,81 +13,146 @@ local SPELL_POWER_MANA, SPELL_POWER_RUNES, SPELL_POWER_CHI, SPELL_POWER_ECLIPSE,
|
||||
SPELL_POWER_MANA, SPELL_POWER_RUNES, SPELL_POWER_CHI, SPELL_POWER_ECLIPSE, SPELL_POWER_SOUL_SHARDS, SPELL_POWER_ARCANE_CHARGES
|
||||
local SPELL_POWER_BURNING_EMBERS, SPELL_POWER_HOLY_POWER, SPELL_POWER_LIGHT_FORCE, SPELL_POWER_SHADOW_ORBS =
|
||||
SPELL_POWER_BURNING_EMBERS, SPELL_POWER_HOLY_POWER, SPELL_POWER_LIGHT_FORCE, SPELL_POWER_SHADOW_ORBS
|
||||
local SPELL_POWER_RAGE, SPELL_POWER_FOCUS, SPELL_POWER_ENERGY, SPELL_POWER_COMBO_POINTS, SPELL_POWER_RUNIC_POWER, SPELL_POWER_LUNAR_POWER =
|
||||
SPELL_POWER_RAGE, SPELL_POWER_FOCUS, SPELL_POWER_ENERGY, SPELL_POWER_COMBO_POINTS, SPELL_POWER_RUNIC_POWER, SPELL_POWER_LUNAR_POWER
|
||||
local SPELL_POWER_MAELSTROM, SPELL_POWER_INSANITY, SPELL_POWER_FURY, SPELL_POWER_PAIN =
|
||||
SPELL_POWER_MAELSTROM, SPELL_POWER_INSANITY, SPELL_POWER_FURY, SPELL_POWER_PAIN
|
||||
|
||||
DogTag_Unit_funcs[#DogTag_Unit_funcs+1] = function(DogTag_Unit, DogTag)
|
||||
|
||||
local L = DogTag_Unit.L
|
||||
|
||||
local wow_700 = select(4, GetBuildInfo()) >= 70000
|
||||
local wow_800 = select(4, GetBuildInfo()) >= 80000
|
||||
local mpEvents = "UNIT_POWER_FREQUENT#$unit;UNIT_MAXPOWER#$unit;UNIT_DISPLAYPOWER#$unit"
|
||||
|
||||
if wow_800 then
|
||||
if Enum and Enum.PowerType then
|
||||
SPELL_POWER_MANA, SPELL_POWER_RUNES, SPELL_POWER_CHI, SPELL_POWER_ECLIPSE, SPELL_POWER_SOUL_SHARDS, SPELL_POWER_ARCANE_CHARGES =
|
||||
Enum.PowerType.Mana, Enum.PowerType.Runes, Enum.PowerType.Chi, Enum.PowerType.LunarPower, Enum.PowerType.SoulShards, Enum.PowerType.ArcaneCharges
|
||||
SPELL_POWER_BURNING_EMBERS, SPELL_POWER_HOLY_POWER, SPELL_POWER_LIGHT_FORCE, SPELL_POWER_SHADOW_ORBS =
|
||||
Enum.PowerType.Obsolete, Enum.PowerType.HolyPower, Enum.PowerType.Obsolete, Enum.PowerType.Obsolete
|
||||
SPELL_POWER_RAGE, SPELL_POWER_FOCUS, SPELL_POWER_ENERGY, SPELL_POWER_COMBO_POINTS, SPELL_POWER_RUNIC_POWER, SPELL_POWER_LUNAR_POWER =
|
||||
Enum.PowerType.Rage, Enum.PowerType.Focus, Enum.PowerType.Energy, Enum.PowerType.ComboPoints, Enum.PowerType.RunicPower, Enum.PowerType.LunarPower
|
||||
SPELL_POWER_MAELSTROM, SPELL_POWER_INSANITY, SPELL_POWER_FURY, SPELL_POWER_PAIN =
|
||||
Enum.PowerType.Maelstrom, Enum.PowerType.Insanity, Enum.PowerType.Fury, Enum.PowerType.Pain
|
||||
end
|
||||
|
||||
-- copied from Blizzard_CombatText, which isn't exposed anywhere else
|
||||
local powerEnumFromStringLookup =
|
||||
{
|
||||
[MANA:lower()] = SPELL_POWER_MANA,
|
||||
[RAGE:lower()] = SPELL_POWER_RAGE,
|
||||
[FOCUS:lower()] = SPELL_POWER_FOCUS,
|
||||
[ENERGY:lower()] = SPELL_POWER_ENERGY,
|
||||
[COMBO_POINTS:lower()] = SPELL_POWER_COMBO_POINTS,
|
||||
}
|
||||
|
||||
if RUNES then
|
||||
powerEnumFromStringLookup[RUNES:lower()] = SPELL_POWER_RUNES
|
||||
end
|
||||
if RUNIC_POWER then
|
||||
powerEnumFromStringLookup[RUNIC_POWER:lower()] = SPELL_POWER_RUNIC_POWER
|
||||
end
|
||||
if SOUL_SHARDS then
|
||||
powerEnumFromStringLookup[SOUL_SHARDS:lower()] = SPELL_POWER_SOUL_SHARDS
|
||||
end
|
||||
if LUNAR_POWER then
|
||||
powerEnumFromStringLookup[LUNAR_POWER:lower()] = SPELL_POWER_LUNAR_POWER
|
||||
end
|
||||
if HOLY_POWER then
|
||||
powerEnumFromStringLookup[HOLY_POWER:lower()] = SPELL_POWER_HOLY_POWER
|
||||
end
|
||||
if MAELSTROM then
|
||||
powerEnumFromStringLookup[MAELSTROM:lower()] = SPELL_POWER_MAELSTROM
|
||||
end
|
||||
if CHI then
|
||||
powerEnumFromStringLookup[CHI:lower()] = SPELL_POWER_CHI
|
||||
end
|
||||
if INSANITY then
|
||||
powerEnumFromStringLookup[INSANITY:lower()] = SPELL_POWER_INSANITY
|
||||
end
|
||||
if ARCANE_CHARGES then
|
||||
powerEnumFromStringLookup[ARCANE_CHARGES:lower()] = SPELL_POWER_ARCANE_CHARGES
|
||||
end
|
||||
if FURY then
|
||||
powerEnumFromStringLookup[FURY:lower()] = SPELL_POWER_FURY
|
||||
end
|
||||
if PAIN then
|
||||
powerEnumFromStringLookup[PAIN:lower()] = SPELL_POWER_PAIN
|
||||
end
|
||||
|
||||
DogTag:AddTag("Unit", "MP", {
|
||||
code = UnitPower,
|
||||
code = function(unit, type)
|
||||
local enum
|
||||
if type then
|
||||
enum = powerEnumFromStringLookup[type:lower()]
|
||||
end
|
||||
return UnitPower(unit, enum)
|
||||
end,
|
||||
arg = {
|
||||
'unit', 'string;undef', 'player'
|
||||
'unit', 'string;undef', 'player',
|
||||
'type', 'string;undef', '@undef',
|
||||
},
|
||||
ret = "number",
|
||||
events = "UNIT_POWER_FREQUENT#$unit;UNIT_DISPLAYPOWER#$unit",
|
||||
doc = L["Return the current mana/rage/energy of unit"],
|
||||
example = ('[MP] => "%d"'):format(UnitPowerMax("player")*.632),
|
||||
example = ('[MP] => "%d"; [MP("player", "Energy")] => "65"'):format(UnitPowerMax("player")*.632),
|
||||
category = L["Power"]
|
||||
})
|
||||
|
||||
DogTag:AddTag("Unit", "MaxMP", {
|
||||
code = UnitPowerMax,
|
||||
code = function(unit, type)
|
||||
local enum
|
||||
if type then
|
||||
enum = powerEnumFromStringLookup[type:lower()]
|
||||
end
|
||||
return UnitPowerMax(unit, enum)
|
||||
end,
|
||||
arg = {
|
||||
'unit', 'string;undef', 'player'
|
||||
'unit', 'string;undef', 'player',
|
||||
'type', 'string;undef', '@undef',
|
||||
},
|
||||
ret = "number",
|
||||
events = "UNIT_MAXPOWER#$unit",
|
||||
doc = L["Return the maximum mana/rage/energy of unit"],
|
||||
example = ('[MaxMP] => "%d"'):format(UnitPowerMax("player")),
|
||||
example = ('[MaxMP] => "%d"; [MaxMP("player", "Energy")] => "100"'):format(UnitPowerMax("player")),
|
||||
category = L["Power"]
|
||||
})
|
||||
|
||||
DogTag:AddTag("Unit", "PercentMP", {
|
||||
alias = "[MP(unit=unit) / MaxMP(unit=unit) * 100]:Round(1)",
|
||||
alias = "[MP(unit=unit, type=type) / MaxMP(unit=unit, type=type) * 100]:Round(1)",
|
||||
arg = {
|
||||
'unit', 'string;undef', 'player'
|
||||
'unit', 'string;undef', 'player',
|
||||
'type', 'string;undef', '@undef',
|
||||
},
|
||||
doc = L["Return the percentage mana/rage/energy of unit"],
|
||||
example = '[PercentMP] => "63.2"; [PercentMP:Percent] => "63.2%"',
|
||||
example = '[PercentMP] => "63.2"; [PercentMP:Percent] => "63.2%"; [PercentMP("player", "Energy")] => "65"',
|
||||
category = L["Power"]
|
||||
})
|
||||
|
||||
DogTag:AddTag("Unit", "MissingMP", {
|
||||
alias = "MaxMP(unit=unit) - MP(unit=unit)",
|
||||
alias = "MaxMP(unit=unit, type=type) - MP(unit=unit, type=type)",
|
||||
arg = {
|
||||
'unit', 'string;undef', 'player'
|
||||
'unit', 'string;undef', 'player',
|
||||
'type', 'string;undef', '@undef',
|
||||
},
|
||||
doc = L["Return the missing mana/rage/energy of unit"],
|
||||
example = ('[MissingMP] => "%d"'):format(UnitPowerMax("player")*.368),
|
||||
example = ('[MissingMP] => "%d"; [MissingMP("player", "Energy")] => "35"'):format(UnitPowerMax("player")*.368),
|
||||
category = L["Power"]
|
||||
})
|
||||
|
||||
DogTag:AddTag("Unit", "FractionalMP", {
|
||||
alias = "Concatenate(MP(unit=unit), '/', MaxMP(unit=unit))",
|
||||
alias = "Concatenate(MP(unit=unit, type=type), '/', MaxMP(unit=unit, type=type))",
|
||||
arg = {
|
||||
'unit', 'string;undef', 'player'
|
||||
'unit', 'string;undef', 'player',
|
||||
'type', 'string;undef', '@undef',
|
||||
},
|
||||
doc = L["Return the current and maximum mana/rage/energy of unit"],
|
||||
example = ('[FractionalMP] => "%d/%d"'):format(UnitPowerMax("player")*.632, UnitPowerMax("player")),
|
||||
example = ('[FractionalMP] => "%d/%d"; [FractionalMP("player", "Energy")] => "65/100"'):format(UnitPowerMax("player")*.632, UnitPowerMax("player")),
|
||||
category = L["Power"]
|
||||
})
|
||||
|
||||
|
||||
DogTag:AddTag("Unit", "Mana", {
|
||||
code = function(unit)
|
||||
return UnitPower(unit, SPELL_POWER_MANA)
|
||||
end,
|
||||
alias = ("MP(unit=unit, type=%q)"):format(MANA:lower()),
|
||||
arg = {
|
||||
'unit', 'string;undef', 'player'
|
||||
},
|
||||
@ -99,9 +164,7 @@ DogTag:AddTag("Unit", "Mana", {
|
||||
})
|
||||
|
||||
DogTag:AddTag("Unit", "MaxMana", {
|
||||
code = function(unit)
|
||||
return UnitPowerMax(unit, SPELL_POWER_MANA)
|
||||
end,
|
||||
alias = ("MaxMP(unit=unit, type=%q)"):format(MANA:lower()),
|
||||
arg = {
|
||||
'unit', 'string;undef', 'player'
|
||||
},
|
||||
@ -325,7 +388,8 @@ if RUNIC_POWER then
|
||||
})
|
||||
end
|
||||
|
||||
if wow_700 then
|
||||
if GetRuneCooldown then
|
||||
local GetRuneCooldown = GetRuneCooldown
|
||||
DogTag:AddTag("Unit", "RunesAvailable", {
|
||||
code = function(unit)
|
||||
local numAvailable = 0
|
||||
@ -349,9 +413,10 @@ if wow_700 then
|
||||
end
|
||||
|
||||
DogTag:AddTag("Unit", "IsMaxMP", {
|
||||
alias = "Boolean(MP(unit=unit) = MaxMP(unit=unit))",
|
||||
alias = "Boolean(MP(unit=unit, type=type) = MaxMP(unit=unit, type=type))",
|
||||
arg = {
|
||||
'unit', 'string;undef', 'player'
|
||||
'unit', 'string;undef', 'player',
|
||||
'type', 'string;undef', '@undef',
|
||||
},
|
||||
doc = L["Return True if unit is at full rage/mana/energy"],
|
||||
example = ('[IsMaxMP] => %q; [IsMaxMP] => ""'):format(L["True"]),
|
||||
@ -359,9 +424,10 @@ DogTag:AddTag("Unit", "IsMaxMP", {
|
||||
})
|
||||
|
||||
DogTag:AddTag("Unit", "HasMP", {
|
||||
alias = "Boolean(MaxMP(unit=unit) > 0)",
|
||||
alias = "Boolean(MaxMP(unit=unit, type=type) > 0)",
|
||||
arg = {
|
||||
'unit', 'string;undef', 'player'
|
||||
'unit', 'string;undef', 'player',
|
||||
'type', 'string;undef', '@undef',
|
||||
},
|
||||
doc = L["Return True if unit has any power type at all"],
|
||||
example = ('[HasMP] => %q; [HasMP] => ""'):format(L["True"]),
|
||||
@ -423,7 +489,6 @@ DogTag:AddTag("Unit", "PowerColor", {
|
||||
})
|
||||
|
||||
|
||||
local wow_501 = select(4, GetBuildInfo()) >= 50100
|
||||
local specialPowers = {
|
||||
{
|
||||
class = "WARLOCK",
|
||||
@ -448,7 +513,7 @@ local specialPowers = {
|
||||
class = "MONK",
|
||||
tag = "Chi",
|
||||
arg2 = SPELL_POWER_CHI or SPELL_POWER_LIGHT_FORCE,
|
||||
eventPowerIdentifier = wow_501 and "CHI" or "LIGHT_FORCE",
|
||||
eventPowerIdentifier = SPELL_POWER_CHI and "CHI" or "LIGHT_FORCE",
|
||||
},
|
||||
}
|
||||
if not wow_700 then -- Parnic: shadow orbs are no more in 7.0
|
||||
|
@ -1,5 +1,5 @@
|
||||
local MAJOR_VERSION = "LibDogTag-Unit-3.0"
|
||||
local MINOR_VERSION = 90000 + (tonumber(("@file-date-integer@"):match("%d+")) or 33333333333333)
|
||||
local MINOR_VERSION = tonumber(("@project-date-integer@"):match("%d+")) or 33333333333333
|
||||
|
||||
if MINOR_VERSION > _G.DogTag_Unit_MINOR_VERSION then
|
||||
_G.DogTag_Unit_MINOR_VERSION = MINOR_VERSION
|
||||
@ -25,7 +25,7 @@ local function formatMinMax(min, max)
|
||||
end
|
||||
|
||||
local found = false
|
||||
DogTag:AddAddonFinder("Unit", "LibStub", "LibRangeCheck-2.0", function(RangeCheckLib)
|
||||
DogTag:AddAddonFinder("Unit", "LibStub", "LibRangeCheck-3.0", function(RangeCheckLib)
|
||||
found = true
|
||||
function MinRange_func(unit)
|
||||
return (RangeCheckLib:getRange(unit))
|
||||
|
@ -1,5 +1,5 @@
|
||||
local MAJOR_VERSION = "LibDogTag-Unit-3.0"
|
||||
local MINOR_VERSION = 90000 + (tonumber(("@file-date-integer@"):match("%d+")) or 33333333333333)
|
||||
local MINOR_VERSION = tonumber(("@project-date-integer@"):match("%d+")) or 33333333333333
|
||||
|
||||
if MINOR_VERSION > _G.DogTag_Unit_MINOR_VERSION then
|
||||
_G.DogTag_Unit_MINOR_VERSION = MINOR_VERSION
|
||||
@ -7,15 +7,61 @@ end
|
||||
|
||||
local _G, coroutine = _G, coroutine
|
||||
local wrap, yield = coroutine.wrap, coroutine.yield
|
||||
local GetWatchedFactionInfo, GetNumFactions, GetFactionInfo, ExpandFactionHeader, CollapseFactionHeader =
|
||||
GetWatchedFactionInfo, GetNumFactions, GetFactionInfo, ExpandFactionHeader, CollapseFactionHeader
|
||||
|
||||
local GetWatchedFactionInfo = C_Reputation and C_Reputation.GetWatchedFactionData and function()
|
||||
local data = C_Reputation.GetWatchedFactionData()
|
||||
return data.name, data.reaction, data.currentReactionThreshold, data.nextReactionThreshold, data.currentStanding
|
||||
end or _G.GetWatchedFactionInfo
|
||||
|
||||
DogTag_Unit_funcs[#DogTag_Unit_funcs+1] = function(DogTag_Unit, DogTag)
|
||||
|
||||
local L = DogTag_Unit.L
|
||||
|
||||
local IterateFactions, TerminateIterateFactions
|
||||
do
|
||||
if C_Reputation and C_Reputation.GetNumFactions then
|
||||
local GetNumFactions = C_Reputation.GetNumFactions
|
||||
local GetFactionDataByIndex = C_Reputation.GetFactionDataByIndex
|
||||
local ExpandFactionHeader = C_Reputation.ExpandFactionHeader
|
||||
local CollapseFactionHeader = C_Reputation.CollapseFactionHeader
|
||||
|
||||
local currentOpenHeader
|
||||
local function iter()
|
||||
for i = 1, GetNumFactions() do
|
||||
local data = GetFactionDataByIndex(i)
|
||||
if data then
|
||||
if data.isHeader == 1 then
|
||||
if data.isCollapsed == 1 then
|
||||
local NumFactions = GetNumFactions()
|
||||
ExpandFactionHeader(i)
|
||||
currentOpenHeader = i
|
||||
NumFactions = GetNumFactions() - NumFactions
|
||||
for j = i+1, i+NumFactions do
|
||||
yield(GetFactionInfo(j))
|
||||
end
|
||||
CollapseFactionHeader(i)
|
||||
currentOpenHeader = nil
|
||||
end
|
||||
else
|
||||
yield(data.name, data.description, data.reaction, data.currentReactionThreshold, data.nextReactionThreshold, data.currentStanding)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
function TerminateIterateFactions()
|
||||
if currentOpenHeader then
|
||||
CollapseFactionHeader(currentOpenHeader)
|
||||
currentOpenHeader = nil
|
||||
end
|
||||
end
|
||||
|
||||
function IterateFactions()
|
||||
currentOpenHeader = nil
|
||||
return wrap(iter)
|
||||
end
|
||||
else
|
||||
local GetNumFactions, GetFactionInfo, ExpandFactionHeader, CollapseFactionHeader =
|
||||
GetNumFactions, GetFactionInfo, ExpandFactionHeader, CollapseFactionHeader
|
||||
|
||||
local currentOpenHeader
|
||||
local function iter()
|
||||
for i = 1, GetNumFactions() do
|
||||
@ -49,7 +95,7 @@ do
|
||||
return wrap(iter)
|
||||
end
|
||||
end
|
||||
DogTag.IterateFactions = IterateFactions
|
||||
DogTag_Unit.IterateFactions = IterateFactions
|
||||
|
||||
DogTag:AddTag("Unit", "Reputation", {
|
||||
code = function(faction)
|
||||
|
@ -1,5 +1,5 @@
|
||||
local MAJOR_VERSION = "LibDogTag-Unit-3.0"
|
||||
local MINOR_VERSION = 90000 + (tonumber(("@file-date-integer@"):match("%d+")) or 33333333333333)
|
||||
local MINOR_VERSION = tonumber(("@project-date-integer@"):match("%d+")) or 33333333333333
|
||||
|
||||
if MINOR_VERSION > _G.DogTag_Unit_MINOR_VERSION then
|
||||
_G.DogTag_Unit_MINOR_VERSION = MINOR_VERSION
|
||||
@ -12,6 +12,8 @@ local UnitExists, UnitGUID, UnitAffectingCombat, UnitIsAFK, UnitIsDeadOrGhost, U
|
||||
UnitExists, UnitGUID, UnitAffectingCombat, UnitIsAFK, UnitIsDeadOrGhost, UnitIsGhost, UnitIsDead, UnitIsDND, UnitIsPVP, UnitIsPVPFreeForAll
|
||||
local GetNumRaidMembers, GetNumPartyMembers, GetPetHappiness, GetRaidTargetIndex, UnitIsTapped, GetBindingText, GetBindingKey, GetRaidRosterInfo =
|
||||
GetNumRaidMembers, GetNumPartyMembers, GetPetHappiness, GetRaidTargetIndex, UnitIsTapped, GetBindingText, GetBindingKey, GetRaidRosterInfo
|
||||
local UnitIsGroupLeader, GetNumGroupMembers =
|
||||
UnitIsGroupLeader, GetNumGroupMembers
|
||||
local UnitName, UnitInRaid, UnitFactionGroup, GetPVPTimer, IsPVPTimerRunning, GetSpellInfo, IsResting =
|
||||
UnitName, UnitInRaid, UnitFactionGroup, GetPVPTimer, IsPVPTimerRunning, GetSpellInfo, IsResting
|
||||
|
||||
@ -24,29 +26,15 @@ local offlineTimes = {}
|
||||
local afkTimes = {}
|
||||
local deadTimes = {}
|
||||
|
||||
-- Parnic: support for cataclysm; Divine Intervention was removed
|
||||
local wow_ver = select(4, GetBuildInfo())
|
||||
local wow_classic = WOW_PROJECT_ID and WOW_PROJECT_ID == WOW_PROJECT_CLASSIC
|
||||
local wow_400 = wow_ver >= 40000
|
||||
local wow_500 = wow_ver >= 50000
|
||||
local wow_600 = wow_ver >= 60000
|
||||
local wow_700 = wow_ver >= 70000
|
||||
local petHappinessEvent = "UNIT_POWER_UPDATE"
|
||||
local partyChangedEvent = "PARTY_MEMBERS_CHANGED"
|
||||
if wow_500 or wow_classic then
|
||||
|
||||
if UnitIsGroupLeader then
|
||||
UnitIsPartyLeader = UnitIsGroupLeader
|
||||
partyChangedEvent = "GROUP_ROSTER_UPDATE"
|
||||
end
|
||||
|
||||
-- Parnic: pet happiness removed in 4.1
|
||||
local wow_401 = wow_ver >= 40100
|
||||
-- ...and back in Classic
|
||||
if wow_classic then
|
||||
petHappinessEvent = "UNIT_HAPPINESS"
|
||||
end
|
||||
|
||||
-- Parnic: GetNumRaidMembers/GetNumPartyMembers removed in 6.0
|
||||
if wow_600 or wow_classic then
|
||||
if GetNumGroupMembers then
|
||||
GetNumRaidMembers = GetNumGroupMembers
|
||||
GetNumPartyMembers = GetNumGroupMembers
|
||||
end
|
||||
@ -63,14 +51,14 @@ _G.iterateGroupMembers = iterateGroupMembers
|
||||
local tmp = {}
|
||||
local function PARTY_MEMBERS_CHANGED(event)
|
||||
local prefix, min, max = "raid", 1, 0
|
||||
if wow_500 then
|
||||
if GetNumGroupMembers then
|
||||
max = GetNumGroupMembers()
|
||||
else
|
||||
max = GetNumRaidMembers()
|
||||
end
|
||||
if wow_500 and max <= 5 or (not wow_500 and max == 0) then
|
||||
if GetNumGroupMembers and max <= 5 or (not GetNumGroupMembers and max == 0) then
|
||||
prefix, min = "party", 0
|
||||
if not wow_500 then
|
||||
if not GetNumGroupMembers then
|
||||
max = GetNumPartyMembers()
|
||||
end
|
||||
end
|
||||
@ -156,54 +144,65 @@ DogTag:AddAddonFinder("Unit", "_G", "CT_RAOptions_UpdateMTs", function(v)
|
||||
end)
|
||||
end)
|
||||
|
||||
local first = true
|
||||
DogTag:AddTimerHandler("Unit", function(currentTime, num)
|
||||
if first then
|
||||
first = false
|
||||
PARTY_MEMBERS_CHANGED()
|
||||
end
|
||||
for guid in pairs(offlineTimes) do
|
||||
for unit in DogTag_Unit.IterateUnitsWithGUID(guid) do
|
||||
DogTag:FireEvent("OfflineDuration", unit)
|
||||
end
|
||||
end
|
||||
for unit, guid in iterateGroupMembers() do
|
||||
if UnitIsDeadOrGhost(unit) then
|
||||
if not deadTimes[guid] then
|
||||
deadTimes[guid] = GetTime()
|
||||
end
|
||||
else
|
||||
if deadTimes[guid] then
|
||||
deadTimes[guid] = nil
|
||||
for unit in DogTag_Unit.IterateUnitsWithGUID(guid) do
|
||||
DogTag:FireEvent("DeadDuration", unit)
|
||||
end
|
||||
end
|
||||
end
|
||||
local durationEventNames = {
|
||||
OfflineDuration = true,
|
||||
DeadDuration = true,
|
||||
AFKDuration = true,
|
||||
}
|
||||
local durationEventsAreSetup = false
|
||||
DogTag:AddEventHandler("Unit", "EventRequested", function(_, event)
|
||||
if not durationEventNames[event] or durationEventsAreSetup then return end
|
||||
durationEventsAreSetup = true
|
||||
|
||||
if UnitIsAFK(unit) then
|
||||
if not afkTimes[guid] then
|
||||
afkTimes[guid] = GetTime()
|
||||
local first = true
|
||||
DogTag:AddTimerHandler("Unit", function(currentTime, num)
|
||||
if first then
|
||||
first = false
|
||||
PARTY_MEMBERS_CHANGED()
|
||||
end
|
||||
for guid in pairs(offlineTimes) do
|
||||
for unit in DogTag_Unit.IterateUnitsWithGUID(guid) do
|
||||
DogTag:FireEvent("OfflineDuration", unit)
|
||||
end
|
||||
else
|
||||
if afkTimes[guid] then
|
||||
afkTimes[guid] = nil
|
||||
for unit in DogTag_Unit.IterateUnitsWithGUID(guid) do
|
||||
DogTag:FireEvent("AFKDuration", unit)
|
||||
end
|
||||
for unit, guid in iterateGroupMembers() do
|
||||
if UnitIsDeadOrGhost(unit) then
|
||||
if not deadTimes[guid] then
|
||||
deadTimes[guid] = GetTime()
|
||||
end
|
||||
else
|
||||
if deadTimes[guid] then
|
||||
deadTimes[guid] = nil
|
||||
for unit in DogTag_Unit.IterateUnitsWithGUID(guid) do
|
||||
DogTag:FireEvent("DeadDuration", unit)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if UnitIsAFK(unit) then
|
||||
if not afkTimes[guid] then
|
||||
afkTimes[guid] = GetTime()
|
||||
end
|
||||
else
|
||||
if afkTimes[guid] then
|
||||
afkTimes[guid] = nil
|
||||
for unit in DogTag_Unit.IterateUnitsWithGUID(guid) do
|
||||
DogTag:FireEvent("AFKDuration", unit)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
for guid in pairs(deadTimes) do
|
||||
for unit in DogTag_Unit.IterateUnitsWithGUID(guid) do
|
||||
DogTag:FireEvent("DeadDuration", unit)
|
||||
for guid in pairs(deadTimes) do
|
||||
for unit in DogTag_Unit.IterateUnitsWithGUID(guid) do
|
||||
DogTag:FireEvent("DeadDuration", unit)
|
||||
end
|
||||
end
|
||||
end
|
||||
for guid in pairs(afkTimes) do
|
||||
for unit in DogTag_Unit.IterateUnitsWithGUID(guid) do
|
||||
DogTag:FireEvent("AFKDuration", unit)
|
||||
for guid in pairs(afkTimes) do
|
||||
for unit in DogTag_Unit.IterateUnitsWithGUID(guid) do
|
||||
DogTag:FireEvent("AFKDuration", unit)
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
DogTag:AddTag("Unit", "OfflineDuration", {
|
||||
@ -457,13 +456,13 @@ DogTag:AddTag("Unit", "IsFeignedDeath", {
|
||||
})
|
||||
|
||||
-- Parnic: pet happiness removed in 4.1
|
||||
if not wow_401 then
|
||||
if GetPetHappiness then
|
||||
DogTag:AddTag("Unit", "HappyNum", {
|
||||
code = function()
|
||||
return GetPetHappiness() or 0
|
||||
end,
|
||||
ret = "number",
|
||||
events = petHappinessEvent,
|
||||
events = "UNIT_HAPPINESS",
|
||||
doc = L["Return the happiness number of your pet"],
|
||||
example = '[HappyNum] => "3"',
|
||||
category = L["Status"]
|
||||
@ -474,7 +473,7 @@ DogTag:AddTag("Unit", "HappyText", {
|
||||
return _G["PET_HAPPINESS" .. (GetPetHappiness() or 0)]
|
||||
end,
|
||||
ret = "string;nil",
|
||||
events = petHappinessEvent,
|
||||
events = "UNIT_HAPPINESS",
|
||||
doc = L["Return a description of how happy your pet is"],
|
||||
example = ('[HappyText] => %q'):format(_G.PET_HAPPINESS3),
|
||||
category = L["Status"]
|
||||
@ -497,7 +496,7 @@ DogTag:AddTag("Unit", "HappyIcon", {
|
||||
'unhappy', 'string', 'B(',
|
||||
},
|
||||
ret = "string;nil",
|
||||
events = petHappinessEvent,
|
||||
events = "UNIT_HAPPINESS",
|
||||
doc = L["Return an icon representative of how happy your pet is"],
|
||||
example = ('[HappyIcon] => ":D"; [HappyIcon] => ":I"; [HappyIcon] => "B("'),
|
||||
category = L["Status"]
|
||||
@ -524,7 +523,7 @@ DogTag:AddTag("Unit", "RaidIcon", {
|
||||
category = L["Status"]
|
||||
})
|
||||
|
||||
if wow_700 or wow_classic then
|
||||
if UnitIsTapDenied then
|
||||
DogTag:AddTag("Unit", "IsNotTappableByMe", {
|
||||
code = UnitIsTapDenied,
|
||||
arg = {
|
||||
@ -928,14 +927,14 @@ DogTag:AddTag("Unit", "StatusColor", {
|
||||
'unit', 'string;undef', 'player'
|
||||
},
|
||||
ret = "string;nil",
|
||||
events = "DeadDuration#$unit",
|
||||
events = "DeadDuration#$unit;OfflineDuration#$unit",
|
||||
doc = L["Return the color or wrap value with the color associated with unit's current status"],
|
||||
example = '["Hello":StatusColor] => "|cff7f7f7fHello|r"; [StatusColor "Hello")] => "|cff7f7f7fHello"',
|
||||
category = L["Status"]
|
||||
})
|
||||
|
||||
-- Parnic: pet happiness removed in 4.1
|
||||
if not wow_401 then
|
||||
if GetPetHappiness then
|
||||
DogTag:AddTag("Unit", "HappyColor", {
|
||||
code = function(value)
|
||||
local x = GetPetHappiness()
|
||||
@ -961,7 +960,7 @@ DogTag:AddTag("Unit", "HappyColor", {
|
||||
'value', 'string;undef', "@undef",
|
||||
},
|
||||
ret = "nil;string",
|
||||
events = petHappinessEvent,
|
||||
events = "UNIT_HAPPINESS",
|
||||
doc = L["Return the color or wrap value with the color associated with your pet's happiness"],
|
||||
example = '["Hello":HappyColor] => "|cff00ff00Hello|r"; [HappyColor "Hello"] => "|cff00ff00Hello"',
|
||||
category = L["Status"]
|
||||
@ -969,8 +968,8 @@ DogTag:AddTag("Unit", "HappyColor", {
|
||||
end
|
||||
|
||||
-- Parnic: DI removed in Cataclysm
|
||||
if not wow_400 then
|
||||
local DIVINE_INTERVENTION = GetSpellInfo(19752)
|
||||
local DIVINE_INTERVENTION = (GetSpellInfo or C_Spell.GetSpellName)(19752)
|
||||
if DIVINE_INTERVENTION then
|
||||
DogTag:AddTag("Unit", "Status", {
|
||||
alias = ("Offline(unit=unit) or (HasDivineIntervention(unit=unit) ? %q) or (IsFeignedDeath(unit=unit) ? %q) or [if Dead(unit=unit) then ((HasSoulstone(unit=unit) ? %q) or Dead(unit=unit))]"):format(DIVINE_INTERVENTION, L["Feigned Death"], L["Soulstoned"]),
|
||||
arg = {
|
||||
|
@ -1,21 +1,20 @@
|
||||
local MAJOR_VERSION = "LibDogTag-Unit-3.0"
|
||||
local MINOR_VERSION = 90000 + (tonumber(("@file-date-integer@"):match("%d+")) or 33333333333333)
|
||||
local MINOR_VERSION = tonumber(("@project-date-integer@"):match("%d+")) or 33333333333333
|
||||
|
||||
if MINOR_VERSION > _G.DogTag_Unit_MINOR_VERSION then
|
||||
_G.DogTag_Unit_MINOR_VERSION = MINOR_VERSION
|
||||
end
|
||||
|
||||
local wow_ver = select(4, GetBuildInfo())
|
||||
local wow_500 = wow_ver >= 50000
|
||||
|
||||
local _G, table, setmetatable, rawget = _G, table, setmetatable, rawget
|
||||
local UnitName, GetActiveTalentGroup, GetTalentTabInfo, UnitIsPlayer, GetNumTalentTabs =
|
||||
UnitName, GetActiveTalentGroup, GetTalentTabInfo, UnitIsPlayer, GetNumTalentTabs
|
||||
local UnitName, GetActiveTalentGroup, GetTalentTabInfo, UnitIsPlayer =
|
||||
UnitName, GetActiveTalentGroup, GetTalentTabInfo, UnitIsPlayer
|
||||
local GetSpecialization, GetSpecializationInfo
|
||||
= GetSpecialization, GetSpecializationInfo
|
||||
|
||||
if wow_500 then
|
||||
if GetActiveSpecGroup then
|
||||
GetActiveTalentGroup = GetActiveSpecGroup
|
||||
GetTalentTabInfo = GetSpecializationInfo
|
||||
GetNumTalentTabs = GetNumSpecializations
|
||||
end
|
||||
|
||||
DogTag_Unit_funcs[#DogTag_Unit_funcs+1] = function(DogTag_Unit, DogTag)
|
||||
@ -53,7 +52,7 @@ DogTag:AddAddonFinder("Unit", "LibStub", "LibTalentQuery-1.0", function(LibTalen
|
||||
LibTalentQuery.RegisterCallback(DogTag_Unit, "TalentQuery_Ready", function(event, name, realm, unitId)
|
||||
local fullName = realm and name .. "-" .. realm or name
|
||||
|
||||
if wow_500 then
|
||||
if GetInspectSpecialization then
|
||||
local inspectSpec = GetInspectSpecialization(unitId)
|
||||
local roleById = GetSpecializationInfoByID(inspectSpec)
|
||||
if roleById ~= nil then
|
||||
@ -80,7 +79,7 @@ DogTag:AddAddonFinder("Unit", "LibStub", "LibTalentQuery-1.0", function(LibTalen
|
||||
local lastUnit
|
||||
local function func(self, name)
|
||||
if name == playerName then
|
||||
if wow_500 then
|
||||
if GetSpecialization then
|
||||
talentSpecNames[playerName] = select(2, GetSpecializationInfo(GetSpecialization()))
|
||||
return
|
||||
end
|
||||
|
@ -1,5 +1,5 @@
|
||||
local MAJOR_VERSION = "LibDogTag-Unit-3.0"
|
||||
local MINOR_VERSION = 90000 + (tonumber(("@file-date-integer@"):match("%d+")) or 33333333333333)
|
||||
local MINOR_VERSION = tonumber(("@project-date-integer@"):match("%d+")) or 33333333333333
|
||||
|
||||
if MINOR_VERSION > _G.DogTag_Unit_MINOR_VERSION then
|
||||
_G.DogTag_Unit_MINOR_VERSION = MINOR_VERSION
|
||||
@ -13,18 +13,10 @@ DogTag_Unit_funcs[#DogTag_Unit_funcs+1] = function(DogTag_Unit, DogTag)
|
||||
|
||||
local L = DogTag_Unit.L
|
||||
|
||||
-- Unfortunatelly there is no way to determine the pair mob/unit who's threat changed,
|
||||
-- so we just fire Threat event for now to update all tags.
|
||||
|
||||
-- Fired when mob's threat list changed
|
||||
DogTag:AddEventHandler( "Unit", "UNIT_THREAT_LIST_UPDATE", function( event, mobId )
|
||||
DogTag:FireEvent( "Threat" )
|
||||
end )
|
||||
|
||||
-- Fired when unit's threat situation changed, not on raw threat value changes
|
||||
DogTag:AddEventHandler( "Unit", "UNIT_THREAT_SITUATION_UPDATE", function( event, unitId )
|
||||
DogTag:FireEvent( "Threat" )
|
||||
end )
|
||||
-- UNIT_THREAT_LIST_UPDATE fires with the unitID of the hostile unit who's threat info changed.
|
||||
-- UNIT_THREAT_SITUATION_UPDATE fires with the unitID of a unit that has just begun or just ceased tanking something.
|
||||
local threatEvents = "UNIT_THREAT_LIST_UPDATE#$unit;UNIT_THREAT_SITUATION_UPDATE#$unit;UNIT_THREAT_SITUATION_UPDATE#player"
|
||||
|
||||
DogTag:AddTag( "Unit", "IsTanking", {
|
||||
code = function( unit )
|
||||
@ -42,7 +34,7 @@ DogTag:AddTag( "Unit", "IsTanking", {
|
||||
'unit', 'string;undef', 'player'
|
||||
},
|
||||
ret = "nil;number",
|
||||
events = "Threat",
|
||||
events = threatEvents,
|
||||
doc = L["Return True if you are the primary tank of the enemy unit or if friendly unit is the primary tank of your target."],
|
||||
example = ('[IsTanking] => %q; [IsTanking] => ""'):format(L["True"]),
|
||||
category = L["Threat"]
|
||||
@ -64,7 +56,7 @@ DogTag:AddTag( "Unit", "ThreatStatus", {
|
||||
'unit', 'string;undef', 'player'
|
||||
},
|
||||
ret = "nil;number",
|
||||
events = "Threat",
|
||||
events = threatEvents,
|
||||
doc = L["Return your threat status for enemy unit or threat status of friendly unit for your target as integer number (3 = securely tanking, 2 = insecurely tanking, 1 = not tanking but higher threat than tank, 0 = not tanking and lower threat than tank)."],
|
||||
example = '[ThreatStatus] => "2"; [ThreatStatus] => ""',
|
||||
category = L["Threat"]
|
||||
@ -125,6 +117,7 @@ DogTag:AddTag( "Unit", "UnitThreatStatusColor", {
|
||||
'unit', 'string;undef', 'player'
|
||||
},
|
||||
ret = "string;nil",
|
||||
events = threatEvents,
|
||||
doc = L["Return the color or wrap value with the color associated with unit's threat status."],
|
||||
example = '["100%":UnitThreatStatusColor] => "|cffff0000100%|r"; [UnitThreatStatusColor( "50%" )] => "|cffffffff50%"',
|
||||
category = L["Threat"]
|
||||
@ -146,7 +139,7 @@ DogTag:AddTag( "Unit", "PercentThreat", {
|
||||
'unit', 'string;undef', 'player'
|
||||
},
|
||||
ret = "nil;number",
|
||||
events = "Threat",
|
||||
events = threatEvents,
|
||||
doc = L["Return the current threat that you have against enemy unit or that friendly unit has against your target as a percentage of the amount required to pull aggro, scaled according to the range from the mob."],
|
||||
example = '[PercentThreat] => "50"',
|
||||
category = L["Threat"]
|
||||
@ -168,7 +161,7 @@ DogTag:AddTag( "Unit", "RawPercentThreat", {
|
||||
'unit', 'string;undef', 'player'
|
||||
},
|
||||
ret = "nil;number",
|
||||
events = "Threat",
|
||||
events = threatEvents,
|
||||
doc = L["Return the current threat that you have against enemy unit or that friendly unit has against your target as a percentage of tank's current threat."],
|
||||
example = '[RawPercentThreat] => "115"',
|
||||
category = L["Threat"]
|
||||
|
@ -1,5 +1,5 @@
|
||||
local MAJOR_VERSION = "LibDogTag-Unit-3.0"
|
||||
local MINOR_VERSION = 90000 + (tonumber(("@file-date-integer@"):match("%d+")) or 33333333333333)
|
||||
local MINOR_VERSION = tonumber(("@project-date-integer@"):match("%d+")) or 33333333333333
|
||||
|
||||
if MINOR_VERSION > _G.DogTag_Unit_MINOR_VERSION then
|
||||
_G.DogTag_Unit_MINOR_VERSION = MINOR_VERSION
|
||||
@ -11,30 +11,52 @@ local UnitName, UnitFactionGroup, UnitPlayerControlled, UnitIsPlayer, UnitIsVisi
|
||||
local InCombatLockdown, GetNumFactions, GetFactionInfo, ExpandFactionHeader, CollapseFactionHeader, GetGuildInfo =
|
||||
InCombatLockdown, GetNumFactions, GetFactionInfo, ExpandFactionHeader, CollapseFactionHeader, GetGuildInfo
|
||||
|
||||
local GetClassicExpansionLevel = GetClassicExpansionLevel
|
||||
|
||||
DogTag_Unit_funcs[#DogTag_Unit_funcs+1] = function(DogTag_Unit, DogTag)
|
||||
|
||||
local L = DogTag_Unit.L
|
||||
|
||||
local tt = CreateFrame("GameTooltip")
|
||||
tt:SetOwner(UIParent, "ANCHOR_NONE")
|
||||
tt.left = {}
|
||||
tt.right = {}
|
||||
for i = 1, 30 do
|
||||
tt.left[i] = tt:CreateFontString()
|
||||
tt.left[i]:SetFontObject(GameFontNormal)
|
||||
tt.right[i] = tt:CreateFontString()
|
||||
tt.right[i]:SetFontObject(GameFontNormal)
|
||||
tt:AddFontStrings(tt.left[i], tt.right[i])
|
||||
local tt
|
||||
if not C_TooltipInfo then
|
||||
tt = CreateFrame("GameTooltip", "LibDogTag-Unit-3.0-"..MAJOR_VERSION.."."..MINOR_VERSION)
|
||||
tt:SetOwner(UIParent, "ANCHOR_NONE")
|
||||
tt.left = {}
|
||||
tt.right = {}
|
||||
for i = 1, 30 do
|
||||
tt.left[i] = tt:CreateFontString()
|
||||
tt.left[i]:SetFontObject(GameFontNormal)
|
||||
tt.right[i] = tt:CreateFontString()
|
||||
tt.right[i]:SetFontObject(GameFontNormal)
|
||||
tt:AddFontStrings(tt.left[i], tt.right[i])
|
||||
end
|
||||
end
|
||||
local nextTime = 0
|
||||
local lastName
|
||||
local lastUnit
|
||||
local function updateTT(unit)
|
||||
if C_TooltipInfo then
|
||||
local tooltipData = C_TooltipInfo.GetUnit(unit)
|
||||
if TooltipUtil.SurfaceArgs then
|
||||
TooltipUtil.SurfaceArgs(tooltipData)
|
||||
for _, line in ipairs(tooltipData.lines) do
|
||||
TooltipUtil.SurfaceArgs(line)
|
||||
end
|
||||
end
|
||||
|
||||
return tooltipData
|
||||
end
|
||||
|
||||
local name = UnitName(unit)
|
||||
local time = GetTime()
|
||||
if lastUnit == unit and lastName == name and nextTime < time then
|
||||
return
|
||||
end
|
||||
-- Parnic: temp: don't do any of this while Wrath Classic is crashing in these functions under certain conditions.
|
||||
-- https://github.com/parnic/LibDogTag-Unit-3.0/issues/8
|
||||
if InCombatLockdown() and GetClassicExpansionLevel and GetClassicExpansionLevel() == LE_EXPANSION_WRATH_OF_THE_LICH_KING then
|
||||
return
|
||||
end
|
||||
lastUnit = unit
|
||||
lastName = name
|
||||
nextTime = time + 1
|
||||
@ -45,13 +67,38 @@ local function updateTT(unit)
|
||||
end
|
||||
end
|
||||
|
||||
-- tooltips can contain any data, including quest info, so check for the type of the line before using it, if present
|
||||
local function TooltipLineCouldBeGuild(line)
|
||||
if not line then
|
||||
return false
|
||||
end
|
||||
if not Enum or not Enum.TooltipDataLineType then
|
||||
return false
|
||||
end
|
||||
|
||||
return line.type == Enum.TooltipDataLineType.None
|
||||
end
|
||||
|
||||
-- there's no special flag for factions vs guilds as of this writing, but if that gets added, this will make things easier
|
||||
local function TooltipLineCouldBeFaction(line)
|
||||
return TooltipLineCouldBeGuild(line)
|
||||
end
|
||||
|
||||
local LEVEL_start = "^" .. (type(LEVEL) == "string" and LEVEL or "Level")
|
||||
local function FigureNPCGuild(unit)
|
||||
updateTT(unit)
|
||||
local left_2 = tt.left[2]:GetText()
|
||||
local info = updateTT(unit)
|
||||
local left_2
|
||||
if info then
|
||||
left_2 = info.lines[2] and info.lines[2].leftText or nil
|
||||
elseif tt then
|
||||
left_2 = tt.left[2] and tt.left[2]:GetText() or nil
|
||||
end
|
||||
if not left_2 or left_2:find(LEVEL_start) then
|
||||
return nil
|
||||
end
|
||||
if info and not TooltipLineCouldBeGuild(info.lines[2]) then
|
||||
return nil
|
||||
end
|
||||
return left_2
|
||||
end
|
||||
|
||||
@ -64,14 +111,27 @@ local function FigureFaction(unit)
|
||||
return faction
|
||||
end
|
||||
|
||||
updateTT(unit)
|
||||
local left_2 = tt.left[2]:GetText()
|
||||
local left_3 = tt.left[3]:GetText()
|
||||
local info = updateTT(unit)
|
||||
local left_2
|
||||
local left_3
|
||||
if info then
|
||||
left_2 = info.lines[2] and info.lines[2].leftText or nil
|
||||
left_3 = info.lines[3] and info.lines[3].leftText or nil
|
||||
elseif tt then
|
||||
left_2 = tt.left[2] and tt.left[2]:GetText() or nil
|
||||
left_3 = tt.left[3] and tt.left[3]:GetText() or nil
|
||||
end
|
||||
if not left_2 or not left_3 then
|
||||
return faction
|
||||
end
|
||||
local hasGuild = not left_2:find(LEVEL_start)
|
||||
local factionText = not hasGuild and left_3 or tt.left[4]:GetText()
|
||||
local left_4
|
||||
if info and info.lines[4] then
|
||||
left_4 = info.lines[4].leftText
|
||||
elseif tt and tt.left[4] then
|
||||
left_4 = tt.left[4]:GetText()
|
||||
end
|
||||
local factionText = not hasGuild and left_3 or left_4
|
||||
if factionText == PVP then
|
||||
return faction
|
||||
end
|
||||
@ -87,22 +147,45 @@ local function FigureZone(unit)
|
||||
if not UnitIsConnected(unit) then
|
||||
return nil
|
||||
end
|
||||
updateTT(unit)
|
||||
local left_2 = tt.left[2]:GetText()
|
||||
local left_3 = tt.left[3]:GetText()
|
||||
local info = updateTT(unit)
|
||||
local left_2
|
||||
local left_3
|
||||
local left_4
|
||||
local left_5
|
||||
if info then
|
||||
left_2 = info.lines[2] and info.lines[2].leftText or nil
|
||||
left_3 = info.lines[3] and info.lines[3].leftText or nil
|
||||
left_4 = info.lines[4] and info.lines[4].leftText or nil
|
||||
left_5 = info.lines[5] and info.lines[5].leftText or nil
|
||||
elseif tt then
|
||||
left_2 = tt.left[2] and tt.left[2]:GetText() or nil
|
||||
left_3 = tt.left[3] and tt.left[3]:GetText() or nil
|
||||
left_4 = tt.left[4] and tt.left[4]:GetText() or nil
|
||||
left_5 = tt.left[5] and tt.left[5]:GetText() or nil
|
||||
end
|
||||
if not left_2 or not left_3 then
|
||||
return nil
|
||||
end
|
||||
local hasGuild = not left_2:find(LEVEL_start)
|
||||
local factionText = not hasGuild and left_3 or tt.left[4]:GetText()
|
||||
if info and not TooltipLineCouldBeGuild(info.lines[2]) then
|
||||
hasGuild = false
|
||||
end
|
||||
local factionText = not hasGuild and left_3 or left_4
|
||||
if info then
|
||||
if not hasGuild then
|
||||
factionText = TooltipLineCouldBeFaction(info.lines[3]) and left_3 or nil
|
||||
else
|
||||
factionText = TooltipLineCouldBeFaction(info.lines[4]) and left_4 or nil
|
||||
end
|
||||
end
|
||||
if factionText == PVP then
|
||||
factionText = nil
|
||||
end
|
||||
local hasFaction = factionText and not UnitPlayerControlled(unit) and not UnitIsPlayer(unit) and (UnitFactionGroup(unit) or factionList[factionText])
|
||||
if hasGuild and hasFaction then
|
||||
return tt.left[5]:GetText()
|
||||
return left_5
|
||||
elseif hasGuild or hasFaction then
|
||||
return tt.left[4]:GetText()
|
||||
return left_4
|
||||
else
|
||||
return left_3
|
||||
end
|
||||
@ -118,7 +201,7 @@ local function UPDATE_FACTION()
|
||||
return
|
||||
end
|
||||
|
||||
for name in DogTag.IterateFactions() do
|
||||
for name in DogTag_Unit.IterateFactions() do
|
||||
factionList[name] = true
|
||||
end
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
local DOGTAG_MAJOR_VERSION = "LibDogTag-3.0"
|
||||
local MAJOR_VERSION = "LibDogTag-Unit-3.0"
|
||||
local MINOR_VERSION = 90000 + (tonumber(("@file-date-integer@"):match("%d+")) or 33333333333333)
|
||||
local MINOR_VERSION = tonumber(("@project-date-integer@"):match("%d+")) or 33333333333333
|
||||
|
||||
if MINOR_VERSION > _G.DogTag_Unit_MINOR_VERSION then
|
||||
_G.DogTag_Unit_MINOR_VERSION = MINOR_VERSION
|
||||
@ -17,9 +17,11 @@ if not DogTag_Unit then
|
||||
return
|
||||
end
|
||||
|
||||
local DogTag = LibStub:GetLibrary(DOGTAG_MAJOR_VERSION)
|
||||
local DogTag, DogTag_Minor = LibStub:GetLibrary(DOGTAG_MAJOR_VERSION)
|
||||
if not DogTag then
|
||||
error(("Cannot load %s without first loading %s"):format(MAJOR_VERSION, DOGTAG_MAJOR_VERSION))
|
||||
elseif DogTag_Minor < 20210319000000 then
|
||||
error(("%s requires a newer version of %s"):format(MAJOR_VERSION, DOGTAG_MAJOR_VERSION))
|
||||
end
|
||||
|
||||
if oldMinor then
|
||||
|
@ -1,13 +1,12 @@
|
||||
--[[
|
||||
Name: LibDogTag-3.0
|
||||
Revision: $Rev$
|
||||
Author: Cameron Kenneth Knight (ckknight@gmail.com)
|
||||
Website: http://www.wowace.com/
|
||||
Description: A library to provide a markup syntax
|
||||
Name: LibDogTag-Unit-3.0
|
||||
Revision: @project-revision@
|
||||
Website: https://www.wowace.com/projects/libdogtag-unit-3-0
|
||||
Description: A library to provide a markup syntax - unit-specific tags
|
||||
]]
|
||||
|
||||
local MAJOR_VERSION = "LibDogTag-Unit-3.0"
|
||||
local MINOR_VERSION = 90000 + (tonumber(("@file-date-integer@"):match("%d+")) or 33333333333333)
|
||||
local MINOR_VERSION = tonumber(("@project-date-integer@"):match("%d+")) or 33333333333333
|
||||
|
||||
if MINOR_VERSION > _G.DogTag_Unit_MINOR_VERSION then
|
||||
_G.DogTag_Unit_MINOR_VERSION = MINOR_VERSION
|
||||
@ -23,10 +22,9 @@ local L = DogTag_Unit.L
|
||||
local newList = DogTag.newList
|
||||
local del = DogTag.del
|
||||
|
||||
local wow_ver = select(4, GetBuildInfo())
|
||||
local wow_500 = wow_ver >= 50000
|
||||
local PartyChangedEvent = "PARTY_MEMBERS_CHANGED"
|
||||
if wow_500 then
|
||||
if UnitIsGroupLeader then
|
||||
-- Changed in wow 5.0
|
||||
PartyChangedEvent = "GROUP_ROSTER_UPDATE"
|
||||
end
|
||||
|
||||
@ -41,17 +39,30 @@ else
|
||||
frame = CreateFrame("Frame")
|
||||
end
|
||||
DogTag_Unit.frame = frame
|
||||
|
||||
local usedEvents = {}
|
||||
DogTag:AddEventHandler("Unit", "EventRequested", function(_, event)
|
||||
if not usedEvents[event] then
|
||||
usedEvents[event] = true
|
||||
pcall(frame.RegisterEvent, frame, event)
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
local normalUnitsWackyDependents = {}
|
||||
|
||||
local function fireEventForDependents(event, unit, ...)
|
||||
local wackyDependents = normalUnitsWackyDependents[unit]
|
||||
if wackyDependents then
|
||||
for unit in pairs(wackyDependents) do
|
||||
unit = next(wackyDependents, nil)
|
||||
while unit ~= nil do
|
||||
local nextUnit = next(wackyDependents, unit)
|
||||
DogTag:FireEvent(event, unit, ...)
|
||||
unit = nextUnit
|
||||
end
|
||||
end
|
||||
end
|
||||
frame:RegisterAllEvents()
|
||||
|
||||
frame:SetScript("OnEvent", function(this, event, unit, ...)
|
||||
fireEventForDependents(event, unit, ...)
|
||||
if unit == "target" then
|
||||
@ -70,6 +81,13 @@ frame:SetScript("OnEvent", function(this, event, unit, ...)
|
||||
DogTag:FireEvent(event, "party" .. num .. "pet", ...)
|
||||
fireEventForDependents(event, "party" .. num .. "pet", ...)
|
||||
end
|
||||
else
|
||||
-- event must not be a unit event, so we can unregister it
|
||||
-- as the only purpose of this is to replay unit events
|
||||
-- with different unit IDs. AFAIK there are no unit events
|
||||
-- that are ever fired without a unitid, so this shouldn't
|
||||
-- have any false positives.
|
||||
frame:UnregisterEvent(event)
|
||||
end
|
||||
end)
|
||||
|
||||
@ -108,6 +126,10 @@ setmetatable(UnitToLocale, {__index=function(self, unit)
|
||||
local num = unit:match("^boss(%d)$")
|
||||
self[unit] = L["Boss #%d"]:format(num)
|
||||
return self[unit]
|
||||
elseif unit:find("^nameplate%d$") then
|
||||
local num = unit:match("^nameplate(%d)$")
|
||||
self[unit] = L["Nameplate #%d"]:format(num)
|
||||
return self[unit]
|
||||
elseif unit:find("^partypet%d$") then
|
||||
local num = unit:match("^partypet(%d)$")
|
||||
self[unit] = UnitToLocale["party" .. num .. "pet"]
|
||||
@ -128,16 +150,16 @@ setmetatable(UnitToLocale, {__index=function(self, unit)
|
||||
self[unit] = L["%s's target"]:format(self[nonTarget])
|
||||
return self[unit]
|
||||
end})
|
||||
DogTag.UnitToLocale = UnitToLocale
|
||||
DogTag_Unit.UnitToLocale = UnitToLocale
|
||||
|
||||
-- [""] = true added 8/26 by Cybeloras. TellMeWhen icons (which implement DogTag) don't always check a unit, in which case they fall back on "", not "player".
|
||||
-- Falling back on "player" (in TellMeWhen) is counter-intuitive. Falling back on "" doesn't seem to cause any issues.
|
||||
local IsLegitimateUnit = { [""] = true, player = true, target = true, focus = true, pet = true, playerpet = true, mouseover = true, npc = true, NPC = true, vehicle = true }
|
||||
DogTag.IsLegitimateUnit = IsLegitimateUnit
|
||||
DogTag_Unit.IsLegitimateUnit = IsLegitimateUnit
|
||||
local IsNormalUnit = { player = true, target = true, focus = true, pet = true, playerpet = true, mouseover = true }
|
||||
local WACKY_UNITS = { targettarget = true, playertargettarget = true, targettargettarget = true, playertargettargettarget = true, pettarget = true, playerpettarget = true, pettargettarget = true, playerpettargettarget = true }
|
||||
DogTag.IsNormalUnit = IsNormalUnit
|
||||
for i = 1, 4 do
|
||||
DogTag_Unit.IsNormalUnit = IsNormalUnit
|
||||
for i = 1, MAX_PARTY_MEMBERS do
|
||||
IsLegitimateUnit["party" .. i] = true
|
||||
IsLegitimateUnit["partypet" .. i] = true
|
||||
IsLegitimateUnit["party" .. i .. "pet"] = true
|
||||
@ -151,7 +173,7 @@ for i = 1, 4 do
|
||||
WACKY_UNITS["partypet" .. i .. "targettarget"] = true
|
||||
WACKY_UNITS["party" .. i .. "pettargettarget"] = true
|
||||
end
|
||||
for i = 1, 40 do
|
||||
for i = 1, MAX_RAID_MEMBERS do
|
||||
IsLegitimateUnit["raid" .. i] = true
|
||||
IsNormalUnit["raid" .. i] = true
|
||||
IsLegitimateUnit["raidpet" .. i] = true
|
||||
@ -162,6 +184,14 @@ for i = 1, 40 do
|
||||
WACKY_UNITS["raidpet" .. i .. "target"] = true
|
||||
WACKY_UNITS["raid" .. i .. "pettarget"] = true
|
||||
end
|
||||
for i = 1, 40 do
|
||||
-- There is no const for max nameplate units,
|
||||
-- but it currently appears to be 40 based on in-game testing
|
||||
-- (i.e. "pull everything in stockades")
|
||||
-- (at some point in the past it used to be 30).
|
||||
IsLegitimateUnit["nameplate" .. i] = true
|
||||
IsNormalUnit["nameplate" .. i] = true
|
||||
end
|
||||
for i = 1, MAX_BOSS_FRAMES do
|
||||
IsLegitimateUnit["boss" .. i] = true
|
||||
IsNormalUnit["boss" .. i] = true
|
||||
@ -196,6 +226,13 @@ end, __call = function(self, key)
|
||||
return self[key]
|
||||
end})
|
||||
|
||||
-- Setting these on the DogTag lib root for backwards-compat with addons that are peeking at internals, e.g ThreatPlates:
|
||||
-- https://github.com/Backupiseasy/ThreatPlates/blob/79c933e25dbc3bb0b99b63f34eec97d0be9dc64d/Init.lua#L127
|
||||
-- However, they could get nulled out if a newer version of LibDogTag-3.0 is loaded later.
|
||||
DogTag.IsNormalUnit = IsNormalUnit
|
||||
DogTag.IsLegitimateUnit = IsLegitimateUnit
|
||||
DogTag.UnitToLocale = UnitToLocale
|
||||
|
||||
local unitToGUID = {}
|
||||
local guidToUnits = {}
|
||||
local wackyUnitToBestUnit = {}
|
||||
@ -326,7 +363,17 @@ local function searchForNameTag(ast)
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
DogTag:AddCompilationStep("Unit", "start", function(t, ast, kwargTypes, extraKwargs)
|
||||
|
||||
-- Since DogTag_Unit isn't upvalued in the same way that DogTag is
|
||||
-- in the function compilation, we instead copy the functions from DogTag_Unit
|
||||
-- that we need onto DogTag so we can used them in here.
|
||||
-- This copy is necessary on every compilation because if a newer version
|
||||
-- of LibDogTag-3.0 is loaded, it will wipe the DogTag lib object.
|
||||
DogTag.IsLegitimateUnit = DogTag_Unit.IsLegitimateUnit
|
||||
DogTag.UnitToLocale = DogTag_Unit.UnitToLocale
|
||||
|
||||
if kwargTypes["unit"] then
|
||||
t[#t+1] = [=[if not DogTag.IsLegitimateUnit[]=]
|
||||
t[#t+1] = extraKwargs["unit"][1]
|
||||
@ -463,6 +510,16 @@ DogTag:AddEventHandler("Unit", "UNIT_TARGETABLE_CHANGED", function(event, unit)
|
||||
DogTag:FireEvent("UnitChanged", unit)
|
||||
end)
|
||||
|
||||
DogTag:AddEventHandler("Unit", "NAME_PLATE_UNIT_ADDED", function(event, unit)
|
||||
refreshGUID(unit)
|
||||
DogTag:FireEvent("UnitChanged", unit)
|
||||
end)
|
||||
|
||||
DogTag:AddEventHandler("Unit", "NAME_PLATE_UNIT_REMOVED", function(event, unit)
|
||||
refreshGUID(unit)
|
||||
DogTag:FireEvent("UnitChanged", unit)
|
||||
end)
|
||||
|
||||
DogTag:AddEventHandler("Unit", "UNIT_PET", function(event, unit)
|
||||
if unit == "player" then unit = "" end
|
||||
local unit_pet = unit .. "pet"
|
||||
@ -482,14 +539,15 @@ DogTag:AddEventHandler("Unit", "INSTANCE_ENCOUNTER_ENGAGE_UNIT", function(event,
|
||||
end
|
||||
end)
|
||||
|
||||
-- These 4 tables are safe to upvalue from DogTag
|
||||
-- because the same tables are reused across DogTag upgrades:
|
||||
local fsToKwargs = DogTag.fsToKwargs
|
||||
local fsToNSList = DogTag.fsToNSList
|
||||
local fsNeedUpdate = DogTag.fsNeedUpdate
|
||||
local fsNeedQuickUpdate = DogTag.fsNeedQuickUpdate
|
||||
local unpackNamespaceList = DogTag.unpackNamespaceList
|
||||
|
||||
local nsListHasUnit = setmetatable({}, { __index = function(self, key)
|
||||
for _, ns in ipairs(unpackNamespaceList[key]) do
|
||||
for _, ns in ipairs(DogTag.unpackNamespaceList[key]) do
|
||||
if ns == "Unit" then
|
||||
self[key] = true
|
||||
return true
|
||||
@ -499,13 +557,6 @@ local nsListHasUnit = setmetatable({}, { __index = function(self, key)
|
||||
return false
|
||||
end })
|
||||
|
||||
local checkYield = DogTag.checkYield
|
||||
if not checkYield then
|
||||
-- If LibDogTag doesn't include checkYield (old version)
|
||||
-- Then just make checkYield an empty function to prevent errors.
|
||||
checkYield = function() end
|
||||
end
|
||||
|
||||
local nextRefreshGUIDsTime = 0
|
||||
DogTag:AddTimerHandler("Unit", function(num, currentTime)
|
||||
if nextRefreshGUIDsTime > currentTime then
|
||||
@ -524,6 +575,7 @@ DogTag:AddTimerHandler("Unit", function(num, currentTime)
|
||||
DogTag:FireEvent("UnitChanged", "mouseover")
|
||||
end
|
||||
if currentTime >= nextUpdateWackyUnitsTime then
|
||||
local checkYield = DogTag.checkYield
|
||||
for unit in pairs(WACKY_UNITS) do
|
||||
local oldGUID = unitToGUID[unit]
|
||||
refreshGUID(unit)
|
||||
|
@ -1,14 +1,31 @@
|
||||
## Interface: 90001
|
||||
## Interface: 110105
|
||||
## Interface-Retail: 110105
|
||||
## Interface-Classic: 11507
|
||||
## Interface-BCC: 20504
|
||||
## Interface-Wrath: 30403
|
||||
## Interface-Cata: 40402
|
||||
## LoadOnDemand: 1
|
||||
## Title: Lib: DogTag-Unit-3.0
|
||||
## Notes: A library to provide unit-oriented tags to LibDogTag-3.0
|
||||
## Author: ckknight
|
||||
## eMail: ckknight@gmail.com
|
||||
## Author: ckknight, Parnic, cybeloras
|
||||
## eMail: ckknight@gmail.com, parnic@parnic.com
|
||||
## Version: 1.0
|
||||
## X-Category: Library
|
||||
## X-Credits: Shefki, Parnic, Andrew Scott, cybeloras
|
||||
## X-Compatible-With: 11305
|
||||
## X-Credits: Shefki, Parnic, cybeloras
|
||||
## X-Curse-Project-ID: 14282
|
||||
## Dependencies: LibDogTag-3.0
|
||||
## OptionalDeps: LibDruidMana-1.0, RangeCheck-1.0, LibTalentQuery-1.0
|
||||
## Category-enUS: Libraries
|
||||
## Category-deDE: Bibliotheken
|
||||
## Category-esES: Bibliotecas
|
||||
## Category-esMX: Bibliotecas
|
||||
## Category-frFR: Bibliothèques
|
||||
## Category-itIT:
|
||||
## Category-koKR:
|
||||
## Category-ptBR: Bibliotecas
|
||||
## Category-ruRU: Библиотеки
|
||||
## Category-zhCN: 函数库
|
||||
## Category-zhTW: 函式庫
|
||||
## Group: LibDogTag
|
||||
|
||||
lib.xml
|
||||
|
@ -1,5 +1,5 @@
|
||||
local MAJOR_VERSION = "LibDogTag-Unit-3.0"
|
||||
local MINOR_VERSION = 90000 + (tonumber(("@file-date-integer@"):match("%d+")) or 33333333333333)
|
||||
local MINOR_VERSION = tonumber(("@project-date-integer@"):match("%d+")) or 33333333333333
|
||||
|
||||
_G.DogTag_Unit_MINOR_VERSION = MINOR_VERSION
|
||||
|
||||
@ -86,6 +86,7 @@ DogTag_Unit.L = {
|
||||
["Party member #%d"] = "Party member #%d",
|
||||
["Raid member #%d"] = "Raid member #%d",
|
||||
["Boss #%d"] = "Boss #%d",
|
||||
["Nameplate #%d"] = "Nameplate #%d",
|
||||
["Arena enemy #%d"] = "Arena enemy #%d",
|
||||
|
||||
-- classifications
|
||||
|
@ -1,5 +1,5 @@
|
||||
local MAJOR_VERSION = "LibDogTag-Unit-3.0"
|
||||
local MINOR_VERSION = 90000 + (tonumber(("@file-date-integer@"):match("%d+")) or 33333333333333)
|
||||
local MINOR_VERSION = tonumber(("@project-date-integer@"):match("%d+")) or 33333333333333
|
||||
|
||||
if MINOR_VERSION > _G.DogTag_Unit_MINOR_VERSION then
|
||||
_G.DogTag_Unit_MINOR_VERSION = MINOR_VERSION
|
||||
|
@ -1,5 +1,5 @@
|
||||
local MAJOR_VERSION = "LibDogTag-Unit-3.0"
|
||||
local MINOR_VERSION = 90000 + (tonumber(("@file-date-integer@"):match("%d+")) or 33333333333333)
|
||||
local MINOR_VERSION = tonumber(("@project-date-integer@"):match("%d+")) or 33333333333333
|
||||
|
||||
if MINOR_VERSION > _G.DogTag_Unit_MINOR_VERSION then
|
||||
_G.DogTag_Unit_MINOR_VERSION = MINOR_VERSION
|
||||
|
@ -1,5 +1,5 @@
|
||||
local MAJOR_VERSION = "LibDogTag-Unit-3.0"
|
||||
local MINOR_VERSION = 90000 + (tonumber(("@file-date-integer@"):match("%d+")) or 33333333333333)
|
||||
local MINOR_VERSION = tonumber(("@project-date-integer@"):match("%d+")) or 33333333333333
|
||||
|
||||
if MINOR_VERSION > _G.DogTag_Unit_MINOR_VERSION then
|
||||
_G.DogTag_Unit_MINOR_VERSION = MINOR_VERSION
|
||||
|
@ -1,5 +1,5 @@
|
||||
local MAJOR_VERSION = "LibDogTag-Unit-3.0"
|
||||
local MINOR_VERSION = 90000 + (tonumber(("@file-date-integer@"):match("%d+")) or 33333333333333)
|
||||
local MINOR_VERSION = tonumber(("@project-date-integer@"):match("%d+")) or 33333333333333
|
||||
|
||||
if MINOR_VERSION > _G.DogTag_Unit_MINOR_VERSION then
|
||||
_G.DogTag_Unit_MINOR_VERSION = MINOR_VERSION
|
||||
|
@ -1,5 +1,5 @@
|
||||
local MAJOR_VERSION = "LibDogTag-Unit-3.0"
|
||||
local MINOR_VERSION = 90000 + (tonumber(("@file-date-integer@"):match("%d+")) or 33333333333333)
|
||||
local MINOR_VERSION = tonumber(("@project-date-integer@"):match("%d+")) or 33333333333333
|
||||
|
||||
if MINOR_VERSION > _G.DogTag_Unit_MINOR_VERSION then
|
||||
_G.DogTag_Unit_MINOR_VERSION = MINOR_VERSION
|
||||
|
Reference in New Issue
Block a user