Skip to content

Commit

Permalink
Improve preview timer, add custom announce messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Aviana committed Jun 29, 2019
1 parent 31e1b05 commit c374e04
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 7 deletions.
24 changes: 17 additions & 7 deletions YaHT.lua
Expand Up @@ -25,8 +25,18 @@ local function OnUpdate(self, elapsed)
local config = YaHT.db.profile
if not config.lock then
self.mockTime = self.mockTime + elapsed
if self.mockTime > 3 then self.mockTime = 0 end
self.texture:SetWidth(self:GetWidth() * self.mockTime/3)
if self.mockTime > self.swingtime then
self.texture:SetVertexColor(config.drawcolor.r,config.drawcolor.g,config.drawcolor.b)
self.texture:SetWidth(self:GetWidth() * (1-(self.mockTime2/SWING_TIME)))
self.mockTime2 = self.mockTime2 + elapsed
if self.mockTime2 > SWING_TIME then
self.mockTime = 0
end
else
self.mockTime2 = 0
self.texture:SetVertexColor(config.timercolor.r,config.timercolor.g,config.timercolor.b)
self.texture:SetWidth(self:GetWidth() * self.mockTime/self.swingtime)
end
return
end
local curTime = GetTime()
Expand Down Expand Up @@ -163,6 +173,7 @@ function YaHT:ApplySettings()
self.mainFrame:Hide()
else
self.mainFrame:Show()
self.mainFrame:SetAlpha(YaHT.db.profile.alpha)
if self.mainFrame.SwingStart then
self.mainFrame.texture:SetVertexColor(config.drawcolor.r,config.drawcolor.g,config.drawcolor.b)
else
Expand All @@ -188,7 +199,7 @@ function YaHT:Load()
self.mainFrame.mockTime = 0
self.mainFrame.time = 0
self.mainFrame.lastshot = GetTime()
-- self.mainFrame.SwingStart = GetTime()
self.mainFrame.swingtime = UnitRangedDamage("player") - SWING_TIME
self.mainFrame:SetScript("OnUpdate", OnUpdate)

self.mainFrame.background = self.mainFrame:CreateTexture("YaHTMainFrameBackground", "BACKGROUND")
Expand All @@ -205,7 +216,7 @@ function YaHT:Load()
end

function YaHT:COMBAT_LOG_EVENT_UNFILTERED()
local _, event, _, casterID, _, _, _, targetID, _, _, _, spellID, _, _, extra_spell_id, _, _, resisted, blocked, absorbed = CombatLogGetCurrentEventInfo()
local _, event, _, casterID, _, _, _, targetID, targetName, _, _, spellID, _, _, extra_spell_id, _, _, resisted, blocked, absorbed = CombatLogGetCurrentEventInfo()
local name, rank, icon, castTime = GetSpellInfo(spellID)
if event == "SWING_DAMAGE" or event == "ENVIRONMENTAL_DAMAGE" or event == "RANGE_DAMAGE" or event == "SPELL_DAMAGE" then
if resisted or blocked or absorbed then return end
Expand All @@ -225,15 +236,15 @@ function YaHT:COMBAT_LOG_EVENT_UNFILTERED()
if YaHT.db.profile.announcetype == "CHANNEL" then
num = GetChannelName(YaHT.db.profile.targetchannel)
end
SendChatMessage("Tranq out!", YaHT.db.profile.announcetype, nil, num or YaHT.db.profile.targetchannel)
SendChatMessage(string.format(YaHT.db.profile.announcemsg,targetName), YaHT.db.profile.announcetype, nil, num or YaHT.db.profile.targetchannel)
end
elseif event == "SPELL_MISSED" and spellID == 19801 then
if YaHT.db.profile.tranqannouncefail then
local num
if YaHT.db.profile.announcetype == "CHANNEL" then
num = GetChannelName(YaHT.db.profile.targetchannel)
end
SendChatMessage("Tranq missed!", YaHT.db.profile.announcetype, nil, num or YaHT.db.profile.targetchannel)
SendChatMessage(string.format(YaHT.db.profile.announcefailmsg,targetName), YaHT.db.profile.announcetype, nil, num or YaHT.db.profile.targetchannel)
end
end
if (name ~= AimedShot and name ~= MultiShot) or (not YaHT.db.profile.showaimed and name == AimedShot) or (not YaHT.db.profile.showmulti and name == MultiShot) then return end
Expand Down Expand Up @@ -299,7 +310,6 @@ end
function YaHT:START_AUTOREPEAT_SPELL()
local config = YaHT.db.profile
local curTime = GetTime()
self.mainFrame.swingtime = UnitRangedDamage("player") - SWING_TIME
self.mainFrame.shooting = true
-- self.mainFrame.ignoregcd = self:GCDcheck()
if curTime - self.mainFrame.lastshot < self.mainFrame.swingtime then
Expand Down
2 changes: 2 additions & 0 deletions defaults.lua
Expand Up @@ -19,6 +19,8 @@ function YaHT:LoadDefaults()
border = "Blizzard Dialog",
fill = true,
announcetype = "SAY",
announcemsg = YaHT.L["announcemsg"],
announcefailmsg = YaHT.L["announcefailmsg"],
bordercolor = {
r = 1,
g = 1,
Expand Down
5 changes: 5 additions & 0 deletions locales/deDE.lua
Expand Up @@ -55,6 +55,11 @@ local L = {
["Raid"] = "Schlachtzug",
["Channel/Playername"] = "Kanal/Spielername",
["Set the channel or player for whisper."] = "Setze den Kanal oder Spieler f\195\188r fl\195\188stern.",
["Announce Message"] = "Ansage Nachricht",
["Announce Fail Message"] = "Ansage Nachricht fehlgeschlagen",
["Set the message to be broadcasted."] = "Setze die Nachricht die gesendet wird.",
["announcemsg"] = "Einlullender Schuss auf %s!",
["announcefailmsg"] = "Einlullender Schuss fehlgeschlagen auf %s!",
}

YaHT.L = L
5 changes: 5 additions & 0 deletions locales/enUS.lua
Expand Up @@ -50,6 +50,11 @@ local L = {
["Raid"] = "Raid",
["Channel/Playername"] = "Channel/Playername",
["Set the channel or player for whisper."] = "Set the channel or player for whisper.",
["Announce Message"] = "Announce Message",
["Announce Fail Message"] = "Announce Fail Message",
["Set the message to be broadcasted."] = "Set the message to be broadcasted.",
["announcemsg"] = "Tranq out on %s!",
["announcefailmsg"] = "Tranq failed on %s!",
}

YaHT.L = L
14 changes: 14 additions & 0 deletions options.lua
Expand Up @@ -260,6 +260,20 @@ function YaHT:CreateConfig()
order = 27,
hidden = function() return not (YaHT.db.profile.announcetype == "WHISPER" or YaHT.db.profile.announcetype == "CHANNEL") end,
},
announcemsg = {
name = L["Announce Message"],
desc = L["Set the message to be broadcasted."],
type = "input",
order = 28,
width = "full",
},
announcefailmsg = {
name = L["Announce Fail Message"],
desc = L["Set the message to be broadcasted."],
type = "input",
order = 29,
width = "full",
},
}
}
}
Expand Down

0 comments on commit c374e04

Please sign in to comment.