Jump to content
This site uses cookies! Learn More

This site uses cookies!

By continuing to use this site, you agree to allow us to store cookies on your computer. :)

  • Add Fight.StopFight(); to anti-drown


    Ordush
    • Product: WRobot General Type: Suggestion Status: Unconfirmed

    The anti-drown mechanics are awesome, however you will still drown if you get in fight under water.
    Perhaps adding

    wManager.Wow.Helpers.Fight.StopFight();

    To the delegation would fix this issue? 🙂




    User Feedback

    Recommended Comments

    //This is how I handle it in my very own fight mechanism:
    
    _fightStartTs = DateTime.Now;
    			// chase target if necessary, otherwise wait
    			while (Conditions.InGameAndConnectedAndAliveAndProductStartedNotInPause && _target.IsAlive && _fightTrigger && !_target.IsTapDenied)
    			{
    				KeepTarget(_targetGuid);
    				//MoveAwayFromEnemies(); // needs to know if enemy is caster
    				KiteIfNecessary(_target);
    				SwimUpForAir();
    				PotionUser.UsePotions();
    				ChaseTarget(_target, () => ClassRotation.Range);
    				HandleEvade(_target);
    				EscapeIfNecessary();
    				Thread.Sleep(150);
    			}
    
    private static void SwimUpForAir()
    		{
    			if (AntiDrown.NeedsAirInCombat)
    			{
    				AntiDrown.GaspForAir();
    			}
    		}
    
    using System;
    using System.Collections.Generic;
    using System.Threading;
    using robotManager.FiniteStateMachine;
    using SmartRobot.Bot.Helpers;
    using wManager.Wow.Enums;
    using wManager.Wow.Helpers;
    using wManager.Wow.ObjectManager;
    
    namespace SmartRobot.Bot.States
    {
    	public class AntiDrown : State
    	{
    		private static DateTime _breathExpires = DateTime.MaxValue;
    
    		static AntiDrown()
    		{
    			EventsLuaWithArgs.OnEventsLuaStringWithArgs += AntiDrownEventHandler;
    		}
    
    		public override string DisplayName => "AntiDrown";
    
    		private bool NeedsAir => DateTime.Now.AddSeconds(30) > _breathExpires;
    		
    		public static bool NeedsAirInCombat => DateTime.Now.AddSeconds(15) > _breathExpires;
    
    		public static bool IsBreathing => _breathExpires != DateTime.MaxValue;
    
    		public override bool NeedToRun => Conditions.InGameAndConnectedAndAliveAndProductStartedNotInPause
    		                                  && ObjectManager.Me.IsSwimming
    		                                  && NeedsAir;
    
    		~AntiDrown()
    		{
    			EventsLuaWithArgs.OnEventsLuaStringWithArgs -= AntiDrownEventHandler;
    		}
    
    		private static void AntiDrownEventHandler(string id, List<string> args)
    		{
    			if ((id == "MIRROR_TIMER_START") & (args[0] == "BREATH"))
    			{
    				//sets BreathExpires to be in the future by x milliseconds
    				var expiryDate = DateTime.Now.AddMilliseconds(double.Parse(args[1]));
    				_breathExpires = expiryDate;
    
    				if (!ObjectManager.Me.HaveBuff("Water Breathing"))
    				{
    					ItemsManager.UseItem(5996);
    				}
    			}
    
    			if (id == "MIRROR_TIMER_STOP")
    			{
    				_breathExpires = DateTime.MaxValue;
    			}
    		}
    
    		public override void Run()
    		{
    			GaspForAir();
    		}
    
    		public static void GaspForAir()
    		{
    			Logger.Info("Swimming up for air");
    			MovementManager.StopMove();
    			while (Conditions.InGameAndConnectedAndAliveAndProductStartedNotInPause && IsBreathing && ObjectManager.Me.IsSwimming)
    			{
    				Move.JumpOrAscend(Move.MoveAction.DownKey, 1000);
    				Thread.Sleep(500);
    			}
    
    			// wait at surface
    			while (Conditions.InGameAndConnectedAndAliveAndProductStartedNotInPause && IsBreathing && !Common.IsAttackedByNpc)
    			{
    				Thread.Sleep(500);
    			}
    		}
    	}
    }

    Hope it helps for inspiration.

    Edited by Matenia

    Share this comment


    Link to comment
    Share on other sites


    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Add a comment...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...