Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function(event)
- if not WA_SnapshotLocale then
- setglobal("WA_SnapshotLocale", {});
- local t = WA_SnapshotLocale;
- t["Rip"] = GetSpellInfo(1079) or "Rip";
- t["Rake"] = GetSpellInfo(1822) or "Rake";
- t["Thrash"] = GetSpellInfo(106830) or "Thrash";
- t["Tiger's Fury"] = GetSpellInfo(5217) or "Tiger's Fury";
- t["Savage Roar"] = GetSpellInfo(52610) or "Savage Roar";
- t["Bloodtalons"] = GetSpellInfo(155672) or "Bloodtalons";
- t["Moonfire"] = GetSpellInfo(8921) or "Moonfire";
- t["Incarnation"] = GetSpellInfo(102543) or "Incarnation: King of the Jungle";
- end
- if not WA_DoTInfo then
- setglobal("WA_DoTInfo", {
- ["Rake"] = {
- ["dur"] = 15,
- ["tick"] = 3,
- },
- ["Rip"] = {
- ["dur"] = 24,
- ["tick"] = 2,
- },
- })
- end
- if event == "PLAYER_TALENT_UPDATE" or not WA_hasFoN then
- setglobal("WA_hasFoN", select(4, GetTalentInfo(4, 3, GetActiveSpecGroup())));
- end
- if event == "PLAYER_TALENT_UPDATE" or event == "LEARNED_SPELL_IN_TAB" or not WA_GetSnapshotState then
- local hasBT = select(4, GetTalentInfo(7, 2, GetActiveSpecGroup()));
- local l = WA_SnapshotLocale;
- setglobal("WA_GetSnapshotState", function(isRake)
- local s = {};
- if UnitBuff("player", l["Tiger's Fury"]) then
- s.TF = true;
- end
- if UnitBuff("player", l["Savage Roar"]) then
- s.SR = true;
- else
- -- Explicitly set a value so we know the state will never be empty.
- s.SR = false;
- end
- if hasBT and (UnitBuff("player", l["Bloodtalons"]) or (WA_SnapshotBloodtalonsFades and GetTime()-WA_SnapshotBloodtalonsFades < 0.250)) then
- s.BT = true;
- end
- if isRake then
- if (WA_SnapshotStealthRake and GetTime() - WA_SnapshotStealthRake < 0.25) or UnitBuff("player", l["Incarnation"]) then
- WA_SnapshotStealthRake = nil;
- s.ImpRake = true;
- end
- end
- return s;
- end)
- end
- if not WA_SnapshotInit then
- setglobal("WA_SnapshotInit", function(dest)
- setglobal("WA_SnapshotData", WA_SnapshotData or {
- ["Thrash"] = {
- ["cache"] = {},
- },
- });
- if dest then
- WA_SnapshotData[dest] = WA_SnapshotData[dest] or {
- ["Rip"] = {
- ["state"] = {},
- ["cache"] = {},
- },
- ["Rake"] = {
- ["state"] = {},
- ["cache"] = {},
- },
- ["Thrash"] = {
- ["state"] = {},
- },
- };
- end
- end)
- end
- if not WA_CacheSnapshot then
- setglobal("WA_CacheSnapshot", function(dest, key)
- if not key or (not dest and key ~= "Thrash") then
- return
- end
- WA_SnapshotInit(dest);
- if key == "Thrash" then
- WA_SnapshotData[key].cache = WA_GetSnapshotState();
- else
- WA_SnapshotData[dest][key].cache = WA_GetSnapshotState(key == "Rake");
- end
- end)
- end
- if not WA_SaveSnapshot then
- setglobal("WA_SaveSnapshot", function(dest, key, isRefresh)
- if not (dest and key) then
- return
- end
- WA_SnapshotInit(dest);
- -- track partial
- if WA_ShowPartialTicks and key ~= "Thrash" then
- if isRefresh and WA_DoTInfo[key] then
- -- Calculate the time left on the bleed when it is refreshed
- local remaining = WA_SnapshotData[dest][key].exp - GetTime();
- -- Calculate what the new duration will be post refresh
- local newDuration = WA_DoTInfo[key].dur + min(WA_DoTInfo[key].dur*0.3, remaining);
- -- Store the new expiration time in the DoT state
- WA_SnapshotData[dest][key].exp = GetTime() + newDuration;
- if WA_SnapshotData[dest][key].partial and remaining < WA_SnapshotData[dest][key].partial then
- -- If we successfully landed a refresh in the partial window, then reset the partial to nil.
- WA_SnapshotData[dest][key].partial = nil;
- elseif remaining > WA_DoTInfo[key].dur*0.3 then
- -- Otherwise, if the refresh happened before pandemic zone we need to adjust the partial length.
- local timeToNextTick = ( remaining - ( WA_SnapshotData[dest][key].partial or 0 ) ) % WA_DoTInfo[key].tick;
- WA_SnapshotData[dest][key].partial = ( newDuration - timeToNextTick ) % WA_DoTInfo[key].tick;
- end
- else
- -- Its not a refresh, so just set the expiration time.
- WA_SnapshotData[dest][key].exp = GetTime() + WA_DoTInfo[key].dur;
- end
- end
- if key == "Thrash" then
- if not WA_SnapshotData[key].cache then
- return
- end
- WA_SnapshotData[dest][key].state =
- WA_shallowCopy(WA_SnapshotData[key].cache);
- else
- if not WA_SnapshotData[dest][key].cache then
- return
- end
- WA_SnapshotData[dest][key].state = WA_shallowCopy(WA_SnapshotData[dest][key].cache);
- WA_SnapshotData[dest][key].cache = {};
- end
- if WA_SnapshotCurrentTarget and WA_SnapshotCurrentTarget == dest then
- WeakAuras.ScanEvents("WA_"..string.upper(key).."_APPLIED");
- end
- end)
- end
- if not WA_ClearSnapshot then
- setglobal("WA_ClearSnapshot", function(dest, key)
- if not (WA_SnapshotData and dest and key and WA_SnapshotData[dest] and WA_SnapshotData[dest][key]) then
- return
- end
- WA_SnapshotData[dest][key].state = {};
- WA_SnapshotData[dest][key].partial = nil;
- WA_SnapshotData[dest][key].exp = nil;
- if WA_SnapshotCurrentTarget and WA_SnapshotCurrentTarget == dest then
- WeakAuras.ScanEvents("WA_"..string.upper(key).."_REMOVED");
- end
- end)
- end
- if not WA_shallowCopy then
- setglobal("WA_shallowCopy", function(orig)
- local orig_type = type(orig)
- local copy
- if orig_type == 'table' then
- copy = {}
- for orig_key, orig_value in pairs(orig) do
- copy[orig_key] = orig_value
- end
- else -- number, string, boolean, etc
- copy = orig
- end
- return copy
- end)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment