Exemplo n.º 1
0
 public frmSpell(Color color, POINT point, CombatRoutine combatRoutine)
 {
     this.color         = color;
     this.point         = point;
     this.combatRoutine = combatRoutine;
     InitializeComponent();
 }
Exemplo n.º 2
0
 public WantMovementCr(CombatRoutine undecoratedCr, CapabilityFlags supportedCapabilities)
 {
     if (undecoratedCr == null) return;
     Log.Info("Storing Combat Routine");
     _undecoratedCr = undecoratedCr;
     SupportedCapabilities = supportedCapabilities;
 }
Exemplo n.º 3
0
 public WantMovementCr(CombatRoutine undecoratedCr, CapabilityFlags supportedCapabilities)
 {
     if (undecoratedCr == null)
     {
         return;
     }
     Log.Info("Storing Combat Routine");
     _undecoratedCr        = undecoratedCr;
     SupportedCapabilities = supportedCapabilities;
 }
Exemplo n.º 4
0
        /// <summary>
        /// Selects the Trinity routine in the RoutineManager
        /// </summary>
        private static void SelectTrinityRoutine()
        {
            if (!IsLatestRoutineInstalled)
            {
                return;
            }

            Application.Current.Dispatcher.BeginInvoke((Action)(() =>
            {
                Logger.LogNormal("Stopping bot to select latest routine");
                BotMain.Stop();

                CombatRoutine trinityRoutine = (CombatRoutine)RoutineManager.Routines.FirstOrDefault(r => r.Name == "Trinity");
                RoutineManager.Current = trinityRoutine;

                Logger.LogNormal("Routine selected, starting bot");
                BotMain.Start();
            }));
        }
Exemplo n.º 5
0
        public Player(UInt32 objBase, bool ManualControl)
            : base(objBase)
        {
            // Find the current player object
            if (objBase == 0)
            {
                this.getObjects();
            }

            // TODO: get correct lStrat at runtime
            this.lStrat = new GeneralWaypointStrategy();

            // TODO: get correct cRoutine at runtime
            this.cRoutine = new RogueRoutine();

            // Units
            units = new List <Unit>();

            // Thread to run user logic
            if (!ManualControl)
            {
                Pulse = new Thread(new ThreadStart(doPulse));
            }
        }
