Jump to content
  • 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

    Matenia

    Posted (edited)

    //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


    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

×
×
  • Create New...