Jump to content
This site uses cookies! Learn More

This site uses cookies!

By continuing to use this site, you agree to allow us to store cookies on your computer. :)

thebk150

Fight Class spells casting in wrong order

Recommended Posts

I've created a basic fight class in C# and I'm running into an issue where it casts spells in the wrong order.  Does anyone have any experience with this?  I had originally tried using frame lock and locking the frame before invoking CombatRotation() and then unlocking the frame as soon as it returned but that didn't fix the issue and caused other performance issues.

 

The issue appears to be the worst when multiple spells are off cooldown.  For example, when I first go into a fight with all of my burst spells, they are almost all invoked in the wrong order.

 

Here's the actual logic I'm using for CombatRotation() and how I'm casting spells.

    public void CombatRotation()
    {

        // Fire Elemental Totem
        if (burstMode && FireElementalTotem.IsSpellUsable)
        {
            SpellManager.CastSpellByNameLUA("Fire Elemental Totem");
            return;
        }

        // Elemental Mastery
        if (burstMode && ElementalMastery.IsSpellUsable)
        {
            SpellManager.CastSpellByNameLUA("Elemental Mastery");
            return;
        }

        // Feral Spirit
        if (burstMode && FeralSpirit.IsSpellUsable)
        {
            SpellManager.CastSpellByNameLUA("Feral Spirit");
            return;
        }

        // Ascendance
        if (burstMode && Ascendance.IsSpellUsable)
        {
            SpellManager.CastSpellByNameLUA("Ascendance");
            return;
        }

        // Stormlash Totem
        if (burstMode && StormlashTotem.IsSpellUsable)
        {
            SpellManager.CastSpellByNameLUA("Stormlash Totem");
            return;
        }

        // Flame Shock
        if (aoeMode && FlameShock.IsSpellUsable && FlameShock.IsDistanceGood && (ObjectManager.Target.BuffTimeLeft("Flame Shock") < 15000))
        {
            SpellManager.CastSpellByNameLUA("Flame Shock");
            return;
        }

        // Fire Nova
        if (aoeMode && FireNova.IsSpellUsable && (ObjectManager.Target.HaveBuff("Flame Shock")))
        {
            Lua.LuaDoString("CastSpellByName('Fire Nova')");
            return;
        }

        // Searing Totem
        if (SearingTotem.IsSpellUsable && !ObjectManager.Me.TotemExist(TotemType.Fire))
        {
            SpellManager.CastSpellByNameLUA("Searing Totem");
            return;
        }

        // Chain Lightning - MW5
        if (aoeMode && ChainLightning.IsSpellUsable && ChainLightning.IsDistanceGood && ObjectManager.Me.BuffStack("Maelstrom Weapon") == 5)
        {
            Lua.LuaDoString("CastSpellByName('Chain Lightning')");
            return;
        }

        // Lightning Bolt - MW5
        if (LightningBolt.IsSpellUsable && LightningBolt.IsDistanceGood && ObjectManager.Me.BuffStack("Maelstrom Weapon") == 5)
        {
            SpellManager.CastSpellByNameLUA("Lightning Bolt");
            return;
        }

        //Stormstrike
        if (Stormstrike.IsSpellUsable && Stormstrike.IsDistanceGood)
        {
            SpellManager.CastSpellByNameLUA("Stormstrike");
            return;
        }

        // Flame Shock
        if (FlameShock.IsSpellUsable && FlameShock.IsDistanceGood && (!ObjectManager.Target.HaveBuff("Flame Shock") || (ObjectManager.Target.BuffTimeLeft("Flame Shock") < 10000)))
        {
            SpellManager.CastSpellByNameLUA("Flame Shock");
            return;
        }

        // Lava Lash
        if (LavaLash.IsSpellUsable && LavaLash.IsDistanceGood)
        {
            SpellManager.CastSpellByNameLUA("Lava Lash");
            return;
        }

        // Unleash Elements
        if (UnleashElements.IsSpellUsable && UnleashElements.IsDistanceGood)
        {
            SpellManager.CastSpellByNameLUA("Unleash Elements");
            return;
        }

        // Earth Shock
        if (EarthShock.IsSpellUsable && EarthShock.IsDistanceGood && ((SpellManager.GetSpellCooldownTimeLeft("Stormstrike") > 1.5) || (SpellManager.GetSpellCooldownTimeLeft("Lava Lash") > 1.5)))
        {
            SpellManager.CastSpellByNameLUA("Earth Shock");
            return;
        }
    }

 