Exemplo n.º 6
0
        private bool LoadProfile(string fileName, bool reloadUI = true)
        {
            using (var sr = new StreamReader(fileName))
            {
                var code = sr.ReadToEnd();

                Log.Write($"Loading file [{fileName}]...", Color.Black);

                //if (fileName.EndsWith(".enc"))
                //{
                //    Log.Write("Decrypting profile...", Color.Black);

                //    try
                //    {
                //        code = Encryption.Decrypt(code);

                //        Log.Write("Profile has been decrypted successfully", Color.Green);
                //    }
                //    catch (Exception ex)
                //    {
                //        Log.Write(ex.Message, Color.Red);
                //    }
                //}

                if (code.Trim() == "")
                {
                    MessageBox.Show("Please select a non blank file", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }

                if (code.ToLower().Contains("class detectkeypress"))
                {
                    MessageBox.Show("DetectKeyPress is already built into CloudMagic, please dont re-create the wheel.", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }

                if (code.ToLower().Contains("wow.speak("))
                {
                    MessageBox.Show("WoW.Speak() is no longer allowed in custom rotations.", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }

                //if (code.Contains("System.IO"))
                //{
                //    MessageBox.Show("using System.IO; is no longer allowed in custom rotations, no IO is needed other than Config Saving which you can already do.", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //    return false;
                //}

                Log.Write($"Compiling file [{fileName}]...", Color.Black);

                var provider   = new CSharpCodeProvider();
                var parameters = new CompilerParameters();

                parameters.ReferencedAssemblies.Add("System.Windows.Forms.dll");
                parameters.ReferencedAssemblies.Add("System.Drawing.dll");
                parameters.ReferencedAssemblies.Add("System.Data.dll");
                parameters.ReferencedAssemblies.Add("System.Xml.dll");
                parameters.ReferencedAssemblies.Add("System.Linq.dll");
                parameters.ReferencedAssemblies.Add("System.dll");
                parameters.ReferencedAssemblies.Add("System.IO.dll");
                parameters.ReferencedAssemblies.Add("System.Core.dll");
                parameters.ReferencedAssemblies.Add("System.Threading.dll");
                parameters.ReferencedAssemblies.Add(Application.ExecutablePath);
                parameters.GenerateInMemory   = true;
                parameters.GenerateExecutable = false;

                var results = provider.CompileAssemblyFromSource(parameters, code);

                if (results.Errors.HasErrors)
                {
                    foreach (CompilerError error in results.Errors)
                    {
                        Log.Write($"Error on line [{error.Line}] - ({error.ErrorNumber}): {error.ErrorText}", Color.Red);
                    }

                    return(false);
                }

                var assembly = results.CompiledAssembly;

                foreach (var t in assembly.GetTypes())
                {
                    if (t.IsClass)
                    {
                        var obj = Activator.CreateInstance(t);
                        combatRoutine = (CombatRoutine)obj;

                        combatRoutine.Load(this);
                        combatRoutine.FileName = fileName;

                        Log.Write("Successfully loaded combat routine: " + combatRoutine.Name, Color.Green);

                        if (SpellBook.Initialize(fileName, reloadUI))
                        {
                            spellbookToolStripMenuItem.Enabled = true;

                            cmdStartBot.Enabled            = true;
                            cmdStartBot.BackColor          = Color.LightGreen;
                            cmdRotationSettings.Enabled    = true;
                            cmdReloadRotation.Enabled      = true;
                            cmdReloadRotationAndUI.Enabled = true;

                            return(true);
                        }

                        spellbookToolStripMenuItem.Enabled = false;

                        cmdStartBot.Enabled   = false;
                        cmdStartBot.BackColor = Color.WhiteSmoke;
                        return(false);
                    }
                }

                return(false);
            }
        }
Exemplo n.º 7
0
        public override void Pulse()
        {
            if (Me.IsDead || Me.IsFlying || Me.IsGhost)
            {
                return;
            }

            if (Settings.EnableAutoDismount && BotManager.Current.Name != "Questing")
            {
                if (Me.Mounted &&
                    ((BotPoi.Current.Type == PoiType.Kill && BotPoi.Current.AsObject.Distance < 30) ||
                     (Me.GotTarget && Me.CurrentTarget.Distance < 30 && !Me.CurrentTarget.IsFriendly)))
                {
                    Lua.DoString("Dismount()");
                }
                else
                {
                    if (Me.Mounted && Me.Combat && !Me.IsMoving && Me.GotTarget && Me.CurrentTarget.Distance < 30 &&
                        !Me.CurrentTarget.IsFriendly)
                    {
                        Lua.DoString("Dismount()");
                    }
                }
            }

            if (Me.IsOnTransport || Me.Mounted)
            {
                return;
            }

            if ((RoutineManager.Current != null) && (RoutineManager.Current != _decoratedCombatRoutine))
            {
                Log.Info("Installing Combat Routine Hook...");
                _undecoratedCombatRoutine = RoutineManager.Current;
                _decoratedCombatRoutine = new WantMovementCr(RoutineManager.Current, CapabilityFlags.All);
                RoutineManager.Current = _decoratedCombatRoutine;
                Log.Info("Combat Routine Hook Installed!");
            }

            if ((_thisTargetMethod != Targeting.Instance) && Settings.EnableTargeting && !Me.HasAura("Food") &&
                !Me.HasAura("Drink"))
            {
                Log.Warning(
                    "Taking control of targeting. If this message is being spammed, something else is trying to take control.");
                Targeting.Instance = _thisTargetMethod;
            }

            if (Targeting.Instance == _thisTargetMethod && Settings.EnableTargeting && !Me.GotTarget &&
                !Me.HasAura("Food") && !Me.HasAura("Drink"))
            {
                if (!Me.GotTarget)
                {
                    Target.AquireTarget();
                }
            }

            if (Me.GotTarget)
            {
                Target.ClearTarget();
            }

            if (!Settings.EnableMovement || Me.HasAura("Food") || Me.HasAura("Drink") || (!Me.Combat && !Me.PetInCombat))
                return;
            if (Settings.EnableFacing && Me.CurrentTarget != null && !Me.CurrentTarget.IsDead && !Me.IsMoving &&
                !Me.IsSafelyFacing(Me.CurrentTarget) && Me.CurrentTarget.Distance <= 50)
            {
                Log.Info("[Facing: {0}] [Target HP: {1}] [Target Distance: {2}]", Me.CurrentTarget.Name,
                    Me.CurrentTarget.HealthPercent, Me.CurrentTarget.Distance);
                Me.CurrentTarget.Face();
            }
            Movement.Move();
        }
Exemplo n.º 8
0
        private bool LoadProfile(string fileName)
        {
            using (var sr = new StreamReader(fileName))
            {
                var code = sr.ReadToEnd();

                if (code.Trim() == "")
                {
                    MessageBox.Show("Please select a non blank file", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }

                if (fileName.EndsWith(".enc"))
                {
                    Log.Write("Decrypting profile...", Color.Black);

                    try
                    {
                        code = Encryption.Decrypt(code);

                        Log.Write("Profile has been decrypted successfully", Color.Green);
                    }
                    catch (Exception ex)
                    {
                        Log.Write(ex.Message, Color.Red);
                    }
                }

                Log.Write($"Compiling profile [{fileName}]...", Color.Black);

                var provider   = new CSharpCodeProvider();
                var parameters = new CompilerParameters();

                parameters.ReferencedAssemblies.Add("System.Windows.Forms.dll"); // For Windows Forms use
                parameters.ReferencedAssemblies.Add("System.Drawing.dll");       // For System.Drawing.Point and System.Drawing.Color use
                parameters.ReferencedAssemblies.Add("System.Data.dll");
                parameters.ReferencedAssemblies.Add("System.Xml.dll");
                parameters.ReferencedAssemblies.Add("System.Linq.dll");
                parameters.ReferencedAssemblies.Add("System.dll");
                parameters.ReferencedAssemblies.Add("System.IO.dll");
                parameters.ReferencedAssemblies.Add("System.Threading.dll");
                parameters.ReferencedAssemblies.Add(Application.ExecutablePath);
                parameters.GenerateInMemory   = true;
                parameters.GenerateExecutable = false;

                var results = provider.CompileAssemblyFromSource(parameters, code);

                if (results.Errors.HasErrors)
                {
                    foreach (CompilerError error in results.Errors)
                    {
                        Log.Write($"Error ({error.ErrorNumber}): {error.ErrorText}", Color.Red);
                    }

                    return(false);
                }

                var assembly = results.CompiledAssembly;

                foreach (var t in assembly.GetTypes())
                {
                    if (t.IsClass)
                    {
                        var obj = Activator.CreateInstance(t);
                        combatRoutine = (CombatRoutine)obj;

                        combatRoutine.Load(this);
                        combatRoutine.FileName = fileName;

                        Log.Write("Successfully loaded combat routine: " + combatRoutine.Name, Color.Green);

                        Overlay.showOverlay(new Point(20, 680));

                        if (SpellBook.Initialize(fileName))
                        {
                            spellbookToolStripMenuItem.Enabled    = true;
                            submitTicketToolStripMenuItem.Enabled = true;

                            cmdStartBot.Enabled         = true;
                            cmdStartBot.BackColor       = Color.LightGreen;
                            cmdRotationSettings.Enabled = true;
                            return(true);
                        }

                        spellbookToolStripMenuItem.Enabled    = false;
                        submitTicketToolStripMenuItem.Enabled = false;

                        cmdStartBot.Enabled   = false;
                        cmdStartBot.BackColor = Color.WhiteSmoke;
                        return(false);
                    }
                }

                return(false);
            }
        }
Exemplo n.º 9
0
        public override void Pulse()
        {
            if (Me.IsDead || Me.IsFlying || Me.IsGhost)
            {
                return;
            }

            if (Settings.EnableAutoDismount && BotManager.Current.Name != "Questing")
            {
                if (Me.Mounted &&
                    ((BotPoi.Current.Type == PoiType.Kill && BotPoi.Current.AsObject.Distance < 30) ||
                     (Me.GotTarget && Me.CurrentTarget.Distance < 30 && !Me.CurrentTarget.IsFriendly)))
                {
                    Lua.DoString("Dismount()");
                }
                else
                {
                    if (Me.Mounted && Me.Combat && !Me.IsMoving && Me.GotTarget && Me.CurrentTarget.Distance < 30 &&
                        !Me.CurrentTarget.IsFriendly)
                    {
                        Lua.DoString("Dismount()");
                    }
                }
            }

            if (Me.IsOnTransport || Me.Mounted)
            {
                return;
            }

            if ((RoutineManager.Current != null) && (RoutineManager.Current != _decoratedCombatRoutine))
            {
                Log.Info("Installing Combat Routine Hook...");
                _undecoratedCombatRoutine = RoutineManager.Current;
                _decoratedCombatRoutine   = new WantMovementCr(RoutineManager.Current, CapabilityFlags.All);
                RoutineManager.Current    = _decoratedCombatRoutine;
                Log.Info("Combat Routine Hook Installed!");
            }

            if ((_thisTargetMethod != Targeting.Instance) && Settings.EnableTargeting && !Me.HasAura("Food") &&
                !Me.HasAura("Drink"))
            {
                Log.Warning(
                    "Taking control of targeting. If this message is being spammed, something else is trying to take control.");
                Targeting.Instance = _thisTargetMethod;
            }

            if (Targeting.Instance == _thisTargetMethod && Settings.EnableTargeting && !Me.GotTarget &&
                !Me.HasAura("Food") && !Me.HasAura("Drink"))
            {
                if (!Me.GotTarget)
                {
                    Target.AquireTarget();
                }
            }

            if (Me.GotTarget)
            {
                Target.ClearTarget();
            }

            if (!Settings.EnableMovement || Me.HasAura("Food") || Me.HasAura("Drink") || (!Me.Combat && !Me.PetInCombat))
            {
                return;
            }
            if (Settings.EnableFacing && Me.CurrentTarget != null && !Me.CurrentTarget.IsDead && !Me.IsMoving &&
                !Me.IsSafelyFacing(Me.CurrentTarget) && Me.CurrentTarget.Distance <= 50)
            {
                Log.Info("[Facing: {0}] [Target HP: {1}] [Target Distance: {2}]", Me.CurrentTarget.Name,
                         Me.CurrentTarget.HealthPercent, Me.CurrentTarget.Distance);
                Me.CurrentTarget.Face();
            }
            Movement.Move();
        }