第一次发版v0.1.0
This commit is contained in:
215
Core.lua
Normal file
215
Core.lua
Normal file
@@ -0,0 +1,215 @@
|
||||
NanamiPlates = {}
|
||||
NanamiPlates.modules = {}
|
||||
NanamiPlates.registry = {}
|
||||
|
||||
local pairs = pairs
|
||||
local tostring = tostring
|
||||
local CreateFrame = CreateFrame
|
||||
|
||||
local superwow_active = (SpellInfo ~= nil) or (UnitGUID ~= nil) or (SUPERWOW_VERSION ~= nil)
|
||||
NanamiPlates.superwow_active = superwow_active
|
||||
|
||||
local _, playerClass = UnitClass("player")
|
||||
playerClass = playerClass or ""
|
||||
NanamiPlates.playerClass = playerClass
|
||||
|
||||
NanamiPlates.castDB = {}
|
||||
NanamiPlates.castTracker = {}
|
||||
NanamiPlates.debuffTracker = {}
|
||||
NanamiPlates.recentMeleeCrits = {}
|
||||
NanamiPlates.recentMeleeHits = {}
|
||||
NanamiPlates.playerClassCache = {}
|
||||
NanamiPlates.playerRole = "DPS"
|
||||
|
||||
local function Print(msg)
|
||||
if DEFAULT_CHAT_FRAME then
|
||||
DEFAULT_CHAT_FRAME:AddMessage("|cffff88cc[Nanami-Plates]|r " .. tostring(msg))
|
||||
end
|
||||
end
|
||||
NanamiPlates.Print = Print
|
||||
|
||||
local function HookScript(frame, script, func)
|
||||
local prev = frame:GetScript(script)
|
||||
frame:SetScript(script, function(a1, a2, a3, a4, a5, a6, a7, a8, a9)
|
||||
if prev then prev(a1, a2, a3, a4, a5, a6, a7, a8, a9) end
|
||||
func(a1, a2, a3, a4, a5, a6, a7, a8, a9)
|
||||
end)
|
||||
end
|
||||
NanamiPlates.HookScript = HookScript
|
||||
|
||||
local function DisableShaguTweaksNameplates()
|
||||
if ShaguTweaks and ShaguTweaks.libnameplate then
|
||||
ShaguTweaks.libnameplate:SetScript("OnUpdate", nil)
|
||||
ShaguTweaks.libnameplate.OnInit = {}
|
||||
ShaguTweaks.libnameplate.OnShow = {}
|
||||
ShaguTweaks.libnameplate.OnUpdate = {}
|
||||
ShaguTweaks.libnameplate.disabled_by_nanamiplates = true
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local function DisablePfUINameplates()
|
||||
if pfUI then
|
||||
if pfUI.modules then pfUI.modules["nameplates"] = nil end
|
||||
if pfNameplates then
|
||||
pfNameplates:Hide()
|
||||
pfNameplates:UnregisterAllEvents()
|
||||
end
|
||||
if pfUI.nameplates then pfUI.nameplates = nil end
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
DisableShaguTweaksNameplates()
|
||||
DisablePfUINameplates()
|
||||
|
||||
local function GetPlayerClassByName(name)
|
||||
if not name then return nil end
|
||||
local cache = NanamiPlates.playerClassCache
|
||||
if cache[name] then return cache[name] end
|
||||
|
||||
local playerName = UnitName("player")
|
||||
if name == playerName then
|
||||
cache[name] = playerClass
|
||||
return playerClass
|
||||
end
|
||||
|
||||
local numRaid = GetNumRaidMembers()
|
||||
if numRaid > 0 then
|
||||
for i = 1, numRaid do
|
||||
local raidName, _, _, _, _, raidClass = GetRaidRosterInfo(i)
|
||||
if raidName == name then
|
||||
cache[name] = raidClass
|
||||
return raidClass
|
||||
end
|
||||
end
|
||||
else
|
||||
local numParty = GetNumPartyMembers()
|
||||
for i = 1, numParty do
|
||||
local partyUnit = "party" .. i
|
||||
if UnitExists(partyUnit) then
|
||||
local partyName = UnitName(partyUnit)
|
||||
if partyName == name then
|
||||
local _, partyClass = UnitClass(partyUnit)
|
||||
cache[name] = partyClass
|
||||
return partyClass
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
NanamiPlates.GetPlayerClassByName = GetPlayerClassByName
|
||||
|
||||
local NP_EventFrame = CreateFrame("Frame", "NanamiPlatesFrame", UIParent)
|
||||
|
||||
NP_EventFrame:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
NP_EventFrame:RegisterEvent("ADDON_LOADED")
|
||||
NP_EventFrame:RegisterEvent("PLAYER_TARGET_CHANGED")
|
||||
NP_EventFrame:RegisterEvent("UNIT_AURA")
|
||||
NP_EventFrame:RegisterEvent("PARTY_MEMBERS_CHANGED")
|
||||
NP_EventFrame:RegisterEvent("RAID_ROSTER_UPDATE")
|
||||
NP_EventFrame:RegisterEvent("PLAYER_LEVEL_UP")
|
||||
NP_EventFrame:RegisterEvent("PLAYER_REGEN_DISABLED")
|
||||
NP_EventFrame:RegisterEvent("PLAYER_REGEN_ENABLED")
|
||||
NP_EventFrame:RegisterEvent("UNIT_CASTEVENT")
|
||||
NP_EventFrame:RegisterEvent("SPELLCAST_STOP")
|
||||
NP_EventFrame:RegisterEvent("CHAT_MSG_SPELL_FAILED_LOCALPLAYER")
|
||||
NP_EventFrame:RegisterEvent("CHARACTER_POINTS_CHANGED")
|
||||
NP_EventFrame:RegisterEvent("QUEST_LOG_UPDATE")
|
||||
|
||||
NP_EventFrame:RegisterEvent("CHAT_MSG_SPELL_HOSTILEPLAYER_DAMAGE")
|
||||
NP_EventFrame:RegisterEvent("CHAT_MSG_SPELL_CREATURE_VS_CREATURE_DAMAGE")
|
||||
NP_EventFrame:RegisterEvent("CHAT_MSG_SPELL_CREATURE_VS_PARTY_DAMAGE")
|
||||
NP_EventFrame:RegisterEvent("CHAT_MSG_SPELL_CREATURE_VS_SELF_DAMAGE")
|
||||
NP_EventFrame:RegisterEvent("CHAT_MSG_SPELL_HOSTILEPLAYER_BUFF")
|
||||
NP_EventFrame:RegisterEvent("CHAT_MSG_SPELL_CREATURE_VS_CREATURE_BUFF")
|
||||
NP_EventFrame:RegisterEvent("CHAT_MSG_SPELL_SELF_DAMAGE")
|
||||
NP_EventFrame:RegisterEvent("CHAT_MSG_SPELL_TRADESKILLS")
|
||||
NP_EventFrame:RegisterEvent("CHAT_MSG_SPELL_PERIODIC_CREATURE_DAMAGE")
|
||||
NP_EventFrame:RegisterEvent("CHAT_MSG_SPELL_PERIODIC_HOSTILEPLAYER_DAMAGE")
|
||||
NP_EventFrame:RegisterEvent("CHAT_MSG_SPELL_PERIODIC_SELF_DAMAGE")
|
||||
NP_EventFrame:RegisterEvent("CHAT_MSG_SPELL_AURA_GONE_OTHER")
|
||||
NP_EventFrame:RegisterEvent("CHAT_MSG_SPELL_AURA_GONE_SELF")
|
||||
NP_EventFrame:RegisterEvent("CHAT_MSG_SPELL_CREATURE_VS_PARTY_BUFF")
|
||||
NP_EventFrame:RegisterEvent("CHAT_MSG_SPELL_CREATURE_VS_SELF_BUFF")
|
||||
|
||||
NP_EventFrame:RegisterEvent("CHAT_MSG_COMBAT_SELF_HITS")
|
||||
NP_EventFrame:RegisterEvent("CHAT_MSG_COMBAT_PARTY_HITS")
|
||||
NP_EventFrame:RegisterEvent("CHAT_MSG_COMBAT_FRIENDLYPLAYER_HITS")
|
||||
NP_EventFrame:RegisterEvent("CHAT_MSG_COMBAT_CREATURE_VS_CREATURE_HITS")
|
||||
NP_EventFrame:RegisterEvent("CHAT_MSG_COMBAT_SELF_RANGED_HITS")
|
||||
NP_EventFrame:RegisterEvent("CHAT_MSG_COMBAT_PARTY_RANGED_HITS")
|
||||
|
||||
NanamiPlates.EventFrame = NP_EventFrame
|
||||
|
||||
NanamiPlates.SPELL_EVENTS = {
|
||||
["CHAT_MSG_SPELL_HOSTILEPLAYER_DAMAGE"] = true,
|
||||
["CHAT_MSG_SPELL_CREATURE_VS_CREATURE_DAMAGE"] = true,
|
||||
["CHAT_MSG_SPELL_CREATURE_VS_PARTY_DAMAGE"] = true,
|
||||
["CHAT_MSG_SPELL_CREATURE_VS_SELF_DAMAGE"] = true,
|
||||
["CHAT_MSG_SPELL_HOSTILEPLAYER_BUFF"] = true,
|
||||
["CHAT_MSG_SPELL_CREATURE_VS_CREATURE_BUFF"] = true,
|
||||
["CHAT_MSG_SPELL_SELF_DAMAGE"] = true,
|
||||
["CHAT_MSG_SPELL_TRADESKILLS"] = true,
|
||||
["CHAT_MSG_SPELL_PERIODIC_CREATURE_DAMAGE"] = true,
|
||||
["CHAT_MSG_SPELL_PERIODIC_HOSTILEPLAYER_DAMAGE"] = true,
|
||||
["CHAT_MSG_SPELL_PERIODIC_SELF_DAMAGE"] = true,
|
||||
["CHAT_MSG_SPELL_AURA_GONE_OTHER"] = true,
|
||||
["CHAT_MSG_SPELL_AURA_GONE_SELF"] = true,
|
||||
["CHAT_MSG_SPELL_CREATURE_VS_PARTY_BUFF"] = true,
|
||||
["CHAT_MSG_SPELL_CREATURE_VS_SELF_BUFF"] = true,
|
||||
["CHAT_MSG_SPELL_FAILED_LOCALPLAYER"] = true,
|
||||
}
|
||||
|
||||
NanamiPlates.SPELL_DAMAGE_EVENTS = {
|
||||
["CHAT_MSG_SPELL_HOSTILEPLAYER_DAMAGE"] = true,
|
||||
["CHAT_MSG_SPELL_CREATURE_VS_CREATURE_DAMAGE"] = true,
|
||||
["CHAT_MSG_SPELL_CREATURE_VS_PARTY_DAMAGE"] = true,
|
||||
["CHAT_MSG_SPELL_CREATURE_VS_SELF_DAMAGE"] = true,
|
||||
["CHAT_MSG_SPELL_SELF_DAMAGE"] = true,
|
||||
["CHAT_MSG_SPELL_PERIODIC_CREATURE_DAMAGE"] = true,
|
||||
["CHAT_MSG_SPELL_PERIODIC_HOSTILEPLAYER_DAMAGE"] = true,
|
||||
["CHAT_MSG_SPELL_PERIODIC_SELF_DAMAGE"] = true,
|
||||
}
|
||||
|
||||
NanamiPlates.COMBAT_EVENTS = {
|
||||
["CHAT_MSG_COMBAT_SELF_HITS"] = true,
|
||||
["CHAT_MSG_COMBAT_PARTY_HITS"] = true,
|
||||
["CHAT_MSG_COMBAT_FRIENDLYPLAYER_HITS"] = true,
|
||||
["CHAT_MSG_COMBAT_CREATURE_VS_CREATURE_HITS"] = true,
|
||||
["CHAT_MSG_COMBAT_SELF_RANGED_HITS"] = true,
|
||||
["CHAT_MSG_COMBAT_PARTY_RANGED_HITS"] = true,
|
||||
}
|
||||
|
||||
NanamiPlates.STUN_EFFECTS = {
|
||||
"Cheap Shot", "Kidney Shot", "Bash", "Hammer of Justice",
|
||||
"Charge Stun", "Intercept Stun", "Concussion Blow",
|
||||
"Gouge", "Sap", "Pounce"
|
||||
}
|
||||
|
||||
NanamiPlates.REMOVE_PENDING_PATTERNS = {
|
||||
SPELLIMMUNESELFOTHER or "%s is immune to your %s.",
|
||||
IMMUNEDAMAGECLASSSELFOTHER or "%s is immune to your %s damage.",
|
||||
SPELLMISSSELFOTHER or "Your %s missed %s.",
|
||||
SPELLRESISTSELFOTHER or "Your %s was resisted by %s.",
|
||||
SPELLEVADEDSELFOTHER or "Your %s was evaded by %s.",
|
||||
SPELLDODGEDSELFOTHER or "Your %s was dodged by %s.",
|
||||
SPELLDEFLECTEDSELFOTHER or "Your %s was deflected by %s.",
|
||||
SPELLREFLECTSELFOTHER or "Your %s was reflected back by %s.",
|
||||
SPELLPARRIEDSELFOTHER or "Your %s was parried by %s.",
|
||||
SPELLLOGABSORBSELFOTHER or "Your %s is absorbed by %s.",
|
||||
}
|
||||
|
||||
NanamiPlates.TANK_CLASSES = {
|
||||
["Warrior"] = true,
|
||||
["Paladin"] = true,
|
||||
["Druid"] = true,
|
||||
["Shaman"] = true,
|
||||
}
|
||||
|
||||
if DEFAULT_CHAT_FRAME then
|
||||
DEFAULT_CHAT_FRAME:AddMessage("|cffff88cc[Nanami-Plates]|r Loading...")
|
||||
end
|
||||
Reference in New Issue
Block a user