Skip to content

Commit

Permalink
v8.0.10 - Spell history, smart aoe, smart aura collection, cooldown c…
Browse files Browse the repository at this point in the history
…onsolidated, melee detection, profiler fixes
  • Loading branch information
pwilkowski committed Nov 3, 2018
1 parent 757f6b7 commit 620ac52
Show file tree
Hide file tree
Showing 6 changed files with 409 additions and 352 deletions.
2 changes: 1 addition & 1 deletion Libs/StdUi
2 changes: 1 addition & 1 deletion MaxDps.toc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Title: MaxDps
## Notes: Rotation helper framework.
## Version: 8.0.9
## Version: 8.0.10
## Author: Kaminaris
## Interface: 80000
## SavedVariables: MaxDpsOptions
Expand Down
28 changes: 14 additions & 14 deletions Modules/profiler.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local StdUi = LibStub('StdUi');

local Profiler = MaxDps:NewModule('Profiler', 'AceEvent-3.0');


function Profiler:Enable()
self.Spells = {};
self.PlayerAuras = {};
Expand Down Expand Up @@ -65,20 +65,23 @@ function Profiler:SanitizeSpellName(spellName)
end

function Profiler:GenerateLua()
local output = '-- Spells\n';
local output = '-- Spells\nlocal S = {\n';
for spellId, spellName in pairs(self.Spells) do
output = output .. 'local _' .. self:SanitizeSpellName(spellName) .. ' = ' .. spellId .. ';\n';
output = output .. ' ' .. self:SanitizeSpellName(spellName) .. ' = ' .. spellId .. ',\n';
end
output = output .. '};\n'

output = output .. '\n-- Player Auras\n';
output = output .. '\n-- Player Auras\nlocal A = {\n';
for auraId, auraName in pairs(self.PlayerAuras) do
output = output .. 'local _' .. self:SanitizeSpellName(auraName) .. ' = ' .. auraId .. ';\n';
output = output .. ' ' .. self:SanitizeSpellName(auraName) .. ' = ' .. auraId .. ',\n';
end
output = output .. '};\n'

output = output .. '\n-- Target Auras\n';
output = output .. '\n-- Target Auras\nlocal TA = {\n';
for auraId, auraName in pairs(self.TargetAuras) do
output = output .. 'local _' .. self:SanitizeSpellName(auraName) .. ' = ' .. auraId .. ';\n';
output = output .. ' ' .. self:SanitizeSpellName(auraName) .. ' = ' .. auraId .. ',\n';
end
output = output .. '};\n'

return output;
end
Expand All @@ -90,16 +93,13 @@ function Profiler:ShowWindow()
return;
end

local f = AceGUI:Create('Window');
f:SetTitle('MaxDps Profiler');
f:SetLayout('Flow');
local f = StdUi:Window(UIParent, 'MaxDps Profiler', 500, 600);
f:SetPoint('CENTER');

local editBox = AceGUI:Create('MultiLineEditBox');
editBox:SetFullWidth(true);
editBox:SetFullHeight(true);
local editBox = StdUi:MultiLineBox(f, 480, 550);
editBox:SetText(self:GenerateLua());
StdUi:GlueTop(editBox.panel, f, 0, -30, 'CENTER');

f:AddChild(editBox);
f:Show();

self.frame = f;
Expand Down
84 changes: 63 additions & 21 deletions core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,25 @@ function MaxDps:Print(...)
MaxDps:DefaultPrint(...);
end

MaxDps.profilerStatus = 0;
function MaxDps:ProfilerStart()
self:EnableModule('Profiler');
self.profilerStatus = 1;
end

function MaxDps:ProfilerStop()
self:DisableModule('Profiler');
self.profilerStatus = 0;
end

function MaxDps:ProfilerToggle()
if self.profilerStatus == 0 then
self:ProfilerStart();
else
self:ProfilerStop();
end
end

function MaxDps:EnableRotation()
if self.NextSpell == nil or self.rotationEnabled then
self:Print(self.Colors.Error .. 'Failed to enable addon!');
Expand All @@ -54,6 +73,7 @@ function MaxDps:EnableRotation()

self:CheckTalents();
self:GetAzeriteTraits();
self:CheckIsPlayerMelee();
if self.ModuleOnEnable then
self.ModuleOnEnable();
end
Expand Down Expand Up @@ -90,23 +110,40 @@ end
function MaxDps:OnEnable()
self:RegisterEvent('PLAYER_TARGET_CHANGED');
self:RegisterEvent('PLAYER_TALENT_UPDATE');
self:RegisterEvent('ACTIONBAR_SLOT_CHANGED');
self:RegisterEvent('PLAYER_REGEN_DISABLED');
self:RegisterEvent('PLAYER_ENTERING_WORLD');

