From a1aa8dd9e080167bf1e1220d9188db556bd47d34 Mon Sep 17 00:00:00 2001 From: shagu Date: Thu, 11 Aug 2022 12:23:47 +0200 Subject: [PATCH] auto-dismount: use tooltip based mount detection * remove mount icons from texture scans * add locales for all 7 supported clients * add locales for turtle-wow custom mounts --- mods/auto-dismount.lua | 52 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 45 insertions(+), 7 deletions(-) diff --git a/mods/auto-dismount.lua b/mods/auto-dismount.lua index d1facdf..edbe876 100644 --- a/mods/auto-dismount.lua +++ b/mods/auto-dismount.lua @@ -9,18 +9,45 @@ local module = ShaguTweaks:register({ module.enable = function(self) local dismount = CreateFrame("Frame") - dismount:RegisterEvent("UI_ERROR_MESSAGE") - dismount.buffs = { "spell_nature_swiftness", "_mount_", "_qirajicrystal_", + -- mount tooltip texts + dismount.strings = { + -- deDE + "^Erhöht Tempo um (.+)%%", + -- enUS + "^Increases speed by (.+)%%", + -- esES + "^Aumenta la velocidad en un (.+)%%", + -- frFR + "^Augmente la vitesse de (.+)%%", + -- ruRU + "^Скорость увеличена на (.+)%%", + -- koKR + "^이동 속도 (.+)%%만큼 증가", + -- zhCN + "^速度提高(.+)%%", + + -- turtle-wow + "speed based on", + "Slow and steady...", + "Riding" + } + + -- shapeshift buff icons + dismount.shapeshifts = { "ability_racial_bearform", "ability_druid_catform", "ability_druid_travelform", - "spell_nature_forceofnature", "ability_druid_aquaticform", "spell_nature_spiritwolf", - "ability_hunter_pet_turtle", "inv_misc_head_dragon_black", "ability_bullrush" } + "spell_nature_forceofnature", "ability_druid_aquaticform", "spell_nature_spiritwolf" + } + -- errors that indicate mount/shapeshift dismount.errors = { SPELL_FAILED_NOT_MOUNTED, ERR_ATTACK_MOUNTED, ERR_TAXIPLAYERALREADYMOUNTED, SPELL_FAILED_NOT_SHAPESHIFT, SPELL_FAILED_NO_ITEMS_WHILE_SHAPESHIFTED, SPELL_NOT_SHAPESHIFTED, SPELL_NOT_SHAPESHIFTED_NOSPACE, ERR_CANT_INTERACT_SHAPESHIFTED, ERR_NOT_WHILE_SHAPESHIFTED, ERR_NO_ITEMS_WHILE_SHAPESHIFTED, ERR_TAXIPLAYERSHAPESHIFTED,ERR_MOUNT_SHAPESHIFTED } + dismount.scanner = ShaguTweaks.libtipscan:GetScanner("dismount") + + dismount:RegisterEvent("UI_ERROR_MESSAGE") dismount:SetScript("OnEvent", function() -- stand up if arg1 == SPELL_FAILED_NOT_STANDING then @@ -28,15 +55,26 @@ module.enable = function(self) return end - -- cancel mount buff + -- scan through buffs and cancel shapeshift/mount for id, errorstring in pairs(dismount.errors) do if arg1 == errorstring then - for i=0,15,1 do + for i=0, 31 do + -- detect mounts based on tooltip text + dismount.scanner:SetPlayerBuff(i) + for _, str in pairs(dismount.strings) do + if dismount.scanner:Find(str) then + CancelPlayerBuff(i) + return + end + end + + -- detect shapeshift based on texture local buff = GetPlayerBuffTexture(i) if buff then - for id, bufftype in pairs(dismount.buffs) do + for id, bufftype in pairs(dismount.shapeshifts) do if string.find(string.lower(buff), bufftype) then CancelPlayerBuff(i) + return end end end