Skip to content

Commit

Permalink
Fix & improve tranq announcement
Browse files Browse the repository at this point in the history
  • Loading branch information
Aviana committed Jun 10, 2017
1 parent d4e9285 commit ba14617
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 15 deletions.
67 changes: 55 additions & 12 deletions YaHT.lua
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,40 @@ function YaHT:OnInitialize()
set = function() YaHT.db.profile.tranq = not YaHT.db.profile.tranq end,
order = 1,
},
fail = {
type = "toggle",
name = L["Tranq fail announce"],
desc = L["Enable failed Tranquilizing Shot announce"],
get = function() return YaHT.db.profile.tranqfailed end,
set = function() YaHT.db.profile.tranqfailed = not YaHT.db.profile.tranqfailed end,
order = 2,
},
channel = {
type = "text",
name = L["Channel"],
desc = L["Channel in which to announce"],
usage = L["<channelname>"],
get = function() return YaHT.db.profile.channel end,
set = function(v) YaHT.db.profile.channel = v end,
order = 2,
order = 3,
},
tranqmsg = {
type = "text",
name = L["Tranq Message"],
desc = L["What to send to the channel"],
usage = L["Use plain text and substitute the targets name with %t"],
get = function() return YaHT.db.profile.tranqmsg end,
set = function(v) YaHT.db.profile.tranqmsg = v end,
order = 4,
},
tranqfailmsg = {
type = "text",
name = L["Tranq fail Message"],
desc = L["What to send to the channel when tranq failed"],
usage = L["<Message>"],
get = function() return YaHT.db.profile.tranqfailmsg end,
set = function(v) YaHT.db.profile.tranqfailmsg = v end,
order = 5,
},
},
order = 5,
Expand Down Expand Up @@ -235,11 +261,13 @@ function YaHT:OnInitialize()

self:RegisterEvent("SPELLCAST_FAILED", "SPELLCAST_STOP")
self:RegisterEvent("SPELLCAST_INTERRUPTED", "SPELLCAST_STOP")
self:RegisterEvent("SPELLCAST_FAILED")
self:RegisterEvent("SPELLCAST_DELAYED")
self:RegisterEvent("START_AUTOREPEAT_SPELL")
self:RegisterEvent("STOP_AUTOREPEAT_SPELL")
self:RegisterEvent("ITEM_LOCK_CHANGED")
self:RegisterEvent("UNIT_RANGEDDAMAGE")
self:RegisterEvent("CHAT_MSG_SPELL_DAMAGESHIELDS_ON_SELF")
self:Hook("CastSpell")
self:Hook("CastSpellByName")
self:Hook("UseAction")
Expand Down Expand Up @@ -334,17 +362,7 @@ function YaHT:StartCast(spellName, rank)
castbar = YaHT.db.profile.multi
self.casttime = 0.5
elseif spellName == L["Tranquilizing Shot"] and YaHT.db.profile.tranq then
local targetName = UnitName("target")
if YaHT.db.profile.channel and YaHT.db.profile.channel ~= "" then
if self.ChatTypes[strupper(YaHT.db.profile.channel)] then
SendChatMessage(L["YaHT: Tranquilizing Shot on "]..targetName, strupper(YaHT.db.profile.channel))
else
local id = GetChannelName(YaHT.db.profile.channel)
if id then
SendChatMessage(L["YaHT: Tranquilizing Shot on "]..targetName, "CHANNEL", nil, id)
end
end
end
self:ScheduleEvent("YaHT_TRANQ", self.Announce, 0.2, self, string.gsub(YaHT.db.profile.tranqmsg,"%%t",UnitName("target")))
end
if not self.casttime then
self.casting = true
Expand Down Expand Up @@ -503,6 +521,23 @@ function YaHT:YAHT_ON_UPDATE()
end
end

function YaHT:Announce(msg)
if self.ChatTypes[strupper(YaHT.db.profile.channel)] then
SendChatMessage(msg, strupper(YaHT.db.profile.channel))
else
local id = GetChannelName(YaHT.db.profile.channel)
if id then
SendChatMessage(msg, "CHANNEL", nil, id)
end
end
end

function YaHT:CHAT_MSG_SPELL_DAMAGESHIELDS_ON_SELF()
if string.find(arg1, L["YaHT_MISS"]) then
self:Announce(YaHT.db.profile.tranqfailmsg)
end
end

function YaHT:UNIT_RANGEDDAMAGE()
self.newswingtime = UnitRangedDamage("player") - SWING_TIME
end
Expand All @@ -513,9 +548,17 @@ function YaHT:SPELLCAST_DELAYED()
end
end

