Jump to content

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;
        }
    }

 

Link to comment
https://wrobot.eu/forums/topic/12104-fight-class-spells-casting-in-wrong-order/
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();
    }
}

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...