Esempio n. 1
0
 /// <summary>
 ///   Adds the contents of another <see cref='Trajet'/> to the end of the collection.
 /// </summary>
 /// <param name='val'>
 ///    A <see cref='Trajet'/> containing the objects to add to the collection.
 /// </param>
 /// <seealso cref='Trajet.Add'/>
 public void AddRange(Trajet val)
 {
     for (int i = 0; i < val.Count; i++)
     {
         this.Add(val[i]);
     }
 }
Esempio n. 2
0
        public Coord ChooseTrajet()
        {
            if (FreeMovement)
            {
                return(null);
            }
            else
            {
                float mindist = float.MaxValue;
                Coord t       = null;
                //	int i;
                Trajet ts = World.trajets.Find((SpawnerLink as MobileSpawner).TrajetGuid);
                return(ts[0]);
            }

            /*
             * if ( SpawnerLink == null )
             * {
             *      float dist = float.MaxValue;
             *      foreach( BaseSpawner bs in World.allSpawners )
             *      {
             *              float xx = X - bs.X;
             *              float yy = Y - bs.Y;
             *              xx *= xx;
             *              yy *= yy;
             *              xx += yy;
             *              if ( xx < dist && bs.MapId == MapId )
             *              {
             *                      dist = xx;
             *                      SpawnerLink = bs;
             *              }
             *      }
             * }
             * return this.SpawnerLink.ChooseTrajet();*/
        }
        public PathForTaxi(int taxiPathId, Character ch)
        {
            int map = ch.MapId;

            mapChange = 0;
            ArrayList list = new ArrayList();

            foreach (TaxiPathNode tpn in Server.Taxi.TaxiPathNodesList)
            {
                if (tpn.TaxiPath == taxiPathId)
                {
                    if (map != tpn.MapId)
                    {
                        mapIds[mapChange].index = tpn.Index;
                        mapIds[mapChange].mapId = tpn.MapId;
                        mapChange++;
                        map = tpn.MapId;
                    }
                    list.Add(tpn);
                }
            }


            int num = list.Count;

            Coord []        coordinates = new Coord[num];
            TaxiPathNode [] tpnArray    = new TaxiPathNode[num];


            foreach (TaxiPathNode tpn in list)
            {
                tpnArray[tpn.Index] = tpn;
            }

            for (int i = 0; i < num; i++)
            {
                if (i == 0)
                {
                    coordinates[i] = new Coord(tpnArray[i].X, tpnArray[i].Y, tpnArray[i].Z, null, null);
                }
                else
                {
                    coordinates[i] = new Coord(tpnArray[i].X, tpnArray[i].Y, tpnArray[i].Z, coordinates[i - 1], null);
                }
            }

            t = new Trajet(coordinates);
        }
Esempio n. 4
0
        public PathForTaxi(int taxiPathId,Character ch)
        {
            int map = ch.MapId;
            mapChange = 0;
            ArrayList list = new ArrayList();
            foreach(TaxiPathNode tpn in Server.Taxi.TaxiPathNodesList)
            {
                if(tpn.TaxiPath == taxiPathId)
                {
                    if (map != tpn.MapId)
                    {
                        mapIds[mapChange].index = tpn.Index;
                        mapIds[mapChange].mapId = tpn.MapId;
                        mapChange++;
                        map = tpn.MapId;
                    }
                    list.Add(tpn);
                }
            }

            int num = list.Count;
            Coord []coordinates = new Coord[num];
            TaxiPathNode []tpnArray = new TaxiPathNode[num];

            foreach(TaxiPathNode tpn in list)
            {
                tpnArray[tpn.Index] = tpn;
            }

            for(int i = 0; i < num; i++)
            {

                if (i == 0)	coordinates[i] = new Coord( tpnArray[i].X,tpnArray[i].Y,tpnArray[i].Z,null,null);
                else coordinates[i] = new Coord( tpnArray[i].X,tpnArray[i].Y,tpnArray[i].Z,coordinates[i-1],null);
            }

            t = new Trajet(coordinates);
        }
Esempio n. 5
0
 /// <summary>
 ///   Initializes a new instance of <see cref='Trajet'/> based on another <see cref='Trajet'/>.
 /// </summary>
 /// <param name='val'>
 ///   A <see cref='Trajet'/> from which the contents are copied
 /// </param>
 public Trajet(Trajet val)
 {
     this.AddRange(val);
 }
Esempio n. 6
0
		public static void RemoveTrajet( Trajet t )
		{
			trajets.Remove( t );
		}
Esempio n. 7
0
 /// <summary>
 ///   Initializes a new instance of <see cref='Trajets'/> containing any array of <see cref='Trajet'/> objects.
 /// </summary>
 /// <param name='val'>
 ///       A array of <see cref='Trajet'/> objects with which to intialize the collection
 /// </param>
 public Trajets(Trajet[] val)
 {
     this.AddRange(val);
 }
Esempio n. 8
0
 /// <summary>
 ///   Inserts a <see cref='Trajet'/> into the <see cref='Trajets'/> at the specified index.
 /// </summary>
 /// <param name='index'>The zero-based index where <paramref name='val'/> should be inserted.</param>
 /// <param name='val'>The <see cref='Trajet'/> to insert.</param>
 /// <seealso cref='Trajets.Add'/>
 public void Insert(int index, Trajet val)
 {
     List.Insert(index, val);
 }
Esempio n. 9
0
 /// <summary>
 ///   Copies the <see cref='Trajets'/> values to a one-dimensional <see cref='Array'/> instance at the 
 ///    specified index.
 /// </summary>
 /// <param name='array'>The one-dimensional <see cref='Array'/> that is the destination of the values copied from <see cref='Trajets'/>.</param>
 /// <param name='index'>The index in <paramref name='array'/> where copying begins.</param>
 /// <exception cref='ArgumentException'>
 ///   <para><paramref name='array'/> is multidimensional.</para>
 ///   <para>-or-</para>
 ///   <para>The number of elements in the <see cref='Trajets'/> is greater than
 ///         the available space between <paramref name='arrayIndex'/> and the end of
 ///         <paramref name='array'/>.</para>
 /// </exception>
 /// <exception cref='ArgumentNullException'><paramref name='array'/> is <see langword='null'/>. </exception>
 /// <exception cref='ArgumentOutOfRangeException'><paramref name='arrayIndex'/> is less than <paramref name='array'/>'s lowbound. </exception>
 /// <seealso cref='Array'/>
 public void CopyTo(Trajet[] array, int index)
 {
     List.CopyTo(array, index);
 }
Esempio n. 10
0
 /// <summary>
 ///   Copies the elements of an array to the end of the <see cref='Trajets'/>.
 /// </summary>
 /// <param name='val'>
 ///    An array of type <see cref='Trajet'/> containing the objects to add to the collection.
 /// </param>
 /// <seealso cref='Trajets.Add'/>
 public void AddRange(Trajet[] val)
 {
     for (int i = 0; i < val.Length; i++)
     {
         this.Add(val[i]);
     }
 }
Esempio n. 11
0
 /// <summary>
 ///   Initializes a new instance of <see cref='CoordEnumerator'/>.
 /// </summary>
 public CoordEnumerator(Trajet mappings)
 {
     this.temp           = ((IEnumerable)(mappings));
     this.baseEnumerator = temp.GetEnumerator();
 }
