Refactor orecamper to be a bit more accurate

This commit is contained in:
2024-11-08 21:02:01 +01:00
parent 76aae3c7e0
commit 6949a1db29
2 changed files with 5 additions and 8 deletions

View File

@@ -16,24 +16,21 @@ function(allstates, e, ...)
if aura_env.lastEvent > 0 and currentTime - aura_env.lastEvent < aura_env.throttle then return end
aura_env.lastEvent = currentTime
print("Current time: " .. currentTime)
local lastEventTime = aura_env.lastEventTimes[targetGUID] or currentTime
print("Last event time: " .. lastEventTime)
local timeSinceLastEvent = currentTime - lastEventTime
print("Time since last event: " .. timeSinceLastEvent)
local dynamicCooldown = math.min(300, timeSinceLastEvent)
local cooldown = timeSinceLastEvent
if cooldown == 0 then cooldown = aura_env.cooldown end
local state = {
changed = true,
show = true,
progressType = "timed",
autoHide = true,
duration = dynamicCooldown,
expirationTime = currentTime + dynamicCooldown,
duration = cooldown,
expirationTime = currentTime + cooldown,
name = string.format("%s", targetName),
}
print(string.format("Setting time for %s to %d", targetGUID, currentTime))
aura_env.lastEventTimes[targetGUID] = currentTime
allstates[targetGUID] = state
return true

View File

@@ -1,4 +1,4 @@
aura_env.cooldown = 300
aura_env.cooldown = 240
aura_env.depositIterator = {}
aura_env.lastEventTimes = {}
aura_env.throttle = 0.5