From ba1461741e2e6497e4159e594b5008eec3d8f1e9 Mon Sep 17 00:00:00 2001 From: Aviana Date: Sat, 10 Jun 2017 17:04:22 +0200 Subject: [PATCH] Fix & improve tranq announcement --- YaHT.lua | 67 +++++++++++++++++++++++++++++++++++++++--------- defaults.lua | 2 ++ locales/deDE.lua | 13 +++++++++- locales/enUS.lua | 13 +++++++++- locales/frFR.lua | 13 +++++++++- locales/zhCN.lua | 12 +++++++++ 6 files changed, 105 insertions(+), 15 deletions(-) diff --git a/YaHT.lua b/YaHT.lua index e2a59a9..fa37075 100644 --- a/YaHT.lua +++ b/YaHT.lua @@ -167,6 +167,14 @@ 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"], @@ -174,7 +182,25 @@ function YaHT:OnInitialize() usage = L[""], 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[""], + get = function() return YaHT.db.profile.tranqfailmsg end, + set = function(v) YaHT.db.profile.tranqfailmsg = v end, + order = 5, }, }, order = 5, @@ -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") @@ -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 @@ -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 @@ -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() diff --git a/defaults.lua b/defaults.lua index d264f68..f79fe62 100644 --- a/defaults.lua +++ b/defaults.lua @@ -47,6 +47,8 @@ YaHT.defaults = { border = 3, alpha = 1, malpha = 0.2, + tranqmsg = L["YaHT_TRANQMSG"], + tranqfailmsg = L["YaHT_FAILEDMSG"], }, } -------------------------------------------------------------------------------------------- diff --git a/locales/deDE.lua b/locales/deDE.lua index 6264a5e..32de22f 100644 --- a/locales/deDE.lua +++ b/locales/deDE.lua @@ -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", + [""] = "", ["Channel"] = "Chatkanal", ["Channel in which to announce"] = "Kanal in dem angesagt wird.", [""] = "", + ["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", @@ -46,7 +54,6 @@ 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.", @@ -54,5 +61,9 @@ AceLocale:RegisterTranslations("deDE", function() ["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) \ No newline at end of file diff --git a/locales/enUS.lua b/locales/enUS.lua index 88b1fd0..e48a932 100644 --- a/locales/enUS.lua +++ b/locales/enUS.lua @@ -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", + [""] = "", ["Channel"] = "Channel", ["Channel in which to announce"] = "Channel in which to announce", [""] = "", + ["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", @@ -46,7 +54,6 @@ 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.", @@ -54,5 +61,9 @@ AceLocale:RegisterTranslations("enUS", function() ["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) \ No newline at end of file diff --git a/locales/frFR.lua b/locales/frFR.lua index f91646c..70bbf15 100644 --- a/locales/frFR.lua +++ b/locales/frFR.lua @@ -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", + [""] = "", ["Channel"] = "Channel", ["Channel in which to announce"] = "Channel in which to announce", [""] = "", + ["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", @@ -46,7 +54,6 @@ 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.", @@ -54,5 +61,9 @@ AceLocale:RegisterTranslations("frFR", function() ["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) \ No newline at end of file diff --git a/locales/zhCN.lua b/locales/zhCN.lua index 465b071..72603bb 100644 --- a/locales/zhCN.lua +++ b/locales/zhCN.lua @@ -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", + [""] = "", ["Channel"] = "Channel", ["Channel in which to announce"] = "Channel in which to announce", [""] = "", + ["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", @@ -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) \ No newline at end of file