Skip to content

Commit

Permalink
Shared codebase for ERA, HC and WOTLK!
Browse files Browse the repository at this point in the history
Shared codebase for ERA, HC and WOTLK - will make my life easier moving forward.  Sounds are now local rather than in game sounds so i can use retail under classic or custom sounds.
  • Loading branch information
Softrix committed Oct 9, 2023
1 parent c496227 commit 3506078
Show file tree
Hide file tree
Showing 30 changed files with 157 additions and 31 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SmartBuff Wrath of the Lich King CLassic
# SmartBuff Wrath of the Lich King CLassic / Classic ERA and Classic Hardcore

For clarity, this repository is ONLY for the WOTLK Classic version of the client as listed above, and it is not the Retail or Classic Era.
For clarity, this repository is ONLY for the Classic version of the client as listed above, and it is not the Retail.

SmartBuff is a buff addon to monitor you, your party or raids buffs easily and quickly allowing you to cast those that are missing - all classes are supported.

Expand Down
12 changes: 10 additions & 2 deletions SmartBuff.buffs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ SMARTBUFF_CONST_GROUPALL = "GROUPALL";
SMARTBUFF_CONST_SELF = "SELF";
SMARTBUFF_CONST_FORCESELF = "FORCESELF";
SMARTBUFF_CONST_TRACK = "TRACK";
SMARTBUFF_CONST_GATHERING = "GATHERING";
SMARTBUFF_CONST_WEAPON = "WEAPON";
SMARTBUFF_CONST_INV = "INVENTORY";
SMARTBUFF_CONST_FOOD = "FOOD";
Expand All @@ -27,6 +28,8 @@ S.CheckFishingPole = "CHECKFISHINGPOLE";
S.NIL = "x";
S.Toybox = { };

SBClassicGatherers = { 2580, 2383, 2481 } -- classic era & hardcore only.

local function GetItems(items)
local t = { };
for _, id in pairs(items) do
Expand Down Expand Up @@ -577,6 +580,7 @@ function SMARTBUFF_InitSpellIDs()
-- Tracking
SMARTBUFF_FINDMINERALS = GetSpellInfo(2580); --"Find Minerals"
SMARTBUFF_FINDHERBS = GetSpellInfo(2383); --"Find Herbs"
SMARTBUFF_FINDTREASURE = GetSpellInfo(2481); --"Find Treasure"
SMARTBUFF_FINDFISH = GetSpellInfo(43308); --"Find Fish"
SMARTBUFF_FINDTREASURE = GetSpellInfo(2481); --"Find Treasure"
SMARTBUFF_TRACKHUMANOIDS = GetSpellInfo(19883); --"Track Humanoids"
Expand Down Expand Up @@ -1111,8 +1115,12 @@ function SMARTBUFF_InitSpellList()
{SMARTBUFF_TRACKELEMENTALS, -1, SMARTBUFF_CONST_TRACK},
{SMARTBUFF_TRACKDEMONS, -1, SMARTBUFF_CONST_TRACK},
{SMARTBUFF_TRACKGIANTS, -1, SMARTBUFF_CONST_TRACK},
{SMARTBUFF_TRACKDRAGONKIN, -1, SMARTBUFF_CONST_TRACK}
};
{SMARTBUFF_TRACKDRAGONKIN, -1, SMARTBUFF_CONST_TRACK},
-- these are used under era and hardcore only.
{SMARTBUFF_FINDMINERALS, -1, SMARTBUFF_CONST_GATHERING},
{SMARTBUFF_FINDHERBS, -1, SMARTBUFF_CONST_GATHERING},
{SMARTBUFF_FINDTREASURE, -1, SMARTBUFF_CONST_GATHERING},
};

