Jump to content

[SOLVED] Move after Frost Nova - is it really that hard?


Recommended Posts

I've been scouring the forums for a solution to this and everything is very unreliable, at least with my limited knowledge.

I've tried these, but for both of these the bot is trying to face the target during the strafe, hence it starts doing circles around the mob not really getting away from it.

wManager.Wow.Helpers.Keybindings.PressKeybindings(wManager.Wow.Enums.Keybindings.STRAFELEFT, 1250);
Move.StrafeLeft(Move.MoveAction.PressKey, 1250);

The only reliable way I found how to get away from the mob is to pause the bot (below code) before the move, which makes the movement go as I want to but it messes the bot up in some situations.

robotManager.Products.Products.InPause = true;
Move.StrafeLeft(Move.MoveAction.PressKey, 1250);
robotManager.Products.Products.InPause = false;

Surely, there is a simple, clean way of doing this?

Link to comment
Share on other sites

8 hours ago, Apexx said:
if (SpellManager.GetSpellCooldownTimeLeft("Frost Nova") > 0)
{
    wManager.Wow.Helpers.Move.Backward(Move.MoveAction.PressKey, 1000);
}

 

I've tried Move.Backward but I don't like backpaddling, hence I wanted to use strafe.

EDIT: also, one would think that Move.MoveAction.PressKey, 1000 would hold the key pressed for one second, however it doesn't. It presses it for a few miliseconds. It feels like the script doesn't pause for it to be resolved and continues with the while loop which I have set to Thread.Sleep(50); Or it might have sth to do with what I described with the strafe, ie the bot doesn't want to move away from the mob and I'm telling him otherwise resulting in only a ms of movement.

Link to comment
Share on other sites

3 minutes ago, Matenia said:

MovementEvents.OnMovementPulse might be what you're looking for.
Intercept all other events for a while, until you're done moving.

Could you please ellaborate on that? How would I use it correctly?

 

EDIT: do I just go with this, then use Move.Backwards and then set it to false?

wManager.Events.MovementEvents.OnMovementPulse += (points, cancelable) =>
{
	cancelable.Cancel = true;
};

 

Link to comment
Share on other sites

10 minutes ago, Matenia said:

