public override void OnThink()
		{
  		if(bootgespawnt == false)
  		{
			Map map = this.Map;
  			if ( map == null )
  				return;			
			this.Z = 0;
			m_PirateShip = new PirateShip();
  			Point3D loc = this.Location;
  			Point3D loccrew = this.Location;
			loc = new Point3D( this.X, this.Y-1, -5 );
			loccrew = new Point3D( this.X, this.Y-1, this.Z );
  			m_PirateShip.MoveToWorld( loc, map ); 
			bootgespawnt = true;
        
			for(int i = 0; i < 5; ++i)
			{
				Pirate m_pirate = new Pirate();
				m_pirate.MoveToWorld( loccrew, map ); 
			}
		}
		
		base.OnThink();
		if ( DateTime.Now < m_NextPickup )
			return;
				
		if ( m_PirateShip == null)
		{
			return;
		} 

		m_NextPickup = DateTime.Now + TimeSpan.FromSeconds( Utility.RandomMinMax( 1, 2 ) );

         
		feindrichtung = Direction.North; //default nord
		foreach ( Item feind in this.GetItemsInRange( 200 ) )
		{      
			if( feind is BaseBoat && feind != m_PirateShip && !(feind is PirateShip) )
			{

				List<Mobile> targets = new List<Mobile>();
				IPooledEnumerable eable = feind.GetMobilesInRange( 16 );

				foreach ( Mobile m in eable )
				{
					if ( m is PlayerMobile )
						targets.Add( m );
				}
				eable.Free();
				if ( targets.Count > 0 )
				{
					m_feindboot = feind as BaseBoat;
					feindrichtung = this.GetDirectionTo( m_feindboot );
					break;
				}
			} 
		}
		if(m_feindboot == null)
		{
			return;
		}
    			
         
		if(m_PirateShip != null && m_feindboot != null)
		{
			if( m_PirateShip != null && (feindrichtung == Direction.North  )  && m_PirateShip.Facing != Direction.North)
			{
				m_PirateShip.Facing = Direction.North;
			}
			else if(m_PirateShip != null &&  (feindrichtung == Direction.South  )  && m_PirateShip.Facing != Direction.South)
			{
				m_PirateShip.Facing = Direction.South;
			}
			else if(m_PirateShip != null &&  (feindrichtung == Direction.East || feindrichtung == Direction.Right || feindrichtung == Direction.Down  ) && m_PirateShip.Facing != Direction.East )
			{
				m_PirateShip.Facing = Direction.East;
			}
			else if(m_PirateShip != null &&  (feindrichtung == Direction.West || feindrichtung == Direction.Left || feindrichtung == Direction.Up  ) && m_PirateShip.Facing != Direction.West )   
			{
				m_PirateShip.Facing = Direction.West;
			}
			m_PirateShip.StartMove(Direction.North, true ); //, false); //Vollgas!

			if(m_PirateShip != null && this.InRange(m_feindboot, 10) && m_PirateShip.IsMoving == true) // In Reichweite? Stop!
			{
				m_PirateShip.StopMove( false );
			}
		}
		else
		{
			if(m_PirateShip != null && m_PirateShip.IsMoving == true)
			{
				m_PirateShip.StopMove( false ); //keiner da? anhalten.
			}
		}
		}
		public void SpawnPirate( Mobile target )
		{
			Map map = target.Map;

			if ( map == null )
				return;

			int pirates = 0;

			foreach ( Mobile m in this.GetMobilesInRange( 10 ) )
			{
				if ( m is Pirate )
					++pirates;
			}

			if ( pirates < 10 && Utility.RandomDouble() <= 0.25)
			{
				BaseCreature pirate = new Pirate();

				Point3D loc = target.Location;
				bool validLocation = false;

				for ( int j = 0; !validLocation && j < 10; ++j )
				{
					int x = target.X + Utility.Random( 3 ) - 1;
					int y = target.Y + Utility.Random( 3 ) - 1;
					int z = map.GetAverageZ( x, y );

					if ( validLocation = map.CanFit( x, y, this.Z, 16, false, false ) )
						loc = new Point3D( x, y, Z );
					else if ( validLocation = map.CanFit( x, y, z, 16, false, false ) )
						loc = new Point3D( x, y, z );
				}

				pirate.MoveToWorld( loc, map );

				pirate.Combatant = target;
			}
		}
Exemple #3
0
        public override void OnThink()
        {
            if (bootgespawnt == false)
            {
                Map map = this.Map;
                if (map == null)
                {
                    return;
                }
                this.Z       = 0;
                m_PirateShip = new PirateShip();
                Point3D loc     = this.Location;
                Point3D loccrew = this.Location;
                loc     = new Point3D(this.X, this.Y - 1, -5);
                loccrew = new Point3D(this.X, this.Y - 1, this.Z);
                m_PirateShip.MoveToWorld(loc, map);
                bootgespawnt = true;

                for (int i = 0; i < 5; ++i)
                {
                    Pirate m_pirate = new Pirate();
                    m_pirate.MoveToWorld(loccrew, map);
                }
            }

            base.OnThink();
            if (DateTime.Now < m_NextPickup)
            {
                return;
            }

            if (m_PirateShip == null)
            {
                return;
            }

            m_NextPickup = DateTime.Now + TimeSpan.FromSeconds(Utility.RandomMinMax(1, 2));


            feindrichtung = Direction.North;     //default nord
            foreach (Item feind in this.GetItemsInRange(200))
            {
                if (feind is BaseBoat && feind != m_PirateShip && !(feind is PirateShip))
                {
                    List <Mobile>     targets = new List <Mobile>();
                    IPooledEnumerable eable   = feind.GetMobilesInRange(16);

                    foreach (Mobile m in eable)
                    {
                        if (m is PlayerMobile)
                        {
                            targets.Add(m);
                        }
                    }
                    eable.Free();
                    if (targets.Count > 0)
                    {
                        m_feindboot   = feind as BaseBoat;
                        feindrichtung = this.GetDirectionTo(m_feindboot);
                        break;
                    }
                }
            }
            if (m_feindboot == null)
            {
                return;
            }


            if (m_PirateShip != null && m_feindboot != null)
            {
                if (m_PirateShip != null && (feindrichtung == Direction.North) && m_PirateShip.Facing != Direction.North)
                {
                    m_PirateShip.Facing = Direction.North;
                }
                else if (m_PirateShip != null && (feindrichtung == Direction.South) && m_PirateShip.Facing != Direction.South)
                {
                    m_PirateShip.Facing = Direction.South;
                }
                else if (m_PirateShip != null && (feindrichtung == Direction.East || feindrichtung == Direction.Right || feindrichtung == Direction.Down) && m_PirateShip.Facing != Direction.East)
                {
                    m_PirateShip.Facing = Direction.East;
                }
                else if (m_PirateShip != null && (feindrichtung == Direction.West || feindrichtung == Direction.Left || feindrichtung == Direction.Up) && m_PirateShip.Facing != Direction.West)
                {
                    m_PirateShip.Facing = Direction.West;
                }
                m_PirateShip.StartMove(Direction.North, true);                                              //, false); //Vollgas!

                if (m_PirateShip != null && this.InRange(m_feindboot, 10) && m_PirateShip.IsMoving == true) // In Reichweite? Stop!
                {
                    m_PirateShip.StopMove(false);
                }
            }
            else
            {
                if (m_PirateShip != null && m_PirateShip.IsMoving == true)
                {
                    m_PirateShip.StopMove(false);               //keiner da? anhalten.
                }
            }
        }