Jump to content

Interrupts


Pasterke

Recommended Posts

Any way to interrupt spells ?

 

something like :

if (SpellManager.KnownSpell(MightyBash)
      && (Me.CurrentTarget.IsCasting
      && Me.CanInterruptCurrentSpellCast)) 
{ 
    do something; 
}

Link to comment
Share on other sites

Hello,

 

sample code (fightclass in c#, save this file in *.cs):

using System;
using System.Threading;
using System.Windows.Forms;
using robotManager.Helpful;
using wManager.Wow.Class;
using wManager.Wow.Helpers;
using wManager.Wow.ObjectManager;

public class Main : ICustomClass
{
    public float Range { get { return 4.5f; } } // Fight Range

    private bool _isLaunched;
    private const string FightClassName = "Interrupts";

    #region ListSpells

    private Spell _mightyBash;

    #endregion ListSpells

    public void Initialize()
    {
        Logging.Write("Loading FightClass: " + FightClassName);

        // Init spells:
        _mightyBash = new Spell("Mighty Bash");

        Logging.Write("FightClass Loaded: " + FightClassName);

        // Launch loop in new thread:
        _isLaunched = true;
        var threadLoop = new Thread(Loop);
        threadLoop.Start();
        Logging.Write("FightClass Launched: " + FightClassName);
       
    }

    private void Loop()
    {
        while (_isLaunched)
        {
            try
            {
                if (Fight.InFight && ObjectManager.Target.IsValid)
                {
                    // Spell Mighty Bash:
                    if (ObjectManager.Target.IsCast && _mightyBash.IsSpellUsable && _mightyBash.IsDistanceGood)
                    {
                        var resultLua =
                            Lua.LuaDoString(
                                "ret = \"false\"; spell, rank, displayName, icon, startTime, endTime, isTradeSkill, castID, interrupt = UnitCastingInfo(\"target\"); if interrupt then ret = \"true\" end",
                                "ret");
                        if (resultLua == "true")
                        {
                            _mightyBash.Launch();
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Logging.Write("Error in FightClass " + FightClassName + ": " + e);
            }
            Thread.Sleep(35); // Wait for UC usage
        }
    }

    public void Dispose()
    {
        _isLaunched = false;
        Logging.Write("FightClass Disposed: " + FightClassName);
    }

    public void ShowConfiguration()
    {
        MessageBox.Show("No setting for this Fight Class: " + FightClassName);
    }
}
Link to comment
Share on other sites

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...