Esempio n. 12
0
        public int Add(Coord val, Coord previous)
        {
            Coord left  = null;
            Coord right = null;

            Trajet where = null;
            float x = 0;
            float y = 0;
            float z = 0;

            if (previous != null)
            {
                foreach (Trajet t in World.trajets)
                {
                    try
                    {
                        Coord current = t[0];
                        bool  debut   = true;
                        while (!(!debut && current == t[0]) && current.next != null)
                        {
                            debut = false;
                            float x1 = current.x;
                            float y1 = current.y;
                            float x2 = current.next.x;
                            float y2 = current.next.y;
                            float x3 = val.x;
                            float y3 = val.y;
                            float x4 = previous.x;
                            float y4 = previous.y;
                            if (x1 == x2)
                            {
                                current = current.next;
                                continue;
                            }
                            float d1 = ((y1 - y2) * (x3 - x4) - (y3 - y4) * (x1 - x2));
                            if (d1 == 0)
                            {
                                current = current.next;
                                continue;
                            }
                            x = ((x3 * y4 - x4 * y3) *
                                 (x1 - x2) - (x1 * y2 - x2 * y1) * (x3 - x4))
                                / d1;
                            y = x * ((y1 - y2) / (x1 - x2))
                                + ((x1 * y2 - x2 * y1) / (x1 - x2));
                            float d1x  = x1 - x2;
                            float d1y  = y1 - y2;
                            float dist = d1x * d1x + d1y * d1y;
                            float dx1  = x1 - x;
                            float dx2  = x2 - x;
                            float dy1  = y1 - y;
                            float dy2  = y2 - y;
                            if ((dx1 == 0 && dy1 == 0) || (dx2 == 0 && dy2 == 0))
                            {
                                current = current.next;
                                continue;
                            }
                            dx1 *= dx1;
                            dy1 *= dy1;
                            dx2 *= dx2;
                            dy2 *= dy2;
                            if (dx1 + dy1 > dist)
                            {
                                current = current.next;
                                continue;
                            }
                            if (dx2 + dy2 > dist)
                            {
                                current = current.next;
                                continue;
                            }
                            float d2x = x3 - x4;
                            float d2y = y3 - y4;
                            dist = d2x * d2x + d2y * d2y;
                            float dx3 = x3 - x;
                            float dx4 = x4 - x;
                            float dy3 = y3 - y;
                            float dy4 = y4 - y;
                            if ((dx3 == 0 && dy3 == 0) || (dx4 == 0 && dy4 == 0))
                            {
                                current = current.next;
                                continue;
                            }
                            dx3 *= dx3;
                            dy3 *= dy3;
                            dx4 *= dx4;
                            dy4 *= dy4;
                            if (dx3 + dy3 > dist)
                            {
                                current = current.next;
                                continue;
                            }
                            if (dx4 + dy4 > dist)
                            {
                                current = current.next;
                                continue;
                            }
                            //calcul du Z
                            float z1 = current.z;
                            float z2 = current.next.z;
                            float z3 = val.z;
                            float z4 = previous.z;

                            /*	float x = ( ( x3 * z4 - x4 * z3 ) *
                             *              (x1 - x2) - (x1 * z2 - x2 * z1) * ( x3 - x4 ) )
                             *              / ( ( z1 - z2 ) * ( x3 - x4 ) - ( z3 - z4 ) * ( x1 - x2 ) );*/
                            z = x * ((z1 - z2) / (x1 - x2))
                                + ((x1 * z2 - x2 * z1) / (x1 - x2));

                            //	Console.WriteLine("Intersection en {0};{1};{2}", x, y, z );
                            left  = current;
                            right = current.next;
                            where = t;
                            break;
                        }
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("{0}", e.Message);
                    }
                    if (where != null)
                    {
                        break;
                    }
                }
                if (where != null)
                {
                    Intersection inter1 = new Intersection(
                        left,
                        right,
                        previous,
                        val,
                        x, y, z);
                    val.previous  = inter1;
                    previous.next = inter1;

                    List.Add(inter1);
                    Intersection inter2 = new Intersection(
                        previous,
                        val,
                        left,
                        right,
                        x, y, z);
                    left.next      = inter2;
                    right.previous = inter2;
                    where.Add(inter2);
                }
            }
            return(List.Add(val));
        }
Esempio n. 13
0
 /// <summary>
 ///   Initializes a new instance of <see cref='Trajet'/> based on another <see cref='Trajet'/>.
 /// </summary>
 /// <param name='val'>
 ///   A <see cref='Trajet'/> from which the contents are copied
 /// </param>
 public Trajet(Trajet val)
 {
     this.AddRange(val);
 }
Esempio n. 14
0
 /// <summary>
 ///   Initializes a new instance of <see cref='CoordEnumerator'/>.
 /// </summary>
 public CoordEnumerator(Trajet mappings)
 {
     this.temp = ((IEnumerable)(mappings));
     this.baseEnumerator = temp.GetEnumerator();
 }
Esempio n. 15
0
 /// <summary>
 ///   Removes a specific <see cref='Trajet'/> from the <see cref='Trajets'/>.
 /// </summary>
 /// <param name='val'>The <see cref='Trajet'/> to remove from the <see cref='Trajets'/>.</param>
 /// <exception cref='ArgumentException'><paramref name='val'/> is not found in the Collection.</exception>
 public void Remove(Trajet val)
 {
     List.Remove(val);
 }
Esempio n. 16
0
 /// <summary>
 ///   Adds a <see cref='Trajet'/> with the specified value to the 
 ///   <see cref='Trajets'/>.
 /// </summary>
 /// <param name='val'>The <see cref='Trajet'/> to add.</param>
 /// <returns>The index at which the new element was inserted.</returns>
 /// <seealso cref='Trajets.AddRange'/>
 public int Add(Trajet val)
 {
     return List.Add(val);
 }
Esempio n. 17
0
			public OnTaxiEndTimer( int delay,Character _ch,Trajet _t ) : base( WowTimer.Priorities.Milisec100 , delay, "OnTaxiEndTimer" )
			{
				ch = _ch;
				Start();
				t = _t;
			}
Esempio n. 18
0
 /// <summary>
 ///   Gets a value indicating whether the 
 ///    <see cref='Trajets'/> contains the specified <see cref='Trajet'/>.
 /// </summary>
 /// <param name='val'>The <see cref='Trajet'/> to locate.</param>
 /// <returns>
 /// <see langword='true'/> if the <see cref='Trajet'/> is contained in the collection; 
 ///   otherwise, <see langword='false'/>.
 /// </returns>
 /// <seealso cref='Trajets.IndexOf'/>
 public bool Contains(Trajet val)
 {
     return List.Contains(val);
 }
Esempio n. 19
0
		public void MoveTaxiTo( Trajet t,PathForTaxi.MapIds[] mapIds, int mapChange)
		{
			if (t.Count != 0)
			{
				if (mapChange == 0)
				{
					int offset = 4;
					float x = X - t[0].x;
					float y = Y - t[0].y;
					float z = Z - t[0].z;
					x *= x;
					y *= y;
					z *= z;
					x = (float)Math.Sqrt( x + y + z );
					float distTotale = x;
					for (int j = 0; j < t.Count - 1;j++)
					{
						x = t[j].x - t[j + 1].x;
						y = t[j].y - t[j + 1].y;
						z = t[j].z - t[j + 1].z;
						x *= x;
						y *= y;
						z *= z;
						distTotale += (float)Math.Sqrt( x + y + z );
					}
				
					float xd = (float)( distTotale / ( 37f / 1000 ) );
					int instantSpeed = (int)xd;
					byte []movePacket = new byte[ 60 + t.Count * 3 * 4 ];
					uint time = (uint)( DateTime.Now.Ticks - localTime );
					Converter.ToBytes( Guid, movePacket, ref offset );	
					Converter.ToBytes( (float)X, movePacket, ref offset );//	X
					Converter.ToBytes( (float)Y, movePacket, ref offset );//	Y
					Converter.ToBytes( (float)Z, movePacket, ref offset );//	Z			
					Converter.ToBytes( (float)this.Orientation, movePacket, ref offset );//	Z	
					Converter.ToBytes( (byte)0, movePacket, ref offset );//	Z	
			
					Converter.ToBytes( (uint)0x00000300, movePacket, ref offset );//	pas d'animation de mouvement, taxi node ?		
							
					Converter.ToBytes( (uint)instantSpeed, movePacket, ref offset );//	Z	
					Converter.ToBytes( (uint)distTotale, movePacket, ref offset );//	Z	
					foreach( Coord c in t )
					{
						Converter.ToBytes( (float)c.x, movePacket, ref offset );//	X
						Converter.ToBytes( (float)c.y, movePacket, ref offset );//	Y
						Converter.ToBytes( (float)c.z, movePacket, ref offset );//	Z
					}
					(this as Character).ToAllPlayerNear(  (OpCodes)0xDD, movePacket, offset );
					OnTaxiEndTimer onTaxiEndTimer = new OnTaxiEndTimer( instantSpeed,this as Character,t );
				}
				else
				{
					if (mapChange == 1 && mapIds[0].index == 0)
					{
						Coord cord = new Coord(this.X,this.Y,this.Z,null,null);
						Coord [] coords= new Coord[1];
						coords[0] = cord;
						Trajet t1 = new Trajet(coords);
						(this as Character).SendMessage("Not supported now");
						OnTaxiEndTimer onTaxiEndTimer1 = new OnTaxiEndTimer(0,this as Character,t1 );
						return;
						//(this as Character).Teleport(t[0].x,t[0].y,t[0].z,30);
						//t.RemoveAt(0);
						//this.MoveTaxiTo( t,mapIds, 0);	
					
					}
					int offset = 4;
					float x = X - t[0].x;
					float y = Y - t[0].y;
					float z = Z - t[0].z;
					x *= x;
					y *= y;
					z *= z;
					x = (float)Math.Sqrt( x + y + z );
					float distTotale = x;
					for (int j = 0; j < t.Count - 1;j++)
					{
						x = t[j].x - t[j + 1].x;
						y = t[j].y - t[j + 1].y;
						z = t[j].z - t[j + 1].z;
						x *= x;
						y *= y;
						z *= z;
						distTotale += (float)Math.Sqrt( x + y + z );
					}
				
					float xd = (float)( distTotale / ( 37f / 1000 ) );
					int instantSpeed = (int)xd;
					byte []movePacket = new byte[ 60 + t.Count * 3 * 4 ];
					uint time = (uint)( DateTime.Now.Ticks - localTime );
					Converter.ToBytes( Guid, movePacket, ref offset );	
					Converter.ToBytes( (float)X, movePacket, ref offset );//	X
					Converter.ToBytes( (float)Y, movePacket, ref offset );//	Y
					Converter.ToBytes( (float)Z, movePacket, ref offset );//	Z			
					Converter.ToBytes( (float)this.Orientation, movePacket, ref offset );//	Z	
					Converter.ToBytes( (byte)0, movePacket, ref offset );//	Z	
			
					Converter.ToBytes( (uint)0x00000300, movePacket, ref offset );//	pas d'animation de mouvement, taxi node ?		
							
					Converter.ToBytes( (uint)instantSpeed, movePacket, ref offset );//	Z	
					Converter.ToBytes( (uint)distTotale, movePacket, ref offset );//	Z	
					foreach( Coord c in t )
					{
						Converter.ToBytes( (float)c.x, movePacket, ref offset );//	X
						Converter.ToBytes( (float)c.y, movePacket, ref offset );//	Y
						Converter.ToBytes( (float)c.z, movePacket, ref offset );//	Z
					}
					(this as Character).ToAllPlayerNear(  (OpCodes)0xDD, movePacket, offset );
					OnTaxiEndTimer onTaxiEndTimer = new OnTaxiEndTimer( instantSpeed,this as Character,t );
				}
			}
			else
			{}
			
			//	Console.WriteLine( "Je vais mettre {0}", instantSpeed );
		}
