Implement player faction cache

This commit is contained in:
2024-10-05 02:12:25 +02:00
parent a1e34b3adf
commit 939be6558a
3 changed files with 8 additions and 22 deletions

View File

@@ -35,13 +35,10 @@ function(allstates, e, ...)
if UnitIsPlayer("nameplate" .. i) then
local name = UnitName("nameplate" .. i)
local faction = UnitFactionGroup("nameplate" .. i)
if faction and faction == "Alliance" then
aura_env.RegisterAlly(name)
end
WeakAurasSaved.Cyka.PlayerFactionCache[name] = faction
end
end
aura_env.CleanAlliance()
return true
end

File diff suppressed because one or more lines are too long

View File

@@ -1,4 +1,5 @@
if not WeakAurasSaved.Cyka then WeakAurasSaved.Cyka = {} end
if not WeakAurasSaved.Cyka.PlayerFactionCache then WeakAurasSaved.Cyka.PlayerFactionCache = {} end
WeakAurasSaved.Cyka.Stinkies = {
["Redbulka"] = true,
["Курлык"] = true,
@@ -21,20 +22,6 @@ local toNotify = { "Succpotato", "Extazyk", "Smokefire", "Smokemantra", "Хих
-- local toNotify = { "Succpotato" }
aura_env.whisperQueue = {}
aura_env.alliancettl = 120
aura_env.alliance = {}
aura_env.CleanAlliance = function()
for k, v in pairs(aura_env.alliance) do
if v < GetTime() - aura_env.alliancettl then
aura_env.alliance[k] = nil
end
end
end
aura_env.RegisterAlly = function(name)
-- print("Spotted ally: " .. name)
aura_env.alliance[name] = GetTime()
end
local killSpamTime = 30
local recentlyKilled = {}
aura_env.RegisterKill = function(source, destination, spellName, overkill)
@@ -47,11 +34,13 @@ aura_env.RegisterKill = function(source, destination, spellName, overkill)
print("Death already reported")
end
local msg = string.format("Alliance %s убил %s с помощью %s с переполнением %d", source, destination, spellName, overkill)
if not aura_env.alliance[source] then
local msg = string.format("Неизвестная фракция %s убил %s с помощью %s с переполнением %d", source, destination, spellName, overkill)
local faction = "Неизвестная фракция"
if WeakAurasSaved.Cyka.PlayerFactionCache[source] then
faction = WeakAurasSaved.Cyka.PlayerFactionCache[source]
end
local msg = string.format("%s %s убил %s с помощью %s с переполнением %d",
faction, source, destination, spellName, overkill)
for k, v in pairs(toNotify) do
-- SendChatMessage(msg, "WHISPER", nil, v)
table.insert(aura_env.whisperQueue, { to = v, msg = msg })