From 79923f5c6ad6e41217ca17817c436a39549387b0 Mon Sep 17 00:00:00 2001 From: CrackedMustache Date: Sun, 28 Apr 2024 17:13:41 +0200 Subject: [PATCH 1/8] Adding cast bar toggle --- addon.lua | 40 ++++++++++++++++++++++++++++++++-------- attackbar.lua | 23 +++++++++++++++++++++++ localization.lua | 2 ++ 3 files changed, 57 insertions(+), 8 deletions(-) diff --git a/addon.lua b/addon.lua index b26f942..0aee4d4 100644 --- a/addon.lua +++ b/addon.lua @@ -1,6 +1,6 @@ SLASH_BCB1, SLASH_BCB2 = '/bcb', '/bear'; -local bcb = {} +bcb = {} local oldUseAction local safeZone= 0.1 local barHeight = 28 @@ -162,6 +162,7 @@ function bcb:ADDON_LOADED(name) BCB_SAVED.debug = false BCB_SAVED.abar_is_enabled = true BCB_SAVED.hunter_is_enabled = true + BCB_SAVED.castbar_is_enabled = true bcb.debug("Variable load failed. Using defaults.") end @@ -209,6 +210,10 @@ function bcb:ADDON_LOADED(name) if(BCB_SAVED.hunter_is_enabled == nil) then BCB_SAVED.hunter_is_enabled = true end + + if( BCB_SAVED.castbar_is_enabled == nil) then + BCB_SAVED.castbar_is_enabled = true + end end @@ -226,9 +231,10 @@ function bcb:PLAYER_ENTERING_WORLD() this:UnregisterEvent("PLAYER_ENTERING_WORLD") - CastingBarFrame:Hide() - CastingBarFrame:UnregisterAllEvents() - + if (BCB_SAVED.castbar_is_enabled) then + CastingBarFrame:Hide() + CastingBarFrame:UnregisterAllEvents() + end --- config frame self.configFrame = CreateFrame("FRAME", "BearCastBar_ConfigFrame", UIParent) @@ -556,11 +562,30 @@ function bcb:PLAYER_ENTERING_WORLD() end end) + self.configFrame.attackBarConfigFrame.CastBar = CreateFrame("CheckButton", "bcb_GlobalCheckbox_CastBar", self.configFrame.attackBarConfigFrame, "UICheckButtonTemplate"); + self.configFrame.attackBarConfigFrame.CastBar:SetPoint("TOPLEFT",self.configFrame.attackBarConfigFrame, 10, -125) + bcb_GlobalCheckbox_CastBarText:SetText(L["Castbar enabled"]) + if (BCB_SAVED.castbar_is_enabled == true) then + self.configFrame.attackBarConfigFrame.CastBar:SetChecked(true) + end + + self.configFrame.attackBarConfigFrame.CastBar:SetScript("OnClick", function() + + if self.configFrame.attackBarConfigFrame.CastBar:GetChecked() then + -- enable bar + SlashCmdList["ATKBAR"]("caston"); + else + -- disable bar + SlashCmdList["ATKBAR"]("castoff") + end + end) ------------------------ - --- CAST BAR --- ------------------------ + + + ----------------------- + --- CAST BAR --- + ----------------------- self.frame:SetWidth(BCB_SAVED.width+8) self.frame:SetHeight(BCB_SAVED.height+8) @@ -672,7 +697,6 @@ function bcb:PLAYER_ENTERING_WORLD() self.resetLag = false self.frame:Hide() --debugging - end function bcb.setHeight(height) diff --git a/attackbar.lua b/attackbar.lua index bdf6859..bc90426 100644 --- a/attackbar.lua +++ b/attackbar.lua @@ -120,6 +120,26 @@ function Abar_chat(msg) BCB_SAVED.hunter_is_enabled = false elseif msg=="hunton" then BCB_SAVED.hunter_is_enabled = true + elseif msg=="caston" then + BCB_SAVED.castbar_is_enabled = true + CastingBarFrame:Hide() + CastingBarFrame:UnregisterAllEvents() + + bcb.frame:RegisterEvent("SPELLCAST_START") + bcb.frame:RegisterEvent("SPELLCAST_CHANNEL_START") + bcb.frame:RegisterEvent("SPELLCAST_CHANNEL_STOP") + bcb.frame:RegisterEvent("SPELLCAST_CHANNEL_UPDATE") + bcb.frame:RegisterEvent("SPELLCAST_STOP") + bcb.frame:RegisterEvent("SPELLCAST_DELAYED") + bcb.frame:RegisterEvent("SPELLCAST_INTERRUPTED")--CHAT_MSG_SPELL_FAILED_LOCALPLAYER --SPELLCAST_CHANNEL_START + bcb.frame:RegisterEvent("CHAT_MSG_SPELL_FAILED_LOCALPLAYER") + + elseif msg=="castoff" then + BCB_SAVED.castbar_is_enabled = false + CastingBarFrame:Show() + CastingBarFrame:RegisterAllEvents() + + bcb.frame:UnregisterAllEvents() else DEFAULT_CHAT_FRAME:AddMessage(L['lock - to lock and hide the anchor']); DEFAULT_CHAT_FRAME:AddMessage(L['unlock - to unlock and show the anchor']); @@ -127,7 +147,10 @@ function Abar_chat(msg) DEFAULT_CHAT_FRAME:AddMessage(L['enable - to enable the attack bar']); DEFAULT_CHAT_FRAME:AddMessage(L['huntoff - to disable the hunter abilities']); DEFAULT_CHAT_FRAME:AddMessage(L['hunton - to enable the hunter abilities']); + DEFAULT_CHAT_FRAME:AddMessage(L['castoff - to disable the cast bar']); + DEFAULT_CHAT_FRAME:AddMessage(L['caston - to enable the cast bar']); end + DEFAULT_CHAT_FRAME:AddMessage(L['Changed!']); end function Abar_selfhit() diff --git a/localization.lua b/localization.lua index fdddf8c..4a3f104 100644 --- a/localization.lua +++ b/localization.lua @@ -20,6 +20,8 @@ L["disable - to disable the attack bar"] = "disable - to disable the attack bar" L["enable - to enable the attack bar"] = "enable - to enable the attack bar" L["huntoff - to disable the hunter abilities"] = "huntoff - to disable the hunter abilities" L["hunton - to enable the hunter abilities"] = "hunton - to enable the hunter abilities" +L["castoff - to disable the cast bar"] = "castoff - to disable the cast bar" +L["caston - to enable the cast bar'"] = "caston - to enable the cast bar'" L["s"] = "s" L["Main"] = "Main" L["Off"] = "Off" From 71dcbdcea86780fe88d13c34e1480f3f9d4d2940 Mon Sep 17 00:00:00 2001 From: CrackedMustache <168352961+CrackedMustache@users.noreply.github.com> Date: Sun, 28 Apr 2024 17:16:14 +0200 Subject: [PATCH 2/8] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d9c7d71..eb47bfd 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ The cast bars look choppy because of the poor GIF quality. ### Options -![image](https://user-images.githubusercontent.com/17283626/46246060-9e51b880-c400-11e8-96a3-1326ec4db16b.png) +![image](https://github.com/CrackedMustache/BearCastBar_CastbarToggle/assets/168352961/384dcd38-d482-43c8-be80-ffd895a92885) Options: From 3f10a9d7a930d684c47ebce8edc131833965e5c0 Mon Sep 17 00:00:00 2001 From: CrackedMustache <168352961+CrackedMustache@users.noreply.github.com> Date: Sun, 28 Apr 2024 17:17:17 +0200 Subject: [PATCH 3/8] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index eb47bfd..bf80518 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ The cast bars look choppy because of the poor GIF quality. ### Options -![image](https://github.com/CrackedMustache/BearCastBar_CastbarToggle/assets/168352961/384dcd38-d482-43c8-be80-ffd895a92885) +![image](https://github.com/CrackedMustache/BearCastBar_CastbarToggle/assets/168352961/54f1cba2-41c4-4c83-9a75-9402756ad7ff) Options: From ad6faa3c7723def1a97d913b945412d628cf474b Mon Sep 17 00:00:00 2001 From: CrackedMustache <168352961+CrackedMustache@users.noreply.github.com> Date: Sun, 28 Apr 2024 17:18:17 +0200 Subject: [PATCH 4/8] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index bf80518..02456d2 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ Options: - Lag protection: reduces the size of the red area to ensure that you can finish casts. - Disable attack bar: disables the whole attack bar (in case you want to use another swing timer) - Disable hunter abilities: disables auto-shot, aimed shot and multi-shot (in case you want to use another hunter timer) +- Disable cast bar: disables the cast bar and reverts back to the blizzard one Feel free to develop the addon further. From b4184079671215bcdb5e512fc5d65934538e7f75 Mon Sep 17 00:00:00 2001 From: CrackedMustache Date: Sun, 28 Apr 2024 17:42:09 +0200 Subject: [PATCH 5/8] Fixing minor things --- README.md | 3 +-- addon.lua | 24 +++++++++++++----------- attackbar.lua | 3 +-- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 02456d2..d9c7d71 100644 --- a/README.md +++ b/README.md @@ -29,14 +29,13 @@ The cast bars look choppy because of the poor GIF quality. ### Options -![image](https://github.com/CrackedMustache/BearCastBar_CastbarToggle/assets/168352961/54f1cba2-41c4-4c83-9a75-9402756ad7ff) +![image](https://user-images.githubusercontent.com/17283626/46246060-9e51b880-c400-11e8-96a3-1326ec4db16b.png) Options: - Lag protection: reduces the size of the red area to ensure that you can finish casts. - Disable attack bar: disables the whole attack bar (in case you want to use another swing timer) - Disable hunter abilities: disables auto-shot, aimed shot and multi-shot (in case you want to use another hunter timer) -- Disable cast bar: disables the cast bar and reverts back to the blizzard one Feel free to develop the addon further. diff --git a/addon.lua b/addon.lua index 0aee4d4..8b930f5 100644 --- a/addon.lua +++ b/addon.lua @@ -220,21 +220,23 @@ function bcb:ADDON_LOADED(name) end function bcb:PLAYER_ENTERING_WORLD() - this:RegisterEvent("SPELLCAST_START") - this:RegisterEvent("SPELLCAST_CHANNEL_START") - this:RegisterEvent("SPELLCAST_CHANNEL_STOP") - this:RegisterEvent("SPELLCAST_CHANNEL_UPDATE") - this:RegisterEvent("SPELLCAST_STOP") - this:RegisterEvent("SPELLCAST_DELAYED") - this:RegisterEvent("SPELLCAST_INTERRUPTED")--CHAT_MSG_SPELL_FAILED_LOCALPLAYER --SPELLCAST_CHANNEL_START - this:RegisterEvent("CHAT_MSG_SPELL_FAILED_LOCALPLAYER") - - this:UnregisterEvent("PLAYER_ENTERING_WORLD") if (BCB_SAVED.castbar_is_enabled) then + this:RegisterEvent("SPELLCAST_START") + this:RegisterEvent("SPELLCAST_CHANNEL_START") + this:RegisterEvent("SPELLCAST_CHANNEL_STOP") + this:RegisterEvent("SPELLCAST_CHANNEL_UPDATE") + this:RegisterEvent("SPELLCAST_STOP") + this:RegisterEvent("SPELLCAST_DELAYED") + this:RegisterEvent("SPELLCAST_INTERRUPTED")--CHAT_MSG_SPELL_FAILED_LOCALPLAYER --SPELLCAST_CHANNEL_START + this:RegisterEvent("CHAT_MSG_SPELL_FAILED_LOCALPLAYER") + CastingBarFrame:Hide() CastingBarFrame:UnregisterAllEvents() end + + this:UnregisterEvent("PLAYER_ENTERING_WORLD") + --- config frame self.configFrame = CreateFrame("FRAME", "BearCastBar_ConfigFrame", UIParent) @@ -564,7 +566,7 @@ function bcb:PLAYER_ENTERING_WORLD() self.configFrame.attackBarConfigFrame.CastBar = CreateFrame("CheckButton", "bcb_GlobalCheckbox_CastBar", self.configFrame.attackBarConfigFrame, "UICheckButtonTemplate"); self.configFrame.attackBarConfigFrame.CastBar:SetPoint("TOPLEFT",self.configFrame.attackBarConfigFrame, 10, -125) - bcb_GlobalCheckbox_CastBarText:SetText(L["Castbar enabled"]) + bcb_GlobalCheckbox_CastBarText:SetText(L["Cast bar enabled"]) if (BCB_SAVED.castbar_is_enabled == true) then self.configFrame.attackBarConfigFrame.CastBar:SetChecked(true) diff --git a/attackbar.lua b/attackbar.lua index bc90426..ae26e00 100644 --- a/attackbar.lua +++ b/attackbar.lua @@ -136,7 +136,7 @@ function Abar_chat(msg) elseif msg=="castoff" then BCB_SAVED.castbar_is_enabled = false - CastingBarFrame:Show() + bcb.frame:Hide() CastingBarFrame:RegisterAllEvents() bcb.frame:UnregisterAllEvents() @@ -150,7 +150,6 @@ function Abar_chat(msg) DEFAULT_CHAT_FRAME:AddMessage(L['castoff - to disable the cast bar']); DEFAULT_CHAT_FRAME:AddMessage(L['caston - to enable the cast bar']); end - DEFAULT_CHAT_FRAME:AddMessage(L['Changed!']); end function Abar_selfhit() From 4c694534abcfeb8fbdf01ddc9dab77df3df64b43 Mon Sep 17 00:00:00 2001 From: CrackedMustache Date: Sun, 28 Apr 2024 17:50:05 +0200 Subject: [PATCH 6/8] Moving files into another directory --- .../BearCastBar.toc | 20 +- addon.lua => BearCastBar/addon.lua | 0 attackbar.lua => BearCastBar/attackbar.lua | 742 +++++++++--------- attackbar.xml => BearCastBar/attackbar.xml | 314 ++++---- .../localization.lua | 0 {textures => BearCastBar/textures}/flat.tga | Bin {textures => BearCastBar/textures}/glaze.tga | Bin {textures => BearCastBar/textures}/smooth.tga | Bin .../textures}/striped.tga | Bin 9 files changed, 538 insertions(+), 538 deletions(-) rename BearCastBar.toc => BearCastBar/BearCastBar.toc (90%) rename addon.lua => BearCastBar/addon.lua (100%) rename attackbar.lua => BearCastBar/attackbar.lua (96%) rename attackbar.xml => BearCastBar/attackbar.xml (96%) rename localization.lua => BearCastBar/localization.lua (100%) rename {textures => BearCastBar/textures}/flat.tga (100%) rename {textures => BearCastBar/textures}/glaze.tga (100%) rename {textures => BearCastBar/textures}/smooth.tga (100%) rename {textures => BearCastBar/textures}/striped.tga (100%) diff --git a/BearCastBar.toc b/BearCastBar/BearCastBar.toc similarity index 90% rename from BearCastBar.toc rename to BearCastBar/BearCastBar.toc index 6bbf13e..77417a0 100644 --- a/BearCastBar.toc +++ b/BearCastBar/BearCastBar.toc @@ -1,11 +1,11 @@ -## Interface: 11200 -## Title: Bear Cast Bar 1.1 -## Notes: Replaces default cast bar. Latency spell cancel support. Attack timers. -## Notes-ruRU: Заменяет панель произнесения. Поддержка задержки заклинаний. Таймеры атаки. -## Author: Kuroneko -## OptionalDeps: -## SavedVariables: -## SavedVariablesPerCharacter: BCB_SAVED -addon.lua -attackbar.xml +## Interface: 11200 +## Title: Bear Cast Bar with Toggle 1.0 +## Notes: Replaces default cast bar. Latency spell cancel support. Attack timers. +## Notes-ruRU: Заменяет панель произнесения. Поддержка задержки заклинаний. Таймеры атаки. +## Author: Kuroneko +## OptionalDeps: +## SavedVariables: +## SavedVariablesPerCharacter: BCB_SAVED +addon.lua +attackbar.xml localization.lua \ No newline at end of file diff --git a/addon.lua b/BearCastBar/addon.lua similarity index 100% rename from addon.lua rename to BearCastBar/addon.lua diff --git a/attackbar.lua b/BearCastBar/attackbar.lua similarity index 96% rename from attackbar.lua rename to BearCastBar/attackbar.lua index ae26e00..d1b023b 100644 --- a/attackbar.lua +++ b/BearCastBar/attackbar.lua @@ -1,371 +1,371 @@ -pont=0.000 -pofft= 0.000 -ont = 0.000 -offt= 0.000 -ons = 0.000 -offs= 0.000 -offh = 0 -onh = 0 -epont=0.000 -epofft= 0.000 -eont = 0.000 -eofft= 0.000 -eons = 0.000 -eoffs= 0.000 -eoffh = 0 -eonh = 0 -testvar = 0 - -local last_auto_hit = 0 -local SWINGTIME = 0.65 -local autorepeat = false -local reload = false -local L = BearCastBar.L - -if not(abar) then abar={} end --- cast spell by name hook -preabar_csbn = CastSpellByName -function abar_csbn(pass, onSelf) - preabar_csbn(pass, onSelf) - abar_spelldir(pass) -end -CastSpellByName = abar_csbn ---use action hook -preabar_useact = UseAction -function abar_useact(p1,p2,p3) - preabar_useact(p1,p2,p3) - local a,b = IsUsableAction(p1) - if a then - if UnitCanAttack("player","target" )then - if IsActionInRange(p1) == 1 then - Abar_Tooltip:ClearLines() - Abar_Tooltip:SetAction(p1) - local spellname = Abar_TooltipTextLeft1:GetText() - if spellname then abar_spelldir(spellname) end - end - end - end -end -UseAction = abar_useact ---castspell hook -preabar_cassple = CastSpell -function abar_casspl(p1,p2) - preabar_cassple(p1,p2) - local spell = GetSpellName(p1,p2) - abar_spelldir(spell) -end -CastSpell = abar_casspl - -function Abar_loaded() - SlashCmdList["ATKBAR"] = Abar_chat; - SLASH_ATKBAR1 = "/abar"; - SLASH_ATKBAR2 = "/atkbar"; - if BCB_SAVED.abar_is_enabled == false then - abar.range = false - abar.h2h = false - abar.timer = false - abar_core:UnregisterAllEvents() - else - if abar.range == nil then - abar.range=true - end - if abar.h2h == nil then - abar.h2h=true - end - if abar.timer == nil then - abar.timer=true - end - end - Abar_Mhr:SetPoint("LEFT",Abar_Frame,"TOPLEFT",6,-13) - Abar_Oh:SetPoint("LEFT",Abar_Frame,"TOPLEFT",6,-35) - Abar_MhrText:SetJustifyH("Left") - Abar_OhText:SetJustifyH("Left") - --ebar_VL() -end - -function Abar_chat(msg) - msg = strlower(msg) - if msg == "fix" then - Abar_reset() - elseif msg=="lock" then - Abar_Frame:Hide() - --ebar_Frame:Hide() - elseif msg=="unlock" then - Abar_Frame:Show() - --ebar_Frame:Show() - elseif msg=="disable" then - abar_core:UnregisterAllEvents() - BCB_SAVED.abar_is_enabled = false - abar.range = false - abar.h2h = false - abar.timer = false - elseif msg=="enable" then - abar_core:RegisterEvent("CHAT_MSG_COMBAT_SELF_MISSES"); - abar_core:RegisterEvent("CHAT_MSG_COMBAT_SELF_HITS"); - abar_core:RegisterEvent("PLAYER_LEAVE_COMBAT") - abar_core:RegisterEvent("VARIABLES_LOADED") - abar_core:RegisterEvent("CHAT_MSG_SPELL_SELF_DAMAGE") - - abar_core:RegisterEvent("CHAT_MSG_COMBAT_CREATURE_VS_SELF_HITS"); - abar_core:RegisterEvent("CHAT_MSG_COMBAT_CREATURE_VS_SELF_MISSES"); - abar_core:RegisterEvent("CHAT_MSG_COMBAT_HOSTILEPLAYER_HITS") - abar_core:RegisterEvent("CHAT_MSG_COMBAT_HOSTILEPLAYER_MISSES") - abar_core:RegisterEvent("START_AUTOREPEAT_SPELL") - abar_core:RegisterEvent("STOP_AUTOREPEAT_SPELL") - abar.range = true - abar.h2h = true - abar.timer = true - BCB_SAVED.abar_is_enabled = true - elseif msg=="huntoff" then - BCB_SAVED.hunter_is_enabled = false - elseif msg=="hunton" then - BCB_SAVED.hunter_is_enabled = true - elseif msg=="caston" then - BCB_SAVED.castbar_is_enabled = true - CastingBarFrame:Hide() - CastingBarFrame:UnregisterAllEvents() - - bcb.frame:RegisterEvent("SPELLCAST_START") - bcb.frame:RegisterEvent("SPELLCAST_CHANNEL_START") - bcb.frame:RegisterEvent("SPELLCAST_CHANNEL_STOP") - bcb.frame:RegisterEvent("SPELLCAST_CHANNEL_UPDATE") - bcb.frame:RegisterEvent("SPELLCAST_STOP") - bcb.frame:RegisterEvent("SPELLCAST_DELAYED") - bcb.frame:RegisterEvent("SPELLCAST_INTERRUPTED")--CHAT_MSG_SPELL_FAILED_LOCALPLAYER --SPELLCAST_CHANNEL_START - bcb.frame:RegisterEvent("CHAT_MSG_SPELL_FAILED_LOCALPLAYER") - - elseif msg=="castoff" then - BCB_SAVED.castbar_is_enabled = false - bcb.frame:Hide() - CastingBarFrame:RegisterAllEvents() - - bcb.frame:UnregisterAllEvents() - else - DEFAULT_CHAT_FRAME:AddMessage(L['lock - to lock and hide the anchor']); - DEFAULT_CHAT_FRAME:AddMessage(L['unlock - to unlock and show the anchor']); - DEFAULT_CHAT_FRAME:AddMessage(L['disable - to disable the attack bar']); - DEFAULT_CHAT_FRAME:AddMessage(L['enable - to enable the attack bar']); - DEFAULT_CHAT_FRAME:AddMessage(L['huntoff - to disable the hunter abilities']); - DEFAULT_CHAT_FRAME:AddMessage(L['hunton - to enable the hunter abilities']); - DEFAULT_CHAT_FRAME:AddMessage(L['castoff - to disable the cast bar']); - DEFAULT_CHAT_FRAME:AddMessage(L['caston - to enable the cast bar']); - end -end - -function Abar_selfhit() - ons,offs=UnitAttackSpeed("player"); - hd,ld,ohd,old = UnitDamage("player") - hd,ld= hd-math.mod(hd,1),ld-math.mod(ld,1) - if old then - ohd,old = ohd-math.mod(ohd,1),old-math.mod(old,1) -end - -if offs then - ont,offt=GetTime(),GetTime() - if ((math.abs((ont-pont)-ons) <= math.abs((offt-pofft)-offs))and not(onh <= offs/ons)) or offh >= ons/offs then - if pofft == 0 then pofft=offt end - pont = ont - tons = ons - offh = 0 - onh = onh +1 - ons = ons - math.mod(ons,0.01) - Abar_Mhrs(tons,L["Main"].." "..ons..L["s"],1,.1,.1) - else - pofft = offt - offh = offh+1 - onh = 0 - ohd,old = ohd-math.mod(ohd,1),old-math.mod(old,1) - offs = offs - math.mod(offs,0.01) - Abar_Ohs(offs,L["Off"].." "..offs..L["s"],1,.1,.1) - end -else - ont=GetTime() - tons = ons - ons = ons - math.mod(ons,0.01) - Abar_Mhrs(tons,L["Main"].." "..ons..L["s"],1,.1,.1) -end - -end - -function Abar_reset() - pont=0.000 - pofft= 0.000 - ont=0.000 - offt= 0.000 - onid=0 - offid=0 -end - -function Abar_event(event) - if event == "START_AUTOREPEAT_SPELL" then autorepeat = true end - if event == "STOP_AUTOREPEAT_SPELL" then autorepeat = false end - if (event=="CHAT_MSG_COMBAT_SELF_MISSES" or event=="CHAT_MSG_COMBAT_SELF_HITS") and abar.h2h == true then Abar_selfhit() end - if event=="PLAYER_LEAVE_COMBAT" then Abar_reset() end - if event == "VARIABLES_LOADED" then Abar_loaded() end - if event == "CHAT_MSG_SPELL_SELF_DAMAGE" then Abar_spellhit(arg1) end - if event == "VARIABLES_LOADED" then Abar_loaded() end -end - -function Abar_spellhit(arg1) - a,b,spell=string.find (arg1, L["Your (.+) hits"]) - if not spell then a,b,spell=string.find (arg1, L["Your (.+) crits"]) end - if not spell then a,b,spell=string.find (arg1, L["Your (.+) is"]) end - if not spell then a,b,spell=string.find (arg1, L["Your (.+) misses"]) end - - rs,rhd,rld =UnitRangedDamage("player"); - rhd,rld= rhd-math.mod(rhd,1),rld-math.mod(rld,1) - if spell == L["Auto Shot"] and abar.range == true and BCB_SAVED.hunter_is_enabled then - last_auto_hit = GetTime() - trs=rs-SWINGTIME - rs = rs-math.mod(rs,0.01)-SWINGTIME - Abar_Mhrs(trs,L["Auto Shot"].." "..rs..L["s"],1,.1,.1) - elseif spell == L["Shoot"] and abar.range==true then - trs=rs - rs = rs-math.mod(rs,0.01) - Abar_Mhrs(trs,L["Wand"].." "..ons..L["s"],.7,.1,1) - elseif (spell == L["Raptor Strike"] or spell == L["Heroic Strike"] or - spell == L["Maul"] or spell == L["Cleave"]) and abar.h2h==true then - hd,ld,ohd,lhd = UnitDamage("player") - hd,ld= hd-math.mod(hd,1),ld-math.mod(ld,1) - if pofft == 0 then pofft=offt end - pont = ont - tons = ons - ons = ons - math.mod(ons,0.01) - Abar_Mhrs(tons,L["Maul"].." "..ons..L["s"],1,.1,.1) - end -end - -function abar_spelldir(spellname) - if abar.range then - local a,b,sparse = string.find (spellname, "(.+)%(") - if sparse then spellname = sparse end - - rs,rhd,rld =UnitRangedDamage("player"); - rhd,rld= rhd-math.mod(rhd,1),rld-math.mod(rld,1) - if spellname == L["Throw"] then - trs=rs - rs = rs-math.mod(rs,0.01) - Abar_Mhrs(trs-1,L["Throw"].." "..(rs)..L["s"],1,.1,.1) - elseif spellname == L["Shoot"] then - rs =UnitRangedDamage("player") - trs=rs - rs = rs-math.mod(rs,0.01) - Abar_Mhrs(trs-1,L["Wand"].." "..(rs)..L["s"],.7,.1,1) - elseif spellname == L["Shoot Bow"] then - trs = rs - rs = rs-math.mod(rs,0.01) - Abar_Mhrs(trs-1,L["Bow"].." "..(rs)..L["s"],1,.1,.1) - elseif spellname == L["Shoot Gun"] then - trs = rs - rs = rs-math.mod(rs,0.01) - Abar_Mhrs(trs-1,L["Gun"].." "..(rs)..L["s"],1,.1,.1) - elseif spellname == L["Shoot Crossbow"] then - trs=rs - rs = rs-math.mod(rs,0.01) - Abar_Mhrs(trs-1,L["X-Bow"].." "..(rs)..L["s"],1,.1,.1) - elseif spellname == L["Aimed Shot"] and BCB_SAVED.hunter_is_enabled then - trs=3 - -- Speed checking from Aviana/YaHT - for i=1,32 do - if UnitBuff("player",i) == "Interface\\Icons\\Ability_Warrior_InnerRage" then - trs = trs/1.3 - end - if UnitBuff("player",i) == "Interface\\Icons\\Ability_Hunter_RunningShot" then - trs = trs/1.4 - end - if UnitBuff("player",i) == "Interface\\Icons\\Racial_Troll_Berserk" then - berserkValue=0 - if((UnitHealth("player")/UnitHealthMax("player")) >= 0.40) then - berserkValue = (1.30 - (UnitHealth("player")/UnitHealthMax("player")))/3 - else - berserkValue = 0.3 - end - trs = trs / (1 + berserkValue) - end - if UnitBuff("player",i) == "Interface\\Icons\\Inv_Trinket_Naxxramas04" then - trs = trs/1.2 - end - if UnitDebuff("player",i) == "Interface\\Icons\\Spell_Shadow_CurseOfTounges" then - trs = trs/0.5 - end - end - rs = 3 - if trs < 2.99 and trs > 3.01 then - rs = trs-math.mod(trs,0.01) - end - --bcb:SPELLCAST_START("Aimed Shot", trs*1000+200) - Abar_Mhrs(trs+0.2,L["Aimed Shot"].." "..(rs)..L["s"],1,.1,.1) -- Some extra time because the release seems to be delayed on Aimed shot - elseif spellname == L["Multi-Shot"] and BCB_SAVED.hunter_is_enabled then - trs = 0.5 - rs = 0.5 - Abar_Mhrs(0.5,L["Multi-Shot"].." "..(rs)..L["s"],1,.1,.1) - end - end - end - - - -function Abar_Update() - local ttime = GetTime() - local left = 0.00 - tSpark=getglobal(this:GetName().. "Spark") - tText=getglobal(this:GetName().. "Tmr") - if abar.timer==true then - left = (this.et-GetTime()) - (math.mod((this.et-GetTime()),.1)) - if string.find(this.txt, L["Auto Shot"].." ") then - lf = GetTime() - last_auto_hit - swingtime = UnitRangedDamage("player") - SWINGTIME - if lf > swingtime and not reload and autorepeat then - reload = true - rl_time = SWINGTIME - math.max(lf - swingtime, 0) - rl_time = rl_time - math.mod(rl_time, 0.01) - Abar_Mhrs(SWINGTIME - math.max(lf - swingtime, 0),L["Reloading"].." "..(rl_time)..L["s"],.5, 1, 0) - end - else - reload = false - end - -- tText:SetText(this.txt.. "{"..left.."}") - tText:SetText(left) - tText:SetPoint("LEFT", this, "LEFT",114, 9); - tText:Show() - else - tText:Hide() - end - this:SetValue(ttime) - tSpark:SetPoint("CENTER", this, "LEFT", (ttime-this.st)/(this.et-this.st)*255, 0); - if ttime>=this.et then - this:Hide() - tSpark:SetPoint("CENTER", this, "LEFT",195, 0); - end -end - - -function Abar_Mhrs(bartime,text,r,g,b) - Abar_Mhr:Hide() - Abar_Mhr.txt = text - local downAb, upAb, latencyAb = GetNetStats() - Abar_Mhr.st = GetTime() - (latencyAb/1000) - Abar_Mhr.et = GetTime() + bartime - Abar_Mhr:SetStatusBarColor(r,g,b) - Abar_MhrText:SetText(text) - Abar_Mhr:SetMinMaxValues(Abar_Mhr.st,Abar_Mhr.et) - Abar_Mhr:SetValue(Abar_Mhr.st) - Abar_Mhr:Show() -end - -function Abar_Ohs(bartime,text,r,g,b) - Abar_Oh:Hide() - Abar_Oh.txt = text - local downAb, upAb, latencyAb = GetNetStats() - Abar_Oh.st = GetTime() - (latencyAb/1000) - Abar_Oh.et = GetTime() + bartime - Abar_Oh:SetStatusBarColor(r,g,b) - Abar_OhText:SetText(text) - Abar_Oh:SetMinMaxValues(Abar_Oh.st,Abar_Oh.et) - Abar_Oh:SetValue(Abar_Oh.st) - Abar_Oh:Show() -end - -function Abar_Boo(inpt) - if inpt == true then return " ON" else return " OFF" end -end +pont=0.000 +pofft= 0.000 +ont = 0.000 +offt= 0.000 +ons = 0.000 +offs= 0.000 +offh = 0 +onh = 0 +epont=0.000 +epofft= 0.000 +eont = 0.000 +eofft= 0.000 +eons = 0.000 +eoffs= 0.000 +eoffh = 0 +eonh = 0 +testvar = 0 + +local last_auto_hit = 0 +local SWINGTIME = 0.65 +local autorepeat = false +local reload = false +local L = BearCastBar.L + +if not(abar) then abar={} end +-- cast spell by name hook +preabar_csbn = CastSpellByName +function abar_csbn(pass, onSelf) + preabar_csbn(pass, onSelf) + abar_spelldir(pass) +end +CastSpellByName = abar_csbn +--use action hook +preabar_useact = UseAction +function abar_useact(p1,p2,p3) + preabar_useact(p1,p2,p3) + local a,b = IsUsableAction(p1) + if a then + if UnitCanAttack("player","target" )then + if IsActionInRange(p1) == 1 then + Abar_Tooltip:ClearLines() + Abar_Tooltip:SetAction(p1) + local spellname = Abar_TooltipTextLeft1:GetText() + if spellname then abar_spelldir(spellname) end + end + end + end +end +UseAction = abar_useact +--castspell hook +preabar_cassple = CastSpell +function abar_casspl(p1,p2) + preabar_cassple(p1,p2) + local spell = GetSpellName(p1,p2) + abar_spelldir(spell) +end +CastSpell = abar_casspl + +function Abar_loaded() + SlashCmdList["ATKBAR"] = Abar_chat; + SLASH_ATKBAR1 = "/abar"; + SLASH_ATKBAR2 = "/atkbar"; + if BCB_SAVED.abar_is_enabled == false then + abar.range = false + abar.h2h = false + abar.timer = false + abar_core:UnregisterAllEvents() + else + if abar.range == nil then + abar.range=true + end + if abar.h2h == nil then + abar.h2h=true + end + if abar.timer == nil then + abar.timer=true + end + end + Abar_Mhr:SetPoint("LEFT",Abar_Frame,"TOPLEFT",6,-13) + Abar_Oh:SetPoint("LEFT",Abar_Frame,"TOPLEFT",6,-35) + Abar_MhrText:SetJustifyH("Left") + Abar_OhText:SetJustifyH("Left") + --ebar_VL() +end + +function Abar_chat(msg) + msg = strlower(msg) + if msg == "fix" then + Abar_reset() + elseif msg=="lock" then + Abar_Frame:Hide() + --ebar_Frame:Hide() + elseif msg=="unlock" then + Abar_Frame:Show() + --ebar_Frame:Show() + elseif msg=="disable" then + abar_core:UnregisterAllEvents() + BCB_SAVED.abar_is_enabled = false + abar.range = false + abar.h2h = false + abar.timer = false + elseif msg=="enable" then + abar_core:RegisterEvent("CHAT_MSG_COMBAT_SELF_MISSES"); + abar_core:RegisterEvent("CHAT_MSG_COMBAT_SELF_HITS"); + abar_core:RegisterEvent("PLAYER_LEAVE_COMBAT") + abar_core:RegisterEvent("VARIABLES_LOADED") + abar_core:RegisterEvent("CHAT_MSG_SPELL_SELF_DAMAGE") + + abar_core:RegisterEvent("CHAT_MSG_COMBAT_CREATURE_VS_SELF_HITS"); + abar_core:RegisterEvent("CHAT_MSG_COMBAT_CREATURE_VS_SELF_MISSES"); + abar_core:RegisterEvent("CHAT_MSG_COMBAT_HOSTILEPLAYER_HITS") + abar_core:RegisterEvent("CHAT_MSG_COMBAT_HOSTILEPLAYER_MISSES") + abar_core:RegisterEvent("START_AUTOREPEAT_SPELL") + abar_core:RegisterEvent("STOP_AUTOREPEAT_SPELL") + abar.range = true + abar.h2h = true + abar.timer = true + BCB_SAVED.abar_is_enabled = true + elseif msg=="huntoff" then + BCB_SAVED.hunter_is_enabled = false + elseif msg=="hunton" then + BCB_SAVED.hunter_is_enabled = true + elseif msg=="caston" then + BCB_SAVED.castbar_is_enabled = true + CastingBarFrame:Hide() + CastingBarFrame:UnregisterAllEvents() + + bcb.frame:RegisterEvent("SPELLCAST_START") + bcb.frame:RegisterEvent("SPELLCAST_CHANNEL_START") + bcb.frame:RegisterEvent("SPELLCAST_CHANNEL_STOP") + bcb.frame:RegisterEvent("SPELLCAST_CHANNEL_UPDATE") + bcb.frame:RegisterEvent("SPELLCAST_STOP") + bcb.frame:RegisterEvent("SPELLCAST_DELAYED") + bcb.frame:RegisterEvent("SPELLCAST_INTERRUPTED")--CHAT_MSG_SPELL_FAILED_LOCALPLAYER --SPELLCAST_CHANNEL_START + bcb.frame:RegisterEvent("CHAT_MSG_SPELL_FAILED_LOCALPLAYER") + + elseif msg=="castoff" then + BCB_SAVED.castbar_is_enabled = false + bcb.frame:Hide() + CastingBarFrame:RegisterAllEvents() + + bcb.frame:UnregisterAllEvents() + else + DEFAULT_CHAT_FRAME:AddMessage(L['lock - to lock and hide the anchor']); + DEFAULT_CHAT_FRAME:AddMessage(L['unlock - to unlock and show the anchor']); + DEFAULT_CHAT_FRAME:AddMessage(L['disable - to disable the attack bar']); + DEFAULT_CHAT_FRAME:AddMessage(L['enable - to enable the attack bar']); + DEFAULT_CHAT_FRAME:AddMessage(L['huntoff - to disable the hunter abilities']); + DEFAULT_CHAT_FRAME:AddMessage(L['hunton - to enable the hunter abilities']); + DEFAULT_CHAT_FRAME:AddMessage(L['castoff - to disable the cast bar']); + DEFAULT_CHAT_FRAME:AddMessage(L['caston - to enable the cast bar']); + end +end + +function Abar_selfhit() + ons,offs=UnitAttackSpeed("player"); + hd,ld,ohd,old = UnitDamage("player") + hd,ld= hd-math.mod(hd,1),ld-math.mod(ld,1) + if old then + ohd,old = ohd-math.mod(ohd,1),old-math.mod(old,1) +end + +if offs then + ont,offt=GetTime(),GetTime() + if ((math.abs((ont-pont)-ons) <= math.abs((offt-pofft)-offs))and not(onh <= offs/ons)) or offh >= ons/offs then + if pofft == 0 then pofft=offt end + pont = ont + tons = ons + offh = 0 + onh = onh +1 + ons = ons - math.mod(ons,0.01) + Abar_Mhrs(tons,L["Main"].." "..ons..L["s"],1,.1,.1) + else + pofft = offt + offh = offh+1 + onh = 0 + ohd,old = ohd-math.mod(ohd,1),old-math.mod(old,1) + offs = offs - math.mod(offs,0.01) + Abar_Ohs(offs,L["Off"].." "..offs..L["s"],1,.1,.1) + end +else + ont=GetTime() + tons = ons + ons = ons - math.mod(ons,0.01) + Abar_Mhrs(tons,L["Main"].." "..ons..L["s"],1,.1,.1) +end + +end + +function Abar_reset() + pont=0.000 + pofft= 0.000 + ont=0.000 + offt= 0.000 + onid=0 + offid=0 +end + +function Abar_event(event) + if event == "START_AUTOREPEAT_SPELL" then autorepeat = true end + if event == "STOP_AUTOREPEAT_SPELL" then autorepeat = false end + if (event=="CHAT_MSG_COMBAT_SELF_MISSES" or event=="CHAT_MSG_COMBAT_SELF_HITS") and abar.h2h == true then Abar_selfhit() end + if event=="PLAYER_LEAVE_COMBAT" then Abar_reset() end + if event == "VARIABLES_LOADED" then Abar_loaded() end + if event == "CHAT_MSG_SPELL_SELF_DAMAGE" then Abar_spellhit(arg1) end + if event == "VARIABLES_LOADED" then Abar_loaded() end +end + +function Abar_spellhit(arg1) + a,b,spell=string.find (arg1, L["Your (.+) hits"]) + if not spell then a,b,spell=string.find (arg1, L["Your (.+) crits"]) end + if not spell then a,b,spell=string.find (arg1, L["Your (.+) is"]) end + if not spell then a,b,spell=string.find (arg1, L["Your (.+) misses"]) end + + rs,rhd,rld =UnitRangedDamage("player"); + rhd,rld= rhd-math.mod(rhd,1),rld-math.mod(rld,1) + if spell == L["Auto Shot"] and abar.range == true and BCB_SAVED.hunter_is_enabled then + last_auto_hit = GetTime() + trs=rs-SWINGTIME + rs = rs-math.mod(rs,0.01)-SWINGTIME + Abar_Mhrs(trs,L["Auto Shot"].." "..rs..L["s"],1,.1,.1) + elseif spell == L["Shoot"] and abar.range==true then + trs=rs + rs = rs-math.mod(rs,0.01) + Abar_Mhrs(trs,L["Wand"].." "..ons..L["s"],.7,.1,1) + elseif (spell == L["Raptor Strike"] or spell == L["Heroic Strike"] or + spell == L["Maul"] or spell == L["Cleave"]) and abar.h2h==true then + hd,ld,ohd,lhd = UnitDamage("player") + hd,ld= hd-math.mod(hd,1),ld-math.mod(ld,1) + if pofft == 0 then pofft=offt end + pont = ont + tons = ons + ons = ons - math.mod(ons,0.01) + Abar_Mhrs(tons,L["Maul"].." "..ons..L["s"],1,.1,.1) + end +end + +function abar_spelldir(spellname) + if abar.range then + local a,b,sparse = string.find (spellname, "(.+)%(") + if sparse then spellname = sparse end + + rs,rhd,rld =UnitRangedDamage("player"); + rhd,rld= rhd-math.mod(rhd,1),rld-math.mod(rld,1) + if spellname == L["Throw"] then + trs=rs + rs = rs-math.mod(rs,0.01) + Abar_Mhrs(trs-1,L["Throw"].." "..(rs)..L["s"],1,.1,.1) + elseif spellname == L["Shoot"] then + rs =UnitRangedDamage("player") + trs=rs + rs = rs-math.mod(rs,0.01) + Abar_Mhrs(trs-1,L["Wand"].." "..(rs)..L["s"],.7,.1,1) + elseif spellname == L["Shoot Bow"] then + trs = rs + rs = rs-math.mod(rs,0.01) + Abar_Mhrs(trs-1,L["Bow"].." "..(rs)..L["s"],1,.1,.1) + elseif spellname == L["Shoot Gun"] then + trs = rs + rs = rs-math.mod(rs,0.01) + Abar_Mhrs(trs-1,L["Gun"].." "..(rs)..L["s"],1,.1,.1) + elseif spellname == L["Shoot Crossbow"] then + trs=rs + rs = rs-math.mod(rs,0.01) + Abar_Mhrs(trs-1,L["X-Bow"].." "..(rs)..L["s"],1,.1,.1) + elseif spellname == L["Aimed Shot"] and BCB_SAVED.hunter_is_enabled then + trs=3 + -- Speed checking from Aviana/YaHT + for i=1,32 do + if UnitBuff("player",i) == "Interface\\Icons\\Ability_Warrior_InnerRage" then + trs = trs/1.3 + end + if UnitBuff("player",i) == "Interface\\Icons\\Ability_Hunter_RunningShot" then + trs = trs/1.4 + end + if UnitBuff("player",i) == "Interface\\Icons\\Racial_Troll_Berserk" then + berserkValue=0 + if((UnitHealth("player")/UnitHealthMax("player")) >= 0.40) then + berserkValue = (1.30 - (UnitHealth("player")/UnitHealthMax("player")))/3 + else + berserkValue = 0.3 + end + trs = trs / (1 + berserkValue) + end + if UnitBuff("player",i) == "Interface\\Icons\\Inv_Trinket_Naxxramas04" then + trs = trs/1.2 + end + if UnitDebuff("player",i) == "Interface\\Icons\\Spell_Shadow_CurseOfTounges" then + trs = trs/0.5 + end + end + rs = 3 + if trs < 2.99 and trs > 3.01 then + rs = trs-math.mod(trs,0.01) + end + --bcb:SPELLCAST_START("Aimed Shot", trs*1000+200) + Abar_Mhrs(trs+0.2,L["Aimed Shot"].." "..(rs)..L["s"],1,.1,.1) -- Some extra time because the release seems to be delayed on Aimed shot + elseif spellname == L["Multi-Shot"] and BCB_SAVED.hunter_is_enabled then + trs = 0.5 + rs = 0.5 + Abar_Mhrs(0.5,L["Multi-Shot"].." "..(rs)..L["s"],1,.1,.1) + end + end + end + + + +function Abar_Update() + local ttime = GetTime() + local left = 0.00 + tSpark=getglobal(this:GetName().. "Spark") + tText=getglobal(this:GetName().. "Tmr") + if abar.timer==true then + left = (this.et-GetTime()) - (math.mod((this.et-GetTime()),.1)) + if string.find(this.txt, L["Auto Shot"].." ") then + lf = GetTime() - last_auto_hit + swingtime = UnitRangedDamage("player") - SWINGTIME + if lf > swingtime and not reload and autorepeat then + reload = true + rl_time = SWINGTIME - math.max(lf - swingtime, 0) + rl_time = rl_time - math.mod(rl_time, 0.01) + Abar_Mhrs(SWINGTIME - math.max(lf - swingtime, 0),L["Reloading"].." "..(rl_time)..L["s"],.5, 1, 0) + end + else + reload = false + end + -- tText:SetText(this.txt.. "{"..left.."}") + tText:SetText(left) + tText:SetPoint("LEFT", this, "LEFT",114, 9); + tText:Show() + else + tText:Hide() + end + this:SetValue(ttime) + tSpark:SetPoint("CENTER", this, "LEFT", (ttime-this.st)/(this.et-this.st)*255, 0); + if ttime>=this.et then + this:Hide() + tSpark:SetPoint("CENTER", this, "LEFT",195, 0); + end +end + + +function Abar_Mhrs(bartime,text,r,g,b) + Abar_Mhr:Hide() + Abar_Mhr.txt = text + local downAb, upAb, latencyAb = GetNetStats() + Abar_Mhr.st = GetTime() - (latencyAb/1000) + Abar_Mhr.et = GetTime() + bartime + Abar_Mhr:SetStatusBarColor(r,g,b) + Abar_MhrText:SetText(text) + Abar_Mhr:SetMinMaxValues(Abar_Mhr.st,Abar_Mhr.et) + Abar_Mhr:SetValue(Abar_Mhr.st) + Abar_Mhr:Show() +end + +function Abar_Ohs(bartime,text,r,g,b) + Abar_Oh:Hide() + Abar_Oh.txt = text + local downAb, upAb, latencyAb = GetNetStats() + Abar_Oh.st = GetTime() - (latencyAb/1000) + Abar_Oh.et = GetTime() + bartime + Abar_Oh:SetStatusBarColor(r,g,b) + Abar_OhText:SetText(text) + Abar_Oh:SetMinMaxValues(Abar_Oh.st,Abar_Oh.et) + Abar_Oh:SetValue(Abar_Oh.st) + Abar_Oh:Show() +end + +function Abar_Boo(inpt) + if inpt == true then return " ON" else return " OFF" end +end diff --git a/attackbar.xml b/BearCastBar/attackbar.xml similarity index 96% rename from attackbar.xml rename to BearCastBar/attackbar.xml index 308d69c..411ae90 100644 --- a/attackbar.xml +++ b/BearCastBar/attackbar.xml @@ -1,157 +1,157 @@ - -