-- Racial
SMARTBUFF_RACIAL = {
Expand Down
137 changes: 116 additions & 21 deletions SmartBuff.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@
-- Cast the most important buffs on you, tanks or party/raid members/pets.
-------------------------------------------------------------------------------

SMARTBUFF_DATE = "071023";
SMARTBUFF_DATE = "091023";

SMARTBUFF_VERSION = "r51."..SMARTBUFF_DATE;
SMARTBUFF_VERSION = "r52."..SMARTBUFF_DATE;
SMARTBUFF_VERSIONNR = 30402;
SMARTBUFF_VERWOTLK = false;
SMARTBUFF_TITLE = "SmartBuff";
SMARTBUFF_SUBTITLE = "Supports you in casting buffs";
SMARTBUFF_DESC = "Cast the most important buffs on you, your tanks, party/raid members/pets";
SMARTBUFF_VERS_TITLE = SMARTBUFF_TITLE .. " " .. SMARTBUFF_VERSION;
SMARTBUFF_OPTIONS_TITLE = SMARTBUFF_VERS_TITLE.." WOTLK ";
SMARTBUFF_OPTIONS_TITLE = SMARTBUFF_VERS_TITLE.." Classic ";

-- addon name
local addonName = ...
Expand Down Expand Up @@ -111,8 +112,22 @@ local cPlayerTrackers = { };
local cDisableTrackSwitch = false;
local cLootOpenedDisable = false;

local cClasses = {"DRUID", "HUNTER", "MAGE", "PALADIN", "PRIEST", "ROGUE", "SHAMAN", "WARLOCK", "WARRIOR", "DEATHKNIGHT", "MONK", "DEMONHUNTER", "EVOKER", "HPET", "WPET", "DKPET", "TANK", "HEALER", "DAMAGER"};
local cIgnoreClasses = { 11, 12, 13, 19 };
local cClasses;
local cIgnoreClasses;

-- client version check
if buildInfo < SMARTBUFF_VERSIONNR then
-- assume we are classic era/hardcore.
cClasses = {"DRUID", "HUNTER", "MAGE", "PALADIN", "PRIEST", "ROGUE", "SHAMAN", "WARLOCK", "WARRIOR", "DEATHKNIGHT", "MONK", "DEMONHUNTER", "EVOKER", "HPET", "WPET", "DKPET", "TANK", "HEALER", "DAMAGER"};
cIgnoreClasses = { 10, 11, 12, 13, 16, 19 };
SMARTBUFF_VERWOTLK = false
else
-- wrath of the lich king.
cClasses = {"DRUID", "HUNTER", "MAGE", "PALADIN", "PRIEST", "ROGUE", "SHAMAN", "WARLOCK", "WARRIOR", "DEATHKNIGHT", "MONK", "DEMONHUNTER", "EVOKER", "HPET", "WPET", "DKPET", "TANK", "HEALER", "DAMAGER"};
cIgnoreClasses = { 11, 12, 13, 19 };
SMARTBUFF_VERWOTLK = true
end

local cOrderGrp = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
local cFonts = {"NumberFontNormal", "NumberFontNormalLarge", "NumberFontNormalHuge", "GameFontNormal", "GameFontNormalLarge", "GameFontNormalHuge", "ChatFontNormal", "QuestFont", "MailTextFontNormal", "QuestTitleFont"};

Expand Down Expand Up @@ -152,10 +167,35 @@ local Icons = {
["NONE"] = { IconPaths.Roles, 20/64, 39/64, 22/64, 41/64 },
};

-- available sounds (34)
local Sounds = { 1141, 3784, 4574, 17318, 15262, 13830, 15273, 10042, 10720, 17316, 3337, 15263, 13267, 8698, 3660,
15712, 9203, 12279, 3273, 13179, 13327, 9632, 10590, 3322, 718, 149, 15686, 6189, 7095, 6341, 6267,
7894, 7914, 10033 }
local tracker = ""

-- available sounds (20)
local soundPath = "Interface\\AddOns\\SmartBuff\\Sounds\\";
local Sounds = {
"igPlayerBind.ogg",
"Aggro_Enter_Warning_State.ogg",
"Aggro_Pulled_Aggro.ogg",
"LFG_DungeonReady.ogg",
"LFG_Rewards.ogg",
"FX_SONIC_SPHEREPULSE_01.ogg",
"EyeOfKilroggDeath.ogg",
"GM_ChatWarning.ogg",
"gruntling_horn_bb.ogg",
"WispPissed3.ogg",
"UR_Kologarn_Slay02.ogg",
"UI_PetBattle_Victory02.ogg",
"PVPWarning.ogg",
"PVPFlagTakenHordeMono.ogg",
"YouAreWeak.ogg",
"PeasantPissed5.ogg",
"HumanFemaleSigh01.ogg",
"HumanMaleSigh01.ogg",
"GnomeMaleLaugh01.ogg",
"Emote_Whistle_01.ogg",
"VO_701_IMage_OF_Millhouse_Manastorm_05.ogg",
"VO_703_Millhouse_Manastorm_29_M.ogg",
"VO_901_Millificent_Manastorm_193617.ogg",
};

local DebugChatFrame = DEFAULT_CHAT_FRAME;

Expand Down Expand Up @@ -217,7 +257,7 @@ local CY = BCC(0.5, 1, 1);

-- function to preview selected warning sound in options screen
function SMARTBUFF_PlaySpashSound()
PlaySound(Sounds[O.AutoSoundSelection]);
PlaySoundFile(soundPath..Sounds[O.AutoSoundSelection]);
end

function SMARTBUFF_ChooseSplashSound()
Expand Down Expand Up @@ -425,7 +465,7 @@ end

-- toggle the auto gathering switcher.
function ToggleAutoGatherer()
if (not isInit) then return end
if (not isInit or not SMARTBUFF_VERWOTLK) then return end
O.TrackSwitchActive = not O.TrackSwitchActive;
if not SmartBuffOptionsFrame:IsShown() then -- quiet while in options
if O.TrackSwitchActive then
Expand All @@ -439,7 +479,7 @@ end

-- Read number of tracking abilities
function ScanPlayerTrackers()
if (not isInit) then return end
if (not isInit or not SMARTBUFF_VERWOTLK) then return end
local count = C_Minimap.GetNumTrackingTypes();
local spellcount = 0;
cPlayerTrackers = { };
Expand All @@ -459,7 +499,7 @@ end
-- toggle trackers
local lastFire = GetTime()
function ToggleGatheringTrackers()
if (not isInit) then return end
if (not isInit or not SMARTBUFF_VERWOTLK) then return end
local tmptable
if O.TrackSwitchActive and not cDisableTrackSwitch and not cLootOpenedDisable then
local currentTime = GetTime()
Expand Down Expand Up @@ -520,6 +560,8 @@ function SMARTBUFF_OnLoad(self)
self:RegisterEvent("UPDATE_MOUSEOVER_UNIT");
self:RegisterEvent("UNIT_SPELLCAST_FAILED");
self:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED");
self:RegisterEvent("MINIMAP_UPDATE_TRACKING")

--auto template events
self:RegisterEvent("ZONE_CHANGED_NEW_AREA")
self:RegisterEvent("GROUP_ROSTER_UPDATE")
Expand Down Expand Up @@ -559,6 +601,12 @@ function SMARTBUFF_OnEvent(self, event, ...)
tStartZone = GetTime();
end

elseif event == "MINIMAP_UPDATE_TRACKING" and not SMARTBUFF_VERWOTLK then
if not GetTrackingTexture() then
-- we dont have a tracker so force a reset.
tracker = "";
end

elseif(event == "ADDON_LOADED" and arg1 == SMARTBUFF_TITLE) then
isLoaded = true;
end
Expand Down Expand Up @@ -1165,7 +1213,7 @@ function SMARTBUFF_SetBuff(buff, i, ia)
cBuffs[i].IDS, cBuffs[i].BookID = SMARTBUFF_GetSpellID(cBuffs[i].BuffS);
end

if (cBuffs[i].IDS == nil and not(SMARTBUFF_IsItem(cBuffs[i].Type) or cBuffs[i].Type == SMARTBUFF_CONST_TRACK)) then
if (cBuffs[i].IDS == nil and not(SMARTBUFF_IsItem(cBuffs[i].Type) or cBuffs[i].Type == SMARTBUFF_CONST_TRACK or (cBuffs[i].Type == SMARTBUFF_CONST_GATHERING and not SMARTBUFF_VERWOTLK))) then
cBuffs[i] = nil;
return i;
end
Expand All @@ -1178,7 +1226,25 @@ function SMARTBUFF_SetBuff(buff, i, ia)
if (cBuffs[i].IDS ~= nil) then
cBuffs[i].IconS = GetSpellTexture(cBuffs[i].BuffS);
else
if (cBuffs[i].Type == SMARTBUFF_CONST_TRACK) then

if (cBuffs[i].Type == SMARTBUFF_CONST_GATHERING) and not SMARTBUFF_VERWOTLK then
local b = false;
for key, spellId in ipairs(SBClassicGatherers) do
spellName = GetSpellInfo(spellId)
if spellName ~= nil then
if IsPlayerSpell(spellId) and spellName == cBuffs[i].BuffS then
b = true;
cBuffs[i].IDS = spellId;
cBuffs[i].IconS = GetSpellTexture(spellId);
end
end
end
if (not b) then
cBuffs[i] = nil;
return i;
end

elseif (cBuffs[i].Type == SMARTBUFF_CONST_TRACK) and SMARTBUFF_VERWOTLK then
local b = false;
for n = 1, C_Minimap.GetNumTrackingTypes() do
local trackN, trackT, trackA, trackC = C_Minimap.GetTrackingInfo(n);
Expand Down Expand Up @@ -1834,7 +1900,7 @@ function SMARTBUFF_BuffUnit(unit, subgroup, mode, spell)
SMARTBUFF_AddMsgD("Exclusive check on " .. spell .. ", current spell = " .. buffnS);
end
if (bUsable and cBuff.Type == SMARTBUFF_CONST_SELF and not SMARTBUFF_IsPlayer(unit)) then bUsable = false end
if (bUsable and not cBuff.Type == SMARTBUFF_CONST_TRACK and not SMARTBUFF_IsItem(cBuff.Type) and not IsUsableSpell(buffnS)) then bUsable = false end
if ((bUsable and not cBuff.Type == SMARTBUFF_CONST_TRACK) and not SMARTBUFF_IsItem(cBuff.Type) and not IsUsableSpell(buffnS)) then bUsable = false end
if (bUsable and bs.SelfNot and SMARTBUFF_IsPlayer(unit)) then bUsable = false end
if (bUsable and cBuff.Params == SG.CheckFishingPole and SMARTBUFF_IsFishingPoleEquiped()) then bUsable = false end

Expand Down Expand Up @@ -1992,8 +2058,24 @@ function SMARTBUFF_BuffUnit(unit, subgroup, mode, spell)
or SMARTBUFF_IsInList(unit, un, bs.AddList))) then
buff = nil;