Basically, for the entire duration that you take over movement (also OnMoveToPulse you'll probably need), you need to cancel all other movement events.

So I should use the code in the way I guessed above? EDIT: nope, that doesn't seem to be the correct usage.

Link to comment
Share on other sites

Absolute pseudo code here!
 

bool isRunning = false;
while(ObjectManager.Target.GetDistance < 5){
  isRunning = true;
  Move.StrafeLeft(Move.MoveAction.PressKey, 1250);
}


MovementEvents.OnMoveToPulse += MovementEvents_OnMoveToPulse;
MovementEvents.OnMovementPulse += MovementEvents_OnMovementPulse;

private static void MovementEvents_OnMovementPulse(List<Vector3> points, CancelEventArgs cancelable)
{
  if(isRunning)
  {
    cancelable.Cancel = true;
  }
}

private static void MovementEvents_OnMoveToPulse(Vector3 point, CancelEventArgs cancelable)
{
  if(isRunning)
  {
    cancelable.Cancel = true;
  }
}

 

Link to comment
Share on other sites

Received an error. Seems the bot doesn't like the ' += ' and ' ; ' in this:

MovementEvents.OnMoveToPulse += MovementEvents_OnMoveToPulse;
MovementEvents.OnMovementPulse += MovementEvents_OnMovementPulse;

Or I put it where it doesn't belong.

Link to comment
Share on other sites

Well, I define the functions underneath. I assume you use the XML Fightclass editor and don't use a C# class/.cs file?

You can define it just like you did in your example code.

 

wManager.Events.MovementEvents.OnMovementPulse += (points, cancelable) =>
{
  if(isRunning)
  {
	cancelable.Cancel = true;
  }
};

 

Link to comment
Share on other sites

Here is the condensed code:

Spoiler
using System;
using System.Linq;
using System.Threading;
using System.Windows.Forms;
using robotManager.Helpful;
using robotManager.Products;
using wManager.Wow.Class;
using wManager.Wow.Enums;
using wManager.Wow.Helpers;
using wManager.Wow.ObjectManager;
using System.Configuration;
using System.ComponentModel;
using System.IO;
using robotManager;
using System.Collections.Generic;
using Timer = robotManager.Helpful.Timer;

public class Main : ICustomClass
{
    public float Range { get { return 29f; } }

    private bool iMageLaunched;
    private ulong _lastTarget;
	private Timer _timer;
	private const int CastEverySeconds = 120;
	private Timer _timerFrostNova;
	private const int CastEverySecondsFrostNova = 26;
	private int cooldownc;
	private bool isTooClose = false;

    public void Initialize() // When product started, initialize and launch Fightclass
    {
        iMageLaunched = true;
        Logging.Write("iMage initialized.");
        Start();
    }

    public void Dispose() // When product stopped
    {
        iMageLaunched = false;
        Logging.Write("iMage stopped.");
    }

    public void ShowConfiguration() // When use click on Fight class settings
    {
        iMageSettings.Load();
        iMageSettings.CurrentSetting.ToForm();
        iMageSettings.CurrentSetting.Save();
    }
	
	MovementEvents.OnMoveToPulse += MovementEvents_OnMoveToPulse;
	MovementEvents.OnMovementPulse += MovementEvents_OnMovementPulse;

	private static void MovementEvents_OnMovementPulse(List<Vector3> points, CancelEventArgs cancelable)
	{
		if (isTooClose)
		{
			cancelable.Cancel = true;
		}
	}

	private static void MovementEvents_OnMoveToPulse(Vector3 point, CancelEventArgs cancelable)
	{
		if (isTooClose)
		{
			cancelable.Cancel = true;
		}
	}

    


    // SPELLS:
    public Spell ConjureWater = new Spell ("Conjure Water");
    // etc etc



    private void CombatRotation()
	{
		if (ObjectManager.Target.GetDistance <= 9 && ObjectManager.Target.GetDistance >= 6 && !ObjectManager.Target.HaveBuff("Frost Nova") && !ObjectManager.Target.HaveBuff("Frostbite") && ObjectManager.Target.HealthPercent >= 25 && (_timerFrostNova == null || _timerFrostNova.IsReady)) // && ObjectManager.Target.GetDistance >= 6 
		{
			if (ObjectManager.Me.IsCast)
			{
				Lua.LuaDoString("SpellStopCasting();");
				Thread.Sleep(250);
				SpellManager.CastSpellByNameLUA("Frost Nova");
				_timerFrostNova = new Timer(CastEverySecondsFrostNova * 1000);
				Thread.Sleep(1500);
			}
			else
			{
				SpellManager.CastSpellByNameLUA("Frost Nova");
				_timerFrostNova = new Timer(CastEverySecondsFrostNova * 1000);
				Thread.Sleep(1500);
			}
			return;
		}
		else if ((ObjectManager.Target.HaveBuff("Frost Nova") || ObjectManager.Target.HaveBuff("Frostbite")) && ObjectManager.Target.GetDistance <= 6)
		{
			while (ObjectManager.Target.GetDistance <= 6)
			{
				isRunning = true
				wManager.Wow.Helpers.Move.Backward(Move.MoveAction.PressKey, 1250); // wManager.Wow.Helpers.Move.StrafeLeft(Move.MoveAction.PressKey, 1500);
			}
			return;
		}
		// etc etc
	}
    
   
    public void Start()
    {
        
        Logging.Write("iMage Loaded");
        while (iMageLaunched)
        {
            if (!Products.InPause)
                {
                    if (!ObjectManager.Me.IsDeadMe)
                    {
                        if (!ObjectManager.Me.IsMounted && !ObjectManager.Me.InCombat && !Fight.InFight && !ObjectManager.Me.HaveBuff("Drink") && !ObjectManager.Me.HaveBuff("Food"))
						{
                            BuffRotation();
							CheckConjureWaterRank();
							CheckConjureFoodRank();
                        }

                        if (Fight.InFight && ObjectManager.Me.Target > 0)
                        {
                            CombatRotation();
                        }
                    }
                }
            Thread.Sleep(50);
        }
        Logging.Write("iMage is now stopped.");
    }


    [Serializable]
    public class iMageSettings : Settings
    {
        public iMageSettings()
        {
            ConfigWinForm(new System.Drawing.Point(400, 400), "iMage" + Translate.Get("Settings"));
        }

        public static iMageSettings CurrentSetting { get; set; }

        public bool Save()
        {
            try
            {
                return Save(AdviserFilePathAndName("iMage-Mage", ObjectManager.Me.Name + "." + Usefuls.RealmName));
            }
            catch (Exception e)
            {
                Logging.WriteError("iMageSettings > Save(): " + e);
                return false;
            }
        }

        public static bool Load()
        {
            try
            {
                if (File.Exists(AdviserFilePathAndName("iMage-Mage", ObjectManager.Me.Name + "." + Usefuls.RealmName)))
                {
                    CurrentSetting =
                        Load<iMageSettings>(AdviserFilePathAndName("iMage-Mage",
                                                                    ObjectManager.Me.Name + "." + Usefuls.RealmName));
                    return true;
                }
                CurrentSetting = new iMageSettings();
            }
            catch (Exception e)
            {
                Logging.WriteError("iMageSettings > Load(): " + e);
            }
            return false;
        }
    }
}

 

 

Link to comment
Share on other sites

Edit: You just pasted the code somewhere...

You need to move

 

MovementEvents.OnMoveToPulse += MovementEvents_OnMoveToPulse;
	MovementEvents.OnMovementPulse += MovementEvents_OnMovementPulse;

to your Initialize function. It needs to be called from somewhere...

Edited by Matenia
Link to comment
Share on other sites

Just now, Seminko said:

Here is the condensed code:

  Reveal hidden contents

using System;
using System.Linq;
using System.Threading;
using System.Windows.Forms;
using robotManager.Helpful;
using robotManager.Products;
using wManager.Wow.Class;
using wManager.Wow.Enums;
using wManager.Wow.Helpers;
using wManager.Wow.ObjectManager;
using System.Configuration;
using System.ComponentModel;
using System.IO;
using robotManager;
using System.Collections.Generic;
using Timer = robotManager.Helpful.Timer;

public class Main : ICustomClass
{
    public float Range { get { return 29f; } }

    private bool iMageLaunched;
    private ulong _lastTarget;
	private Timer _timer;
	private const int CastEverySeconds = 120;
	private Timer _timerFrostNova;
	private const int CastEverySecondsFrostNova = 26;
	private int cooldownc;
	private bool isTooClose = false;

    public void Initialize() // When product started, initialize and launch Fightclass
    {
        iMageLaunched = true;
        Logging.Write("iMage initialized.");
        Start();
    }

    public void Dispose() // When product stopped
    {
        iMageLaunched = false;
        Logging.Write("iMage stopped.");
    }

    public void ShowConfiguration() // When use click on Fight class settings
    {
        iMageSettings.Load();
        iMageSettings.CurrentSetting.ToForm();
        iMageSettings.CurrentSetting.Save();
    }
	
	MovementEvents.OnMoveToPulse += MovementEvents_OnMoveToPulse;
	MovementEvents.OnMovementPulse += MovementEvents_OnMovementPulse;

	private static void MovementEvents_OnMovementPulse(List<Vector3> points, CancelEventArgs cancelable)
	{
		if (isTooClose)
		{
			cancelable.Cancel = true;
		}
	}

	private static void MovementEvents_OnMoveToPulse(Vector3 point, CancelEventArgs cancelable)
	{
		if (isTooClose)
		{
			cancelable.Cancel = true;
		}
	}

    


    // SPELLS:
    public Spell ConjureWater = new Spell ("Conjure Water");
    // etc etc



    private void CombatRotation()
	{
		if (ObjectManager.Target.GetDistance <= 9 && ObjectManager.Target.GetDistance >= 6 && !ObjectManager.Target.HaveBuff("Frost Nova") && !ObjectManager.Target.HaveBuff("Frostbite") && ObjectManager.Target.HealthPercent >= 25 && (_timerFrostNova == null || _timerFrostNova.IsReady)) // && ObjectManager.Target.GetDistance >= 6 
		{
			if (ObjectManager.Me.IsCast)
			{
				Lua.LuaDoString("SpellStopCasting();");
				Thread.Sleep(250);
				SpellManager.CastSpellByNameLUA("Frost Nova");
				_timerFrostNova = new Timer(CastEverySecondsFrostNova * 1000);
				Thread.Sleep(1500);
			}
			else
			{
				SpellManager.CastSpellByNameLUA("Frost Nova");
				_timerFrostNova = new Timer(CastEverySecondsFrostNova * 1000);
				Thread.Sleep(1500);
			}
			return;
		}
		else if ((ObjectManager.Target.HaveBuff("Frost Nova") || ObjectManager.Target.HaveBuff("Frostbite")) && ObjectManager.Target.GetDistance <= 6)
		{
			while (ObjectManager.Target.GetDistance <= 6)
			{
				wManager.Wow.Helpers.Move.Backward(Move.MoveAction.PressKey, 1250); // wManager.Wow.Helpers.Move.StrafeLeft(Move.MoveAction.PressKey, 1500);
			}
			return;
		}
		// etc etc
	}
    
   
    public void Start()
    {
        
        Logging.Write("iMage Loaded");
        while (iMageLaunched)
        {
            if (!Products.InPause)
                {
                    if (!ObjectManager.Me.IsDeadMe)
                    {
                        if (!ObjectManager.Me.IsMounted && !ObjectManager.Me.InCombat && !Fight.InFight && !ObjectManager.Me.HaveBuff("Drink") && !ObjectManager.Me.HaveBuff("Food"))
						{
                            BuffRotation();
							CheckConjureWaterRank();
							CheckConjureFoodRank();
                        }

                        if (Fight.InFight && ObjectManager.Me.Target > 0)
                        {
                            CombatRotation();
                        }
                    }
                }
            Thread.Sleep(50);
        }
        Logging.Write("iMage is now stopped.");
    }


    [Serializable]
    public class iMageSettings : Settings
    {
        public iMageSettings()
        {
            ConfigWinForm(new System.Drawing.Point(400, 400), "iMage" + Translate.Get("Settings"));
        }

        public static iMageSettings CurrentSetting { get; set; }

        public bool Save()
        {
            try
            {
                return Save(AdviserFilePathAndName("iMage-Mage", ObjectManager.Me.Name + "." + Usefuls.RealmName));
            }
            catch (Exception e)
            {
                Logging.WriteError("iMageSettings > Save(): " + e);
                return false;
            }
        }

        public static bool Load()
        {
            try
            {
                if (File.Exists(AdviserFilePathAndName("iMage-Mage", ObjectManager.Me.Name + "." + Usefuls.RealmName)))
                {
                    CurrentSetting =
                        Load<iMageSettings>(AdviserFilePathAndName("iMage-Mage",
                                                                    ObjectManager.Me.Name + "." + Usefuls.RealmName));
                    return true;
                }
                CurrentSetting = new iMageSettings();
            }
            catch (Exception e)
            {
                Logging.WriteError("iMageSettings > Load(): " + e);
            }
            return false;
        }
    }
}

 

 

Using Visual studio? Ctrl+K Ctrl+D, formats your code, i was really confused, thought you were doing the events in the ShowConfiguration().

also would you not do?

MovementEvents.OnMoveToPulse += delegate { MovementEvents_OnMoveToPulse; };
MovementEvents.OnMovementPulse += delegate { MovementEvents_OnMovementPulse; };

 

Link to comment
Share on other sites

9 minutes ago, Matenia said:

Edit: You just pasted the code somewhere...

You need to move

 

MovementEvents.OnMoveToPulse += MovementEvents_OnMoveToPulse;
	MovementEvents.OnMovementPulse += MovementEvents_OnMovementPulse;

to your Initialize function. It needs to be called from somewhere...

Didn't help. Now it says MovementEvents doesn't exist in the current context

 

5 minutes ago, Marsbar said:

Using Visual studio? Ctrl+K Ctrl+D, formats your code, i was really confused, thought you were doing the events in the ShowConfiguration().

No I don't, i use Notepad++ and the code looks good inside but gets messed up when I paste it here

 

5 minutes ago, Marsbar said:

also would you not do?

MovementEvents.OnMoveToPulse += delegate { MovementEvents_OnMoveToPulse; };
MovementEvents.OnMovementPulse += delegate { MovementEvents_OnMovementPulse; };

 

Tried using this and same as above, it doesn't exist in the current context. Am I missing "an include"? I mean "using xyz"?

Link to comment
Share on other sites

5 minutes ago, Marsbar said:

Ahh...

using wManager.Events;

Alright, this solved the error.

Now it has a problem with these two, saying that the line if (isTooClose) or to be more specific Main.isTooClose requires a link to an object (or sth similar, I have it in my native language, not english)

	private static void MovementEvents_OnMovementPulse(List<Vector3> points, CancelEventArgs cancelable)
	{
		if (isTooClose)
		{
			cancelable.Cancel = true;
		}
	}

	private static void MovementEvents_OnMoveToPulse(Vector3 point, CancelEventArgs cancelable)
	{
		if (isTooClose)
		{
			cancelable.Cancel = true;
		}
	}

 

Also, this is my first encounter with C# hence these, probably obvious, mistakes on my part.

Link to comment
Share on other sites

I believe that is because they're static.

A lot of these types of errors can easily be highlighted by a better editor that references the wrobot dlls. Visual studio community edition is free (although quite a heavy editor) and there are some others, its all based on preference.

Link to comment
Share on other sites

1 minute ago, Marsbar said:

I believe that is because they're static.

A lot of these types of errors can easily be highlighted by a better editor that references the wrobot dlls. Visual studio community edition is free (although quite a heavy editor) and there are some others, its all based on preference.

Ha, no error this time... Let me see if it does what we're after... Be back in a second with an update.

Link to comment
Share on other sites

For reference, here is the code without errors, but still bad movement:

Spoiler
using System;
using System.Linq;
using System.Threading;
using System.Windows.Forms;
using robotManager.Helpful;
using robotManager.Products;
using wManager.Wow.Class;
using wManager.Wow.Enums;
using wManager.Wow.Helpers;
using wManager.Wow.ObjectManager;
using System.Configuration;
using System.ComponentModel;
using System.IO;
using robotManager;
using System.Collections.Generic;
using Timer = robotManager.Helpful.Timer;

public class Main : ICustomClass
{
    public float Range { get { return 29f; } }

    private bool iMageLaunched;
    private ulong _lastTarget;
	private Timer _timer;
	private const int CastEverySeconds = 120;
	private Timer _timerFrostNova;
	private const int CastEverySecondsFrostNova = 26;
	private int cooldownc;
	private bool isTooClose = false;

    public void Initialize() // When product started, initialize and launch Fightclass
    {
        iMageLaunched = true;
		MovementEvents.OnMoveToPulse += MovementEvents_OnMoveToPulse;
		MovementEvents.OnMovementPulse += MovementEvents_OnMovementPulse;
		Logging.Write("iMage initialized.");
        Start();
    }

    public void Dispose() // When product stopped
    {
        iMageLaunched = false;
        Logging.Write("iMage stopped.");
    }

    public void ShowConfiguration() // When use click on Fight class settings
    {
        iMageSettings.Load();
        iMageSettings.CurrentSetting.ToForm();
        iMageSettings.CurrentSetting.Save();
    }

	private void MovementEvents_OnMovementPulse(List<Vector3> points, CancelEventArgs cancelable)
	{
		if (isTooClose)
		{
			cancelable.Cancel = true;
		}
	}

	private void MovementEvents_OnMoveToPulse(Vector3 point, CancelEventArgs cancelable)
	{
		if (isTooClose)
		{
			cancelable.Cancel = true;
		}
	}

    


    // SPELLS:
    public Spell ConjureWater = new Spell ("Conjure Water");
    // etc etc



    private void CombatRotation()
	{
		if (ObjectManager.Target.GetDistance <= 9 && ObjectManager.Target.GetDistance >= 6 && !ObjectManager.Target.HaveBuff("Frost Nova") && !ObjectManager.Target.HaveBuff("Frostbite") && ObjectManager.Target.HealthPercent >= 25 && (_timerFrostNova == null || _timerFrostNova.IsReady)) // && ObjectManager.Target.GetDistance >= 6 
		{
			if (ObjectManager.Me.IsCast)
			{
				Lua.LuaDoString("SpellStopCasting();");
				Thread.Sleep(250);
				SpellManager.CastSpellByNameLUA("Frost Nova");
				_timerFrostNova = new Timer(CastEverySecondsFrostNova * 1000);
				Thread.Sleep(1500);
			}
			else
			{
				SpellManager.CastSpellByNameLUA("Frost Nova");
				_timerFrostNova = new Timer(CastEverySecondsFrostNova * 1000);
				Thread.Sleep(1500);
			}
			return;
		}
		else if ((ObjectManager.Target.HaveBuff("Frost Nova") || ObjectManager.Target.HaveBuff("Frostbite")) && ObjectManager.Target.GetDistance <= 6)
		{
			while (ObjectManager.Target.GetDistance <= 6)
			{
				isTooClose = true;
				wManager.Wow.Helpers.Move.Backward(Move.MoveAction.PressKey, 1250); // wManager.Wow.Helpers.Move.StrafeLeft(Move.MoveAction.PressKey, 1500);
			}
			return;
		}
		// etc etc
	}
    
   
    public void Start()
    {
        
        Logging.Write("iMage Loaded");
        while (iMageLaunched)
        {
            if (!Products.InPause)
                {
                    if (!ObjectManager.Me.IsDeadMe)
                    {
                        if (!ObjectManager.Me.IsMounted && !ObjectManager.Me.InCombat && !Fight.InFight && !ObjectManager.Me.HaveBuff("Drink") && !ObjectManager.Me.HaveBuff("Food"))
						{
                            BuffRotation();
							CheckConjureWaterRank();
							CheckConjureFoodRank();
                        }

                        if (Fight.InFight && ObjectManager.Me.Target > 0)
                        {
                            CombatRotation();
                        }
                    }
                }
            Thread.Sleep(50);
        }
        Logging.Write("iMage is now stopped.");
    }


    [Serializable]
    public class iMageSettings : Settings
    {
        public iMageSettings()
        {
            ConfigWinForm(new System.Drawing.Point(400, 400), "iMage" + Translate.Get("Settings"));
        }

        public static iMageSettings CurrentSetting { get; set; }

        public bool Save()
        {
            try
            {
                return Save(AdviserFilePathAndName("iMage-Mage", ObjectManager.Me.Name + "." + Usefuls.RealmName));
            }
            catch (Exception e)
            {
                Logging.WriteError("iMageSettings > Save(): " + e);
                return false;
            }
        }

        public static bool Load()
        {
            try
            {
                if (File.Exists(AdviserFilePathAndName("iMage-Mage", ObjectManager.Me.Name + "." + Usefuls.RealmName)))
                {
                    CurrentSetting =
                        Load<iMageSettings>(AdviserFilePathAndName("iMage-Mage",
                                                                    ObjectManager.Me.Name + "." + Usefuls.RealmName));
                    return true;
                }
                CurrentSetting = new iMageSettings();
            }
            catch (Exception e)
            {
                Logging.WriteError("iMageSettings > Load(): " + e);
            }
            return false;
        }
    }
}

 

 

Link to comment
Share on other sites

I'd be surprised if it doesn't error;

BuffRotation();
CheckConjureWaterRank();
CheckConjureFoodRank();

These functions don't exist, also you left out using wManager.Events; again :P

Link to comment
Share on other sites

You actually need to set isTooClose to false again after the while loop and maybe give it a short Thread.Sleep(500) or so at the end of each iteration.
Does the bot interrupt movement and then starts strafing again? Or is the strafing itself just choppy?

 

I highly recommend getting Visual Studio and doing a basic C# tutorial (or even Java, they're essentially the same

Link to comment
Share on other sites

2 minutes ago, Marsbar said:

I'd be surprised if it doesn't error;

BuffRotation();
CheckConjureWaterRank();
CheckConjureFoodRank();

These functions don't exist,

They exist :) I just removed them from the enclosed code because they're not relevant for our issue :)

 

3 minutes ago, Marsbar said:

also you left out using wManager.Events; again :P

True, adding it now :)

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
 Share

×
×
  • Create New...