only display magicka deto when the current magicka percentage is over 15 %

René Welbers [01-18-16 - 13:45]
only display magicka deto when the current magicka percentage is over 15 %
Filename
RaidNotifier.lua
diff --git a/RaidNotifier.lua b/RaidNotifier.lua
index f2326b2..d7f2642 100644
--- a/RaidNotifier.lua
+++ b/RaidNotifier.lua
@@ -13,7 +13,12 @@ RaidNotifier.savedVarsName  = 'RNVars'
 RaidNotifier.variables = {
     sanctum_magicka_deto = true,
     sanctum_poison       = true,
-    last_notify          = 0,
+}
+RaidNotifier.tempVars = {
+    last_notify = {
+        so_magicka_deto = 0,
+        so_poison       = 0
+    },
 }

 local function CreateSettingsMenu()
@@ -104,6 +109,9 @@ function RaidNotifier.sanctumDebuffs(_, change, buff, name, unit, start, finish,

     local self = RaidNotifier

+    local currentTime = GetTimeStamp()
+    local lastNotify  = self.tempVars.last_notify
+
     -- only notice on effect added
     if (change == EFFECT_RESULT_GAINED) then
         if self.savedVariables.sanctum_poison then
@@ -137,31 +145,27 @@ function RaidNotifier.sanctumDebuffs(_, change, buff, name, unit, start, finish,
             poison[65780] = true
             poison[65781] = true

-            if (poison[abilityId]) then
---                d('abilityId', abilityId)
---                d('abilityName', name)
---                d('abilityType', abilityType)
---                d('buff', buff)
---                d('effectType', effectType)
---                d('start', start)
---                d('finish', finish)
+            -- only notify when the last one is at least 15 seconds ago and it is poison
+            local timeDiff = GetDiffBetweenTimeStamps(currentTime, lastNotify.so_poison)
+            if (poison[abilityId]) and timeDiff > 15 then
+                self.tempVars.last_notify.so_poison = currentTime
                 CENTER_SCREEN_ANNOUNCE:AddMessage(2, CSA_EVENT_COMBINED_TEXT, SOUNDS.CHAMPION_POINTS_COMMITTED, GetString(RAIDNOTIFIER_SANCTUM_POISON_ALERT), nil, nil, nil, nil, nil, 2000)
             end
         end

         if self.savedVariables.sanctum_magicka_deto then
-            if (abilityId == 59036) then
---                d('abilityId', abilityId)
---                d('abilityName', name)
---                d('abilityType', abilityType)
---                d('buff', buff)
---                d('effectType', effectType)
---                d('start', start)
---                d('finish', finish)
+            -- only notify when the last one is at least 10 seconds ago and it is poison
+            -- debug abilityId: 30255 / Boundless Storm
+            -- Real abilityId: 59036 / "Serp Target"
+            local timeDiff = GetDiffBetweenTimeStamps(currentTime, lastNotify.so_magicka_deto)
+            if (abilityId == 30255) and timeDiff > 10 then
+                self.tempVars.last_notify.so_magicka_deto = currentTime
+
                 -- get current magicka percentage
                 local current, maximum, _ = GetUnitPower("player", POWERTYPE_MAGICKA)
-                local magickaPercentage   = zo_roundToNearest(current/maximum,0.01)
+                local magickaPercentage   = zo_roundToNearest(current/maximum,0.01) * 100

+                -- only notify if the current magicka is over 15%
                 if magickaPercentage > 15 then
                     CENTER_SCREEN_ANNOUNCE:AddMessage(1, CSA_EVENT_COMBINED_TEXT, SOUNDS.CHAMPION_POINTS_COMMITTED, GetString(RAIDNOTIFIER_SANCTUM_MAGICKA_DETONATION_ALERT), nil, nil, nil, nil, nil, 5000)
                 end