self:RegisterEvent('ACTIONBAR_HIDEGRID');
self:RegisterEvent('ACTIONBAR_PAGE_CHANGED');
self:RegisterEvent('LEARNED_SPELL_IN_TAB');
self:RegisterEvent('CHARACTER_POINTS_CHANGED');
self:RegisterEvent('ACTIVE_TALENT_GROUP_CHANGED');
self:RegisterEvent('PLAYER_SPECIALIZATION_CHANGED');
self:RegisterEvent('UPDATE_MACROS');
self:RegisterEvent('VEHICLE_UPDATE');
self:RegisterEvent('ACTIONBAR_SLOT_CHANGED', 'ButtonFetch');
self:RegisterEvent('ACTIONBAR_HIDEGRID', 'ButtonFetch');
self:RegisterEvent('ACTIONBAR_PAGE_CHANGED', 'ButtonFetch');
self:RegisterEvent('LEARNED_SPELL_IN_TAB', 'ButtonFetch');
self:RegisterEvent('CHARACTER_POINTS_CHANGED', 'ButtonFetch');
self:RegisterEvent('ACTIVE_TALENT_GROUP_CHANGED', 'ButtonFetch');
self:RegisterEvent('PLAYER_SPECIALIZATION_CHANGED', 'ButtonFetch');
self:RegisterEvent('UPDATE_MACROS', 'ButtonFetch');
self:RegisterEvent('VEHICLE_UPDATE', 'ButtonFetch');
self:RegisterEvent('UPDATE_STEALTH', 'ButtonFetch');

self:RegisterEvent('UNIT_ENTERED_VEHICLE');
self:RegisterEvent('UNIT_EXITED_VEHICLE');
-- self:RegisterEvent('PLAYER_REGEN_ENABLED');

if not self.playerUnitFrame then
self.spellHistory = {};

self.playerUnitFrame = CreateFrame('Frame');
self.playerUnitFrame:RegisterUnitEvent('UNIT_SPELLCAST_SUCCEEDED', 'player');
self.playerUnitFrame:SetScript('OnEvent', function(_, event, unit, lineId, spellId)
if IsPlayerSpell(spellId) then
tinsert(self.spellHistory, 1, spellId);

if #self.spellHistory > 5 then
tremove(self.spellHistory);
end
end
end);
end

self:Print(self.Colors.Info .. 'Initialized');
end

Expand Down Expand Up @@ -158,24 +195,29 @@ function MaxDps:ButtonFetch()
end
end

MaxDps.ACTIONBAR_SLOT_CHANGED = MaxDps.ButtonFetch;
MaxDps.ACTIONBAR_HIDEGRID = MaxDps.ButtonFetch;
MaxDps.ACTIONBAR_PAGE_CHANGED = MaxDps.ButtonFetch;
MaxDps.LEARNED_SPELL_IN_TAB = MaxDps.ButtonFetch;
MaxDps.CHARACTER_POINTS_CHANGED = MaxDps.ButtonFetch;
MaxDps.ACTIVE_TALENT_GROUP_CHANGED = MaxDps.ButtonFetch;
MaxDps.PLAYER_SPECIALIZATION_CHANGED = MaxDps.ButtonFetch;
MaxDps.UPDATE_MACROS = MaxDps.ButtonFetch;
MaxDps.VEHICLE_UPDATE = MaxDps.ButtonFetch;
function MaxDps:PrepareFrameData()
if not self.FrameData then
self.FrameData = {
cooldown = self.PlayerCooldowns,
};
end

self.FrameData.timeShift, self.FrameData.currentSpell, self.FrameData.gcdRemains = MaxDps:EndCast();
self.FrameData.gcd = self:GlobalCooldown();
self.FrameData.buff, self.FrameData.debuff = MaxDps:CollectAuras();
self.FrameData.talents = self.PlayerTalents;
self.FrameData.azerite = self.AzeriteTraits;
self.FrameData.spellHistory = self.spellHistory;
end

function MaxDps:InvokeNextSpell()
-- invoke spell check
local oldSkill = self.Spell;

local timeShift, currentSpell, gcd = MaxDps:EndCast();
local auras, targetAuras = MaxDps:CollectAuras();
self:PrepareFrameData();

self.Spell = self:NextSpell(timeShift, currentSpell, gcd, self.PlayerTalents, self.AzeriteTraits);
--For backward compatibility only
self.Spell = self:NextSpell(self.FrameData.timeShift, self.FrameData.currentSpell, self.FrameData.gcd, self.PlayerTalents, self.AzeriteTraits);

if (oldSkill ~= self.Spell or oldSkill == nil) and self.Spell ~= nil then
self:GlowNextSpell(self.Spell);
Expand Down
Loading

0 comments on commit 620ac52

Please sign in to comment.