Untitled diff
351 líneas
--[[
--[[
#1 Cast_Interrupt reset
#1 Cast_Interrupt reset
# Nostalrius Bug
# Nostalrius Bug
--> "ITEM_LOCK CHANGED" van a "SPELLCAST_STOP" helyett
--> "ITEM_LOCK CHANGED" van a "SPELLCAST_STOP" helyett
--> reportolva van már nostalrius bugtrackeren, ha fixelik cseréljem le "SPELLCAST_STOP"-ra
--> reportolva van már nostalrius bugtrackeren, ha fixelik cseréljem le "SPELLCAST_STOP"-ra
--> https://report.nostalrius.org/plugins/tracker/?aid=310
--> https://report.nostalrius.org/plugins/tracker/?aid=310
]]
]]
local AddOn = "rais_AutoShot"
local AddOn = "rais_AutoShot"
local _G = getfenv(0)
local _G = getfenv(0)
local Textures = {
local Textures = {
Bar = "Interface\\AddOns\\"..AddOn.."\\Textures\\Bar.tga",
Bar = "Interface\\AddOns\\"..AddOn.."\\Textures\\Bar.tga",
}
}
local Table = {
local Table = {
["posX"] = 0;
["posX"] = 0;
["posY"] = -235;
["posY"] = -235;
["Width"] = 100;
["Width"] = 100;
["Height"] = 15;
["Height"] = 15;
}
}
local AimedCastBar = true; -- true / false
local AimedCastBar = false; -- true / false
local castStart = false;
local castStart = false;
local swingStart = false;
local swingStart = false;
local aimedStart = false;
local aimedStart = false;
local shooting = false; -- player adott pillantban lő-e
local shooting = false; -- player adott pillantban lő-e
local posX, posY -- player position when starts Casting
local posX, posY -- player position when starts Casting
local interruptTime -- Concussive shot miatt
local interruptTime -- Concussive shot miatt
local castTime = 0.65
local castTime = 0.65
local swingTime
local swingTime
local berserkValue = false
local function AutoShotBar_Create()
local function Bar_Create()
Table["posX"] = Table["posX"] *GetScreenWidth() /1000;
Table["posX"] = Table["posX"] *GetScreenWidth() /1000;
Table["posY"] = Table["posY"] *GetScreenHeight() /1000;
Table["posY"] = Table["posY"] *GetScreenHeight() /1000;
Table["Width"] = Table["Width"] *GetScreenWidth() /1000;
Table["Width"] = Table["Width"] *GetScreenWidth() /1000;
Table["Height"] = Table["Height"] *GetScreenHeight() /1000;
Table["Height"] = Table["Height"] *GetScreenHeight() /1000;
_G[AddOn.."_Frame_Timer"] = CreateFrame("Frame",nil,UIParent);
_G[AddOn.."_Frame_Timer"] = CreateFrame("Frame",nil,UIParent);
local Frame = _G[AddOn.."_Frame_Timer"];
local Frame = _G[AddOn.."_Frame_Timer"];
Frame:SetFrameStrata("HIGH");
Frame:SetFrameStrata("HIGH");
Frame:SetWidth(Table["Width"]);
Frame:SetWidth(Table["Width"]);
Frame:SetHeight(Table["Height"]);
Frame:SetHeight(Table["Height"]);
Frame:SetPoint("CENTER",UIParent,"CENTER",Table["posX"],Table["posY"]);
Frame:SetPoint("CENTER",UIParent,"CENTER",Table["posX"],Table["posY"]);
Frame:SetAlpha(0);
Frame:SetAlpha(0);
_G[AddOn.."_Texture_Timer"] = Frame:CreateTexture(nil,"OVERLAY");
_G[AddOn.."_Texture_Timer"] = Frame:CreateTexture(nil,"OVERLAY");
local Bar = _G[AddOn.."_Texture_Timer"];
local Bar = _G[AddOn.."_Texture_Timer"];
Bar:SetHeight(Table["Height"]);
Bar:SetHeight(Table["Height"]);
Bar:SetTexture(Textures.Bar);
Bar:SetTexture(Textures.Bar);
Bar:SetPoint("CENTER",Frame,"CENTER");
Bar:SetPoint("CENTER",Frame,"CENTER");
local Background = Frame:CreateTexture(nil,"ARTWORK");
local Background = Frame:CreateTexture(nil,"ARTWORK");
Background:SetTexture(15/100, 15/100, 15/100, 1);
Background:SetTexture(15/100, 15/100, 15/100, 1);
Background:SetAllPoints(Frame);
Background:SetAllPoints(Frame);
local Border = Frame:CreateTexture(nil,"BORDER");
local Border = Frame:CreateTexture(nil,"BORDER");
Border:SetPoint("CENTER",Frame,"CENTER");
Border:SetPoint("CENTER",Frame,"CENTER");
Border:SetWidth(Table["Width"] +3);
Border:SetWidth(Table["Width"] +3);
Border:SetHeight(Table["Height"] +3);
Border:SetHeight(Table["Height"] +3);
Border:SetTexture(0,0,0);
Border:SetTexture(0,0,0);
local Border = Frame:CreateTexture(nil,"BACKGROUND");
local Border = Frame:CreateTexture(nil,"BACKGROUND");
Border:SetPoint("CENTER",Frame,"CENTER");
Border:SetPoint("CENTER",Frame,"CENTER");
Border:SetWidth(Table["Width"] +6);
Border:SetWidth(Table["Width"] +6);
Border:SetHeight(Table["Height"] +6);
Border:SetHeight(Table["Height"] +6);
Border:SetTexture(1,1,1);
Border:SetTexture(1,1,1);
end
end
local sST,sSCD = 0,0
local sST,sSCD = 0,0
local sSTold
local sSTold
local function GlobalCD_Check()
local function GlobalCD_Check()
local _,_,offset,numSpells = GetSpellTabInfo(GetNumSpellTabs())
local _,_,offset,numSpells = GetSpellTabInfo(GetNumSpellTabs())
local numAllSpell = offset + numSpells;
local numAllSpell = offset + numSpells;
for i=1,numAllSpell do
for i=1,numAllSpell do
local name = GetSpellName(i,"BOOKTYPE_SPELL");
local name = GetSpellName(i,"BOOKTYPE_SPELL");
if ( name == "Serpent Sting" ) then
if ( name == "Serpent Sting" ) then
sST,sSCD = GetSpellCooldown(i,"BOOKTYPE_SPELL")
sST,sSCD = GetSpellCooldown(i,"BOOKTYPE_SPELL")
end
end
end
end
end
end
local function Cast_Start()
local function Cast_Start()
_G[AddOn.."_Texture_Timer"]:SetVertexColor(1,0,0);
_G[AddOn.."_Texture_Timer"]:SetVertexColor(1,0,0);
posX, posY = GetPlayerMapPosition("player");
posX, posY = GetPlayerMapPosition("player");
castStart = GetTime();
castStart = GetTime();
end
end
local function Cast_Update()
local function Cast_Update()
_G[AddOn.."_Frame_Timer"]:SetAlpha(1);
_G[AddOn.."_Frame_Timer"]:SetAlpha(1);
local relative = GetTime() - castStart
local relative = GetTime() - castStart
if ( relative > castTime ) then
if ( relative > castTime ) then
castStart = false;
castStart = false;
elseif ( swingStart == false ) then
elseif ( swingStart == false ) then
_G[AddOn.."_Texture_Timer"]:SetWidth(Table["Width"] * relative/castTime);
_G[AddOn.."_Texture_Timer"]:SetWidth(Table["Width"] * relative/castTime);
end
end
end
end
local function Cast_Interrupted()
local function Cast_Interrupted()
_G[AddOn.."_Frame_Timer"]:SetAlpha(0);
_G[AddOn.."_Frame_Timer"]:SetAlpha(0);
swingStart = false;
swingStart = false;
Cast_Start()
Cast_Start()
end
end
local function Shot_Start()
local function Shot_Start()
Cast_Start();
Cast_Start();
shooting = true;
shooting = true;
end
end
local function Shot_End()
local function Shot_End()
if ( swingStart == false ) then
if ( swingStart == false ) then
_G[AddOn.."_Frame_Timer"]:SetAlpha(0);
_G[AddOn.."_Frame_Timer"]:SetAlpha(0);
end
end
castStart = false
castStart = false
shooting = false
shooting = false
end
end
local function Swing_Start()
local function Swing_Start()
swingTime = UnitRangedDamage("player") - castTime;
swingTime = UnitRangedDamage("player") - castTime;
_G[AddOn.."_Texture_Timer"]:SetVertexColor(1,1,1);
_G[AddOn.."_Texture_Timer"]:SetVertexColor(1,1,1);
castStart = false
castStart = false
swingStart = GetTime();
swingStart = GetTime();
end
end
local AimedTooltip = CreateFrame("GameTooltip","AimedTooltip",UIParent,"GameTooltipTemplate");
local AimedTooltip = CreateFrame("GameTooltip","AimedTooltip",UIParent,"GameTooltipTemplate");
AimedTooltip:SetOwner(UIParent,"ANCHOR_NONE");
AimedTooltip:SetOwner(UIParent,"ANCHOR_NONE");
local AimedID
local AimedID
local function AimedID_Get()
local function AimedID_Get()
local _,_,offset,numSpells = GetSpellTabInfo(GetNumSpellTabs())
local _,_,offset,numSpells = GetSpellTabInfo(GetNumSpellTabs())
local numAllSpell = offset + numSpells;
local numAllSpell = offset + numSpells;
for spellID=1,numAllSpell do
for spellID=1,numAllSpell do
local name = GetSpellName(spellID,"BOOKTYPE_SPELL");
local name = GetSpellName(spellID,"BOOKTYPE_SPELL");
if ( name == "Aimed Shot" ) then
if ( name == "Aimed Shot" ) then
AimedID = spellID
AimedID = spellID
end
end
end
end
end
end
local function Aimed_Start()
local function Aimed_Start()
aimedStart = GetTime()
aimedStart = GetTime()
if ( swingStart == false ) then
if ( swingStart == false ) then
_G[AddOn.."_Frame_Timer"]:SetAlpha(0);
_G[AddOn.."_Frame_Timer"]:SetAlpha(0);
end
end
castStart = false
castStart = false
--[[
--[[
AimedTooltip:ClearLines();
AimedTooltip:ClearLines();
AimedTooltip:SetInventoryItem("player", 18)
AimedTooltip:SetInventoryItem("player", 18)
local speed_base = string.gsub(AimedTooltipTextRight3:GetText(),"Speed ","")
local speed_base = string.gsub(AimedTooltipTextRight3:GetText(),"Speed ","")
local speed_haste = UnitRangedDamage("player");
local speed_haste = UnitRangedDamage("player");
local castTime_Aimed = 3 * speed_haste / speed_base -- rapid 1.4 / quick 1.3 / berserking / spider 1.2
local castTime_Aimed = 3 * speed_haste / speed_base -- rapid 1.4 / quick 1.3 / berserking / spider 1.2
]]
]]
local castTime_Aimed = 3
-- azt kéne, hogy alapból megnézi mennyi az auto-shot casttime (speed_haste) belogoláskor pl. (a lényeg, hogy modosító buff ne legyen), majd utána ahhoz viszonítja az épp jelenlévőt. De lehet ez se jó, mert hátha van olyan amit auto-shotét csökkenti, aimedét nem (mint pl. quiver)
-- azt kéne, hogy alapból megnézi mennyi az auto-shot casttime (speed_haste) belogoláskor pl. (a lényeg, hogy modosító buff ne legyen), majd utána ahhoz viszonítja az épp jelenlévőt. De lehet ez se jó, mert hátha van olyan amit auto-shotét csökkenti, aimedét nem (mint pl. quiver)
local castTime_Aimed = 3
for i=1,32 do
if UnitBuff("player",i) == "Interface\\Icons\\Ability_Warrior_InnerRage" then
castTime_Aimed = castTime_Aimed/1.3
end
if UnitBuff("player",i) == "Interface\\Icons\\Ability_Hunter_RunningShot" then
castTime_Aimed = castTime_Aimed/1.4
end
if UnitBuff("player",i) == "Interface\\Icons\\Racial_Troll_Berserk" then
castTime_Aimed = castTime_Aimed/ (1 + berserkValue)
end
if UnitBuff("player",i) == "Interface\\Icons\\Inv_Trinket_Naxxramas04" then
castTime_Aimed = castTime_Aimed/1.2
end
end
--[[local _,_,latency = GetNetStats();
latency = latency/1000;
castTime_Aimed = castTime_Aimed - latency;]]
if ( AimedCastBar == true ) then
if ( AimedCastBar == true ) then
CastingBarFrameStatusBar:SetStatusBarColor(1.0, 0.7, 0.0);
CastingBarFrameStatusBar:SetStatusBarColor(1.0, 0.7, 0.0);
CastingBarSpark:Show();
CastingBarSpark:Show();
CastingBarFrame.startTime = GetTime();
CastingBarFrame.startTime = GetTime();
CastingBarFrame.maxValue = CastingBarFrame.startTime + castTime_Aimed;
CastingBarFrame.maxValue = CastingBarFrame.startTime + castTime_Aimed;
CastingBarFrameStatusBar:SetMinMaxValues(CastingBarFrame.startTime, CastingBarFrame.maxValue);
CastingBarFrameStatusBar:SetMinMaxValues(CastingBarFrame.startTime, CastingBarFrame.maxValue);
CastingBarFrameStatusBar:SetValue(CastingBarFrame.startTime);
CastingBarFrameStatusBar:SetValue(CastingBarFrame.startTime);
CastingBarText:SetText("Aimed Shot "..string.format("%.2f",castTime_Aimed));
CastingBarText:SetText("Aimed Shot");
-- CastingBarText:SetText(castTime_Aimed);
--CastingBarText:SetText(castTime_Aimed);
CastingBarFrame:SetAlpha(1.0);
CastingBarFrame:SetAlpha(1.0);
CastingBarFrame.holdTime = 0;
CastingBarFrame.holdTime = 0;
CastingBarFrame.casting = 1;
CastingBarFrame.casting = 1;
CastingBarFrame.fadeOut = nil;
CastingBarFrame.fadeOut = nil;
CastingBarFrame:Show();
CastingBarFrame:Show();
CastingBarFrame.mode = "casting";
CastingBarFrame.mode = "casting";
end
end
end
end
UseAction_Real = UseAction;
UseAction_Real = UseAction;
function UseAction( slot, checkFlags, checkSelf )
function UseAction( slot, checkFlags, checkSelf )
AimedTooltip:ClearLines();
AimedTooltip:ClearLines();
AimedTooltip:SetAction(slot);
AimedTooltip:SetAction(slot);
local spellName = AimedTooltipTextLeft1:GetText();
local spellName = AimedTooltipTextLeft1:GetText();
if ( spellName == "Aimed Shot" ) then
if ( spellName == "Aimed Shot" ) then
Aimed_Start()
Aimed_Start()
end
end
UseAction_Real( slot, checkFlags, checkSelf );
UseAction_Real( slot, checkFlags, checkSelf );
end
end
CastSpell_Real = CastSpell;
CastSpell_Real = CastSpell;
function CastSpell(spellID, spellTab)
function CastSpell(spellID, spellTab)
AimedID_Get();
AimedID_Get();
if ( spellID == AimedID and spellTab == "BOOKTYPE_SPELL" ) then
if ( spellID == AimedID and spellTab == "BOOKTYPE_SPELL" ) then
Aimed_Start()
Aimed_Start()
end
end
CastSpell_Real(spellID,spellTab);
CastSpell_Real(spellID,spellTab);
end
end
CastSpellByName_Real = CastSpellByName;
CastSpellByName_Real = CastSpellByName;
function CastSpellByName(spellName)
function CastSpellByName(spellName,target)
if ( spellName == "Aimed Shot" ) then
if ( spellName == "Aimed Shot" ) then
Aimed_Start()
Aimed_Start()
end
end
CastSpellByName_Real(spellName)
CastSpellByName_Real(spellName,target)
end
end
local Frame = CreateFrame("Frame");
local Frame = CreateFrame("Frame");
Frame:RegisterAllEvents()
--Frame:RegisterAllEvents()
Frame:RegisterEvent("PLAYER_LOGIN")
Frame:RegisterEvent("PLAYER_LOGIN")
Frame:RegisterEvent("SPELLCAST_STOP")
Frame:RegisterEvent("SPELLCAST_STOP")
Frame:RegisterEvent("CURRENT_SPELL_CAST_CHANGED")
Frame:RegisterEvent("CURRENT_SPELL_CAST_CHANGED")
Frame:RegisterEvent("START_AUTOREPEAT_SPELL")
Frame:RegisterEvent("START_AUTOREPEAT_SPELL")
Frame:RegisterEvent("STOP_AUTOREPEAT_SPELL")
Frame:RegisterEvent("STOP_AUTOREPEAT_SPELL")
Frame:RegisterEvent("ITEM_LOCK_CHANGED")
Frame:RegisterEvent("ITEM_LOCK_CHANGED")
Frame:SetScript("OnEvent",function()
Frame:SetScript("OnEvent",function()
if ( event == "PLAYER_LOGIN" ) then
if ( event == "PLAYER_LOGIN" ) then
AutoShotBar_Create();
Bar_Create();
DEFAULT_CHAT_FRAME:AddMessage("|cff00ccff"..AddOn.."|cffffffff Loaded");
DEFAULT_CHAT_FRAME:AddMessage("|cff00ccff"..AddOn.."|cffffffff Loaded");
end
end
if ( event == "START_AUTOREPEAT_SPELL" ) then
if ( event == "START_AUTOREPEAT_SPELL" ) then
Shot_Start();
Shot_Start();
end
end
if ( event == "STOP_AUTOREPEAT_SPELL" ) then
if ( event == "STOP_AUTOREPEAT_SPELL" ) then
Shot_End();
Shot_End();
end
end
if ( event == "SPELLCAST_STOP" ) then
if ( event == "SPELLCAST_STOP" ) then
if ( aimedStart ~= false ) then
if ( aimedStart ~= false ) then
aimedStart = false
aimedStart = false
end
end
GlobalCD_Check();
GlobalCD_Check();
if ( sSCD == 1.5 ) then
if ( sSCD == 1.5 ) then
sSTold = sST
sSTold = sST
end
end
end
end
if ( event == "CURRENT_SPELL_CAST_CHANGED" ) then
if ( event == "CURRENT_SPELL_CAST_CHANGED" ) then
if ( swingStart == false and aimedStart == false ) then
if ( swingStart == false and aimedStart == false ) then
interruptTime = GetTime()
interruptTime = GetTime()
Cast_Interrupted();
Cast_Interrupted();
end
end
end
end
if ( event == "ITEM_LOCK_CHANGED" ) then
if ( event == "ITEM_LOCK_CHANGED" ) then
if ( shooting == true ) then
if ( shooting == true ) then
GlobalCD_Check();
GlobalCD_Check();
--[[local _,_,offset,numSpells = GetSpellTabInfo(GetNumSpellTabs())
--[[local _,_,offset,numSpells = GetSpellTabInfo(GetNumSpellTabs())
local numAllSpell = offset + numSpells;
local numAllSpell = offset + numSpells;
for i=1,numAllSpell do
for i=1,numAllSpell do
local name = GetSpellName(i,"BOOKTYPE_SPELL");
local name = GetSpellName(i,"BOOKTYPE_SPELL");
if ( name == "Aimed Shot" ) then
if ( name == "Aimed Shot" ) then
aST,aSCD = GetSpellCooldown(i,"BOOKTYPE_SPELL")
aST,aSCD = GetSpellCooldown(i,"BOOKTYPE_SPELL")
end
end
end]]
end]]
if ( aimedStart ~= false ) then
if ( aimedStart ~= false ) then
_G[AddOn.."_Frame_Timer"]:SetAlpha(1);
_G[AddOn.."_Frame_Timer"]:SetAlpha(1);
Cast_Start();
Cast_Start();
elseif ( sSCD ~= 1.5 ) then
elseif ( sSCD ~= 1.5 ) then
Swing_Start();
Swing_Start();
elseif ( sSTold == sST ) then
elseif ( sSTold == sST ) then
Swing_Start();
Swing_Start();
else
else
sSTold = sST;
sSTold = sST;
end
end
-- if ( GetTime()-interruptTime > 0.3 ) then -- ha Concussive Shot castolás megy Auto-Shot castolás közben, ne induljon el a swingtimer
-- if ( GetTime()-interruptTime > 0.3 ) then -- ha Concussive Shot castolás megy Auto-Shot castolás közben, ne induljon el a swingtimer
-- end
-- end
end
end
end
end
--[[if ( UnitName("target") ) then
--[[if ( UnitName("target") ) then
if ( event ~= "CHAT_MSG_CHANNEL" and event ~= "TABARD_CANSAVE_CHANGED" and event ~= "SPELL_UPDATE_COOLDOWN" and event ~= "CHAT_MSG_SPELL_FAILED_LOCALPLAYER" and event ~= "CURSOR_UPDATE" and event ~= "CHAT_MSG_COMBAT_SELF_HITS" and event ~= "SPELL_UPDATE_USABLE" and event ~= "UPDATE_MOUSEOVER_UNIT" and event ~= "UNIT_HAPPINESS" and event ~= "PLAYER_TARGET_CHANGED" and event ~= "UNIT_MANA" and event ~= "UNIT_HEALTH" ) then
if ( event ~= "CHAT_MSG_CHANNEL" and event ~= "TABARD_CANSAVE_CHANGED" and event ~= "SPELL_UPDATE_COOLDOWN" and event ~= "CHAT_MSG_SPELL_FAILED_LOCALPLAYER" and event ~= "CURSOR_UPDATE" and event ~= "CHAT_MSG_COMBAT_SELF_HITS" and event ~= "SPELL_UPDATE_USABLE" and event ~= "UPDATE_MOUSEOVER_UNIT" and event ~= "UNIT_HAPPINESS" and event ~= "PLAYER_TARGET_CHANGED" and event ~= "UNIT_MANA" and event ~= "UNIT_HEALTH" ) then
if ( event ~= "ACTIONBAR_UPDATE_STATE" and event ~= "CURRENT_SPELL_CAST_CHANGED" ) then
if ( event ~= "ACTIONBAR_UPDATE_STATE" and event ~= "CURRENT_SPELL_CAST_CHANGED" ) then
if ( event ~= "UNIT_COMBAT" and event ~= "UI_ERROR_MESSAGE"and event ~= "SPELLCAST_INTERRUPTED" ) then
if ( event ~= "UNIT_COMBAT" and event ~= "UI_ERROR_MESSAGE"and event ~= "SPELLCAST_INTERRUPTED" ) then
DEFAULT_CHAT_FRAME:AddMessage(event);
DEFAULT_CHAT_FRAME:AddMessage(event);
end
end
end
end
end
end
end]]
end]]
if ( event == "UNIT_AURA" ) then
for i=1,16 do
if ( UnitBuff("player",i) == "Interface\\Icons\\Racial_Troll_Berserk" ) then
if ( berserkValue == false ) then
if((UnitHealth("player")/UnitHealthMax("player")) >= 0.40) then
berserkValue = (1.30 - (UnitHealth("player")/UnitHealthMax("player")))/3
else
berserkValue = 0.30
end
end
else
berserkValue = false
end
end
end
end)
end)
Frame:SetScript("OnUpdate",function()
Frame:SetScript("OnUpdate",function()
if ( shooting == true ) then
if ( shooting == true ) then
if ( castStart ~= false ) then
if ( castStart ~= false ) then
local cposX, cposY = GetPlayerMapPosition("player") -- player position atm
local cposX, cposY = GetPlayerMapPosition("player") -- player position atm
if ( posX == cposX and posY == cposY ) then
if ( posX == cposX and posY == cposY ) then
Cast_Update();
Cast_Update();
else
else
Cast_Interrupted();
Cast_Interrupted();
end
end
end
end
end
end
if ( swingStart ~= false ) then
if ( swingStart ~= false ) then
local relative = GetTime() - swingStart
local relative = GetTime() - swingStart
_G[AddOn.."_Texture_Timer"]:SetWidth(Table["Width"] - (Table["Width"]*relative/swingTime));
_G[AddOn.."_Texture_Timer"]:SetWidth(Table["Width"] - (Table["Width"]*relative/swingTime));
if ( relative > swingTime ) then
if ( relative > swingTime ) then
if ( shooting == true and aimedStart == false ) then
if ( shooting == true and aimedStart == false ) then
Cast_Start()
Cast_Start()
else
else
_G[AddOn.."_Texture_Timer"]:SetWidth(0);
_G[AddOn.."_Texture_Timer"]:SetWidth(0);
_G[AddOn.."_Frame_Timer"]:SetAlpha(0);
_G[AddOn.."_Frame_Timer"]:SetAlpha(0);
end
end
swingStart = false;
swingStart = false;
end
end
end
end
end)
end)