local root=(arg[1] or '.')..'/' local function Check(native,methodAvailable,class) class=class or 'HUNTER' local now,keys=0,false local frames,modules,timers={},{},{} local methods={} local noop=function() end local function object(kind,name,parent) local f=setmetatable({scripts={},events={},shown=true,parent=parent,kind=kind}, {__index=function(t,k) return methods[k] or (string.find(k,'^[A-Z]') and noop or nil) end}) if kind=='StatusBar' and not methodAvailable then f.SetTimerDuration=false end if name then _G[name]=f end table.insert(frames,f);return f end function methods:RegisterEvent(name) self.events[name]=true end function methods:RegisterUnitEvent(name) self.events[name]=true end function methods:SetScript(name,callback) self.scripts[name]=callback end function methods:Show() self.shown=true end function methods:Hide() self.shown=false end function methods:IsShown() return self.shown end function methods:CreateTexture() return object('Texture',nil,self) end function methods:CreateFontString() return object('FontString',nil,self) end function methods:SetText(value) self.text=value end function methods:SetStatusBarColor(...) self.color=arg end function methods:SetPoint(...) self.point=arg end function methods:GetStatusBarTexture() self.fill=self.fill or object('Texture');return self.fill end function methods:SetMinMaxValues(low,high) self.low,self.high=low,high;self.nativeTimer=nil end function methods:SetValue(value) self.value=value end function methods:SetTimerDuration(duration) self.nativeTimer=duration end function methods:ClearAllPoints() self.point=nil end function methods:GetLeft() return 20 end function methods:GetBottom() return 40 end CreateFrame=object UIParent=object('Frame');CastingBarFrame=object('StatusBar') GetTime=function() return now end UnitClass=function() return class,class end UnitAffectingCombat=function() return false end UnitAttackSpeed=function() return 2,2 end UnitRangedDamage=function() return 2 end GetInventoryItemTexture=function() return 'weapon' end C_Item={GetItemInventoryType=function() return 13 end} local swingType={MainHand=1,OffHand=2,Ranged=3} Enum={PlayerSwingType=swingType,StatusBarInterpolation={Immediate=0},StatusBarTimerDirection={ElapsedTime=0},NumericRuleFormatRounding={Down=0}} C_SwingTimer={EnableRangeCheck=noop,IsTargetWithinSwingRange=function() return true end} C_EventUtils={IsEventValid=function() return true end} local queued=false C_Spell={IsNextMeleeSpell=function(id) return id==6807 end,GetSpellName=function() return 'Maul' end} GetActionInfo=function(slot) if slot==1 then return 'spell',6807 end end IsCurrentAction=function(slot) return slot==1 and queued end C_Timer={NewTimer=function(delay,callback) local timer={at=now+delay,callback=callback,cancelled=false} function timer:Cancel() self.cancelled=true end table.insert(timers,timer);return timer end} C_DurationUtil={CreateDuration=function() local d={} function d:SetTimeFromEnd(finish,total) self.finish,self.total=finish,total end function d:GetRemainingDuration() return math.max(0,(self.finish or 0)-now) end return d end,CreateDurationTextBinding=function() local b={enabled=false} function b:SetFontString(text) self.text=text end function b:SetDuration(d) self.duration=d end function b:SetFormatter(formatter) self.formatter=formatter end function b:SetExpiredText(text) self.expired=text end function b:Enable() self.enabled=true end function b:Disable() self.enabled=false end return b end} C_StringUtil={CreateNumericRuleFormatter=function() return {AddBreakpoint=function(self,v) assert(v.step==.1);self.rule=v end} end} ShaguTweaks_config={} ShaguTweaks={T=setmetatable({},{__index=function(t,k) return k end}),GetGlobalEnv=function() return getfenv(0) end, API={durationtimers=native,AreMoveModifiersDown=function() return keys end}} if not native then C_DurationUtil.CreateDurationTextBinding=nil end dofile(root..'api.lua') ShaguTweaks.API.AreMoveModifiersDown=function() return keys end assert((ShaguTweaks.API.durationtimers and true or false)==native) function ShaguTweaks:register(m) modules[m.title]=m;return m end dofile(root..'mods/swing-timer.lua') modules['Swing Timer']:enable();modules['Wand Timer']:enable() local mh,oh,ra=ShaguTweaksSwingTimer_mainhand,ShaguTweaksSwingTimer_offhand,ShaguTweaksSwingTimer_ranged local listener,driver for _,frame in ipairs(frames) do if frame.events.PLAYER_SWING then listener=frame end if frame.scripts.OnUpdate then driver=frame end end local useNative=native and methodAvailable assert((driver==nil)==useNative) local function emit(name,a,b,c,d) event,arg1,arg2,arg3,arg4=name,a,b,c,d;listener.scripts.OnEvent() end local function advance(seconds) local finish=now+seconds while true do local nextTimer for _,timer in ipairs(timers) do if not timer.cancelled and timer.at<=finish and (not nextTimer or timer.at