Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- BAS={}
- function BAS.GetWeaponSpeed()
- local WeaponSpeed = nil
- BASScannerTooltip:SetOwner(UIParent, "ANCHOR_NONE")
- BASScannerTooltip:SetInventoryItem("player", 18)
- for i=1,10 do
- text = getglobal("BASScannerTooltipTextRight"..i)
- if text:IsVisible() then
- _, _, WeaponSpeed = string.find(text:GetText(), "([%,%.%d]+)")
- if speedmax then
- if not tonumber(WeaponSpeed) then
- WeaponSpeed = string.gsub(WeaponSpeed, "%,", "%.")
- end
- break
- end
- end
- end
- return WeaponSpeed
- end
- function BAS.CheckQuiver()
- local tmpTxt, line, result;
- local lines = BASScannerTooltip:NumLines();
- for i=1, lines do
- tmpText = getglobal("BASScannerTooltipTextLeft"..i);
- val = nil;
- if (tmpText:GetText()) then
- line = tmpText:GetText();
- if string.find(line, "speed by") then
- _, _,result = string.find(line, "speed by (%d+)")
- end
- end
- end
- return result
- end
- function BAS.GetBagSpeed()
- local result
- for i = 1,4 do
- local invID = ContainerIDToInventoryID(i)
- if invID then
- local bagLink = GetInventoryItemLink("player",invID)
- if bagLink then
- _, _, Color, Ltype, Id, Enchant, Suffix, Unique, Name = string.find(bagLink, "|?c?f?f?(%x*)|?H?([^:]*):?(%d*):?(%d*):?(%d*):?(%d*)|?h?%[(.+)%]")
- bagHyperLink = Ltype..":"..Id..":"..Enchant..":"..Suffix
- BASScannerTooltip:SetOwner(UIParent, "ANCHOR_NONE")
- BASScannerTooltip:SetHyperlink(bagHyperLink)
- result = BAS.CheckQuiver()
- if result then
- break
- end
- end
- end
- end
- return result
- end
- function BAS.GetBaseSpeed()
- local W_Speed, B_Speed = BAS.GetWeaponSpeed(), BAS.GetBagSpeed()
- if W_Speed then
- if B_Speed then
- W_Speed = W_Speed / (1 + B_Speed/100)
- W_Speed = floor(W_Speed*100)/100
- end
- end
- return W_Speed
- end
- function BAS.GetKoefSpeed()
- local un_mode_speed, mode_speed, result
- un_mode_speed = BAS.GetBaseSpeed()
- mode_speed = floor(UnitRangedDamage("player")*100)/100
- if un_mode_speed and mode_speed and mode_speed~=0 then
- result = un_mode_speed/mode_speed
- end
- return result
- end
- function BAS.CheckCastSpeed()
- local tmpTxt, line, result;
- local lines = BASScannerTooltip:NumLines();
- for i=1, lines do
- tmpText = getglobal("BASScannerTooltipTextLeft"..i);
- val = nil;
- if (tmpText:GetText()) then
- line = tmpText:GetText();
- if string.find(line, "sec cast") then
- _, _,result = string.find(line, "(%d+) sec cast")
- end
- end
- end
- return result
- end
- function BAS.FindInBook(spell)
- spell = gsub(spell, "%-", "%%%-")
- local i = 1
- local SPELLNUM = nil
- while true do
- local spellName, spellRank = GetSpellName(i, BOOKTYPE_SPELL)
- if not spellName then
- break
- end
- if string.find(spellName .. '(Rank ' .. spellRank .. ')', spell) then
- SPELLNUM = i
- end
- i = i + 1
- end
- return SPELLNUM
- end
- function BAS.GetCD(spell)
- local SPELLNUM = BAS.FindInBook(spell)
- if not SPELLNUM then
- return nil
- end
- start, duration = GetSpellCooldown(SPELLNUM, BOOKTYPE_SPELL)
- if duration ~= 0 then
- return duration - GetTime() + start
- else
- return 0
- end
- end
- local BAS_CastSpell = CastSpell
- function CastSpell(spell, tab, a, b, c, d, e)
- local name = GetSpellName(spell, tab)
- BAS.LastCastName = name
- BAS.LastCastTime = GetTime()
- if name == "Aimed Shot" then
- BAS.CastBarCastSpell(name)
- end
- return BAS_CastSpell(spell, tab, a, b, c, d, e)
- end
- local BAS_UseAction = UseAction
- function UseAction(slot, checkCursor, onSelf, a, b, c, d, e)
- BASScannerTooltip:SetOwner(UIParent, "ANCHOR_NONE")
- BASScannerTooltip:SetAction(slot)
- local name = BASScannerTooltipTextLeft1:GetText()
- BAS.LastCastName = name
- BAS.LastCastTime = GetTime()
- if name == "Aimed Shot" then
- BAS.CastBarCastSpell(name)
- end
- return BAS_UseAction(slot, checkCursor, onSelf, a, b, c, d, e)
- end
- local BAS_CastSpellByName = CastSpellByName
- function CastSpellByName(spell, onSelf, a, b, c, d, e)
- local _, _, name = string.find(spell or "", "([%w%'%s]+)")
- BAS.LastCastName = name
- BAS.LastCastTime = GetTime()
- if name == "Aimed Shot" then
- BAS.CastBarCastSpell(name)
- end
- return BAS_CastSpellByName(spell, onSelf, a, b, c, d, e)
- end
- BAS.Ping = 0.2
- function BAS.CastBarCastSpell(name)
- if CastingBarText:GetText() ~= name then
- local cast_time = nil
- local SPELLNUM = BAS.FindInBook(name)
- if SPELLNUM then
- BASScannerTooltip:SetOwner(UIParent, "ANCHOR_NONE")
- BASScannerTooltip:SetSpell(SPELLNUM, BOOKTYPE_SPELL)
- cast_time = BAS.CheckCastSpeed()
- else
- cast_time = 3
- end
- cast_time = cast_time + BAS.Ping
- cast_time = cast_time*1000
- cast_time = cast_time/BAS.GetKoefSpeed()
- CastingBarFrameStatusBar:SetStatusBarColor(1.0, 0.7, 0.0);
- CastingBarSpark:Show();
- CastingBarFrame.startTime = GetTime();
- CastingBarFrame.maxValue = CastingBarFrame.startTime + (cast_time / 1000);
- CastingBarFrameStatusBar:SetMinMaxValues(CastingBarFrame.startTime, CastingBarFrame.maxValue);
- CastingBarFrameStatusBar:SetValue(CastingBarFrame.startTime);
- CastingBarText:SetText(name);
- CastingBarFrame:SetAlpha(1.0);
- CastingBarFrame.holdTime = 0;
- CastingBarFrame.casting = 1;
- CastingBarFrame.fadeOut = nil;
- CastingBarFrame:Show();
- CastingBarFrame.mode = "casting";
- end
- end
- BAS.autoshot = nil
- BAS.time_shoot = 0
- BAS.LastCastTime = 0
- BAS.LastCastName = ""
- function BAS.GetTimeToShoot()
- local speed = UnitRangedDamage("player")
- local result = speed - (GetTime() - BAS.time_shoot)
- if result < 0 then
- result = 0
- end
- return result
- end
- function BAS.OnLoad()
- this:RegisterEvent("START_AUTOREPEAT_SPELL")
- this:RegisterEvent("STOP_AUTOREPEAT_SPELL")
- this:RegisterEvent("ITEM_LOCK_CHANGED")
- this:RegisterEvent("SPELLCAST_STOP")
- end
- BAS.ShotCount = 0
- function BAS.OnEvent(event)
- if event == "START_AUTOREPEAT_SPELL" then
- BAS.autoshot = true
- local ammoSlot = GetInventorySlotInfo("AmmoSlot")
- BAS.ammoCount = GetInventoryItemCount("player", ammoSlot)
- if ((BAS.ammoCount == 1) and (not GetInventoryItemTexture("player", ammoSlot))) then
- BAS.ammoCount = 0
- end
- elseif event == "STOP_AUTOREPEAT_SPELL" then
- BAS.autoshot = false
- elseif event == "ITEM_LOCK_CHANGED" then
- if BAS.autoshot then
- local ammoSlot = GetInventorySlotInfo("AmmoSlot")
- local ammoCount = GetInventoryItemCount("player", ammoSlot)
- if ((ammoCount == 1) and (not GetInventoryItemTexture("player", ammoSlot))) then
- ammoCount = 0
- end
- if ammoCount == BAS.ammoCount - 1 then
- BAS.time_shoot = GetTime()
- BAS.ammoCount = ammoCount
- Printd(BAS.LastCastName.."| "..(GetTime() - BAS.LastCastTime).."| "..BAS.GetCD(BAS.LastCastName))
- if not (BAS.LastCastName ~= "Auto Shot" and (GetTime() - BAS.LastCastTime) < 0.6 and BAS.GetCD(BAS.LastCastName) < 1.5) then
- BAS.ShotCount = BAS.ShotCount + 1
- Printd(BAS.ShotCount)
- end
- end
- end
- end
- end
- function BAS.OnUpdate()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement