Add nearbyPlayers wa

This commit is contained in:
M. David
2022-08-23 14:17:07 +02:00
parent 9398a5edba
commit b0efa87221
2 changed files with 88 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
-- COMBAT_LOG_EVENT_UNFILTERED
function(allstates, e, ...)
local caster = select(6, ...)
local target = select(10, ...)
aura_env.processEvent(allstates, caster, target)
end

View File

@@ -0,0 +1,81 @@
if not WeakAurasSaved.Cyka then WeakAurasSaved.Cyka = {} end
if not WeakAurasSaved.Cyka.Cache then WeakAurasSaved.Cyka.Cache = {} end
if not WeakAurasSaved.Cyka.Cache.PlayerInfo then WeakAurasSaved.Cyka.Cache.PlayerInfo = {} end
local allianceRaces = {
"Draenai",
"Dwarf",
"Gnome",
"Human",
"Night Elf",
"Worgen"
}
PlayerController = {
nearbyPlayers = {},
addPlayer = function(self, name)
self.nearbyPlayers[name] = Player:New(name)
end,
getPlayers = function(self)
end
}
Player = {
guid = nil,
lastSighted = nil,
info = nil,
update = function(self)
self.lastSighted = GetTime()
end,
getFormatted = function(self)
-- Color by class
-- Format time
return info.name .. " " .. self.lastSighted
end
}
PlayerInfo = {
class = nil,
race = nil,
name = nil,
isHostile = nil,
}
function Player:New(guid)
o = {}
setmetatable(o, self)
self.__index = self
o.guid = guid or ""
o.lastSighted = GetTime()
o.info = PlayerInfo:New(guid)
return o
end
function PlayerInfo:New(guid)
o = {}
setmetatable(o, self)
self.__index = self
local info
if WeakAurasSaved.Cyka.Cache.PlayerInfo[guid] then
info = WeakAurasSaved.Cyka.Cache.PlayerInfo[guid]
else
info = GetPlayerInfoByGUID(guid)
WeakAurasSaved.Cyka.Cache.PlayerInfo[guid] = {
class = info.class,
race = info.race,
name = info.name,
isHostile = allianceRaces[race] ~= nil
}
end
o.class = info.class or ""
o.race = info.race or ""
o.name = info.name or ""
o.isHostile = info.isHostile or true
return o
end
aura_env.processEvent = function(allstates, caster, target)
end