diff --git a/LegionWA/NearbyPlayers/Event.lua b/LegionWA/NearbyPlayers/Event.lua new file mode 100644 index 0000000..113d2f1 --- /dev/null +++ b/LegionWA/NearbyPlayers/Event.lua @@ -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 \ No newline at end of file diff --git a/LegionWA/NearbyPlayers/Init.lua b/LegionWA/NearbyPlayers/Init.lua new file mode 100644 index 0000000..8b280a4 --- /dev/null +++ b/LegionWA/NearbyPlayers/Init.lua @@ -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