Skip to content

Commit

Permalink
No more antidaze.
Browse files Browse the repository at this point in the history
More nil checks
  • Loading branch information
ynazar1 committed Nov 16, 2024
1 parent 5568c3e commit 279dd28
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 78 deletions.
61 changes: 14 additions & 47 deletions SmartBuff.lua
Original file line number Diff line number Diff line change
Expand Up @@ -524,9 +524,9 @@ function SMARTBUFF_OnEvent(self, event, ...)
if (event == "PLAYER_ENTERING_WORLD" and isInit and O.Toggle) then
isSetZone = true;
tStartZone = GetTime();

-- elseif (event == "PLAYER_ENTERING_WORLD" and isLoaded and isPlayer and not isInit and not InCombatLockdown()) then
-- SMARTBUFF_Options_Init(self);
end
if (event == "PLAYER_ENTERING_WORLD" and isLoaded and isPlayer and not isInit and not InCombatLockdown()) then
SMARTBUFF_Options_Init(self);
end
elseif (event == "ADDON_LOADED" and arg1 == SMARTBUFF_TITLE) then
isLoaded = true;
Expand Down Expand Up @@ -633,30 +633,6 @@ function SMARTBUFF_OnEvent(self, event, ...)
if (UnitAffectingCombat("player") and (arg1 == "player" or string.find(arg1, "^party") or string.find(arg1, "^raid"))) then
isSyncReq = true;
end

-- checks if aspect of cheetah or pack is active and cancel it if someone gets dazed
if (sPlayerClass == "HUNTER" and O.AntiDaze and (arg1 == "player" or string.find(arg1, "^party") or string.find(arg1, "^raid") or string.find(arg1, "pet"))) then
local _, stuntex = C_Spell.GetSpellTexture(1604); --get Dazed icon
if (SMARTBUFF_IsDebuffTexture(arg1, stuntex)) then
buff = nil;
if (arg1 == "player" and SMARTBUFF_CheckBuff(arg1, SMARTBUFF_AOTC)) then
buff = SMARTBUFF_AOTC;
elseif (SMARTBUFF_CheckBuff(arg1, SMARTBUFF_AOTP, true)) then
buff = SMARTBUFF_AOTP;
end
if (buff) then
if (O.ToggleAutoSplash and not SmartBuffOptionsFrame:IsVisible()) then
SmartBuffSplashFrame:Clear();
SmartBuffSplashFrame:SetTimeVisible(1);
SmartBuffSplashFrame:AddMessage("!!! CANCEL " .. buff .. " !!!", O.ColSplashFont.r, O.ColSplashFont.g,
O.ColSplashFont.b, 1.0);
end
if (O.ToggleAutoChat) then
SMARTBUFF_AddMsgWarn("!!! CANCEL " .. buff .. " !!!", true);
end
end
end
end
end

if (event == "UI_ERROR_MESSAGE") then
Expand Down Expand Up @@ -1050,6 +1026,7 @@ end

-- Set the buff array
function SMARTBUFF_SetBuffs()
if (InCombatLockdown()) then return end
if (B == nil) then return; end

local n = 1;
Expand Down Expand Up @@ -1550,15 +1527,15 @@ function SMARTBUFF_SyncBuffTimers()
rbTime = 0;
buffS = cBuffs[i].BuffS;

-- TOCHECK
if B[CS()][ct][buffS].RBTime then
-- CHECK FOR NOT NIL; possible overkill with double check
if (B[CS()][ct][buffS] ~= nil) and (B[CS()][ct][buffS].RBTime ~= nil) then
rbTime = B[CS()][ct][buffS].RBTime;
if (rbTime <= 0) then
rbTime = O.RebuffTimer;
end
end

if (buffS and B[CS()][ct][buffS].EnableS and cBuffs[i].IDS ~= nil and cBuffs[i].DurationS > 0) then
if (buffS and (B[CS()][ct][buffS] ~= nil) and B[CS()][ct][buffS].EnableS and cBuffs[i].IDS ~= nil and cBuffs[i].DurationS > 0) then
if (cBuffs[i].Type ~= SMARTBUFF_CONST_SELF or (cBuffs[i].Type == SMARTBUFF_CONST_SELF and SMARTBUFF_IsPlayer(unit))) then
SMARTBUFF_SyncBuffTimer(unit, unit, cBuffs[i]);
end
Expand Down Expand Up @@ -3062,7 +3039,6 @@ function SMARTBUFF_Options_Init(self)
if (O.BuffInCities == nil) then O.BuffInCities = true; end
if (O.LinkSelfBuffCheck == nil) then O.LinkSelfBuffCheck = true; end
if (O.LinkGrpBuffCheck == nil) then O.LinkGrpBuffCheck = true; end
if (O.AntiDaze == nil) then O.AntiDaze = true; end

if (O.ScrollWheel ~= nil and O.ScrollWheelUp == nil) then O.ScrollWheelUp = O.ScrollWheel; end
if (O.ScrollWheel ~= nil and O.ScrollWheelDown == nil) then O.ScrollWheelDown = O.ScrollWheel; end
Expand Down Expand Up @@ -3496,10 +3472,6 @@ function SMARTBUFF_OLinkGrpBuffCheck()
O.LinkGrpBuffCheck = not O.LinkGrpBuffCheck;
end

