ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   AddOn Search/Requests (https://www.esoui.com/forums/forumdisplay.php?f=165)
-   -   (Auto) switch off roll-by-double-tap when stealing? (https://www.esoui.com/forums/showthread.php?t=9918)

AlexFullmoon 09/17/21 04:36 AM

(Auto) switch off roll-by-double-tap when stealing?
 
It is probably the most often cause for failing stealth.

Preferable variants (though at this moment anything will do):
  • A button/shortcut to switch roll dodge, with reminder to activate it after entering combat
  • Automatic switch (if in stealth and not in combat)

Baertram 09/17/21 05:48 AM

I think this should be somehow possible by reading the current combat setting for dodge roll double tap and changing it.
You can try if the SetSetting lines work if you call them in chat via entring it into the chat editbox with starting /script and pressing return key

Code:

/script SetSetting(SETTING_TYPE_COMBAT, COMBAT_SETTING_ROLL_DODGE_DOUBLE_TAP, "false")
or "true" as last parameter if you want to enable it again


For addon devs who want to create such an addon:

Lua Code:
  1. --Upon start of sneak
  2. local function disableDoubleTap()
  3.     if not IsUnitInCombat("player") and GetSetting_Bool(SETTING_TYPE_COMBAT, COMBAT_SETTING_ROLL_DODGE_DOUBLE_TAP) then
  4.       --Disable double tap
  5.       SetSetting(SETTING_TYPE_COMBAT, COMBAT_SETTING_ROLL_DODGE_DOUBLE_TAP, "false")
  6.     end
  7. end
  8.  
  9. --Upon entering combat or stop of sneak
  10. local function enableDoubleTapAgain()
  11.    if not GetSetting_Bool(SETTING_TYPE_COMBAT, COMBAT_SETTING_ROLL_DODGE_DOUBLE_TAP)  then
  12.      --Enable double tap again
  13.      SetSetting(SETTING_TYPE_COMBAT, COMBAT_SETTING_ROLL_DODGE_DOUBLE_TAP, "true")
  14.    end
  15. end
  16.  
  17. local EM = EVENT_MANAGER
  18. --Event triggered if the player's combat state changes
  19. EM:RegisterForEvent(addonName .. "_PLAYER_COMBAT_STATE", EVENT_PLAYER_COMBAT_STATE, function(eventId, combatState)
  20.     if combatState == true then
  21.         enableDoubleTapAgain()
  22.     end
  23. end)
  24.  
  25. --Event triggered as the player's hidden state (sneak) changes
  26. EM:RegisterForEvent(addonName .. "_STEALTH_STATE_CHANGED", EVENT_STEALTH_STATE_CHANGED, function(eventId, stealthState)
  27.     local stealthStatesToDisableDoubleTap = {
  28.         --The stealth_states below are constants that can be set by the game upon getting into stealth, getting detected etc.
  29.         --Change the entries to true where the setting for double tap should be disabled as the stealth state changes.
  30.         --The enabling will be done via the "getting into combat" then (see above)
  31.         [STEALTH_STATE_NONE]                    = false,
  32.         [STEALTH_STATE_DETECTED]                = false,
  33.         [STEALTH_STATE_HIDING]                  = true,
  34.         [STEALTH_STATE_HIDDEN]                  = true,
  35.         [STEALTH_STATE_HIDDEN_ALMOST_DETECTED]  = true,
  36.         [STEALTH_STATE_STEALTH]                 = true,
  37.         [STEALTH_STATE_STEALTH_ALMOST_DETECTED] = true,
  38.     }
  39.     if stealthStatesToDisableDoubleTap[stealthState] then
  40.         disableDoubleTap()
  41.     end
  42. end)
  43. EM:AddFilterForEvent(addonName .. "_STEALTH_STATE_CHANGED", EVENT_STEALTH_STATE_CHANGED, REGISTER_FILTER_UNIT_TAG, "player")

You can try to add this to any of your addon's callback function to EVENT_ADD_ON_LOADED and see if it works that way, if noone will create a new addon for you.

Adding a keybind is a bit more to do. You need 1 XML file called bindings.xml and add it to the txt file of the addon (at the bottom, after the existing etries to .lua and .xml files) so it is loaded for the addon. And the content of the bindings.xml file needs to be this:
Code:

<Bindings>
    <Layer name="SI_KEYBINDINGS_CATEGORY_GENERAL">
        <Category name="My AddOn">
            <Action name="MYADDON_TOGGLE_DOUBLETAPDODGE">
                <Down>
                    MYADDON.ToggleDoubleTapDodge()
                </Down>
            </Action>
        </Category>
    </Layer>
</Bindings>

And lua code which can be added below the lines I had provided above:
Lua Code:
  1. --My addon's global table name, must be unique for ALL addons or you will overwrite other addons code!
  2. MYADDON = {}
  3. --Create the text for the keybinding
  4. ZO_CreateStringId("SI_BINDING_NAME_MYADDON_TOGGLE_DOUBLETAPDODGE", "Toggle double tap dodge")
  5. --The function called from the keybind
  6. function MYADDON.ToggleDoubleTapDodge()
  7.     local newValue = "false"
  8.     if not GetSetting_Bool(SETTING_TYPE_COMBAT, COMBAT_SETTING_ROLL_DODGE_DOUBLE_TAP) then
  9.         newValue = "true"
  10.     end
  11.     --Enable double tap again
  12.     SetSetting(SETTING_TYPE_COMBAT, COMBAT_SETTING_ROLL_DODGE_DOUBLE_TAP, newValue)
  13. end


All times are GMT -6. The time now is 07:10 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI