-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathHSBatching.lua
80 lines (74 loc) · 2.77 KB
/
HSBatching.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
local _, addon = ...
-- Allows you to set your hearthstone as you teleport away to your previous location at the end of the hearthstone cast.
-- Only works if the binding confirmation and the HS spell cast are processed in the same batch (<10ms as of patch 1.14)
local HSframe = CreateFrame("Frame");
local currentFPS = GetCVar("maxfps")
local HSstart = 0
local batchingWindow = 0.006
local bindConfirmation = string.gsub(CONFIRM_BINDER,"%%s",".-")
local IsCurrentSpell = C_Spell and C_Spell.IsCurrentSpell or _G.IsCurrentSpell
local ConfirmBinder
if C_PlayerInteractionManager and C_PlayerInteractionManager.ConfirmationInteraction and Enum and Enum.PlayerInteractionType and Enum.PlayerInteractionType.Binder then
ConfirmBinder = function()
return C_PlayerInteractionManager.ConfirmationInteraction(Enum.PlayerInteractionType.Binder)
end
else
ConfirmBinder = _G.ConfirmBinder
end
local function SwitchBindLocation()
if GetTime() - HSstart > 10 - batchingWindow then
ConfirmBinder()
HSframe:SetScript("OnUpdate", nil)
SetCVar("maxfps", currentFPS)
HSstart = 0
--print('bind-ok')
elseif GetFramerate() < 20 then
SetCVar("maxfps", currentFPS)
end
addon.isCastingHS = false
end
--[[
hooksecurefunc("SetCVar",function(n,v)
if n == "maxfps" then
print(n,v)--ok
C_Timer.After(1,function()
print(GetCVar("maxfps"))
end)
end
end)
]]
local function StartHSTimer()
if HSstart == 0 and addon.settings.profile.enableHSbatch then
--print('start-hs')
local size = addon.settings.profile.batchSize or 6
batchingWindow = size / 1e3
currentFPS = GetCVar("maxfps")
HSstart = GetTime()
HSframe:SetScript("OnUpdate", SwitchBindLocation)
local bind = _G.StaticPopup1 and _G.StaticPopup1.text and
_G.StaticPopup1.text:GetText() or ""
if bind:find(bindConfirmation) then
SetCVar("maxfps", "300")
addon.isCastingHS = 0.5
addon.StartTimer(10-batchingWindow,"Hearthstone")
end
end
end
if _G.C_Container and _G.C_Container.UseContainerItem then -- DF+
hooksecurefunc(C_Container, "UseContainerItem", function(...)
if (C_Container.GetContainerItemID(...) == 6948) then
StartHSTimer()
end
end)
else
hooksecurefunc("UseContainerItem", function(...)
if _G.GetContainerItemID(...) == 6948 then StartHSTimer() end
end)
end
hooksecurefunc("UseAction", function(...)
local event, id = GetActionInfo(...)
--print(event,id,IsCurrentSpell(id))
if event == "item" and id == 6948 or
event == "macro" and (IsCurrentSpell(8690) or IsCurrentSpell(556)) or
event == "spell" and id == 556 then StartHSTimer() end
end)