function SMARTBUFF_OAntiDaze()
O.AntiDaze = not O.AntiDaze;
end

function SMARTBUFF_OScrollWheelUp()
O.ScrollWheelUp = not O.ScrollWheelUp;
isKeyUpChanged = true;
Expand Down Expand Up @@ -3551,6 +3523,9 @@ function SMARTBUFF_OSelfFirst()
end

function SMARTBUFF_OToggleBuff(s, i)
if (cBuffs[i] == nil) then
return
end
local bs = GetBuffSettings(cBuffs[i].BuffS);
if (bs == nil) then
return;
Expand Down Expand Up @@ -3874,7 +3849,6 @@ function SMARTBUFF_Options_OnShow()
SmartBuffOptionsFrame_cbInShapeshift:SetChecked(O.InShapeshift);
SmartBuffOptionsFrame_cbFixBuffIssue:SetChecked(O.SBButtonFix);

SmartBuffOptionsFrame_cbAntiDaze:SetChecked(O.AntiDaze);
SmartBuffOptionsFrame_cbLinkGrpBuffCheck:SetChecked(O.LinkGrpBuffCheck);
SmartBuffOptionsFrame_cbLinkSelfBuffCheck:SetChecked(O.LinkSelfBuffCheck);

Expand Down Expand Up @@ -4003,16 +3977,6 @@ function SMARTBUFF_SetCheckButtonBuffs(mode)
SMARTBUFF_SetBuffs();
end

SmartBuffOptionsFrame_cbAntiDaze:Hide();

if (sPlayerClass == "HUNTER" or sPlayerClass == "ROGUE" or sPlayerClass == "WARRIOR") then
SmartBuffOptionsFrameBLDuration:Hide();
if (sPlayerClass == "HUNTER") then
SmartBuffOptionsFrame_cbLinkGrpBuffCheck:Hide();
SmartBuffOptionsFrame_cbAntiDaze:Show();
end
end

if (sPlayerClass == "DRUID" or sPlayerClass == "SHAMAN") then
SmartBuffOptionsFrame_cbInShapeshift:Show();
else
Expand Down Expand Up @@ -4056,6 +4020,7 @@ function SMARTBUFF_DropDownTemplate_OnClick(self)
UIDropDownMenu_SetSelectedValue(SmartBuffOptionsFrame_ddTemplates, i);
tmp = SMARTBUFF_TEMPLATES[i];
--SMARTBUFF_AddMsgD("Selected/Current Buff-Template: " .. tmp .. "/" .. currentTemplate);
SMARTBUFF_SetBuffs()
if (currentTemplate ~= tmp) then
SmartBuff_BuffSetup:Hide();
iLastBuffSetup = -1;
Expand Down Expand Up @@ -4643,7 +4608,9 @@ local function OnScroll(self, cData, sBtnName)
btn:SetNormalFontObject("GameFontNormalSmall");
btn:SetHighlightFontObject("GameFontHighlightSmall");
btn:SetText(cData[n]);
btn:SetChecked(t[cData[n]].EnableS);
if (t[cData[n]] ~= nil) then
btn:SetChecked(t[cData[n]].EnableS);
end
btn:Show();
else
btn:Hide();
Expand Down
31 changes: 0 additions & 31 deletions SmartBuff.xml
Original file line number Diff line number Diff line change
Expand Up @@ -933,37 +933,6 @@
</OnLeave>
</Scripts>
</CheckButton>
<CheckButton name="SmartBuffOptionsFrame_cbAntiDaze" inherits="UICheckButtonTemplate">
<Size>
<AbsDimension x="24" y="24" />
</Size>
<Anchors>
<Anchor point="TOPLEFT" relativeTo="SmartBuffOptionsFrame_cbAutoSwitchTmp" relativePoint="TOPLEFT">
<Offset>
<AbsDimension x="0" y="-20" />
</Offset>
</Anchor>
</Anchors>
<HitRectInsets>
<AbsInset left="0" right="0" top="0" bottom="0" />
</HitRectInsets>
<Scripts>
<OnLoad>
getglobal(self:GetName().."Text"):SetText(SMARTBUFF_OFT_ANTIDAZE);
getglobal(self:GetName().."Text"):SetFontObject(GameFontNormalSmall);
</OnLoad>
<OnClick>
SMARTBUFF_OAntiDaze();
</OnClick>
<OnEnter>
GameTooltip:SetOwner(self, "ANCHOR_RIGHT");
GameTooltip:SetText(SMARTBUFF_OFTT_ANTIDAZE, SMARTBUFF_TTC_R, SMARTBUFF_TTC_G, SMARTBUFF_TTC_B, SMARTBUFF_TTC_A);
</OnEnter>
<OnLeave>
GameTooltip:Hide();
</OnLeave>
</Scripts>
</CheckButton>
<CheckButton name="SmartBuffOptionsFrame_cbLinkSelfBuffCheck" inherits="UICheckButtonTemplate" hidden="true">
<Size>
<AbsDimension x="24" y="24" />
Expand Down

0 comments on commit 279dd28

Please sign in to comment.