-- Gathering ability ------------------------------------------------------------------------
if (cBuff.Type == SMARTBUFF_CONST_GATHERING and not SMARTBUFF_VERWOTLK) then
local b = false;
for key, spellId in ipairs(SBClassicGatherers) do
spellName = GetSpellInfo(spellId)
if spellName ~= nil and spellName ~= tracker then
if IsPlayerSpell(spellId) and spellName == buffnS then
CastSpellByName(spellName)
tracker = spellName
SMARTBUFF_AddMsgD(spellName.." applied.");
end
else
isPrompting = false
end
end

-- Tracking ability ------------------------------------------------------------------------
if (cBuff.Type == SMARTBUFF_CONST_TRACK) then
elseif (cBuff.Type == SMARTBUFF_CONST_TRACK) then
local count = C_Minimap.GetNumTrackingTypes();
for n = 1, C_Minimap.GetNumTrackingTypes() do
local trackN, trackT, trackA, trackC = C_Minimap.GetTrackingInfo(n);
Expand Down Expand Up @@ -2468,7 +2550,7 @@ function SMARTBUFF_SetMissingBuffMessage(target, buff, icon, bCanCharge, nCharge

-- play sound
if (O.ToggleAutoSound) then
PlaySound(Sounds[O.AutoSoundSelection]);
PlaySoundFile(soundPath..Sounds[O.AutoSoundSelection]);
end
end

Expand Down Expand Up @@ -3023,7 +3105,7 @@ function SMARTBUFF_Options_Init(self)
if (isInit) then return; end

-- test if this is the intended client
if (buildInfo < SMARTBUFF_VERSIONNR) or (buildInfo > 100000) then
if buildInfo > 100000 then
if smVerWarn then
DEFAULT_CHAT_FRAME:AddMessage("|cff00e0ffSmartbuff Build "..SMARTBUFF_VERSION.." (Client: "..buildInfo..")|cffffffff "..SMARTBUFF_NOTINTENDEDCLIENT)
end
Expand Down Expand Up @@ -3064,7 +3146,7 @@ function SMARTBUFF_Options_Init(self)
if (O.RebuffTimer == nil) then O.RebuffTimer = 20; end
if (O.SplashDuration == nil) then O.SplashDuration = 2; end
if (O.SplashIconSize == nil) then O.SplashIconSize = 16; end
if (O.BuffTarget == nil) then O.BuffTarget = false; end
if (O.BuffTarget == nil) then O.BuffTarget = true; end
if (O.BuffPvP == nil) then O.BuffPvP = false; end
if (O.BuffInCities == nil) then O.BuffInCities = true; end
if (O.LinkSelfBuffCheck == nil) then O.LinkSelfBuffCheck = true; end
Expand Down Expand Up @@ -3249,6 +3331,10 @@ function SMARTBUFF_Options_Init(self)
-- regardless of the option in settings, grab info on gathering trackers
ScanPlayerTrackers();

if not SMARTBUFF_VERWOTLK then
O.TrackSwitchActive = false;
end

isSyncReq = true;

end
Expand Down Expand Up @@ -3545,7 +3631,6 @@ end

function SMARTBUFF_OptionsFrame_Toggle()
if (not isInit) then return; end

if(SmartBuffOptionsFrame:IsVisible()) then
if(iLastBuffSetup > 0) then
SmartBuff_BuffSetup:Hide();
Expand Down Expand Up @@ -3851,6 +3936,16 @@ function SMARTBUFF_Options_OnShow()

SMARTBUFF_Splash_Show();

-- if we are classic era or hardcore, hide some
-- stuff we dont need or can't use.
if not SMARTBUFF_VERWOTLK then
SmartBuffOptionsFrame_cbGatherAutoSwitch:Disable();
SmartBuffOptionsFrame_cbGatherAutoSwitchFish:Disable();
SmartBuffOptionsFrame_cbGatherAutoDisableTracker:Disable();
SmartBuffOptionsFrame_cbFixBuffIssue:Disable();
end


SMARTBUFF_AddMsgD("Option frame updated: " .. currentTemplate);
end

Expand Down
4 changes: 2 additions & 2 deletions SmartBuff.toc
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
## Interface: 30402
## Title: |TInterface\Addons\Smartbuff\Icons\IconEnabled:0|t SmartBuff |cffffffff(WOTLK)|r by |cff00ff00Codermik & Aeldra|r
## Title: |TInterface\Addons\Smartbuff\Icons\IconEnabled:0|t SmartBuff |cffffffff(WOTLK)|r
## Version: 52.30402
## Author: |cff20d2ffCodermik & Aeldra|r (EU-Proudmoore)
## Contributing Author: |cff20d2ffSpeedwaystar
## Notes: Cast the most important buffs on you or party/raid members/pets. Use /sbm for options menu.
## Notes: Automatically cast buffs on yourself, your party or raid members and their pets. Use /sbm for the options menu.
## DefaultState: Enabled
## LoadOnDemand: 0
## SavedVariables: SMARTBUFF_OptionsGlobal
Expand Down
4 changes: 2 additions & 2 deletions SmartBuff.xml
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@
<AbsDimension x="560" y="770" />
</Size>
<Anchors>
<Anchor x="-866" y="245" point="CENTER" />
<Anchor point="CENTER" />
</Anchors>
<Layers>
<Layer>
Expand Down Expand Up @@ -1578,7 +1578,7 @@
end
</OnShow>
<OnLoad>
SmartBuffOptionsFrameSlider_OnLoad(self, 1, 34, 1);
SmartBuffOptionsFrameSlider_OnLoad(self, 1, 23, 1);
BackdropTemplateMixin.OnBackdropLoaded(self);
</OnLoad>
<OnEnter>
Expand Down
19 changes: 19 additions & 0 deletions SmartBuff_Vanilla.toc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## Interface: 11404
## Title: |TInterface\Addons\Smartbuff\Icons\IconEnabled:0|t SmartBuff |cffffffff(ERA, HC)|r
## Version: 52.11404
## Author: |cff20d2ffCodermik & Aeldra|r (EU-Proudmoore)
## Contributing Author: |cff20d2ffSpeedwaystar
## Notes: Automatically cast buffs on yourself, your party or raid members and their pets. Use /sbm for the options menu.
## DefaultState: Enabled
## LoadOnDemand: 0
## SavedVariables: SMARTBUFF_OptionsGlobal
## SavedVariablesPerCharacter: SMARTBUFF_Options, SMARTBUFF_Buffs

Libs\LibStub\LibStub.lua
Libs\CallbackHandler-1.0\CallbackHandler-1.0.lua
Libs\LibRangeCheck-2.0\LibRangeCheck-2.0.lua
SmartBuff.globals.lua
SmartBuff.xml

Libs\Broker_SmartBuff\LibDataBroker-1.1.lua
Libs\Broker_SmartBuff\Broker_SmartBuff.lua
Binary file added Sounds/Aggro_Enter_Warning_State.ogg
Binary file not shown.
Binary file added Sounds/Aggro_Pulled_Aggro.ogg
Binary file not shown.
Binary file added Sounds/Emote_Whistle_01.ogg
Binary file not shown.
Binary file added Sounds/EyeOfKilroggDeath.ogg
Binary file not shown.
Binary file added Sounds/FX_SONIC_SPHEREPULSE_01.ogg
Binary file not shown.
Binary file added Sounds/GM_ChatWarning.ogg
Binary file not shown.
Binary file added Sounds/GnomeMaleLaugh01.ogg
Binary file not shown.
Binary file added Sounds/HumanFemaleSigh01.ogg
Binary file not shown.
Binary file added Sounds/HumanMaleSigh01.ogg
Binary file not shown.
Binary file added Sounds/LFG_DungeonReady.ogg
Binary file not shown.
Binary file added Sounds/LFG_Rewards.ogg
Binary file not shown.
Binary file added Sounds/PVPFlagTakenHordeMono.ogg
Binary file not shown.
Binary file added Sounds/PVPWarning.ogg
Binary file not shown.
Binary file added Sounds/PeasantPissed5.ogg
Binary file not shown.
Binary file added Sounds/UI_PetBattle_Victory02.ogg
Binary file not shown.
Binary file added Sounds/UR_Kologarn_Slay02.ogg
Binary file not shown.
Binary file added Sounds/VO_701_IMage_OF_Millhouse_Manastorm_05.ogg
Binary file not shown.
Binary file added Sounds/VO_703_Millhouse_Manastorm_29_M.ogg
Binary file not shown.
Binary file added Sounds/VO_901_Millificent_Manastorm_193617.ogg
Binary file not shown.
Binary file added Sounds/WispPissed3.ogg
Binary file not shown.
Binary file added Sounds/YouAreWeak.ogg
Binary file not shown.
Binary file added Sounds/gruntling_horn_bb.ogg
Binary file not shown.
Binary file added Sounds/igPlayerBind.ogg
Binary file not shown.
8 changes: 6 additions & 2 deletions localization.en.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
SMARTBUFF_WHATSNEW = "\n\n"
.." |cff00e0ffClassic & Retail versions by Codermik with additional\n"
.." retail coding by Speedwaystar.\n\n"
.." |cffffffffChanges in r52.091023 (WOTLK Classic):\n\n"
.." * Fixed lua error on new installs (when config empty).\n"
.." |cffffffffChanges in r52.091023 (Classic):\n\n"
.." * Classic Era, Hardcore and WOTLK now share \n"
.." the same codebase, this will make my life\n"
.." so much easier moving forward :)\n"
.." * Sounds are now local, this allows me to provide \n"
.." retail or custom sounds for splash prompts.\n"
.."\n\n"
.." |cffffff00I currently play on the Mirage Raceway EU classic\n"
.." WOTLK server as Alliance, I play on Mik, Gabella,\n"
Expand Down

0 comments on commit 3506078

Please sign in to comment.