October 29, 20178 yr 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?
October 29, 20178 yr if (SpellManager.GetSpellCooldownTimeLeft("Frost Nova") > 0) { wManager.Wow.Helpers.Move.Backward(Move.MoveAction.PressKey, 1000); }
October 30, 20178 yr Author 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.
October 30, 20178 yr MovementEvents.OnMovementPulse might be what you're looking for. Intercept all other events for a while, until you're done moving.
October 30, 20178 yr Author 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; };
October 30, 20178 yr Basically, for the entire duration that you take over movement (also OnMoveToPulse you'll probably need), you need to cancel all other movement events.
October 30, 20178 yr Author 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.
October 30, 20178 yr 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; } }
October 30, 20178 yr Author 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.
October 30, 20178 yr 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; } };
October 30, 20178 yr Author Nope I use CSharp Edit: should I post my code? Maybe it would be easier to spot where the issue is
October 30, 20178 yr Author 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; } } }
October 30, 20178 yr 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 October 30, 20178 yr by Matenia
October 30, 20178 yr 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; };
October 30, 20178 yr Author 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"?
October 30, 20178 yr Author 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.
October 30, 20178 yr 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.
October 30, 20178 yr Author 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.
October 30, 20178 yr Author Nope, does the same thing :( moves an inch back, waits a few ms, moves an inch back etc... definitely not that 1250ms as expected
October 30, 20178 yr Author 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; } } }
October 30, 20178 yr 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
October 30, 20178 yr 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
October 30, 20178 yr Author 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 :)
Create an account or sign in to comment