Beispiel #1
0
        public bool MoveTo(Item m, bool run, int range)
        {
            if (m_Mobile.Deleted || m_Mobile.DisallowAllMoves || m == null || m.Deleted)
            {
                return(false);
            }

            if (m_Mobile.InRange(m, range))
            {
                m_Path = null;
                return(true);
            }

            if (m_Path != null && m_Path.Goal == m)
            {
                //Temrael Fix
                if (m_Path.Follow(run, 1) == PathFollowerResult.ReachedDestination)
                {
                    m_Path = null;
                    return(true);
                }
            }
            else if (!m_AI.DoMove(m_Mobile.GetDirectionTo(m), true))
            {
                m_Path       = new PathFollower(m_Mobile, m);
                m_Path.Mover = new MoveMethod(m_AI.DoMoveImpl);

                //Temrael Fix
                //if( m_Path.Follow( run, 1 ) )
                if (m_Path.Follow(run, 1) == PathFollowerResult.ReachedDestination)
                {
                    m_Path = null;
                    return(true);
                }
            }
            else
            {
                m_Path = null;
                return(true);
            }

            return(false);
        }
Beispiel #2
0
		/*
        *  Walk at range distance from mobile
        * 
        *	iSteps : Number of steps
        *	bRun   : Do we run
        *	iWantDistMin : The minimum distance we want to be
        *  iWantDistMax : The maximum distance we want to be
        * 
        */

		public virtual bool WalkMobileRange(Mobile m, int iSteps, bool bRun, int iWantDistMin, int iWantDistMax)
		{
			if (m_Mobile.Deleted || m_Mobile.DisallowAllMoves)
			{
				return false;
			}

			if (m != null)
			{
				for (int i = 0; i < iSteps; i++)
				{
					// Get the curent distance
					int iCurrDist = (int)m_Mobile.GetDistanceToSqrt(m);

					if (iCurrDist < iWantDistMin || iCurrDist > iWantDistMax)
					{
						bool needCloser = (iCurrDist > iWantDistMax);
						bool needFurther = !needCloser;

						if (needCloser && m_Path != null && m_Path.Goal == m)
						{
							if (m_Path.Follow(bRun, 1))
							{
								m_Path = null;
							}
						}
						else
						{
							Direction dirTo;

							if (iCurrDist > iWantDistMax)
							{
								dirTo = m_Mobile.GetDirectionTo(m);
							}
							else
							{
								dirTo = m.GetDirectionTo(m_Mobile);
							}

							// Add the run flag
							if (bRun)
							{
								dirTo = dirTo | Direction.Running;
							}

							if (!DoMove(dirTo, true) && needCloser)
							{
								m_Path = new PathFollower(m_Mobile, m);
								m_Path.Mover = DoMoveImpl;

								if (m_Path.Follow(bRun, 1))
								{
									m_Path = null;
								}
							}
							else
							{
								m_Path = null;
							}
						}
					}
					else
					{
						return true;
					}
				}

				// Get the curent distance
				int iNewDist = (int)m_Mobile.GetDistanceToSqrt(m);

				if (iNewDist >= iWantDistMin && iNewDist <= iWantDistMax)
				{
					return true;
				}
				else
				{
					return false;
				}
			}

			return false;
		}
Beispiel #3
0
		public virtual bool MoveTo(Mobile m, bool run, int range)
		{
			if (m_Mobile.Deleted || m_Mobile.DisallowAllMoves || m == null || m.Deleted)
			{
				return false;
			}

			if (m_Mobile.InRange(m, range))
			{
				m_Path = null;
				return true;
			}

			if (m_Path != null && m_Path.Goal == m)
			{
				if (m_Path.Follow(run, 1))
				{
					m_Path = null;
					return true;
				}
			}
			else if (!DoMove(m_Mobile.GetDirectionTo(m), true))
			{
				m_Path = new PathFollower(m_Mobile, m);
				m_Path.Mover = DoMoveImpl;

				if (m_Path.Follow(run, 1))
				{
					m_Path = null;
					return true;
				}
			}
			else
			{
				m_Path = null;
				return true;
			}

			return false;
		}
Beispiel #4
0
		public virtual bool MoveTo(IPoint3D p, bool run, int range)
		{
			if (m_Mobile.Deleted || m_Mobile.DisallowAllMoves || p == null || (p is IDamageable && ((IDamageable)p).Deleted))
			{
				return false;
			}

			if (m_Mobile.InRange(p, range))
			{
				m_Path = null;
				return true;
			}

			if (m_Path != null && m_Path.Goal == p)
			{
				if (m_Path.Follow(run, 1))
				{
					m_Path = null;
					return true;
				}
			}
			else if (!DoMove(m_Mobile.GetDirectionTo(p), true))
			{
				m_Path = new PathFollower(m_Mobile, p);
				m_Path.Mover = DoMoveImpl;

				if (m_Path.Follow(run, 1))
				{
					m_Path = null;
					return true;
				}
			}
			else
			{
				m_Path = null;
				return true;
			}

			return false;
		}