function YaHT:SPELLCAST_FAILED()
self:CancelScheduledEvent("YaHT_TRANQ")
end

function YaHT:SPELLCAST_STOP()
self.casting = nil
self.castblock = nil
if incTranq and YaHT.db.profile.channel and YaHT.db.profile.channel ~= "" then
local msg = string.gsub(YaHT.db.profile.tranqmsg, "%%t", currTarget)
self:Announce(msg)
end
end

function YaHT:START_AUTOREPEAT_SPELL()
Expand Down
2 changes: 2 additions & 0 deletions defaults.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ YaHT.defaults = {
border = 3,
alpha = 1,
malpha = 0.2,
tranqmsg = L["YaHT_TRANQMSG"],
tranqfailmsg = L["YaHT_FAILEDMSG"],
},
}
--------------------------------------------------------------------------------------------
13 changes: 12 additions & 1 deletion locales/deDE.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,17 @@ AceLocale:RegisterTranslations("deDE", function()
["Tranq options"] = "'Einlullender Schuss' Optionen",
["Tranq announce"] = "'Einlullender Schuss' Ansage",
["Enable Tranquilizing Shot announce"] = "Melde 'Einlullender Schuss' an einen Kanal",
["Tranq fail announce"] = "'Einlullender Schuss' Verfehl-Ansage",
["Enable failed Tranquilizing Shot announce"] = "Melde 'Einlullender Schuss verfehlt' an einen Kanal",
["<Message>"] = "<Nachricht>",
["Channel"] = "Chatkanal",
["Channel in which to announce"] = "Kanal in dem angesagt wird.",
["<channelname>"] = "<Kanalname>",
["Tranq Message"] = "'Einlullender Schuss' Nachricht",
["What to send to the channel"] = "Was an den Kanal \195\188bermittelt wird.",
["Use plain text and substitute the targets name with %t"] = "Benutze Klartext und verwende %t um den namen des Ziels zu setzen",
["Tranq fail Message"] = "Einlull Verfehl-Nachricht",
["What to send to the channel when tranq failed"] = "Was an den Kanal \195\188bermittelt wird wenn fehlgeschlagen",
["Reset Settings"] = "Einstellungen zurücksetzen",

["Timer options"] = "Messleistenoptionen",
Expand All @@ -46,13 +54,16 @@ AceLocale:RegisterTranslations("deDE", function()
["Viper Sting"] = "Vipernbiss",
["Tranquilizing Shot"] = "Einlullender Schuss",

["YaHT: Tranquilizing Shot on "] = "YaHT: Einlullender Schuss auf ",
["Loaded. The hunt begins!"] = "Geladen. Die Jagt beginnt!",
["Locked."] = "Verriegelt.",
["Unlocked."] = "Entriegelt.",
["Do you really want to reset to default for your current profile?"] = "Möchtest du wirklich dein momentanes Profil zurücksetzen?",
["OK"] = "OK",
["Cancel"] = "Abbrechen",
["Current profile has been reset."] = "Das momentane Profil wurde zurückgesetzt.",

["YaHT_MISS"] = "Einlullender Schuss hat .+ verfehlt",
["YaHT_FAILEDMSG"] = "YaHT: Einlullender Schuss fehlgeschlagen!",
["YaHT_TRANQMSG"] = "YaHT: Einlullender Schuss auf %t",
}
end)
13 changes: 12 additions & 1 deletion locales/enUS.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,17 @@ AceLocale:RegisterTranslations("enUS", function()
["Tranq options"] = "Tranq options",
["Tranq announce"] = "Tranq announce",
["Enable Tranquilizing Shot announce"] = "Enable Tranquilizing Shot announce",
["Tranq fail announce"] = "Tranq fail announce",
["Enable failed Tranquilizing Shot announce"] = "Enable failed Tranquilizing Shot announce",
["<Message>"] = "<Message>",
["Channel"] = "Channel",
["Channel in which to announce"] = "Channel in which to announce",
["<channelname>"] = "<channelname>",
["Tranq Message"] = "Tranq Message",
["What to send to the channel"] = "What to send to the channel",
["Use plain text and substitute the targets name with %t"] = "Use plain text and substitute the targets name with %t",
["Tranq fail Message"] = "Tranq fail Message",
["What to send to the channel when tranq failed"] = "What to send to the channel when tranq failed",
["Reset Settings"] = "Reset Settings",

["Timer options"] = "Timer options",
Expand All @@ -46,13 +54,16 @@ AceLocale:RegisterTranslations("enUS", function()
["Viper Sting"] = "Viper Sting",
["Tranquilizing Shot"] = "Tranquilizing Shot",

["YaHT: Tranquilizing Shot on "] = "YaHT: Tranquilizing Shot on ",
["Loaded. The hunt begins!"] = "Loaded. The hunt begins!",
["Locked."] = "Locked.",
["Unlocked."] = "Unlocked.",
["Do you really want to reset to default for your current profile?"] = "Do you really want to reset to default for your current profile?",
["OK"] = "OK",
["Cancel"] = "Cancel",
["Current profile has been reset."] = "Current profile has been reset.",

["YaHT_MISS"] = "Your Tranquilizing Shot missed .+",
["YaHT_FAILEDMSG"] = "YaHT: Tranquilizing Shot failed!",
["YaHT_TRANQMSG"] = "YaHT: Tranquilizing Shot on %t",
}
end)
13 changes: 12 additions & 1 deletion locales/frFR.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,17 @@ AceLocale:RegisterTranslations("frFR", function()
["Tranq options"] = "Tranq options",
["Tranq announce"] = "Tranq announce",
["Enable Tranquilizing Shot announce"] = "Enable Tranquilizing Shot announce",
["Tranq fail announce"] = "Tranq fail announce",
["Enable failed Tranquilizing Shot announce"] = "Enable failed Tranquilizing Shot announce",
["<Message>"] = "<Message>",
["Channel"] = "Channel",
["Channel in which to announce"] = "Channel in which to announce",
["<channelname>"] = "<channelname>",
["Tranq Message"] = "Tranq Message",
["What to send to the channel"] = "What to send to the channel",
["Use plain text and substitute the targets name with %t"] = "Use plain text and substitute the targets name with %t",
["Tranq fail Message"] = "Tranq fail Message",
["What to send to the channel when tranq failed"] = "What to send to the channel when tranq failed",
["Reset Settings"] = "Reset Settings",

["Timer options"] = "Timer options",
Expand All @@ -46,13 +54,16 @@ AceLocale:RegisterTranslations("frFR", function()
["Viper Sting"] = "Morsure de vip\195\168re",
["Tranquilizing Shot"] = "Tir tranquillisant",

["YaHT: Tranquilizing Shot on "] = "YaHT: Tranquilizing Shot on ",
["Loaded. The hunt begins!"] = "Loaded. The hunt begins!",
["Locked."] = "Locked.",
["Unlocked."] = "Unlocked.",
["Do you really want to reset to default for your current profile?"] = "Do you really want to reset to default for your current profile?",
["OK"] = "OK",
["Cancel"] = "Cancel",
["Current profile has been reset."] = "Current profile has been reset.",

["YaHT_MISS"] = "Votre Tir tranquillisant a raté .+",
["YaHT_FAILEDMSG"] = "YaHT: Tranquilizing Shot failed!",
["YaHT_TRANQMSG"] = "YaHT: Tranquilizing Shot on %t",
}
end)
12 changes: 12 additions & 0 deletions locales/zhCN.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,17 @@ AceLocale:RegisterTranslations("zhCN", function()
["Tranq options"] = "Tranq options",
["Tranq announce"] = "Tranq announce",
["Enable Tranquilizing Shot announce"] = "Enable Tranquilizing Shot announce",
["Tranq fail announce"] = "Tranq fail announce",
["Enable failed Tranquilizing Shot announce"] = "Enable failed Tranquilizing Shot announce",
["<Message>"] = "<Message>",
["Channel"] = "Channel",
["Channel in which to announce"] = "Channel in which to announce",
["<channelname>"] = "<channelname>",
["Tranq Message"] = "Tranq Message",
["What to send to the channel"] = "What to send to the channel",
["Use plain text and substitute the targets name with %t"] = "Use plain text and substitute the targets name with %t",
["Tranq fail Message"] = "Tranq fail Message",
["What to send to the channel when tranq failed"] = "What to send to the channel when tranq failed",
["Reset Settings"] = "Reset Settings",

["Timer options"] = "Timer options",
Expand Down Expand Up @@ -54,5 +62,9 @@ AceLocale:RegisterTranslations("zhCN", function()
["OK"] = "OK",
["Cancel"] = "Cancel",
["Current profile has been reset."] = "Current profile has been reset.",

["YaHT_MISS"] = "你的宁神射击没有击中.+",
["YaHT_FAILEDMSG"] = "YaHT: Tranquilizing Shot failed!",
["YaHT_TRANQMSG"] = "YaHT: Tranquilizing Shot on %t",
}
end)

0 comments on commit ba14617

Please sign in to comment.