Guest User

blade of woe suppression lua snippet

a guest
Aug 23rd, 2017
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.96 KB | None | 0 0
  1. -------------------------------------------------------------------------------
  2. -- Vampire's Woe
  3. -------------------------------------------------------------------------------
  4. --[[
  5. -- Copyright (c) 2017 James A. Keene (Phinix) All rights reserved.
  6. --
  7. -- Permission is hereby granted, free of charge, to any person obtaining
  8. -- a copy of this software and associated documentation (the "Software"),
  9. -- to operate the Software for personal use only. Permission is NOT granted
  10. -- to modify, merge, publish, distribute, sublicense, re-upload, and/or sell
  11. -- copies of the Software. Additionally, licensed use of the Software
  12. -- will be subject to the following:
  13. --
  14. -- The above copyright notice and this permission notice shall be
  15. -- included in all copies or substantial portions of the Software.
  16. --
  17. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  18. -- EXPRESS OR IMPLIED. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  19. -- HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  20. -- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  21. -- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  22. -- OTHER DEALINGS IN THE SOFTWARE.
  23. --
  24. -------------------------------------------------------------------------------
  25. --
  26. -- DISCLAIMER:
  27. --
  28. -- This Add-on is not created by, affiliated with or sponsored by ZeniMax
  29. -- Media Inc. or its affiliates. The Elder Scrolls® and related logos are
  30. -- registered trademarks or trademarks of ZeniMax Media Inc. in the United
  31. -- States and/or other countries. All rights reserved.
  32. --
  33. -- You can read the full terms at:
  34. -- https://account.elderscrollsonline.com/add-on-terms
  35. --]]
  36.  
  37. local VWoe = _G['VWoeAddon']
  38. VWoe.Name = "VampireWoe"
  39. VWoe.Author = "Phinix"
  40. VWoe.Version = "1.04"
  41.  
  42. local AccountDefaults = { sSynergy = true,sSynergy2 = true, sBiteAlly = true, sDebug = true }
  43.  
  44. -------------------------------------------------------------------------------------------------------------------------------------------------------------------
  45. -- Synergy hook
  46. -------------------------------------------------------------------------------------------------------------------------------------------------------------------
  47. local function HookSynergy()
  48.     ZO_PreHook(SYNERGY, "OnSynergyAbilityChanged",
  49.     function(self)
  50.         local synergyName, iconFilename = GetSynergyInfo()
  51.         if (VWoe.ASV.sSynergy) then
  52.             if iconFilename and iconFilename:find("ability_vampire_002") then
  53.                 if (not IsUnitPlayer('reticleover')) or ((IsUnitPlayer('reticleover')) and (not VWoe.ASV.sBiteAlly)) then
  54.                     SHARED_INFORMATION_AREA:SetHidden(self, true)
  55.                     return true
  56.                 end
  57.             end
  58.         end
  59.         if (VWoe.ASV.sSynergy2) then
  60.             if iconFilename and iconFilename:find("darkbrotherhood_003") then
  61.                 SHARED_INFORMATION_AREA:SetHidden(self, true)
  62.                 return true
  63.             end
  64.         end
  65.         --[[
  66.         if synergyName and iconFilename then
  67.             d(synergyName.." "..iconFilename)
  68.         end
  69.         ]]
  70.     end)
  71. end
  72.  
  73. -------------------------------------------------------------------------------------------------------------------------------------------------------------------
  74. -- Keybind functions
  75. -------------------------------------------------------------------------------------------------------------------------------------------------------------------
  76. function VWoe.Swap()
  77.     if (VWoe.ASV.sSynergy) then
  78.         VWoe.ASV.sSynergy = false
  79.         if (VWoe.ASV.sDebug) then d("Vampire feeding synergy is no longer supressed.") end
  80.     elseif (not VWoe.ASV.sSynergy) then
  81.         VWoe.ASV.sSynergy = true
  82.         if (VWoe.ASV.sDebug) then d("Vampire feeding synergy is being supressed.") end
  83.     end
  84. end
  85.  
  86. function VWoe.Swap2()
  87.     if (VWoe.ASV.sSynergy2) then
  88.         VWoe.ASV.sSynergy2 = false
  89.         if (VWoe.ASV.sDebug) then d("Blade of Woe synergy is no longer supressed.") end
  90.     elseif (not VWoe.ASV.sSynergy2) then
  91.         VWoe.ASV.sSynergy2 = true
  92.         if (VWoe.ASV.sDebug) then d("Blade of Woe synergy is being supressed.") end
  93.     end
  94. end
  95.  
  96. -------------------------------------------------------------------------------------------------------------------------------------------------------------------
  97. -- Set up the Addon Settings options panel
  98. -------------------------------------------------------------------------------------------------------------------------------------------------------------------
  99. local function CreateSettingsWindow(addonName)
  100.     local panelData = {
  101.         type                    = "panel",
  102.         name                    = "Vampire's Woe",
  103.         displayName             = "Vampire's Woe",
  104.         author                  = VWoe.Author,
  105.         version                 = VWoe.Version,
  106.         registerForRefresh      = true,
  107.         registerForDefaults     = true
  108.     }
  109.  
  110.     local optionsData = {
  111.     {
  112.         type            = "description",
  113.         text            = "Block the Vampire Feeding synergy from triggering."
  114.     },
  115.     {
  116.         type            = "checkbox",
  117.         name            = "Suppress Vampire Feeding Synergy",
  118.         tooltip         = "Block the Vampire Feeding synergy from triggering.",
  119.         getFunc         = function() return VWoe.ASV.sSynergy end,
  120.         setFunc         = function(value) VWoe.ASV.sSynergy = value end,
  121.         default         = AccountDefaults.sSynergy
  122.     },
  123.     {
  124.         type            = "checkbox",
  125.         name            = "Suppress Blade of Woe Synergy",
  126.         tooltip         = "Block the Blade of Woe synergy from triggering.",
  127.         getFunc         = function() return VWoe.ASV.sSynergy2 end,
  128.         setFunc         = function(value) VWoe.ASV.sSynergy2 = value end,
  129.         default         = AccountDefaults.sSynergy2
  130.     },
  131.     {
  132.         type            = "checkbox",
  133.         name            = "Bite Ally When Suppressed",
  134.         tooltip         = "Allows you to bite and pass vampirism to an ally even when the feeding synergy is suppressed.",
  135.         getFunc         = function() return VWoe.ASV.sBiteAlly end,
  136.         setFunc         = function(value) VWoe.ASV.sBiteAlly = value end,
  137.         default         = AccountDefaults.sBiteAlly
  138.     },
  139.     {
  140.         type            = "checkbox",
  141.         name            = "Display Toggle Message",
  142.         tooltip         = "Show a chat notice when vampire feeding is toggled on or off using the keybind.",
  143.         getFunc         = function() return VWoe.ASV.sDebug end,
  144.         setFunc         = function(value) VWoe.ASV.sDebug = value end,
  145.         default         = AccountDefaults.sDebug
  146.     }
  147.     }
  148.  
  149.     local LAM = LibStub("LibAddonMenu-2.0")
  150.     LAM:RegisterAddonPanel("VWoe_Panel", panelData)
  151.     LAM:RegisterOptionControls("VWoe_Panel", optionsData)
  152. end
  153.  
  154. -------------------------------------------------------------------------------------------------------------------------------------------------------------------
  155. -- Init
  156. -------------------------------------------------------------------------------------------------------------------------------------------------------------------
  157.  
  158. local function OnAddonLoaded(event, addonName)
  159.     if addonName ~= VWoe.Name then return end
  160.     EVENT_MANAGER:UnregisterForEvent(VWoe.Name, EVENT_ADD_ON_LOADED)
  161.     ZO_CreateStringId("SI_BINDING_NAME_TOGGLE_SUPPRESSION", "Toggle Feeding Suppression")
  162.     ZO_CreateStringId("SI_BINDING_NAME_TOGGLE_SUPPRESSION2", "Toggle Blade of Woe Suppression")
  163.     VWoe.ASV = ZO_SavedVars:NewAccountWide(VWoe.Name, 1.0, 'AccountSettings', AccountDefaults)
  164.     CreateSettingsWindow(addonName)
  165.     HookSynergy()
  166. end
  167.  
  168. EVENT_MANAGER:RegisterForEvent(VWoe.Name, EVENT_ADD_ON_LOADED, OnAddonLoaded)
Add Comment
Please, Sign In to add comment