Esempio n. 20
0
 /// <summary>
 ///    Returns the index of a <see cref='Trajet'/> in 
 ///       the <see cref='Trajets'/>.
 /// </summary>
 /// <param name='val'>The <see cref='Trajet'/> to locate.</param>
 /// <returns>
 ///   The index of the <see cref='Trajet'/> of <paramref name='val'/> in the 
 ///   <see cref='Trajets'/>, if found; otherwise, -1.
 /// </returns>
 /// <seealso cref='Trajets.Contains'/>
 public int IndexOf(Trajet val)
 {
     return List.IndexOf(val);
 }
Esempio n. 21
0
 public static void OnUnmountTaxi(Character ch,Trajet t)
 {
     ch.MountModel = (int)0;
     ch.taxiOn = false;
     ch.Copper =(uint)(ch.Copper - ch.TaxiPrice);
     if(ch.Summon != null) ch.Summon.Freeze = false;
     int offset = 4;
     ch.Speed = 8f;
     ch.RunSpeed = 7f;
     Converter.ToBytes( 1, ch.tempBuff, ref offset );
     Converter.ToBytes( (byte)0, ch.tempBuff, ref offset );
     ch.PrepareUpdateData( ch.tempBuff, ref offset , UpdateType.UpdateFull, false );
     ch.Send( OpCodes.SMSG_UPDATE_OBJECT, ch.tempBuff, offset );
     ch.ItemsUpdate();
     ch.ForcePosition(t[t.Count - 1].x,t[t.Count - 1].y,t[t.Count - 1].z,ch.Orientation);
 }
Esempio n. 22
0
 /// <summary>
 ///   Removes a specific <see cref='Trajet'/> from the <see cref='Trajets'/>.
 /// </summary>
 /// <param name='val'>The <see cref='Trajet'/> to remove from the <see cref='Trajets'/>.</param>
 /// <exception cref='ArgumentException'><paramref name='val'/> is not found in the Collection.</exception>
 public void Remove(Trajet val)
 {
     List.Remove(val);
 }
Esempio n. 23
0
 /// <summary>
 ///   Adds a <see cref='Trajet'/> with the specified value to the
 ///   <see cref='Trajets'/>.
 /// </summary>
 /// <param name='val'>The <see cref='Trajet'/> to add.</param>
 /// <returns>The index at which the new element was inserted.</returns>
 /// <seealso cref='Trajets.AddRange'/>
 public int Add(Trajet val)
 {
     return(List.Add(val));
 }
Esempio n. 24
0
 /// <summary>
 ///   Gets a value indicating whether the
 ///    <see cref='Trajets'/> contains the specified <see cref='Trajet'/>.
 /// </summary>
 /// <param name='val'>The <see cref='Trajet'/> to locate.</param>
 /// <returns>
 /// <see langword='true'/> if the <see cref='Trajet'/> is contained in the collection;
 ///   otherwise, <see langword='false'/>.
 /// </returns>
 /// <seealso cref='Trajets.IndexOf'/>
 public bool Contains(Trajet val)
 {
     return(List.Contains(val));
 }
Esempio n. 25
0
 /// <summary>
 ///    Returns the index of a <see cref='Trajet'/> in
 ///       the <see cref='Trajets'/>.
 /// </summary>
 /// <param name='val'>The <see cref='Trajet'/> to locate.</param>
 /// <returns>
 ///   The index of the <see cref='Trajet'/> of <paramref name='val'/> in the
 ///   <see cref='Trajets'/>, if found; otherwise, -1.
 /// </returns>
 /// <seealso cref='Trajets.Contains'/>
 public int IndexOf(Trajet val)
 {
     return(List.IndexOf(val));
 }
Esempio n. 26
0
		public static Trajet AllocateTrajet()
		{
			Trajet t = new Trajet();
			trajets.Add( t );
			return t;
		}
Esempio n. 27
0
 /// <summary>
 ///   Inserts a <see cref='Trajet'/> into the <see cref='Trajets'/> at the specified index.
 /// </summary>
 /// <param name='index'>The zero-based index where <paramref name='val'/> should be inserted.</param>
 /// <param name='val'>The <see cref='Trajet'/> to insert.</param>
 /// <seealso cref='Trajets.Add'/>
 public void Insert(int index, Trajet val)
 {
     List.Insert(index, val);
 }
