WoWInterface SVN mikma

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /
    from Rev 688 to Rev 689
    Reverse comparison

Rev 688 → Rev 689

EnemyScanner2/EnemyScanner2.lua New file
0,0 → 1,135
local db
local _
 
local function debugprint(chatframe,text,r,g,b)
if debug then
_G["ChatFrame"..chatframe]:AddMessage(text,r,g,b)
end
end
 
local function isTargetHostile(flag)
local HOSTILEUNITFLAG = 0x548
if bit.band(flag,HOSTILEUNITFLAG) == HOSTILEUNITFLAG then
return true
end
end
 
local function DecimalToHex(r,g,b)
return string.format("|cff%02x%02x%02x", r*255, g*255, b*255)
end
 
local EnemyScanner2 = CreateFrame("Button", nil, UIParent)
EnemyScanner2:SetScript("OnEvent", function(self, event, ...)
if self[event] then return self[event](self, event, ...) end
end)
 
EnemyScanner2:RegisterEvent("PLAYER_ENTERING_WORLD")
 
function EnemyScanner2:PLAYER_ENTERING_WORLD()
-- Realm name is available only after PEW
local realmName = GetCVar("realmName")
if not EnemyScanner2DB then
EnemyScanner2DB = { [realmName] = {}, }
end
db = EnemyScanner2DB[realmName]
EnemyScanner2:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
EnemyScanner2:RegisterEvent("UPDATE_MOUSEOVER_UNIT")
EnemyScanner2:RegisterEvent("PLAYER_TARGET_CHANGED")
EnemyScanner2:UnregisterEvent("PLAYER_ENTERING_WORLD")
end
 
local function GetStats(unit)
if UnitExists(unit) and UnitIsPlayer(unit) and UnitIsEnemy("player",unit) then
local guidsource = UnitGUID(unit)
local level = UnitLevel(unit)
local class, classFilename, race, raceFilename, sex, name, realm = GetPlayerInfoByGUID(guidsource)
local added = ""
if not db[guidsource] then
db[guidsource] = level
debugprint(4,name.." added and level set to: "..level)
end
if level > db[guidsource] then
db[guidsource] = level
debugprint(4,name.." upgraded level to: "..level)
end
end
 
end
 
function EnemyScanner2:UPDATE_MOUSEOVER_UNIT()
GetStats("mouseover")
end
 
function EnemyScanner2:PLAYER_TARGET_CHANGED()
GetStats("target")
end
 
function EnemyScanner2:COMBAT_LOG_EVENT_UNFILTERED(_, _, minievent, _, guidsource, source, sourceflags, sourceflagsraid, guidtarget, target, targetflags, targetflagsraid, ...)
if isTargetHostile(sourceflags) then --and not UnitIsPVPSanctuary("player") then
if guidsource == '' then
if debug then
ChatFrame4:AddMessage(minievent..", "..guidsource and guidsource or "nil, "..source and source or "nil, "..sourceflags..", "..sourceflagsraid,...,1,0,0)
end
return
end
source = source:match("[^-]+")
local spellID,spellName = ...
local level
 
-- Stealth/Prowl watch
local spellwatch = {
[66] = true, -- Mage, Invisibility
[1784] = true, -- Rogue, Stealth
[5215] = true, -- Druid, Prowl
}
 
if minievent == "SPELL_AURA_APPLIED" then
if spellwatch[spellID] then
local classFilename = select(2,GetPlayerInfoByGUID(guidsource))
local texture = select(3,GetSpellInfo(spellID))
local r,g,b = RAID_CLASS_COLORS[classFilename].r,RAID_CLASS_COLORS[classFilename].g,RAID_CLASS_COLORS[classFilename].b
RaidNotice_AddMessage(RaidWarningFrame, source..": |T"..texture..":0|t"..spellName, RAID_CLASS_COLORS[classFilename])
debugprint(4,source..": |T"..texture..":0|t"..spellName,r,g,b)
end
end
 
-- Catch if action is melee
if minievent:match("[^_]+") == "SWING" then
-- Turn ie. "SWING_MISS" text into "Swing Miss"
spellName = minievent:gsub('_',' '):lower()
spellName = spellName:gsub("(%l)(%w*)", function(a,b) return string.upper(a)..b end)
end
 
-- Check if action is spell
if minievent:match("[^_]+") ~= "SWING" and tonumber(spellID) then
level = GetSpellLevelLearned(spellID)
spellName = GetSpellLink(spellID)
end
 
if not db[guidsource] then
db[guidsource] = 0
end
 
local texture = select(3,GetSpellInfo(spellID))
if not texture then
texture = "Interface\\Icons\\INV_MISC_QUESTIONMARK"
end
 
-- If spell is greater than the one stored in database, upgrade it in the database
if level and (db[guidsource] < level) then
-- If spell level is greater than current max level in expansion, don't upgrade
if level > MAX_PLAYER_LEVEL_TABLE[GetAccountExpansionLevel()] then
level = MAX_PLAYER_LEVEL_TABLE[GetAccountExpansionLevel()]
else
level = GetSpellLevelLearned(spellID)
end
db[guidsource] = level
end
 
local class, classFilename, race, raceFilename, sex, name, realm = GetPlayerInfoByGUID(guidsource)
local r,g,b = RAID_CLASS_COLORS[classFilename].r,RAID_CLASS_COLORS[classFilename].g,RAID_CLASS_COLORS[classFilename].b
local levelcolor = GetQuestDifficultyColor(db[guidsource])
local levelcolorhex = DecimalToHex(levelcolor.r,levelcolor.g,levelcolor.b)
debugprint(3,source.." |T"..texture..":0|t "..spellName.." - "..levelcolorhex..db[guidsource],r,g,b)
end
end
\ No newline at end of file
EnemyScanner2/EnemyScanner2.toc New file
0,0 → 1,8
## Interface: 60000
## Author: Mikma
## Title: EnemyScanner 2
## Notes: Enemy detected and level estimated
## SavedVariables: EnemyScanner2DB
## Version: 1
 
EnemyScanner2.lua
\ No newline at end of file