Skip to content

Commit

Permalink
change tied global cooldown spells to use gemcooldown + spell ready t…
Browse files Browse the repository at this point in the history
…o work around MQ bug with shared cooldown spells not working correct.y
  • Loading branch information
RekkasGit committed Mar 17, 2023
1 parent 1def53a commit 2131f06
Showing 1 changed file with 61 additions and 44 deletions.
105 changes: 61 additions & 44 deletions E3Next/Processors/Casting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public static CastReturn Cast(int targetID, Data.Spell spell, Func<Int32, Int32,


CastReturn returnValue = CastReturn.CAST_RESIST;
//TODO: Add bard logic back in

//using (_log.Trace())
{

Expand Down Expand Up @@ -862,7 +862,6 @@ public static bool MemorizeSpell(Data.Spell spell)

public static Boolean CheckMana(Data.Spell spell)
{

Int32 currentMana = MQ.Query<Int32>("${Me.CurrentMana}");
Int32 pctMana = MQ.Query<Int32>("${Me.PctMana}");
if (currentMana >= spell.Mana)
Expand Down Expand Up @@ -1019,6 +1018,64 @@ public static bool ItemInCooldown(Data.Spell spell)
}
return true;
}


public static bool SpellInCooldown(Data.Spell spell)
{

recheckCooldown:
bool returnValue = false;

//if (SpellInSharedCooldown(spell)) return true;

_log.Write($"Checking if spell is ready on {spell.CastName}");

if (MQ.Query<bool>($"${{Me.SpellReady[{spell.CastName}]}}") && MQ.Query<Int32>($"${{Me.GemTimer[{spell.CastName}]}}")<1)
{
_log.Write($"CheckReady Success! on {spell.CastName}");

returnValue = false;
return returnValue;
}
_log.Write($"Checking if spell are on cooldown for {spell.CastName}");

//if (MQ.Query<bool>("${Me.SpellInCooldown}") && MQ.Query<bool>($"${{Bool[${{Me.Gem[{spell.CastName}]}}]}}"))
if (InGlobalCooldown())
{
_log.Write("Spells in cooldown, redoing check.");
MQ.Delay(20);
goto recheckCooldown;
}

return true;
}
private static Dictionary<string, List<string>> _sharedCooldownLookup = new Dictionary<string, List<string>>() {
{ "Miasmic Spear", new List<string>() { "Spear of Muram" } },
{ "Spear of Muram", new List<string>() { "Miasmic Spear" } },
{ "Focused Hail of Arrows", new List<string>() { "Hail of Arrows" } },
{ "Hail of Arrows", new List<string>() { "Focused Hail of Arrows" } },
{ "Mana Flare", new List<string>() { "Mana Recursion" } },
{ "Mana Recursion", new List<string>() { "Mana Flare" } }
};
private static bool SpellInSharedCooldown(Spell spell)
{
if (!_sharedCooldownLookup.ContainsKey(spell.CastName)) return false;

if (MQ.Query<bool>($"${{Bool[${{Me.Gem[{spell.CastName}]}}]}}"))
{
if (!MQ.Query<bool>($"${{Me.SpellReady[{spell.CastName}]}}")) { return true; }
foreach (string spellName in _sharedCooldownLookup[spell.CastName])
{
if(MQ.Query<bool>($"${{Bool[${{Me.Gem[{spellName}]}}]}}"))
{
if (!MQ.Query<bool>($"${{Me.SpellReady[{spellName}]}}")) { return true; }
}
}
}
return false;
}


public static Boolean CheckReady(Data.Spell spell)
{
if (spell.CastType == CastType.None) return false;
Expand All @@ -1043,52 +1100,12 @@ public static Boolean CheckReady(Data.Spell spell)
bool returnValue = false;
if (spell.CastType == Data.CastType.Spell && spell.SpellInBook)
{
recheckCooldown:

//deal with grouped spells should put in a method if it gets bigger than these two
if (spell.CastName == "Focused Hail of Arrows" || spell.CastName == "Hail of Arrows")
{
if (MQ.Query<bool>("${Bool[${Me.Gem[Focused Hail of Arrows]}]}") && MQ.Query<bool>("${Bool[${Me.Gem[Hail of Arrows]}]}"))
{
returnValue = true;
if (!MQ.Query<bool>("${Me.SpellReady[Focused Hail of Arrows]}")) { returnValue = false; }
if (!MQ.Query<bool>("${Me.SpellReady[Hail of Arrows]}")) { returnValue = false; }

return returnValue;
}
}
if (spell.CastName == "Mana Flare" || spell.CastName == "Mana Recursion")
{
if (MQ.Query<bool>("${Bool[${Me.Gem[Mana Flare]}]}") && MQ.Query<bool>("${Bool[${Me.Gem[Mana Recursion]}]}"))
{
returnValue = true;
if (!MQ.Query<bool>("${Me.SpellReady[Mana Flare]}")) { returnValue = false; }
if (!MQ.Query<bool>("${Me.SpellReady[Mana Recursion]}")) { returnValue = false; }

return returnValue;
}
}

_log.Write($"Checking if spell is ready on {spell.CastName}");

if (MQ.Query<bool>($"${{Me.SpellReady[{spell.CastName}]}}"))
if (!SpellInCooldown(spell))
{
_log.Write($"CheckReady Success! on {spell.CastName}");

returnValue = true;
return returnValue;
}
_log.Write($"Checking if spell are on cooldown for {spell.CastName}");

//if (MQ.Query<bool>("${Me.SpellInCooldown}") && MQ.Query<bool>($"${{Bool[${{Me.Gem[{spell.CastName}]}}]}}"))
if (InGlobalCooldown())
{
_log.Write("Spells in cooldown, redoing check.");
MQ.Delay(20);
goto recheckCooldown;
return true;
}


}
else if (spell.CastType == Data.CastType.Item)
{
Expand Down

0 comments on commit 2131f06

Please sign in to comment.