Fix stinky detector spam

This commit is contained in:
2024-12-14 23:56:44 +01:00
parent 5ef92b23de
commit 468a68c3e7
2 changed files with 14 additions and 10 deletions

View File

@@ -22,7 +22,7 @@ function(allstates, e, prefix, msg, ...)
allstates[stinky].changed = true
aura_env.detectedStinkies[stinky] = nil
else
allstates[stinky].progress = string.format("%20s", elapsed)
allstates[stinky].progress = string.format("%20ss", string.format("%.1f", elapsed))
allstates[stinky].changed = true
end
else
@@ -35,7 +35,7 @@ function(allstates, e, prefix, msg, ...)
expirationTime = GetTime() + ttl,
autohide = true,
index = GetTime(),
progress = string.format("%20s", elapsed)
progress = string.format("%20ss", string.format("%.1f", elapsed))
}
end
end

View File

@@ -1,7 +1,7 @@
---@class aura_env
---@field config table<string, any>
---@field stinkies table<string, boolean>
---@field detectedStinkies table<string, {seen: number, soundPlayed: number?}>
---@field detectedStinkies table<string, {seen: number, muteUntil: number?}>
---@field StinkyDetected fun(name: string)
aura_env.stinkies = {}
aura_env.detectedStinkies = {}
@@ -25,12 +25,16 @@ for _, name in ipairs(stinkies) do
end
aura_env.StinkyDetected = function(name)
print("StinkyDetected", name)
DevTools_Dump(aura_env.detectedStinkies)
aura_env.detectedStinkies[name] = { seen = GetTime() }
if not aura_env.detectedStinkies[name].soundPlayed or
aura_env.detectedStinkies[name].soundPlayed < GetTime() - aura_env.config.soundThrottle then
PlaySoundFile("Interface\\Sounds\\Domination.ogg", "Master")
aura_env.detectedStinkies[name].soundPlayed = GetTime()
local now = GetTime()
local existing = aura_env.detectedStinkies[name]
if not existing then
aura_env.detectedStinkies[name] = { seen = now, muteUntil = 0 }
else
existing.seen = now
end
if existing.muteUntil < now then
print(existing.muteUntil, now)
PlaySoundFile("Interface\\Sounds\\Domination.ogg", "Master")
end
aura_env.detectedStinkies[name].muteUntil = now + aura_env.config.alertThrottle
end