-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathMain.lua
120 lines (101 loc) · 2.89 KB
/
Main.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
local addonName, addonTable = ...
_G[addonName] = addonTable
--- @type MaxDps
if not MaxDps then return end
local MaxDps = MaxDps
local IsActionInRange = IsActionInRange
local GetPowerRegen = GetPowerRegen
local UnitPowerMax = UnitPowerMax
local UnitPower = UnitPower
local GetActionInfo = GetActionInfo
local TableContains = tContains
local PowerTypeFocus = Enum.PowerType.Focus
local ipairs = ipairs
local select = select
local Hunter = MaxDps:NewModule('Hunter')
addonTable.Hunter = Hunter
Hunter.spellMeta = {
__index = function(t, k)
print('Spell Key ' .. k .. ' not found!')
end
}
local _PetBasics = {
49966, -- Smack
16827, -- Claw
17253 -- Bite
}
function Hunter:Enable()
if MaxDps:IsRetailWow() then
Hunter:InitializeDatabase()
Hunter:CreateConfig()
end
if MaxDps.Spec == 1 then
MaxDps.NextSpell = Hunter.BeastMastery
MaxDps:Print(MaxDps.Colors.Info .. 'Hunter Beast Mastery', "info")
elseif MaxDps.Spec == 2 then
MaxDps.NextSpell = Hunter.Marksmanship
MaxDps:Print(MaxDps.Colors.Info .. 'Hunter Marksmanship', "info")
elseif MaxDps.Spec == 3 then
MaxDps.NextSpell = Hunter.Survival
MaxDps:Print(MaxDps.Colors.Info .. 'Hunter Survival', "info")
end
return true
end
function Hunter:Focus(minus, timeShift)
local casting = GetPowerRegen()
local powerMax = UnitPowerMax('player', PowerTypeFocus)
local power = UnitPower('player', PowerTypeFocus) -- + (casting * timeShift)
if power > powerMax then
power = powerMax
end
power = power - minus
return power, powerMax, casting
end
function Hunter:FocusTimeToMax()
local regen = GetPowerRegen()
local focusMax = UnitPowerMax('player', PowerTypeFocus)
local focus = UnitPower('player', PowerTypeFocus)
local ttm = (focusMax - focus) / regen
if ttm < 0 then
ttm = 0
end
return ttm
end
local function isHunterPetBasic(slot)
local id = select(2, GetActionInfo(slot))
return TableContains(_PetBasics, id)
end
function Hunter:FindPetBasicSlot()
if self.PetBasicSlot and isHunterPetBasic(self.PetBasicSlot) then
return self.PetBasicSlot
end
for slot = 1, 120 do
if isHunterPetBasic(slot) then
self.PetBasicSlot = slot
return slot
end
end
return nil
end
-- Requires a pet's basic ability to be on an action bar somewhere.
local lastWarning
function Hunter:TargetsInPetRange()
local slot = self:FindPetBasicSlot()
if slot == nil then
local t = GetTime()
if not lastWarning or t - lastWarning > 5 then
MaxDps:Print(MaxDps.Colors.Error .. 'At least one pet basic ability needs to be on YOUR action bar (One of those: Smack, Claw, Bite).', "error")
MaxDps:Print(MaxDps.Colors.Error .. 'Read this for more information: goo.gl/ZF6FXt', "error")
lastWarning = t
end
return 1
end
local count = 0
for _, unit in ipairs(MaxDps.visibleNameplates) do
if IsActionInRange(slot, unit) then
count = count + 1
end
end
if WeakAuras then WeakAuras.ScanEvents('MAXDPS_TARGET_COUNT', count) end
return count
end