diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..75404a0 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,30 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "label": "echo", + "type": "shell", + "command": "echo Hello" + },{ + "label": "cwd", + "type": "shell", + "command": "${cwd}\\" + }, + { + "label": "localdeploy", + "type": "shell", + "command": "Copy-Item", + "args": [ + "-Force", + "-Recurse", + "-Verbose", + "-Path", + "${cwd}\\*", + "-Destination", + "D:\\Games\\Turtle WoW 1.12\\Interface\\AddOns\\CallOfElements" + ] + } + ] +} \ No newline at end of file diff --git a/COE_TotemLogic.lua b/COE_TotemLogic.lua index 40b4db7..fb89a5d 100644 --- a/COE_TotemLogic.lua +++ b/COE_TotemLogic.lua @@ -37,20 +37,17 @@ function COE_Totem:Rescan() -- Reset all active totems -- ------------------------ - COE_Totem:DeactivateTimer( COE.ActiveTotems.Earth ); - COE_Totem:DeactivateTimer( COE.ActiveTotems.Fire ); - COE_Totem:DeactivateTimer( COE.ActiveTotems.Water ); - COE_Totem:DeactivateTimer( COE.ActiveTotems.Air ); + COE_Totem:ResetTimers(); + COE.ActiveTotems.Earth = nil; COE.ActiveTotems.Fire = nil; COE.ActiveTotems.Water = nil; COE.ActiveTotems.Air = nil; - + COE_Totem:UpdateAllFrames(); COETotemFrame.Reconfigure = true; end - --[[ ---------------------------------------------------------------- METHOD: COE_Totem:ThrowTotem @@ -681,11 +678,13 @@ end still active timer of the same element -------------------------------------------------------------------]] function COE_Totem:ActivatePendingTotem( totem ) + COE:DebugMessage("Method Executing: ActivatePendingTotem with totem parameter ".. totem.SpellName); -- deactivate still active totem of the same element -- -------------------------------------------------- - local active = COE.ActiveTotems[COE.TotemPending.Totem.Element]; - if( active ) then + COE:DebugMessage("Method Executing: ActivatePendingTotem - identifying active totems of type".. COE.TotemPending.Totem.Element); + local active = COE.ActiveTotems[COE.TotemPending.Totem.Element]; + if( active ) then COE_Totem:DeactivateTimer( active ); end @@ -857,6 +856,7 @@ end PURPOSE: Issues an expiration warning for the specified totem -------------------------------------------------------------------]] function COESched_ExpirationWarning( timemark, totem ) + COE:DebugMessage("Method Executing: COESched_ExpirationWarning with totem parameter ".. totem.SpellName); if( COE_Config:GetSaved( COEOPT_ENABLETOTEMBAR ) == 1 and COE_Config:GetSaved( COEOPT_ENABLETIMERS ) == 1 and @@ -901,6 +901,7 @@ end a notification if the totem is destroyed -------------------------------------------------------------------]] function COE_Totem:TotemDamage() + COE:DebugMessage("Method Executing: TotemDamage"); local num, regex, i; for num, regex in COESTR_TOTEMDAMAGE do @@ -949,6 +950,7 @@ end PURPOSE: Resets all active timers to zero -------------------------------------------------------------------]] function COE_Totem:ResetTimers() + COE:DebugMessage("Method Executing: COE_Totem:ResetTimers"); local k; for k = 1, 4 do diff --git a/COE_TotemVisual.lua b/COE_TotemVisual.lua index 02e893a..3144890 100644 --- a/COE_TotemVisual.lua +++ b/COE_TotemVisual.lua @@ -1562,7 +1562,6 @@ end associated totem has an active timer -------------------------------------------------------------------]] function COE_Totem:SetTimerText() - if( this.totem == COE.NoTotem ) then return; end; @@ -1641,7 +1640,9 @@ function COE_Totem:SetTimerText() -- if timer has just expired, deactivate it -- if it isn't active anyway, the call doesn't hurt -- ------------------------------------------------- - COE_Totem:DeactivateTimer( this.totem ); +-- TODO: I'm removing this as it appears entirely unnecessary to be done in this method + --COE:DebugMessage("Calling DeactivateTimer with totem: ".. this.totem.SpellName); + --COE_Totem:DeactivateTimer( this.totem ); timertext:Hide(); overlaytex:Hide(); diff --git a/CallOfElements.lua b/CallOfElements.lua index eb222f5..6b8d732 100644 --- a/CallOfElements.lua +++ b/CallOfElements.lua @@ -63,7 +63,8 @@ function COE:Init() COE.Initialized = true; this:RegisterEvent( "VARIABLES_LOADED" ); - + this:RegisterEvent("SPELLCAST_STOP"); + -- register shell command -- ----------------------- SlashCmdList["COE"] = COEProcessShellCommand; @@ -71,8 +72,25 @@ function COE:Init() end + end +--[[ ---------------------------------------------------------------- + METHOD: COE:FindSpellId + + PURPOSE: Utility function that can provide spell ID from name. + Run in client chat with '/script COE:FindSpellName("a_spell_name")'. +-------------------------------------------------------------------]] +function COE:FindSpellId(spellNameTarget) + local spellName; + for i = 1, 1000 do + spellName = GetSpellName(i, BOOKTYPE_SPELL); + if (spellName == spellNameTarget) then + print(spellName .. "is id: " .. i); + + end + end +end --[[ ---------------------------------------------------------------- METHOD: COE:OnEvent @@ -85,6 +103,54 @@ function COE:OnEvent( event ) -- fix saved variables if this update has to do so -- ------------------------------------------------ COE:FixSavedVariables(); + + elseif ( event == "SPELLCAST_STOP" ) then + COE_TotemicRecallTimerResetCount = 0; + + TotemicRecallTimerReset(); + end +end + +--[[ ---------------------------------------------------------------- + Totemic Recall Reset Logic + + This is very janky. The return values from GetSpellCooldown for + spell ID 35 (Totemic Recall) are very inconsistent. But if a + delay is introduced, then the next call seems valid. I suspect + this might break if something has a CD of 6 seconds. +-------------------------------------------------------------------]] +COE_TotemicRecallPreviousCDExpired = true; +-- Using counter to keep track of calls to reset +COE_TotemicRecallTimerResetCount = 0; + +-- Local function to change variable with Chronos scheduler +function TotemicRecallEndCountdown() + COE_TotemicRecallPreviousCDExpired = true; +end + +function TotemicRecallTimerReset() + + -- Get totemic recall spell cooldown information + local TRstart, TRduration = GetSpellCooldown( COESTR_TOTEMICRECALLID, BOOKTYPE_SPELL ); + COE:DebugMessage("Totemic Recall spell CD values: ".. TRstart ..", ".. TRduration); + + -- The first GetSpellCooldown returns the wrong information and fires for any spell cast, regardless of spell ID + -- So this will set a quick timer to recall this method and get the right GetSpellCooldown info + if ( TRstart > 0 and COE_TotemicRecallPreviousCDExpired) then + + -- No more than one call is necessary to check if the cooldown is actually Totemic Recall + if (TRduration < 6 and COE_TotemicRecallTimerResetCount < 1) then + Chronos.schedule(.25, TotemicRecallTimerReset); + COE_TotemicRecallTimerResetCount = COE_TotemicRecallTimerResetCount + 1; + + elseif (TRduration == 6) then + COE_TotemicRecallPreviousCDExpired = false; + COE_TotemicRecallTimerResetCount = 0; + Chronos.schedule(6, TotemicRecallEndCountdown); + COE:DebugMessage("Totemic Recall initiating reset of timers."); + COE_Totem:ResetTimers(); + end + end end @@ -107,7 +173,7 @@ end; -------------------------------------------------------------------]] function COE:DebugMessage( msg ) if( COE.DebugMode ) then - DEFAULT_CHAT_FRAME:AddMessage( "[COE] " .. msg, 0.5, 0.5, 0.5 ); + DEFAULT_CHAT_FRAME:AddMessage( "[COE] " .. msg, 1, 0, 0 ); end end; diff --git a/Localization.lua b/Localization.lua index 0c253c4..0679606 100644 --- a/Localization.lua +++ b/Localization.lua @@ -52,6 +52,12 @@ COESTR_MAXAMOUNT = "to (%d*)"; COESTR_TRINKET = "^.*%[Enamored Water Spirit%].*$"; +-- Spell Names and IDs +-- ---------------- +COESTR_TOTEMICRECALL = "Totemic Recall"; +COESTR_TOTEMICRECALLID = 35; + + -- Totem Advisor -- -------------- COESTR_POISON = "Poison";