Esempio n. 28
0
		void OnCommand( string cmd )
		{
			if ( Player.AccessLevel == AccessLevels.PlayerLevel )
			{
				string lower = cmd.ToLower();
				if ( lower.StartsWith( ".help" ) )
				{
					SendMessage( "Command lists" );
					SendMessage( ".whois" );
					SendMessage( ".mount" );
					SendMessage( ".unmount" );
				}
				else
					if ( lower.StartsWith( ".whois" ) )
				{					
					foreach( Account a in World.allConnectedAccounts )
					{
						if ( a.SelectedChar != null )
							SendMessage( a.SelectedChar.Name + " is online at ( " + a.SelectedChar.X.ToString() + "; " + a.SelectedChar.Y.ToString() + "; "+ a.SelectedChar.Z.ToString() + ") " );
					}
					SendMessage( "User online : " + World.allConnectedAccounts.Count.ToString() );
				}
				else
					if ( lower.StartsWith( ".mount" ) )
				{
					if ( selection != null && selection is Mobile )
					{
						if ( World.MountsList[ ( selection as Mobile ).Id ] != null )
							Mount( selection as Mobile );
					}
				}
				else
					if ( lower.StartsWith( ".unmount" ) )
				{
					if ( this.MountModel != 0 )
						UnMount();
				}				
			}
			else			
			if ( Player.AccessLevel == AccessLevels.Admin )
			{
				string lower = cmd.ToLower();
				if ( lower.StartsWith( ".importspawner" ) )
				{
					ImportSpawner();
				}
				else
					if ( lower.StartsWith( ".exportspawner" ) )
				{
					ExportSpawner();
				}
				else
					if ( lower.StartsWith( ".import" ) )
				{
					ImportWad();
				}
				else
					if ( lower.StartsWith( ".help" ) )
				{
					SendMessage( "Command lists" );
					SendMessage( ".help" );
					SendMessage( ".Addnpc [MobName|MobId] [amount] [faction]" );
					SendMessage( ".AddItem ItemName [amount]" );
					SendMessage( ".Addgo GameObjectNumber" );
					SendMessage( ".AddSpawner [MobName|MobId] amount frequency" );
					SendMessage( ".AddGoSpawner GameObjectId frequency [classname]" );
					SendMessage( ".kill" );
					SendMessage( ".nuke" );
					SendMessage( ".info" );
					SendMessage( ".where" );
					SendMessage( ".remove" );
					SendMessage( ".set xp Amount" );
					SendMessage( ".set faction FactionNumber" );
					SendMessage( ".set godmode [on/off]" );
					SendMessage( ".set turbo [on/off]" );
					SendMessage( ".password NewPassword" );
					SendMessage( ".grant [account|selected char] AccessLevel" );
					SendMessage( ".go LocationName | [ X Y Z MapId ]" );
					SendMessage( ".addlocation LocationName" );
					SendMessage( ".restart XMinutes" );
					SendMessage( ".whois" );
					SendMessage( ".broadcast Message" );
					SendMessage( ".hide" );
					SendMessage( ".unhide" );
					SendMessage( ".docgen" );
					SendMessage( ".removego" );
					SendMessage( ".armagedon" );
					SendMessage( ".mount" );
					SendMessage( ".unmount" );
				}
				else
					if ( lower.StartsWith( ".mount" ) )
				{
					if ( selection != null && selection is Mobile )
					{
						if ( World.MountsList[ ( selection as Mobile ).Id ] != null )
							Mount( selection as Mobile );

					}
				}
				else
					if ( lower.StartsWith( ".test" ) )
				{
					string []tt = cmd.Split( new char[]{ ' ' } );
					if ( tt.Length != 3 )
					{
						SendMessage( "Usage : .test MobName1 MobName2" );
						return;
					}
					if ( testCombatStarted )
					{
						SendMessage( "A fight test is not finished yet !!" );
						return;
					}
					//tt[ 1 ] = "SilverwingWarrior";
					//tt[ 2 ] = "RazorHillGrunt";
					ConstructorInfo ct1 = Utility.FindConstructor( tt[ 1 ] , Utility.externAsm[ "creatures" ] );
					ConstructorInfo ct2 = Utility.FindConstructor( tt[ 2 ] , Utility.externAsm[ "creatures" ] );
					
					testCombatStarted = true;
					
					for(int t = 0;t < 50;t++ )
					{
						BaseCreature bc = (BaseCreature)ct1.Invoke( null );	
						bc.Faction = Factions.Alliance;
						World.Add( bc, -13210f + (float)( Utility.Random( 50 ) - 25 ), 267.6f+ (float)( Utility.Random( 50 ) - 25 ), 22f, 0 );
						team1.Add( bc );
						bc = (BaseCreature)ct2.Invoke( null );	
						bc.Faction = Factions.Horde;
						World.Add( bc, -13210f + (float)( Utility.Random( 50 ) - 25 ), 287.6f+ (float)( Utility.Random( 50 ) - 25 ), 22f, 0 );
						team2.Add( bc );
					}
					MobBalance mb = new MobBalance( this );

					
				}
				else
					if ( lower.StartsWith( ".." ) )
				{
					string []ss = lower.Split( new char[] { ' ' } );
					ff = (uint)Convert.ToInt32( ss[ 1 ] );
					SendMessage("num = " + ff.ToString("X8" ));
					/*	if ( selection is Mobile )
							( selection as Mobile ).SendSmallUpdateToPlayerNearMe( new int[] { (int)UpdateFields.UNIT_DYNAMIC_FLAGS }, new object[] { ff } );
					*/
					SendSmallUpdate( new int[]{ (int)UpdateFields.UNIT_FIELD_FACTIONTEMPLATE }, new object[]{ ff } );				
				}
				else
					if ( lower.StartsWith( ".close" ) )
				{
					MainConsole.StopAllThread();
				}
				else
					if ( lower.StartsWith( ".mars" ) )
				{/*
					

					Hashtable hy = null;
					hy = World.mapZones.GetZoneHash( MapId, ZoneId, X, Y );//(Hashtable)World.mapZones.Azeroth[  MapId * 1024 + ZoneId ];
					for(float x = X - 16;x < X + 16;x+=MapZones.UNITSIZE )
					{
						for(float y = Y - 16;y < Y + 16;y++ )
						{
							int coordy = (int)( y / ( MapZones.UNITSIZE * 0.5f ) );
							int coordx = (int)( x / MapZones.UNITSIZE );
							bool decal = false;;
							if ( (int)( coordy & 1  ) == 1 )
							{
								decal = true;
								coordx -= (int)( MapZones.UNITSIZE * 0.5f );							
							}
							uint cx = (uint)( coordx + 0x8000 );
							uint cy = (uint)( coordy + 0x8000 );
							object o = hy[ (uint)( ( coordx << 16 ) + coordy ) ];
							if ( o != null )
							{
								float xx = (float)coordx * ( MapZones.UNITSIZE );
								float yy = (float)coordy * MapZones.UNITSIZE * 0.5f;
								if ( decal )
								{
									xx += MapZones.UNITSIZE * 0.5f;
								}
								GameObject go = World.Add( 621682, xx, yy, (float)o, MapId );
								World.allSpawners[ linkedSpawner ].Bind( go );								
							}
						}
					}
					account.RefreshMobileList( true );*/


					MapPoint mp = World.mapZones.NearestPoint( null, MapId, ZoneId, X, Y );
					SendMessage( "X=" + mp.x.ToString() + " Y=" + mp.y.ToString() );
					GameObject go = World.Add( 621682, mp.x , mp.y, mp.z, 0, MapId );
					World.allSpawners[ linkedSpawner ].Bind( go );	
					account.RefreshMobileList( true );
					//MainConsole.StopAllThread();
					//	Mobile.GetDirection( this, selection as Mobile );
					//		return;
					//	p.Kill();
					//for(float xxa = X - 10;xxa < 
					//string []ss = lower.Split( new char[] { ' ' } );
					//uint xff = (uint)Convert.ToUInt32( ss[ 1 ] );

					//	Items[ 24 ].SendSmallUpdate( new int[]{ (int)UpdateFields.ITEM_FIELD_FLAGS }, new object[]{ xff }, this );				
					
					/*
				Converter.ToBytes( cast.id, tempBuff, ref offset );
				Converter.ToBytes( (byte)1, tempBuff, ref offset );
				ToAllPlayerNear( OpCodes.SMSG_CAST_RESULT, tempBuff, offset );
				offset = 4;*/
					/*Converter.ToBytes( 6, tempBuff, ref offset );
					Converter.ToBytes( (byte)2, tempBuff, ref offset );
					Converter.ToBytes( (byte)xff, tempBuff, ref offset );
					Converter.ToBytes( msg, tempBuff, ref offset );
					ToAllPlayerNear( OpCodes.SMSG_CAST_RESULT, tempBuff, offset );*/
					cast.id = 8613;
					cast.type = 2;
					
					//SpellFaillure( ( SpellFailedReason )xff );
					/*		int ff2 = (int)Convert.ToInt32( ss[ 2 ] );
							SendMessage("num = " + xff.ToString("X8" ));
					
							int offset = 4;
							Converter.ToBytes( 1, tempBuff, ref offset );
							Converter.ToBytes( xff, tempBuff, ref offset );
							Converter.ToBytes( ff2, tempBuff, ref offset );
							if ( selection is Mobile )
								this.Send( OpCodes.SMSG_SET_FACTION_STANDING, tempBuff, offset );
						*/		
					//	ReputationAdjustments[ World.FactionAssociated[ Factions.Stormwind ] ] = (int)xff;
					//	this.Player.RefreshFactionReactions();
					//	( selection as Mobile ).SendSmallUpdateToPlayerNearMe( new int[] { (int)UpdateFields.UNIT_FIELD_FLAGS }, new object[] { ff } );
					
				}
				else
					if ( lower.StartsWith( ".mare" ) )
				{
					/*	if ( selection ==null )
							return;
						string []ss = lower.Split( new char[] { ' ' } );
						int ff1 = Convert.ToInt32( ss[ 1 ] );
				//		int ff2 = Convert.ToInt32( ss[ 2 ] );
						SendMessage("num = " + ff1.ToString("X8" ));
						int offset = 4;
						Converter.ToBytes( selection.Guid, tempBuff, ref offset );
						Converter.ToBytes( ff1, tempBuff, ref offset );
						this.Send( OpCodes.SMSG_AI_REACTION, tempBuff, offset );
						return;*/
					/*	if ( selection is Mobile )
							( selection as Mobile ).SendSmallUpdateToPlayerNearMe( new int[] { (int)UpdateFields.PLAYER_FLAGS }, new object[] { ff } );
					*/
					/*	for(int z = 0;z < 32;z++ )
							zones[ z ] = 0;
						for(int z = 0; z < 32 * 32;z++)
						{
							if ( z >= ff1 && z < ff2 )
							{
								int e = z % 32;
								int n = ( z / 32 );
								zones[ n ] |= (uint)( 1 << ( e ) );
							}
						}
						for(int z = 0;z < 32;z++ )
						{
							this.SendSmallUpdate( new int[] { (int)UpdateFields.PLAYER_EXPLORED_ZONES_1 + z }, new object[] { zones[ z ] } );	
						}*/
				}
				else
					if ( lower.StartsWith( ".marb" ) )
				{
					string []ss = lower.Split( new char[] { ' ' } );
					ff = (uint)Convert.ToInt32( ss[ 1 ] );
					SendMessage("num = " + ff.ToString("X8" ));
					if ( selection is Mobile )
						( selection as Mobile ).SendSmallUpdateToPlayerNearMe( new int[] { (int)UpdateFields.PLAYER_FIELD_BYTES }, new object[] { ff } );
					
				}
				else
					if ( lower.StartsWith( ".marf" ) )
				{
					string []ss = lower.Split( new char[] { ' ' } );
					ff = (uint)Convert.ToInt32( ss[ 1 ] );
					SendMessage("num = " + ff.ToString("X8" ));
					if ( selection is Mobile )
						( selection as Mobile ).SendSmallUpdateToPlayerNearMe( new int[] { (int)UpdateFields.UNIT_NPC_FLAGS }, new object[] { ff } );
					
				}
					/*else
					if ( lower.StartsWith( ".s" ) )
					{
						string []ss = lower.Split( new char[] { ' ' } );
						SpellFaillure( (Server.SpellFailedReason)Convert.ToInt32( ss[ 1 ] ) );
					}*/
					/*	else
								if ( lower.StartsWith( ".s" ) )
							{
								string []ss = lower.Split( new char[] { ' ' } );
								if ( ss.Length > 1 )
									ff |= (uint)( 1 << Convert.ToInt32( ss[ 1 ] ) );
								if ( selection is Character )
									( selection as Character ).SendSmallUpdateToPlayerNearMe( new int[] { (int)UpdateFields.UNIT_FIELD_FLAGS }, new object[] { ff } );
								else
									( selection as Mobile ).SendSmallUpdateToPlayerNearMe( new int[] { (int)UpdateFields.UNIT_FIELD_FLAGS }, new object[] { ff } );
								Console.WriteLine("rage = {0}", ff.ToString("X8" ));
							}	
							else
							if ( lower.StartsWith( ".u" ) )
							{
								string []ss = lower.Split( new char[] { ' ' } );
								if ( ss.Length > 1 )
									ff &= (uint)0xffffffff ^ (uint)( 1 << Convert.ToInt32( ss[ 1 ] ) );
								if ( selection is Character )
									( selection as Character ).SendSmallUpdateToPlayerNearMe( new int[] { (int)UpdateFields.UNIT_FIELD_FLAGS }, new object[] { ff } );
								else
									( selection as Mobile ).SendSmallUpdateToPlayerNearMe( new int[] { (int)UpdateFields.UNIT_FIELD_FLAGS }, new object[] { ff } );
					
								Console.WriteLine("rage = {0}", ff.ToString("X8" ));
							}		*/				
					
				else
					if ( lower.StartsWith( ".unmount" ) )
				{
					if ( this.MountModel != 0 )
						UnMount();
				}	
				else
					if ( lower.StartsWith( ".set faction" ) )
				{
					string []tt = cmd.Split( new char[]{ ' ' } );
					if ( selection is Mobile )
					{
						if ( tt.Length == 3 )
						{
							int fac = Convert.ToInt32( tt[ 2 ] );
							( selection as Mobile ).SendSmallUpdateToPlayerNearMe( new int[]{ (int)UpdateFields.UNIT_FIELD_FACTIONTEMPLATE }, new object[]{ (int)fac } );
						}
						else
							SendMessage("Usage : .set faction FACTION_NUMBER" );
					}
					else
						SendMessage("You must select a mobile first !" );

				}	
					
				else
					if ( lower.StartsWith( ".removego" ) )
				{					
					Object nearest = null;
					float nearestdist = float.MaxValue;
					foreach( Object o in World.allGameObjects )
					{
						float dist = Distance( o );
						if ( dist < nearestdist )
						{
							nearestdist = dist;
							nearest = o;
						}
					}
					if ( nearest != null )
						World.Remove( nearest, this );
				}
				else
					if ( lower.StartsWith( ".docgen" ) )
				{		
					SendMessage("Documentation is being generated, please wait.");
					Console.WriteLine( "Documentation is being generated, please wait." );
					DateTime startTime = DateTime.Now;
					Docs.Document();
					DateTime endTime = DateTime.Now;
					Console.WriteLine("Documentation has been completed. The entire process took {0:F1} seconds.", (endTime - startTime).TotalSeconds );
					SendMessage("Documentation has been completed. The entire process took " + (endTime - startTime).TotalSeconds.ToString( "F1" ) + " seconds." );
					return;
				}
				else
					if ( lower == ".hide" )
				{					
					this.Visible = InvisibilityLevel.GM;
					AuraEffect st = gmInvisibilityAura;
					Aura aura = new Aura();
					aura.OnRelease = new Aura.AuraReleaseDelegate( OnGMInvisibilityEnded );
					AddAura( st, aura );
				}
				else
					if ( lower.StartsWith( ".unhide" ) )
				{					
					this.Visible = InvisibilityLevel.Visible;
					this.ReleaseAura( gmInvisibilityAura );
				}
				else
					if ( lower.StartsWith( ".whois" ) )
				{					
					foreach( Account a in World.allConnectedAccounts )
					{
						if ( a.SelectedChar != null )
							SendMessage( a.Username.ToString() + " : " + a.SelectedChar.Name + " is online at ( " + a.SelectedChar.X.ToString() + "; " + a.SelectedChar.Y.ToString() + "; "+ a.SelectedChar.Z.ToString() + ") " );
						else
							SendMessage( a.Username.ToString() + " : [loggout]" );
					}
					SendMessage( "User online : " + World.allConnectedAccounts.Count.ToString() );
				}
				else
					if ( lower.StartsWith( ".broadcast " ) )
				{
					string tt = cmd.Remove( 0, 11 );
					foreach( Account a in World.allConnectedAccounts )
					{
						if ( a.SelectedChar != null )
							SendMessage( a.Username.ToString() + ", " + tt );
					}						
				}
				else
					if ( lower.StartsWith( ".restart " ) )
				{
					string []tt = cmd.Split( new char[]{ ' ' } );
					if ( tt.Length == 2 )
					{
						World.Restart( Convert.ToInt32( tt[ 1 ] ) );
					}
					else
						SendMessage( "Usage : .restart minutes" );
				}
				else
					if ( lower.StartsWith( ".addlocation " ) )
				{
					string []tt = cmd.Split( new char[]{ ' ' } );
					if ( tt.Length == 2 )
					{
						TextReader tr = new StreamReader( "./scripts/Globals/Locations.cs" );
						string txt = tr.ReadToEnd();
						tr.Close();
						TextWriter tw = new StreamWriter( "./scripts/Globals/Locations.cs" );
						int i = txt.IndexOf( "#region Locations" );
						string ne = "\t\t\tWorld.Locations[ \"" + tt[ 1 ] + "\" ] = new Position( " + X.ToString() + "f, " + Y.ToString() + "f, " + Z.ToString() + "f, 0 );" + tw.NewLine;
						tw.Write( txt.Substring( 0, i + "#region Locations".Length ) );
						tw.Write( tw.NewLine + ne );
						tw.Write( txt.Substring( i + "#region Locations".Length ) );
						//	txt.Insert( i + "#region Locations".Length + 2, ne );
						//	tw.Write( txt );
						tw.Close();
						SendMessage( "Done : " + ne );
					}
					else
						SendMessage( "Usage : .addlocation LocationName" );
				}
				else
					if ( lower.StartsWith( ".zone" ) )
				{
					string []tt = cmd.Split( new char[]{ ' ' } );
					this.ZoneUpdateRequested( Convert.ToInt32( tt[ 1 ] ) );
				}
				else
					if ( lower.StartsWith( ".grant " ) )
				{
					string acclevel = lower.Remove( 0, 7 );
					string []tt = acclevel.Split( new char[]{ ' ' } );
					Account acc = null;
					if ( tt.Length == 1 )
					{
						if ( selection is Character )
						{
							acclevel = tt[ 0 ];
							acc = ( selection as Character ).Player;
						}
						else
						{
							SendMessage( "Can only be used on character" );
							return;
						}
					}
					else
					{
						if ( tt.Length > 2 || tt.Length == 0 )
						{
							SendMessage( "Usage : .grant [Account] AccessLevel" );
							return;
						}
						acclevel = tt[ 1 ];
						acc = World.allAccounts.FindByUserName( tt[ 0 ].ToUpper() );
						if ( acc == null )
						{
							SendMessage( tt[ 0 ] + " account not found !" );
							return;
						}
					}
					if ( acclevel == "admin" )
					{
						SendMessage( "The account " + acc.Username + " is now an administrator" );
						acc.AccessLevel = AccessLevels.Admin;
					}
					else
						if ( acclevel == "gm" )
					{
						SendMessage( "The account " + acc.Username + " is now a game master" );
						acc.AccessLevel = AccessLevels.GM;
					}
					else
						if ( acclevel == "player" )
					{
						SendMessage( "The account " + acc.Username + " have now player access level" );
						acc.AccessLevel = AccessLevels.PlayerLevel;
					}
					else
						SendMessage( acclevel + " is not a valid access level !" );					
				}
				else
					if ( lower.StartsWith( ".password " ) )
				{
					string []tt = cmd.Split( new char[]{ ' ' } );
					if ( tt.Length < 2 )
					{
						SendMessage( "Usage : .password NewPassword" );
						return;
					}
					Player.Password = tt[ 1 ];
					SendMessage( "Your new password is : " + tt[ 1 ] );
					SendMessage( "Don't forget it !" );
				}
				else
					if ( lower.StartsWith( ".info" ) )
				{
					if ( selection != null )
					{
						string ret = "";
						if ( selection is BaseSpawner )
						{
							( selection as BaseSpawner ).DisplayInfo( this );
							//		ret += "Spawner for " + ( selection as BaseSpawner ).Name;
							//		SendMessage( ret );
							return;
						}
						else
							if ( selection is Character )
							ret += "Player : ";
						else
							if ( ( selection as Mobile ).SummonedBy != null )
							ret += "Summoned creature : ";
						else							
							ret += "Creature : ";
						Mobile mob = ( selection as Mobile );
						ret += mob.Name + " Faction : " + mob.Faction.ToString();
						SendMessage( ret );
						ret = "Pos : " + mob.X.ToString() + ", " + mob.Y.ToString() + ", " + selection.Z.ToString() + ", " + selection.MapId.ToString();
						SendMessage( ret );
						ret = "HitPoints : " + mob.HitPoints.ToString() + " / " + mob.BaseHitPoints.ToString();
						SendMessage( ret );
						ret = "Mana : " + mob.Mana.ToString() + " / " + mob.BaseMana.ToString();
						SendMessage( ret );
						ret = "Level : " + mob.Level.ToString() + " / " + mob.Exp.ToString() + " Xp";
						SendMessage( ret );
					}
					else
						SendMessage( "You must select a mobile before" );
				}
				else
					if ( lower.StartsWith( ".kill" ) )
				{
					if ( selection != null && selection is Mobile )
					{
						( selection as Mobile ).LooseHits( this, ( selection as Mobile ).HitPoints, true );
					}
				}
				else
					if ( lower.StartsWith( ".addgospawner" ) )
				{
					GameObjectSpawner bc = null;
					string []tt = cmd.Split( new char[]{ ' ' } );
					if ( tt.Length == 3 )
					{
						
						try
						{
							if ( Utility.FindConstructor( tt[ 1 ] ) != null )
							{
								ConstructorInfo cttest = Utility.FindConstructor( tt[ 1 ] );
								GameObject go = (GameObject)cttest.Invoke( null );
								if ( go.DefaultModel == 0 )
								{
									SendMessage( "This class does not implement the DefaultModel property !" );
									return;
								}
								bc = new GameObjectSpawner();
								bc.Init( tt[ 1 ], Convert.ToInt32( tt[ 2 ] ) );
								World.Add( bc, X, Y, Z, MapId );
							}
							else
							{
								bc = new GameObjectSpawner();
								int id = Convert.ToInt32( tt[ 1 ] );
								bc.Init( id, Convert.ToInt32( tt[ 2 ] ) );
								World.Add( bc, X, Y, Z, MapId );
							}



						}
						catch( Exception )
						{
						}
					}
					else
						if ( tt.Length == 4 )
					{
						try
						{
							bc = new GameObjectSpawner();
							int id = Convert.ToInt32( tt[ 1 ] );
							bc.Init( id, Convert.ToInt32( tt[ 2 ] ), tt[ 3 ] );
							World.Add( bc, X, Y, Z, MapId );
						}
						catch( Exception )
						{
						}
					}
					else
						SendMessage( "usage : .addgospawner gameobjectname frequency [gameobjectclass]" );
					if ( bc != null )//	Ajoute le spawner dans la liste des autres spawnpoints
					{
						if ( this.linkedSpawner == -1 )//	No spawner near the player
						{
								
						}
						else
						{
							int num = World.allSpawners.Count - 1;
							ArrayList al = new ArrayList();
							World.regSpawners[ num ] = al;
							for(int t = 0;t < num;t++ )
							{
								BaseSpawner bs2 = World.allSpawners[ t ] as BaseSpawner;
								if ( bc.MapId != bs2.MapId )
									continue;
								if ( bc.QuickDistance( bs2 ) < 150 * 150 )
									al.Add( t );
							}
								
							foreach( int i in al )
							{
								( World.regSpawners[ i ] as ArrayList ).Add( num );
							}
						}
					}
				}
				else
					if ( lower.StartsWith( ".armagedon" ) )
				{
					MobileList newMobs = new MobileList();
					int n = 0;
					foreach( Mobile m in World.allMobiles )
						if ( m is Character )
						{
							newMobs.Add( m );
						}
						else
							n++;
					n += World.allSpawners.Count;
					LinkedSpawner = -1;
					World.allSpawners.Clear();
					World.allMobiles = newMobs;
					Player.RefreshMobileList( true );
					SendMessage( n.ToString() + " mobs/spawners removed !" );
				}					
				else
					if ( lower.StartsWith( ".nuke" ) )
				{
					MobileList newMobs = new MobileList();
					int n = 0;
					foreach( Mobile m in World.allMobiles )
						if ( m is Character )//|| m is BaseSpawner )
						{
							newMobs.Add( m );
						}
						else
							n++;

					World.allSpawners.Clear();
					World.allMobiles = newMobs;
					SendMessage( n.ToString() + " mobs removed !" );
					
				}
				else
					if ( lower.StartsWith( ".set godmode on" ) )
				{
					if ( selection != null && selection is Mobile )
					{
						( selection as Mobile ).GodMode = true;
					}
					else
						GodMode = true;
				}
				else
					if ( lower.StartsWith( ".set godmode off" ) )
				{
					if ( selection != null && selection is Mobile )
					{
						( selection as Mobile ).GodMode = false;
					}
					else
						GodMode = false;
				}
				else
					if ( lower.StartsWith( ".set turbo on" ) )
				{
					RunSpeed = 40f;
					this.ChangeRunSpeed( 40f );
				}
				else
					if ( lower.StartsWith( ".set turbo off" ) )
				{
					RunSpeed = 7f;
					this.ChangeRunSpeed( 7f );
					/*
						int offset = 4;
						Converter.ToBytes( 1, tempBuff, ref offset );
						Converter.ToBytes( (byte)0, tempBuff, ref offset );
						WalkSpeed = 4.777f;
						RunSpeed = 7f;
						this.PrepareUpdateData( tempBuff, ref offset , UpdateType.UpdateFull, false );
						this.Send( OpCodes.SMSG_UPDATE_OBJECT, tempBuff, offset );*/
				}
				else
					if ( lower.StartsWith( ".guid" ) )
				{
					if ( selection == null )
						SendMessage( "Guid : " + Guid.ToString( "X16" ) );
					else
						SendMessage( "Guid : " + selection.Guid.ToString( "X16" ) );
						
				}
				else
					if ( lower.StartsWith( ".addspawner" ) )
				{
					string []tt = cmd.Split( new char[]{ ' ' } );
					if ( tt.Length == 4 )
					{
						ConstructorInfo ct = null;
						try
						{
							MobileSpawner bc = new MobileSpawner();

							try
							{
								int mid = (int)Convert.ToInt32( tt[ 1 ] );
								ct = World.MobilePool( mid );
							}
							catch(Exception)
							{
								ct = Utility.FindConstructor( tt[ 1 ], Utility.externAsm[ "creatures" ] );
								if ( ct == null )
									ct = Utility.FindConstructor( tt[ 1 ] );
							}

							BaseCreature b = (BaseCreature)ct.Invoke( null );
							float rec = float.MaxValue;
							foreach( BaseSpawner bs in World.allSpawners )
							{
								float xx = X - bs.X;
								float yy = Y - bs.Y;
								xx *= xx;
								yy *= yy;
								xx += xx;
								if ( xx < rec && bs.MapId == MapId )
								{
									rec = xx;
									bc.ZoneId = bs.ZoneId;
									bc.MapId = bs.MapId;
								}
							}
							//MapPoint mp = World.mapZones.NearestPoint( bc.MapId, bc.ZoneId, X, Y );
							bc.RealX = X;
							bc.RealY = Y;
							bc.RealZ = Z;
							bc.Model = b.Model;
							bc.Id = 99999999 - b.Id;
							bc.Orientation = Orientation;							
							bc.Init( ct, b.Id, Convert.ToInt32( tt[ 3 ] ), Convert.ToInt32( tt[ 2 ] ) );
							World.Add( bc, X, Y, Z, MapId );
							if ( this.linkedSpawner == -1 )//	No spawner near the player
							{
								
							}
							else
							{
								int num = World.allSpawners.Count - 1;
								ArrayList al = new ArrayList();
								World.regSpawners[ num ] = al;
								for(int t = 0;t < num;t++ )
								{
									BaseSpawner bs2 = World.allSpawners[ t ] as BaseSpawner;
									if ( bc.MapId != bs2.MapId )
										continue;
									if ( bc.QuickDistance( bs2 ) < 150 * 150 )
										al.Add( t );
								}
								
								foreach( int i in al )
								{
									( World.regSpawners[ i ] as ArrayList ).Add( num );
								}
							}

							bc.ForceRespawn();
							Player.RefreshMobileList( true );
						}
						catch( Exception )
						{
						}
					}
					else
						SendMessage( "usage : .addspawner mobname amount frequency" );
				}
				else
					if ( lower.StartsWith( ".set xp" ) )
				{
					string []tt = cmd.Split( new char[]{ ' ' } );
					if ( tt.Length == 3 )
					{
						Character c = selection as Character;
						if ( c == null )
							c = this;
						try 
						{
							uint a = Convert.ToUInt32( tt[ 2 ] ) - c.Exp;
							c.EarnXP( (int)a );
						}
						catch( Exception )
						{
							this.SendMessage( "usage : .set xp amount" );
						}
					}
				}
				else
					if ( lower.StartsWith( ".debug" ) )
				{
					if ( selection != null )
					{
						if ( selection is BaseCreature )
						{
							BaseCreature bc = selection as BaseCreature;
							if ( bc.DebugSniffer != null )
							{
								bc.DebugSniffer = null;
								SendMessage( "Debug Off" );
								return;
							}
							else
							{
								bc.DebugSniffer = this;
								SendMessage( "Debug On" );
							}
						}
					}
				}
					#region TRAJETS !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
				else
					if ( lower.StartsWith( ".hidepath" ) )
				{
					ArrayList toRemove = new ArrayList();
					foreach( GameObject go in World.allGameObjects )
						if ( go.Id >= 621680 && go.Id <= 621683 )
							toRemove.Add( go );
					foreach( GameObject go in toRemove )
						World.allGameObjects.Remove( go );
					this.account.RefreshMobileList( true );
				}
				else
					if ( lower.StartsWith( ".showpath" ) )
				{
					foreach( Trajet tr in World.trajets )
					{
						bool start = true;
						foreach( Coord c in tr )
						{
							GameObject go;
							if ( Distance( c.x, c.y, c.z ) < 400 * 400 )
							{
								if ( c is Intersection )
								{
									go = World.Add( 621682, c.x, c.y, c.z, MapId );
								}
								else
								{					
									if ( start )
										go = World.Add( 621681, c.x, c.y, c.z, MapId );							
									else
										go = World.Add( 621680, c.x, c.y, c.z, MapId );							
								}
							}
							start = false;
						}
					}
					this.account.RefreshMobileList( true );
				}
				else
					if ( lower.StartsWith( ".delpath" ) )
				{
					if ( startTrajetFlag != null )
						DestroyObject( startTrajetFlag.Guid );
					World.RemoveTrajet( path );
					path.Clear();
					path = null;//World.AllocateTrajet();					
					SendMessage( "Path is removed" );
				}
				else
					if ( lower.StartsWith( ".startpath" ) )
				{		
					if ( selection is MobileSpawner )
					{
						World.trajets.Dirty = true;
						if ( startTrajetFlag != null )
							DestroyObject( startTrajetFlag.Guid );
						path = World.AllocateTrajet();
						( selection as MobileSpawner ).TrajetGuid = path.Guid;
						startTrajetFlag = World.Add( 621681, X, Y, Z, MapId );
						foreach( Object o in this.KnownObjects )
							if ( o is BaseCreature )
							{
								if ( ( o as BaseCreature ).SpawnerLink == selection )
								{
									( o as BaseCreature ).Freeze = true;
								}
							}
						//startTrajetFlag.Decay = DateTime.Now.Add( TimeSpan.FromMinutes( 15.0 ) );
						SendMessage( "Start a new path for the spawner" );
					}
					else
						SendMessage( "You must select a spawner before starting a new path" );
				}
				else
					if ( lower.StartsWith( ".endpath" ) )
				{					
					if ( startTrajetFlag != null )
					{
						World.Remove( startTrajetFlag, this );				
					}
					if ( path != null && path.Count > 1 )
					{
						path[ 0 ].previous = path[ path.Count - 1 ];
						path[ path.Count - 1 ].next = path[ 0 ];
					}
					foreach( Object o in this.KnownObjects )
						if ( o is BaseCreature )
						{
							if ( ( o as BaseCreature ).SpawnerLink == selection )
							{
								( o as BaseCreature ).Freeze = true;
							}
						}										
					path = null;			
					SendMessage( "Path loop completed" );
				}

					#endregion TRAJETS !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
				else
					if ( lower.StartsWith( ".cast " ) )
				{
					string []tt = cmd.Split( new char[]{ ' ' } );
					if ( selection != null && selection is Mobile )
					{
						try
						{
							int i = Convert.ToInt32( tt[ 1 ] );
							( selection as Mobile ).FakeCast( i, this );
						}
						catch( Exception )
						{
							SendMessage( "Invalid spell id !" );
						}
					}
					else
						SendMessage( "You must target a mobile !" );
				}
				else
					if ( lower.StartsWith( ".additem " ) )
				{					
					string []tt = cmd.Split( new char[]{ ' ' } );
					if ( tt.Length == 3 )
					{
						try 
						{
							CreateAndAddObject( tt[ 1 ], Convert.ToInt32( tt[ 2 ] ) );
						}
						catch( Exception )
						{
							this.SendMessage( "usage : .additem ItemName [number]" );
						}
					}
					else
						if ( tt.Length == 2 )
						CreateAndAddObject( tt[ 1 ] );
					else
						this.SendMessage( "usage : .additem ItemName [number]" );
				}
				else
					if ( lower.StartsWith( ".addgo " ) )
				{

					try
					{
						cmd = cmd.Remove( 0, 7 );
						string []tt = cmd.Split( new char[]{ ' ' } );
						int i = Convert.ToInt32( tt[ 0 ] );
						if ( GameObjectDescription.all[ i ]== null )
						{
							SendMessage( "Unknow Game object " + i.ToString() );
							return;
						}
						GameObject go = null;
						if ( World.GameObjectsAssociated.Exist( i ) )
						{
							go = World.Add( i, Utility.ClassName( World.GameObjectsAssociated[ i ].ToString() ), X, Y, Z, MapId );
							go.Id = i;
						}
						else
							go = World.Add( i, X, Y, Z, MapId );
						if ( this.linkedSpawner == -1 )
						{
							SendMessage( "You cannot place a game object here, first place a spawner !" );
						}
						else
						{
							World.allSpawners[ linkedSpawner ].Bind( go );
							account.RefreshMobileList( true );
						}
					}
					catch( Exception )
					{
					}
				}
				else
					if ( lower.StartsWith( ".where" ) )
				{
					SendMessage( "X = " + X.ToString() + ", Y = " + Y.ToString() + ", Z = " + Z.ToString() + " mapId = " + this.MapId.ToString() );					
				}
				else
					if ( lower == ".remove" )
				{
					if ( selection != null )
					{
						selection.Delete();
						
						if ( selection.Guid > 0xF100000000000000 )
						{
							World.allSpawners.Remove( selection as BaseSpawner );
							SendMessage( "Spawnpoint deleted" );
							this.linkedSpawner = -1;
							
						}
						else
						{
							World.allMobiles.Remove( selection as Mobile );
							SendMessage( ( selection as Mobile ).Name + " deleted" );
						}
						account.HeartBeat();
					}
				}
				else
					if ( lower.StartsWith( ".addnpc " ) )
				{
					//SendMessage( cmd );
					string []cmds = cmd.Split( new char[]{ ' ' } );
					if ( cmds.Length < 2 )
					{
						SendMessage( "Usage : .addnpc NpcName [howmany]" );
						return;
					}
					Factions fact = Factions.NoFaction;
					
					int n = 1;
					if ( cmds.Length == 3 )
					{
						try
						{
							n = Convert.ToInt32( cmds[ 2 ] );
						}
						catch(Exception)
						{
						}
					}
					if ( cmds.Length == 4 )
					{
						try
						{
							fact = (Factions)Convert.ToInt32( cmds[ 3 ] );
						}
						catch(Exception)
						{
						}
					}
					for(int t = 0;t < n;t++ )
					{
						ConstructorInfo ct = null;
						try
						{
							int mid = (int)Convert.ToInt32( cmds[ 1 ] );
							ct = World.MobilePool( mid );
						}
						catch(Exception)
						{
							ct = Utility.FindConstructor( cmds[ 1 ] , Utility.externAsm[ "creatures" ] );
							if ( ct == null )
								ct = Utility.FindConstructor( cmds[ 1 ] );
						}

						if ( ct == null )
						{
							SendMessage( cmds[ 1 ] + " is not a valid Npc !!!" );
							return;
						}
						BaseCreature bc = null;
						try
						{
							bc =  (BaseCreature)ct.Invoke( null );
						}
						catch( Exception e )
						{
							//			Console.WriteLine( "{0}\n{1}\n{2}\n", e.Message, e.Source, e.StackTrace );
							SendMessage( e.Message );
							SendMessage( e.Source );
							SendMessage( e.StackTrace );
							return;
						}
						bc.X = X;
						bc.Y = Y;
						bc.Z = Z;
						bc.ZoneId = ZoneId;
						bc.MapId = MapId;
						bc.InitStats();
						float nearest = float.MaxValue;
						BaseSpawner nearSpawner = null;
						foreach( BaseSpawner bs in World.allSpawners )
							if ( bs.Distance( this ) < nearest )
							{
								nearest = bs.Distance( this );
								nearSpawner = bs;
							}
						if ( nearSpawner != null )
							nearSpawner.Bind( bc );
						World.allMobiles.Add( bc, true );	
						if ( fact != Factions.NoFaction )
							bc.Faction = fact;
						Player.RefreshMobileList( true );
					}
				}
				else
					if ( lower.StartsWith( ".move" ) )
				{
					byte []b4 = new byte[] {0x00, 0x31, 0x96, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x32, 0x36, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1D, 0x00, 0x00, 0x00, 0x57, 0x65, 0x6C, 0x63, 0x6F, 0x6D, 0x65, 0x20, 0x74, 0x6F, 0x20, 0x57, 0x6F, 0x72, 0x6C, 0x64, 0x20, 0x6F, 0x66, 0x20, 0x57, 0x61, 0x72, 0x63, 0x72, 0x61, 0x66, 0x74, 0x00, 0x00};
					int offset = 9;
					Converter.ToBytes( Guid, b4, ref offset );
					Player.Handler.Send( 0x96, b4 );

					foreach( Mobile m in World.allMobiles )
						if ( !( m is Character ) )
							m.MovementHeartBeat( account.Handler, this );
				}
				else
					if ( lower.StartsWith( ".save" ) )
				{
					MainConsole.world.SaveGame();
				}
				else
					if ( lower.StartsWith( ".load" ) )
				{
				}
				else
					/*					if (lower.StartsWith( ".stest" ))
									{
										ConstructorInfo ct1 = Utility.FindConstructor( "RazorHillGrunt" , Utility.externAsm );
										for(int i = 0;i < 400;i+=30 )
										for(int t = i;t < i + 30;t++ )
										{
											BaseCreature bc = (BaseCreature)ct1.Invoke( null );	
											bc.Faction = (Factions)t;
											bc.Name = "Faction " + t.ToString();
											bc.Id = t + 65000;
											World.Add( bc, -13234f + (float)( t / 30 ) * 2, 238f+ (float)( t % 30 ) * 2, 22f, 0 );
											bc.Freeze = true;						
										}
									}
									else*/
					if ( lower.StartsWith( ".mark" ) )
				{
					mark = new Position( X, Y, Z, MapId );
					SendMessage( "Mark at " + X.ToString() + ", " + Y.ToString() + ", " + Z.ToString() + ", " + MapId.ToString() );
				}
				else
					if ( lower.StartsWith( ".recall" ) )
				{
					if ( mark == null )
						SendMessage( "You must mark a location first !" );
					else
						Teleport( mark.X, mark.Y, mark.Z, mark.MapId );
				}
				else
					if ( lower.StartsWith( ".go " ) )
				{	
					cmd = cmd.Remove( 0, 4 );
					string []val = cmd.Split( new char[]{' '} );
					if ( !( val.Length != 4 || val.Length != 2 ) )
					{
						SendMessage( "Need at 1 or 4 parameters !" );
						SendMessage( "usage : .go X Y Z MapId or .go Location" );
						return;
					}
					if ( val.Length == 1 && World.Locations[ val[ 0 ] ] == null )
					{
						SendMessage( val[ 0 ] + " is an unknown location" );
						return;
					}
					if ( val.Length == 1 )
					{
						Position pos = (Position)World.Locations[ val[ 0 ] ];
						Teleport( pos.X, pos.Y, pos.Z, pos.MapId );
					}
					else
						Teleport( Convert.ToSingle( val[ 0 ] ), 
							Convert.ToSingle( val[ 1 ] ), Convert.ToSingle( val[ 2 ] ),
							Convert.ToInt32( val[ 3 ] ) );
		
				}
				else
					if ( onCommand != null && !onCommand( this, cmd ) )
					return;
				else
					SendMessage( "Unknown command !" );
			}
		}
Esempio n. 29
0
 /// <summary>
 ///   Adds the contents of another <see cref='Trajet'/> to the end of the collection.
 /// </summary>
 /// <param name='val'>
 ///    A <see cref='Trajet'/> containing the objects to add to the collection.
 /// </param>
 /// <seealso cref='Trajet.Add'/>
 public void AddRange(Trajet val)
 {
     for (int i = 0; i < val.Count; i++)
     {
         this.Add(val[i]);
     }
 }