Share this post


Link to post
Share on other sites

Hello, try to lock wow frame (you can do it only because you don't sleep thread, you will get better reactivity)

public void CombatRotation()
{
    try
    {
        wManager.Wow.Memory.WowMemory.LockFrame();

        // Fire Elemental Totem
        if (burstMode && FireElementalTotem.IsSpellUsable)
        {
            SpellManager.CastSpellByNameLUA("Fire Elemental Totem");
            return;
        }

        // Elemental Mastery
        if (burstMode && ElementalMastery.IsSpellUsable)
        {
            SpellManager.CastSpellByNameLUA("Elemental Mastery");
            return;
        }

        // Feral Spirit
        if (burstMode && FeralSpirit.IsSpellUsable)
        {
            SpellManager.CastSpellByNameLUA("Feral Spirit");
            return;
        }

        // Ascendance
        if (burstMode && Ascendance.IsSpellUsable)
        {
            SpellManager.CastSpellByNameLUA("Ascendance");
            return;
        }

        // Stormlash Totem
        if (burstMode && StormlashTotem.IsSpellUsable)
        {
            SpellManager.CastSpellByNameLUA("Stormlash Totem");
            return;
        }

        // Flame Shock
        if (aoeMode && FlameShock.IsSpellUsable && FlameShock.IsDistanceGood && (ObjectManager.Target.BuffTimeLeft("Flame Shock") < 15000))
        {
            SpellManager.CastSpellByNameLUA("Flame Shock");
            return;
        }

        // Fire Nova
        if (aoeMode && FireNova.IsSpellUsable && (ObjectManager.Target.HaveBuff("Flame Shock")))
        {
            Lua.LuaDoString("CastSpellByName('Fire Nova')");
            return;
        }

        // Searing Totem
        if (SearingTotem.IsSpellUsable && !ObjectManager.Me.TotemExist(TotemType.Fire))
        {
            SpellManager.CastSpellByNameLUA("Searing Totem");
            return;
        }

        // Chain Lightning - MW5
        if (aoeMode && ChainLightning.IsSpellUsable && ChainLightning.IsDistanceGood && ObjectManager.Me.BuffStack("Maelstrom Weapon") == 5)
        {
            Lua.LuaDoString("CastSpellByName('Chain Lightning')");
            return;
        }

        // Lightning Bolt - MW5
        if (LightningBolt.IsSpellUsable && LightningBolt.IsDistanceGood && ObjectManager.Me.BuffStack("Maelstrom Weapon") == 5)
        {
            SpellManager.CastSpellByNameLUA("Lightning Bolt");
            return;
        }

        //Stormstrike
        if (Stormstrike.IsSpellUsable && Stormstrike.IsDistanceGood)
        {
            SpellManager.CastSpellByNameLUA("Stormstrike");
            return;
        }

        // Flame Shock
        if (FlameShock.IsSpellUsable && FlameShock.IsDistanceGood && (!ObjectManager.Target.HaveBuff("Flame Shock") || (ObjectManager.Target.BuffTimeLeft("Flame Shock") < 10000)))
        {
            SpellManager.CastSpellByNameLUA("Flame Shock");
            return;
        }

        // Lava Lash
        if (LavaLash.IsSpellUsable && LavaLash.IsDistanceGood)
        {
            SpellManager.CastSpellByNameLUA("Lava Lash");
            return;
        }

        // Unleash Elements
        if (UnleashElements.IsSpellUsable && UnleashElements.IsDistanceGood)
        {
            SpellManager.CastSpellByNameLUA("Unleash Elements");
            return;
        }

        // Earth Shock
        if (EarthShock.IsSpellUsable && EarthShock.IsDistanceGood && ((SpellManager.GetSpellCooldownTimeLeft("Stormstrike") > 1.5) || (SpellManager.GetSpellCooldownTimeLeft("Lava Lash") > 1.5)))
        {
            SpellManager.CastSpellByNameLUA("Earth Shock");
            return;
        }
    }
    catch (Exception e)
    {
        Logging.WriteError("Error: " + e);
    }
    finally
    {
        wManager.Wow.Memory.WowMemory.UnlockFrame();
    }
}

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...