From d63162666208944c7f5e510934a2604d171c8c8c Mon Sep 17 00:00:00 2001 From: shagu Date: Sun, 23 Apr 2017 13:11:21 +0200 Subject: [PATCH] autoshift: use locale independent checks --- env/locales_deDE.lua | 11 ---------- env/locales_enUS.lua | 11 ---------- env/locales_frFR.lua | 11 ---------- env/locales_koKR.lua | 11 ---------- env/locales_ruRU.lua | 11 ---------- env/locales_zhCN.lua | 11 ---------- modules/autoshift.lua | 47 +++++++++++-------------------------------- 7 files changed, 12 insertions(+), 101 deletions(-) diff --git a/env/locales_deDE.lua b/env/locales_deDE.lua index 358191ef..3a080c32 100644 --- a/env/locales_deDE.lua +++ b/env/locales_deDE.lua @@ -27,17 +27,6 @@ pfUI_locale["deDE"]["itemtypes"] = { ["INVTYPE_THROWN"] = "Wurfwaffe", } -pfUI_locale["deDE"]["stances"] = { - ['BattleStance'] = "Kampfhaltung", - ['DefensiveStance'] = "Verteidigungshaltung", - ['BerserkerStance'] = "Berserkerhaltung", - ['wantBattleStance'] = "Muss in Kampfhaltung sein.", - ['wantDefensiveStance'] = "Muss in Verteidigungshaltung sein.", - ['wantBerserkerStance'] = "Muss in Berserkerhaltung sein.", - ['wantBattleDefStance'] = "Muss in Kampfhaltung, Verteidigungshaltung sein.", - ['wantBattleBerserkStance'] = "Muss in Kampfhaltung, Berserkerhaltung sein.", -} - pfUI_locale["deDE"]["interrupts"] = { ["Schildhieb"] = true; ["Zuschlagen"] = true; diff --git a/env/locales_enUS.lua b/env/locales_enUS.lua index 3e94105b..6e1776ca 100644 --- a/env/locales_enUS.lua +++ b/env/locales_enUS.lua @@ -27,17 +27,6 @@ pfUI_locale["enUS"]["itemtypes"] = { ["INVTYPE_THROWN"] = "Thrown", } -pfUI_locale["enUS"]["stances"] = { - ['BattleStance'] = "Battle Stance", - ['DefensiveStance'] = "Defensive Stance", - ['BerserkerStance'] = "Berserker Stance", - ['wantBattleStance'] = "Must be in Battle Stance", - ['wantDefensiveStance'] = "Must be in Defensive Stance", - ['wantBerserkerStance'] = "Must be in Berserker Stance", - ['wantBattleDefStance'] = "Must be in Battle Stance, Defensive Stance", - ['wantBattleBerserkStance'] = "Must be in Battle Stance, Berserker Stance", -} - pfUI_locale["enUS"]["interrupts"] = { ["Shield Bash"] = true; ["Pummel"] = true; diff --git a/env/locales_frFR.lua b/env/locales_frFR.lua index 098b4a65..4705bed5 100644 --- a/env/locales_frFR.lua +++ b/env/locales_frFR.lua @@ -27,17 +27,6 @@ pfUI_locale["frFR"]["itemtypes"] = { ["INVTYPE_THROWN"] = "Arme de jet", } -pfUI_locale["frFR"]["stances"] = { - ['BattleStance'] = "Posture de combat", - ['DefensiveStance'] = "Posture défensive", - ['BerserkerStance'] = "Posture berserker", - ['wantBattleStance'] = "Requiert Posture de combat", - ['wantDefensiveStance'] = "Requiert Posture défensive", - ['wantBerserkerStance'] = "Requiert Posture berserker", - ['wantBattleDefStance'] = "Requiert Posture de combat, Posture défensive", - ['wantBattleBerserkStance'] = "Requiert Posture de combat, Posture berserker", -} - pfUI_locale["frFR"]["interrupts"] = { ["Coup de bouclier"] = true; ["Volée de coups"] = true; diff --git a/env/locales_koKR.lua b/env/locales_koKR.lua index 21dc8441..861acba6 100644 --- a/env/locales_koKR.lua +++ b/env/locales_koKR.lua @@ -27,17 +27,6 @@ pfUI_locale["koKR"]["itemtypes"] = { ["INVTYPE_THROWN"] = "투척류", } -pfUI_locale["koKR"]["stances"] = { - ['BattleStance'] = "전투 태세", - ['DefensiveStance'] = "방어 태세", - ['BerserkerStance'] = "광폭 태세", - ['wantBattleStance'] = "전투 태세 필요", - ['wantDefensiveStance'] = "방어 태세 필요", - ['wantBerserkerStance'] = "광폭 태세 필요", - ['wantBattleDefStance'] = "전투 태세 필요, 방어 태세 필요", - ['wantBattleBerserkStance'] = "전투 태세 필요, 공폭 태세 필요", -} - pfUI_locale["koKR"]["interrupts"] = { ["방패 가격"] = true; ["자루 공격"] = true; diff --git a/env/locales_ruRU.lua b/env/locales_ruRU.lua index 92b85c3d..3a222bc1 100644 --- a/env/locales_ruRU.lua +++ b/env/locales_ruRU.lua @@ -27,17 +27,6 @@ pfUI_locale["ruRU"]["itemtypes"] = { ["INVTYPE_THROWN"] = "Метательное", } -pfUI_locale["ruRU"]["stances"] = { - ['BattleStance'] = "Боевая стойка", - ['DefensiveStance'] = "Оборонительная стойка", - ['BerserkerStance'] = "Стойка берсерка", - ['wantBattleStance'] = "Необходимо находиться в Боевая стойка.", - ['wantDefensiveStance'] = "Необходимо находиться в Оборонительная стойка.", - ['wantBerserkerStance'] = "Необходимо находиться в Стойка берсерка.", - ['wantBattleDefStance'] = "Необходимо находиться в Боевая стойка, Оборонительная стойка.", - ['wantBattleBerserkStance'] = "Необходимо находиться в Боевая стойка, Стойка берсерка.", -} - pfUI_locale["ruRU"]["interrupts"] = { ["Удар щитом"] = true; ["Зуботычина"] = true; diff --git a/env/locales_zhCN.lua b/env/locales_zhCN.lua index 234c98df..b123e81b 100644 --- a/env/locales_zhCN.lua +++ b/env/locales_zhCN.lua @@ -27,17 +27,6 @@ pfUI_locale["zhCN"]["itemtypes"] = { ["INVTYPE_THROWN"] = "投掷武器", } -pfUI_locale["zhCN"]["stances"] = { - ['BattleStance'] = "战斗姿态", - ['DefensiveStance'] = "防御姿态", - ['BerserkerStance'] = "狂暴姿态", - ['wantBattleStance'] = "必须在战斗姿态中", - ['wantDefensiveStance'] = "必须在防御姿态中", - ['wantBerserkerStance'] = "必须在狂暴姿态中", - ['wantBattleDefStance'] = "必须在战斗姿态, 防御姿态中", - ['wantBattleBerserkStance'] = "必须在战斗姿态, 狂暴姿态中", -} - pfUI_locale["zhCN"]["interrupts"] = { ["盾击"] = true; ["拳击"] = true; diff --git a/modules/autoshift.lua b/modules/autoshift.lua index 8720c2f5..3396633e 100644 --- a/modules/autoshift.lua +++ b/modules/autoshift.lua @@ -4,50 +4,27 @@ pfUI:RegisterModule("autoshift", function () pfUI.autoshift.lastError = "" pfUI.autoshift.CastSpellByName = _G["CastSpellByName"] + pfUI.autoshift.scanString = string.gsub(SPELL_FAILED_ONLY_SHAPESHIFT, "%%s", "(.+)") - hooksecurefunc("CastSpell", function(spellId, spellbookTabNum) - if pfUI.autoshift.lastError == L["stances"]['wantBattleStance'] then - pfUI.autoshift.CastSpellByName(L["stances"]['BattleStance']) - elseif pfUI.autoshift.lastError == L["stances"]['wantBattleDefStance'] then - pfUI.autoshift.CastSpellByName(L["stances"]['BattleStance']) - elseif pfUI.autoshift.lastError == L["stances"]['wantBattleBerserkStance'] then - pfUI.autoshift.CastSpellByName(L["stances"]['BerserkerStance']) - elseif pfUI.autoshift.lastError == L["stances"]['wantBerserkerStance'] then - pfUI.autoshift.CastSpellByName(L["stances"]['BerserkerStance']) - elseif pfUI.autoshift.lastError == L["stances"]['wantDefensiveStance'] then - pfUI.autoshift.CastSpellByName(L["stances"]['DefensiveStance']) + function pfUI.autoshift:SwitchStance() + for stance in string.gfind(pfUI.autoshift.lastError, pfUI.autoshift.scanString) do + for _, stance in pairs({ strsplit(",", stance)}) do + pfUI.autoshift.CastSpellByName(string.gsub(stance,"^%s*(.-)%s*$", "%1")) + end end pfUI.autoshift.lastError = "" + end + + hooksecurefunc("CastSpell", function(spellId, spellbookTabNum) + pfUI.autoshift:SwitchStance() end) hooksecurefunc("CastSpellByName", function(spellName, onSelf) - if pfUI.autoshift.lastError == L["stances"]['wantBattleStance'] then - pfUI.autoshift.CastSpellByName(L["stances"]['BattleStance']) - elseif pfUI.autoshift.lastError == L["stances"]['wantBattleDefStance'] then - pfUI.autoshift.CastSpellByName(L["stances"]['BattleStance']) - elseif pfUI.autoshift.lastError == L["stances"]['wantBattleBerserkStance'] then - pfUI.autoshift.CastSpellByName(L["stances"]['BerserkerStance']) - elseif pfUI.autoshift.lastError == L["stances"]['wantBerserkerStance'] then - pfUI.autoshift.CastSpellByName(L["stances"]['BerserkerStance']) - elseif pfUI.autoshift.lastError == L["stances"]['wantDefensiveStance'] then - pfUI.autoshift.CastSpellByName(L["stances"]['DefensiveStance']) - end - pfUI.autoshift.lastError = "" + pfUI.autoshift:SwitchStance() end) hooksecurefunc("UseAction", function(slot, checkCursor, onSelf) - if pfUI.autoshift.lastError == L["stances"]['wantBattleStance'] then - pfUI.autoshift.CastSpellByName(L["stances"]['BattleStance']) - elseif pfUI.autoshift.lastError == L["stances"]['wantBattleDefStance'] then - pfUI.autoshift.CastSpellByName(L["stances"]['BattleStance']) - elseif pfUI.autoshift.lastError == L["stances"]['wantBattleBerserkStance'] then - pfUI.autoshift.CastSpellByName(L["stances"]['BerserkerStance']) - elseif pfUI.autoshift.lastError == L["stances"]['wantBerserkerStance'] then - pfUI.autoshift.CastSpellByName(L["stances"]['BerserkerStance']) - elseif pfUI.autoshift.lastError == L["stances"]['wantDefensiveStance'] then - pfUI.autoshift.CastSpellByName(L["stances"]['DefensiveStance']) - end - pfUI.autoshift.lastError = "" + pfUI.autoshift:SwitchStance() end) pfUI.autoshift.buffs = { "spell_nature_swiftness", "_mount_", "_qirajicrystal_",