RonSwanson 2 Posted February 1, 2017 Share Posted February 1, 2017 Hey I am not sure if Cast Time is even being accounted for in C#. For Example Spell.CastTime = 2000 which would be a 2 second cast. I dont think the bot even cares for that value. I believe it does not care for the cast time value because I feel like in C# the bot interrupts its spells a lot. How can I get my Combat Rotation more fluent so each spell is used efficiently and not interrupted by the same spell and or the next spell in line. What is best practice for this Bot? I am asking this because I am writing a Wrotation so it needs to be able to perform better then a human. Link to comment https://wrobot.eu/forums/topic/4943-making-combat-routine-more-efficient-c-help/ Share on other sites More sharing options...
iMod 99 Posted February 1, 2017 Share Posted February 1, 2017 9 hours ago, Doobie said: Hey I am not sure if Cast Time is even being accounted for in C#. For Example Spell.CastTime = 2000 which would be a 2 second cast. I dont think the bot even cares for that value. I believe it does not care for the cast time value because I feel like in C# the bot interrupts its spells a lot. How can I get my Combat Rotation more fluent so each spell is used efficiently and not interrupted by the same spell and or the next spell in line. What is best practice for this Bot? I am asking this because I am writing a Wrotation so it needs to be able to perform better then a human. /// <summary> /// Determines if the spell is known or not /// </summary> /// <param name="spell">The spell we want to check</param> /// <returns>Returns true if the spell is known otherwise false</returns> public static bool IsSpellKnown(Spell spell) { // Check spell bool isSpellKnown = Lua.LuaDoString<bool>($"return IsSpellKnown({spell.Id});"); // Return return isSpellKnown; } /// <summary> /// Determines if the given target has the buff with the given conditions /// </summary> /// <param name="spell">The spell you want to check</param> /// <param name="target">The target you want to check</param> /// <param name="buffTimeLeft">Recast if buff time is under the given time</param> /// <param name="stacks">How much stacks you want at the target</param> /// <param name="owner">Flag that determines if we need to be the owner</param> /// <returns>Returns true if the target has the spell on it with the given conditions otherwise false</returns> public static bool HasBuff(Spell spell, WoWUnit target, double buffTimeLeft = 0, int stacks = 0, bool owner = true) { // Get target auras List<Aura> auraList = target.GetAllBuff(); // Get aura Aura aura = null; if (owner) { // Set aura = auraList.Where(s => s.ToString().Contains(spell.Name) && s.Owner == ObjectManager.Me.Guid).FirstOrDefault(); } else { // Set aura = auraList.FirstOrDefault(s => s.ToString().Contains(spell.Name)); } // Any found? if (aura != null) { // Validate if (aura.TimeLeftSeconde > buffTimeLeft && aura.Stack >= stacks) { // Return return true; } } // Return return false; } /// <summary> /// Cast a spell /// </summary> /// <param name="spell">The spell you want to cast</param> /// <param name="target">The target you want to cast at</param> /// <param name="debuff">The debuff we are looking for</param> /// <param name="buffTimeLeft">Recast if buff time is under the given time</param> /// <param name="stacks">How much stacks you want at the target</param> /// <param name="owner">Flag that determines if we need to be the owner</param> /// <param name="force">Force use the skill and ignore debuffs</param> /// <returns>Returns true if we can cast the spell otherwise false</returns> public static bool CastSpell(Spell spell, WoWUnit target, double buffTimeLeft = 0, int stacks = 0, Spell debuff = null, bool owner = true, bool force = false) { // Check if the spell is known if (!IsSpellKnown(spell)) { // Skip return false; } // Wait until global cooldown is done Thread.Sleep(SpellManager.GlobalCooldownTimeLeft()); // Check if buff exists bool hasDebuff; if (debuff != null) { hasDebuff = Functions.HasBuff(debuff, target, buffTimeLeft, stacks, owner); } else { hasDebuff = Functions.HasBuff(spell, target, buffTimeLeft, stacks, owner); } // Validate spell if (!ObjectManager.Me.IsStunned && !ObjectManager.Me.IsDead && !ObjectManager.Me.IsCast && !target.IsDead && spell.IsSpellUsable && spell.IsDistanceGood && (force || !hasDebuff) && !TraceLine.TraceLineGo(target.Position)) { if (target.Guid == ObjectManager.Me.Guid) { // Cast on self Lua.LuaDoString($"CastSpellByID({spell.Id}, \"player\")"); } else { // Cast on target Lua.LuaDoString($"CastSpellByID({spell.Id}, \"target\")"); } // Log Logging.WriteDebug($"Cast: {spell.NameInGame}"); // Return return true; } // Return return false; } Short answer: Check if you are currently casting with "ObjectManager.Me.IsCast". I would recommend to put all the validations into a method. Another way would be to use @Droidz inbuild engine. Have fun. PS: If a method is missing just call me, I just copied it right out of my framework. BTW: It is used for WOTLK and I'm not sure if there where changes in the lua commands. But at the end it should give you an idea how it could be done. There are allways multi ways to reach the goal. Link to comment https://wrobot.eu/forums/topic/4943-making-combat-routine-more-efficient-c-help/#findComment-22902 Share on other sites More sharing options...
RonSwanson 2 Posted February 1, 2017 Author Share Posted February 1, 2017 @iMod So what is cast time actually doing and what is Timer doing. SliceandDiceTimer = new Timer(1000 * 36); I guess what I am asking is what is the difference between Spell.CastTime and Timer? And how would you use them together in a good fashion. Link to comment https://wrobot.eu/forums/topic/4943-making-combat-routine-more-efficient-c-help/#findComment-22910 Share on other sites More sharing options...
iMod 99 Posted February 1, 2017 Share Posted February 1, 2017 1 minute ago, Doobie said: @iMod So what is cast time actually doing and what is Timer doing. SliceandDiceTimer = new Timer(1000 * 36); I guess what I am asking is what is the difference between Spell.CastTime and Timer? And how would you use them together in a good fashion. Cast time should give you the time you need to cast, but i never used it. Timer is just a .net class nothing special. you can use it to make sure that you dont cast a spell until the timer countdown is done for example. Link to comment https://wrobot.eu/forums/topic/4943-making-combat-routine-more-efficient-c-help/#findComment-22911 Share on other sites More sharing options...
Bear T.O.E. 63 Posted June 26, 2017 Share Posted June 26, 2017 How would you add a timers to allow the bot to what for say Frost Runes to all come off cool down before the bot casts a specific spell? Link to comment https://wrobot.eu/forums/topic/4943-making-combat-routine-more-efficient-c-help/#findComment-28359 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now