Exemplo n.º 1
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 = new MoveMethod( 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;
        }
Exemplo n.º 2
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 = new MoveMethod( DoMoveImpl );

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

            return false;
        }
Exemplo n.º 3
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;

			Map map = m_Mobile.Map;

			if (m != null)
			{
				//if were a human mob that can run show that to the world walk/run accordingly
				if (CanRun)
				{
					if ((m.Direction & Direction.Running) != 0)
						bRun = true;
					else
						bRun = false;
				}

				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)
							{
								IPooledEnumerable eable = map.GetItemsInRange(m_Mobile.Location, 10);
								foreach (Item item in eable)
								{
									if (item is BaseBoat && ((BaseBoat)item).Contains(m) && (((BaseBoat)item).PPlank.IsOpen || ((BaseBoat)item).SPlank.IsOpen) && !((BaseBoat)item).Contains(m_Mobile))
									{
										if (((BaseBoat)item).PPlank.IsOpen)
											((BaseBoat)item).PPlank.OnDoubleClick(m_Mobile);
										else
											((BaseBoat)item).SPlank.OnDoubleClick(m_Mobile);
									}
								}

								m_Path = new PathFollower(m_Mobile, m);
								m_Path.Mover = new MoveMethod(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;
		}
Exemplo n.º 4
0
		public bool MoveTo(Point3D px, bool run, int range)
		{
			Direction dirTo;

			dirTo = m_Mobile.GetDirectionTo(px);
			// Add the run flag
			if (run)
				dirTo = dirTo | Direction.Running;

			if (m_Mobile.InRange(px, range))
			{
				m_Mobile.Direction = dirTo; //make sure we point toward are enemy
				m_Path = null;
				return true;
			}

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

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

			return false;
		}
Exemplo n.º 5
0
		public virtual bool MoveToNavPoint(Point3D m, bool run)
		{
			if (m_Mobile.Deleted || m_Mobile.DisallowAllMoves || m == Point3D.Zero)
				return false;


			if (NavPath != null)
			{

				NavPath.Follow(run, 1);

			}

			else
			{

				NavPath = new PathFollower(m_Mobile, (IPoint3D)m);
				NavPath.Mover = new MoveMethod(DoMoveImpl);
				NavPath.Follow(run, 1);

			}

			return false;
		}
Exemplo n.º 6
0
		public virtual bool MoveToSound(Point3D m, bool run, int Range)
		{
			if (m_Mobile.Deleted || m_Mobile.DisallowAllMoves || m == Point3D.Zero)
				return false;

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

			if (m_Path != null && m_Path.Goal == (IPoint3D)m)
			{
				if (m_Path.Follow(run, Range))
				{
					m_Path = null;
					return true;
				}
			}

			else
			{
				m_Path = new PathFollower(m_Mobile, (IPoint3D)m);
				m_Path.Mover = new MoveMethod(DoMoveImpl);

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

			return false;
		}