diff --git a/Elementarist.lua b/Elementarist.lua
index 6e60b16..8451c2d 100755
--- a/Elementarist.lua
+++ b/Elementarist.lua
@@ -51,11 +51,12 @@ Elementarist.tier6Talent = nil
Elementarist.tier7Talent = nil
Elementarist.hasT17_4pcs = false
Elementarist.lastSpell = nil
+Elementarist.lastCastTime = nil
Elementarist.CustomIDs = {
["Alchemist's Flask Item"] = 75525,
["Alchemist's Flask Spell"] = 79640,
["Crystal of Insanity Item"] = 86569,
- ["Crystal of Insanity Spell"] = 127230
+ ["Crystal of Insanity Spell"] = 127230,
["Whispers of Insanity Item"] = 118922,
["Whispers of Insanity Spell"] = 176151
}
@@ -764,6 +765,18 @@ function Elementarist:GetSpellCooldownRemaining(spell)
return d
end
+function Elementarist:Count(needle,...)
+ local c = 0;
+
+ for i = 1, select("#", ...) do
+ if (select(i, ...) == needle) then
+ c = c + 1;
+ end
+ end
+
+ return c;
+end
+
function Elementarist:hasGlyph(glyph)
local i, _, enabled, glyphSpellID;
diff --git a/modules/elemental.lua b/modules/elemental.lua
index d69942d..8a80878 100755
--- a/modules/elemental.lua
+++ b/modules/elemental.lua
@@ -78,12 +78,18 @@ Elementarist.elemental = {
-- check current spell
local spellInCast, _, _, _, sICstartTime, sICendTime = UnitCastingInfo("player")
+
if (spellInCast) then
if ( (sICendTime - sICstartTime) / 1000 ) < Elementarist.lastBaseGCD then
sICendTime = sICstartTime + (Elementarist.lastBaseGCD * 1000)
end
+ Elementarist.lastCastTime = sICendTime;
timeshift = timeshift + (sICendTime / 1000) - GetTime()
else
+ -- to prevent tick in current spell, check if last one finished in short time
+ if (Elementarist.lastCastTime) and ((Elementarist.lastCastTime / 1000) + Elementarist.lastBaseGCD >= GetTime() ) then
+ spellInCast = Elementarist.lastSpell;
+ end
-- no spell in cast, check global cd via Ghost Wolf
if (Elementarist.SpellList["Ghost Wolf"]) then
local ftcd = Elementarist:GetSpellCooldownRemaining(Elementarist.SpellList["Ghost Wolf"])
@@ -100,7 +106,12 @@ Elementarist.elemental = {
-- if item level >575 and Earthquake is enabled
if (ElementaristDB.EnableEQ) then
if (Elementarist.iLvl>=575) or (Elementarist.person["foeCount"]>1) then
- if (exspell1 ~= Elementarist.SpellList["Earthquake"]) and (exspell2 ~= Elementarist.SpellList["Earthquake"]) and ((Elementarist.SpellList["Earthquake"]) ~= spellInCast) then
+ local eqCharges, maxEqCharges, cdStart, cdLength = GetSpellCharges(Elementarist.SpellList["Earthquake"]);
+ if (eqCharges<maxEqCharges) and (((cdStart + cdLength)- GetTime()) - timeshift <= 0) then
+ eqCharges = eqCharges + 1;
+ end
+ eqCharges = eqCharges - Elementarist:Count(Elementarist.SpellList["Earthquake"],spellInCast,exspell1,exspell2);
+ if (eqCharges > 0) then
d = Elementarist:GetSpellCooldownRemaining(Elementarist.SpellList["Earthquake"])
if (d) and (d<0.5) then
return Elementarist.SpellList["Earthquake"]
@@ -111,7 +122,7 @@ Elementarist.elemental = {
-- if Tier7 talent is Liquid Magma and fire totem has 10 sec or more, use it
if (Elementarist.tier7Talent == 21200) then
- if (exspell1 ~= Elementarist.SpellList["Liquid Magma"]) and (exspell2 ~= Elementarist.SpellList["Liquid Magma"]) and ((Elementarist.SpellList["Liquid Magma"]) ~= spellInCast) then
+ if (Elementarist:Count(Elementarist.SpellList["Liquid Magma"],spellInCast,exspell1,exspell2) == 0) then
local haveFireTotem,fireTotemName,d,_ = GetTotemInfo(1);
if (fireTotemName ~= "") and (d-timeshift > 10) then
d = Elementarist:GetSpellCooldownRemaining(Elementarist.SpellList["Liquid Magma"])
@@ -124,7 +135,7 @@ Elementarist.elemental = {
-- if Tier6 talent is Unleashed Fury Unleash Flame
if (Elementarist.tier6Talent == 21773) then
- if (exspell1 ~= Elementarist.SpellList["Unleash Flame"]) and (exspell2 ~= Elementarist.SpellList["Unleash Flame"]) then
+ if (Elementarist:Count(Elementarist.SpellList["Unleash Flame"],spellInCast,exspell1,exspell2) == 0) then
e = Elementarist:GetSpellCooldownRemaining(Elementarist.SpellList["Unleash Flame"])
if (e-timeshift <= 0) then
return Elementarist.SpellList["Unleash Flame"];
@@ -137,7 +148,7 @@ Elementarist.elemental = {
if (not fsExpiration) then
fsExpiration = 0
end
- if (exspell1 ~= Elementarist.SpellList["Flame Shock"]) and (exspell2 ~= Elementarist.SpellList["Flame Shock"]) and (exspell1 ~= Elementarist.SpellList["Earth Shock"]) and (exspell2 ~= Elementarist.SpellList["Earth Shock"]) then
+ if (Elementarist:Count(Elementarist.SpellList["Flame Shock"],spellInCast,exspell1,exspell2) == 0 and Elementarist:Count(Elementarist.SpellList["Earth Shock"],spellInCast,exspell1,exspell2) == 0) then
if IsSpellInRange(Elementarist.SpellList["Flame Shock"], "target") == 1 then
d = Elementarist:GetSpellCooldownRemaining(Elementarist.SpellList["Flame Shock"])
if ((d - timeshift) <= 0) then
@@ -174,12 +185,8 @@ Elementarist.elemental = {
if (lvbCharges<maxLvbCharges) and (((cdStart + cdLength)- GetTime()) - timeshift <= 0) then
lvbCharges = lvbCharges + 1;
end
- if (exspell1 == Elementarist.SpellList["Lava Burst"]) then
- lvbCharges = lvbCharges - 1;
- end
- if (exspell2 == Elementarist.SpellList["Lava Burst"]) then
- lvbCharges = lvbCharges - 1;
- end
+ lvbCharges = lvbCharges - Elementarist:Count(Elementarist.SpellList["Lava Burst"],spellInCast,exspell1,exspell2);
+
if (
(lvbCharges > 0)
or
@@ -188,8 +195,7 @@ Elementarist.elemental = {
if (IsSpellInRange(Elementarist.SpellList["Flame Shock"], "target") == 1) and
(
((fsExpiration~=0) and ((fsExpiration-GetTime()-timeshift) > LvBct)) or
- (exspell1 == Elementarist.SpellList["Flame Shock"]) or
- (exspell2 == Elementarist.SpellList["Flame Shock"])
+ (Elementarist:Count(Elementarist.SpellList["Flame Shock"],spellInCast,exspell1,exspell2) > 0)
) then
d = Elementarist:GetSpellCooldownRemaining(Elementarist.SpellList["Lava Burst"])
if ((d-timeshift) <= 0) or ((ascendanceExp-GetTime()-timeshift) > 0) then
@@ -201,10 +207,8 @@ Elementarist.elemental = {
-- if Tier6 talent is Elemental Blast use it
if (Elementarist.tier6Talent == 19267) then
if (
- (exspell1 ~= Elementarist.SpellList["Elemental Blast"]) and
- (exspell2 ~= Elementarist.SpellList["Elemental Blast"]) and
- (IsSpellInRange(Elementarist.SpellList["Elemental Blast"], "target") == 1) and
- (Elementarist.SpellList["Elemental Blast"] ~= spellInCast)
+ (Elementarist:Count(Elementarist.SpellList["Elemental Blast"],spellInCast,exspell1,exspell2) == 0) and
+ (IsSpellInRange(Elementarist.SpellList["Elemental Blast"], "target") == 1)
) then
d = Elementarist:GetSpellCooldownRemaining(Elementarist.SpellList["Elemental Blast"])
if ((d - timeshift) <= 0) then
@@ -214,7 +218,7 @@ Elementarist.elemental = {
end
-- Earth shock if Lightning Shield count >=17 and not on cd, and FS debuff remaining > FS cooldown, or FS debuff remaining between FS and FS cd + 2sec and LS count>=13, or has T17 4pcs and LS Count >= 12
- if ( (exspell1 ~= Elementarist.SpellList["Earth Shock"]) and (exspell2 ~= Elementarist.SpellList["Earth Shock"]) and (exspell1 ~= Elementarist.SpellList["Flame Shock"]) and (exspell2 ~= Elementarist.SpellList["Flame Shock"]) ) then
+ if (Elementarist:Count(Elementarist.SpellList["Flame Shock"],spellInCast,exspell1,exspell2) == 0 and Elementarist:Count(Elementarist.SpellList["Earth Shock"],spellInCast,exspell1,exspell2) == 0) then
if ( (fsExpiration - GetTime() - timeshift) > Elementarist.lastShockCD ) then
d = Elementarist:GetSpellCooldownRemaining(Elementarist.SpellList["Earth Shock"])
local _, _, _, lscount = Elementarist:hasBuff("player",Elementarist.SpellList["Lightning Shield"])
@@ -231,11 +235,7 @@ Elementarist.elemental = {
end
-- Searing Totem
- if (
- (exspell1 ~= Elementarist.SpellList["Searing Totem"]) and
- (exspell2 ~= Elementarist.SpellList["Searing Totem"]) and
- (Elementarist.SpellList["Searing Totem"] ~= spellInCast)
- ) then
+ if (Elementarist:Count(Elementarist.SpellList["Searing Totem"],spellInCast,exspell1,exspell2) == 0) then
local haveFireTotem,fireTotemName,fireTotemStart,fireTotemDuration = GetTotemInfo(1);
if (fireTotemName == "") or (fireTotemDuration and (fireTotemStart + fireTotemDuration - GetTime() ) <= timeshift) then
return Elementarist.SpellList["Searing Totem"];
@@ -243,7 +243,7 @@ Elementarist.elemental = {
end
-- refresh FS
- if (exspell1 ~= Elementarist.SpellList["Flame Shock"]) and (exspell2 ~= Elementarist.SpellList["Flame Shock"]) then
+ if (Elementarist:Count(Elementarist.SpellList["Flame Shock"],spellInCast,exspell1,exspell2) == 0) then
if (doFS) and ((fsExpiration - GetTime() - timeshift) < 9) then
return Elementarist.SpellList["Flame Shock"]
end