Beispiel #5
0
        private static void Game_OnOnGameUpdate(EventArgs args)
        {
            PlayerPosition = ObjectManager.Player.ServerPosition.To2D();

            //Set evading to false after blinking
            if (PreviousTickPosition.IsValid() &&
                PlayerPosition.Distance(PreviousTickPosition) > 200)
            {
                Evading = false;
            }

            PreviousTickPosition = PlayerPosition;

            //Remove the detected skillshots that have expired.
            DetectedSkillshots.RemoveAll(skillshot => !skillshot.IsActive());

            //Trigger OnGameUpdate on each skillshot.
            foreach (var skillshot in DetectedSkillshots)
            {
                skillshot.Game_OnGameUpdate();
            }

            //Evading disabled
            if (!Config.Menu.Item("Enabled").GetValue <KeyBind>().Active)
            {
                Evading      = false;
                EvadeToPoint = Vector2.Zero;
                PathFollower.Stop();
                return;
            }

            if (PlayerChampionName == "Olaf" && Config.Menu.Item("DisableEvadeForOlafR").GetValue <bool>() && ObjectManager.Player.HasBuff("OlafRagnarok"))
            {
                Evading      = false;
                EvadeToPoint = Vector2.Zero;
                PathFollower.Stop();
                return;
            }

            //Avoid sending move/cast packets while dead.
            if (ObjectManager.Player.IsDead)
            {
                Evading      = false;
                EvadeToPoint = Vector2.Zero;
                PathFollower.Stop();
                return;
            }

            //Avoid sending move/cast packets while channeling interruptable spells that cause hero not being able to move.
            if (ObjectManager.Player.IsCastingInterruptableSpell(true))
            {
                Evading      = false;
                EvadeToPoint = Vector2.Zero;
                PathFollower.Stop();
                return;
            }

            if (ObjectManager.Player.IsWindingUp && !Orbwalking.IsAutoAttack(ObjectManager.Player.LastCastedSpellName()))
            {
                Evading = false;
                return;
            }

            /*Avoid evading while stunned or immobile.*/
            if (Utils.ImmobileTime(ObjectManager.Player) - Utils.TickCount > Game.Ping / 2 + 70)
            {
                Evading = false;
                return;
            }

            /*Avoid evading while dashing.*/
            if (ObjectManager.Player.IsDashing())
            {
                Evading = false;
                return;
            }

            //Don't evade while casting R as sion
            if (PlayerChampionName == "Sion" && ObjectManager.Player.HasBuff("SionR"))
            {
                PathFollower.Stop();
                return;
            }

            //Spell Shielded
            if (ObjectManager.Player.IsSpellShielded())
            {
                PathFollower.Stop();
                return;
            }

            if (NoSolutionFound)
            {
                PathFollower.Stop();
            }

            var currentPath = ObjectManager.Player.GetWaypoints();
            var safeResult  = IsSafe(PlayerPosition);
            var safePath    = IsSafePath(currentPath, 100);

            /*FOLLOWPATH*/
            if (FollowPath && !NoSolutionFound && (Keepfollowing || !Evading) && EvadeToPoint.IsValid() && safeResult.IsSafe)
            {
                if (EvadeSpellDatabase.Spells.Any(evadeSpell => evadeSpell.Name == "Walking" && evadeSpell.Enabled))
                {
                    if (Utils.TickCount - lastSentMovePacketT2 > 300)
                    {
                        var candidate = Pathfinding.Pathfinding.PathFind(PlayerPosition, EvadeToPoint);
                        PathFollower.Follow(candidate);
                        lastSentMovePacketT2 = Utils.TickCount;
                    }
                }
            }
            else
            {
                FollowPath = false;
            }

            NoSolutionFound = false;

            //Continue evading
            if (Evading && IsSafe(EvadePoint).IsSafe)
            {
                if (safeResult.IsSafe)
                {
                    //We are safe, stop evading.
                    Evading = false;
                }
                else
                {
                    if (Utils.TickCount - lastSentMovePacketT > 1000 / 15)
                    {
                        lastSentMovePacketT = Utils.TickCount;
                        ObjectManager.Player.SendMovePacket(EvadePoint);
                    }
                    return;
                }
            }
            //Stop evading if the point is not safe.
            else if (Evading)
            {
                Evading = false;
            }

            //The path is not safe.
            if (!safePath.IsSafe)
            {
                //Inside the danger polygon.
                if (!safeResult.IsSafe)
                {
                    //Search for an evade point:
                    TryToEvade(safeResult.SkillshotList, EvadeToPoint.IsValid() ? EvadeToPoint : Game.CursorPos.To2D());
                }
                //Outside the danger polygon.
                else
                {
                    FollowPath = true;
                    //Stop at the edge of the skillshot.
                    if (EvadeSpellDatabase.Spells.Any(evadeSpell => evadeSpell.Name == "Walking" && evadeSpell.Enabled))
                    {
                        ObjectManager.Player.SendMovePacket(safePath.Intersection.Point);
                    }
                }
            }
        }