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 PirateCrew2) { ++pirates; } } if (pirates < 10 && Utility.RandomDouble() <= 0.25) { BaseCreature PirateCrew2 = new PirateCrew2(); 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); } } PirateCrew2.MoveToWorld(loc, map); PirateCrew2.Combatant = target; } }
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 PirateCrew2) ++pirates; } if ( pirates < 10 && Utility.RandomDouble() <= 0.25) { BaseCreature PirateCrew2 = new PirateCrew2(); 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 ); } PirateCrew2.MoveToWorld(loc, map); PirateCrew2.Combatant = target; } }
public override void OnThink() { #region Pirate Can Say Random Phrases From A [.txt] File if (DateTime.Now >= nextAbilityTime && Combatant == null && active == true) { nextAbilityTime = DateTime.Now + TimeSpan.FromSeconds(Utility.RandomMinMax(4, 6)); if (text == null) { try { text = new StreamReader(path, System.Text.Encoding.Default, false); } catch { } } Talk(); Emote(); } #endregion Pirate Can Say Random Phrases From A [.txt] File if (boatspawn == false) { Map map = this.Map; if (map == null) { return; } this.Z = 0; m_PirateShip_Boat = new PirateShip_Boat(); Point3D loc = this.Location; Point3D loccrew = this.Location; loc = new Point3D(this.X, this.Y - 1, Map.GetAverageZ(this.X, this.Y)); loccrew = new Point3D(this.X, this.Y - 1, loc.Z + 1); m_PirateShip_Boat.MoveToWorld(loc, map); boatspawn = true; for (int i = 0; i < 5; ++i) { PirateCrew2 m_PirateCrew2 = new PirateCrew2(); m_PirateCrew2.MoveToWorld(loccrew, map); } } base.OnThink(); if (DateTime.Now < m_NextPickup) { return; } if (m_PirateShip_Boat == null) { return; } m_NextPickup = DateTime.Now + TimeSpan.FromSeconds(Utility.RandomMinMax(1, 2)); enemydirection = Direction.North; foreach (Item enemy in this.GetItemsInRange(200)) { if (enemy is BaseBoat && enemy != m_PirateShip_Boat && !(enemy is PirateShip_Boat)) { List <Mobile> targets = new List <Mobile>(); IPooledEnumerable eable = enemy.GetMobilesInRange(16); foreach (Mobile m in eable) { if (m is PlayerMobile) { targets.Add(m); } } eable.Free(); if (targets.Count > 0) { m_enemyboat = enemy as BaseBoat; enemydirection = this.GetDirectionTo(m_enemyboat); break; } } } if (m_enemyboat == null) { return; } if (m_PirateShip_Boat != null && m_enemyboat != null) { if (m_PirateShip_Boat != null && (enemydirection == Direction.North) && m_PirateShip_Boat.Facing != Direction.North) { m_PirateShip_Boat.Facing = Direction.North; } else if (m_PirateShip_Boat != null && (enemydirection == Direction.South) && m_PirateShip_Boat.Facing != Direction.South) { m_PirateShip_Boat.Facing = Direction.South; } else if (m_PirateShip_Boat != null && (enemydirection == Direction.East || enemydirection == Direction.Right || enemydirection == Direction.Down) && m_PirateShip_Boat.Facing != Direction.East) { m_PirateShip_Boat.Facing = Direction.East; } else if (m_PirateShip_Boat != null && (enemydirection == Direction.West || enemydirection == Direction.Left || enemydirection == Direction.Up) && m_PirateShip_Boat.Facing != Direction.West) { m_PirateShip_Boat.Facing = Direction.West; } m_PirateShip_Boat.StartMove(Direction.North, true); if (m_PirateShip_Boat != null && this.InRange(m_enemyboat, 10) && m_PirateShip_Boat.IsMoving == true) { m_PirateShip_Boat.StopMove(false); } } else { if (m_PirateShip_Boat != null && m_PirateShip_Boat.IsMoving == true) { m_PirateShip_Boat.StopMove(false); } } }
public override void OnThink() { #region Pirate Can Say Random Phrases From A [.txt] File if (DateTime.Now >= nextAbilityTime && Combatant == null && active == true) { nextAbilityTime = DateTime.Now + TimeSpan.FromSeconds(Utility.RandomMinMax(4, 6)); if (text == null) { try { text = new StreamReader(path, System.Text.Encoding.Default, false); } catch { } } Talk(); Emote(); } #endregion Pirate Can Say Random Phrases From A [.txt] File if(boatspawn == false) { Map map = this.Map; if ( map == null ) return; this.Z = 0; m_PirateShip_Boat = new PirateShip_Boat(); Point3D loc = this.Location; Point3D loccrew = this.Location; loc = new Point3D( this.X, this.Y-1, Map.GetAverageZ(this.X, this.Y)); loccrew = new Point3D( this.X, this.Y-1, loc.Z+1 ); m_PirateShip_Boat.MoveToWorld(loc, map); boatspawn = true; for(int i = 0; i < 5; ++i) { PirateCrew2 m_PirateCrew2 = new PirateCrew2(); m_PirateCrew2.MoveToWorld(loccrew, map); } } base.OnThink(); if ( DateTime.Now < m_NextPickup ) return; if (m_PirateShip_Boat == null) { return; } m_NextPickup = DateTime.Now + TimeSpan.FromSeconds( Utility.RandomMinMax( 1, 2 ) ); enemydirection = Direction.North; foreach ( Item enemy in this.GetItemsInRange( 200 ) ) { if (enemy is BaseBoat && enemy != m_PirateShip_Boat && !(enemy is PirateShip_Boat)) { List<Mobile> targets = new List<Mobile>(); IPooledEnumerable eable = enemy.GetMobilesInRange( 16 ); foreach ( Mobile m in eable ) { if ( m is PlayerMobile ) targets.Add( m ); } eable.Free(); if ( targets.Count > 0 ) { m_enemyboat = enemy as BaseBoat; enemydirection = this.GetDirectionTo(m_enemyboat); break; } } } if (m_enemyboat == null) { return; } if (m_PirateShip_Boat != null && m_enemyboat != null) { if (m_PirateShip_Boat != null && (enemydirection == Direction.North) && m_PirateShip_Boat.Facing != Direction.North) { m_PirateShip_Boat.Facing = Direction.North; } else if (m_PirateShip_Boat != null && (enemydirection == Direction.South) && m_PirateShip_Boat.Facing != Direction.South) { m_PirateShip_Boat.Facing = Direction.South; } else if (m_PirateShip_Boat != null && (enemydirection == Direction.East || enemydirection == Direction.Right || enemydirection == Direction.Down) && m_PirateShip_Boat.Facing != Direction.East) { m_PirateShip_Boat.Facing = Direction.East; } else if (m_PirateShip_Boat != null && (enemydirection == Direction.West || enemydirection == Direction.Left || enemydirection == Direction.Up) && m_PirateShip_Boat.Facing != Direction.West) { m_PirateShip_Boat.Facing = Direction.West; } m_PirateShip_Boat.StartMove(Direction.North, true); if (m_PirateShip_Boat != null && this.InRange(m_enemyboat, 10) && m_PirateShip_Boat.IsMoving == true) { m_PirateShip_Boat.StopMove(false); } } else { if (m_PirateShip_Boat != null && m_PirateShip_Boat.IsMoving == true) { m_PirateShip_Boat.StopMove(false); } } }