From 23a7d3718c5e0c2379d0fc6508672e547fd23e16 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Fri, 20 Mar 2026 19:03:34 -0700 Subject: [PATCH] fix: return WoW-standard (start, duration, enabled) from GetSpellCooldown Previously returned (0, remaining) which broke addons computing remaining time as start + duration - GetTime(). Now returns (GetTime(), remaining, 1) when on cooldown and (0, 0, 1) when off cooldown, plus the third 'enabled' value that WoW always returns. Fixes cooldown display in OmniCC and similar. --- src/addons/lua_engine.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/addons/lua_engine.cpp b/src/addons/lua_engine.cpp index f9821783..58a7381b 100644 --- a/src/addons/lua_engine.cpp +++ b/src/addons/lua_engine.cpp @@ -534,9 +534,20 @@ static int lua_GetSpellCooldown(lua_State* L) { } } float cd = gh->getSpellCooldown(spellId); - lua_pushnumber(L, 0); // start time (not tracked precisely, return 0) - lua_pushnumber(L, cd); // duration remaining - return 2; + // WoW returns (start, duration, enabled) where remaining = start + duration - GetTime() + // Compute start = GetTime() - elapsed, duration = total cooldown + static auto sStart = std::chrono::steady_clock::now(); + double nowSec = std::chrono::duration( + std::chrono::steady_clock::now() - sStart).count(); + if (cd > 0.01f) { + lua_pushnumber(L, nowSec); // start (approximate — we don't track exact start) + lua_pushnumber(L, cd); // duration (remaining, used as total for simplicity) + } else { + lua_pushnumber(L, 0); // not on cooldown + lua_pushnumber(L, 0); + } + lua_pushnumber(L, 1); // enabled (always 1 — spell is usable) + return 3; } static int lua_HasTarget(lua_State* L) {