/// <summary>
        /// calculates distance between 2 points
        /// </summary>
        /// <param name="p1"></param>
        /// <param name="p2"></param>
        /// <returns></returns>
        public int GetDistance(IGameLocation location)
        {
            if (RegionID == location.RegionID)
            {
                return(GetDistanceTo(location));
            }

            return(-1);
        }
Exemple #2
0
 /// <summary>
 /// calculates distance between 2 points
 /// </summary>
 /// <param name="p1"></param>
 /// <param name="p2"></param>
 /// <returns></returns>
 public float GetDistance(IGameLocation location)
 {
     if (this.RegionID == location.RegionID)
     {
         return(Vector3.Distance(Position, location.Position));
     }
     else
     {
         return(-1);
     }
 }
Exemple #3
0
 /// <summary>
 /// calculates distance between 2 points
 /// </summary>
 /// <param name="p1"></param>
 /// <param name="p2"></param>
 /// <returns></returns>
 public int GetDistance(IGameLocation location)
 {
     if (this.RegionID == location.RegionID)
     {
         return(base.GetDistanceTo(location));
     }
     else
     {
         return(-1);
     }
 }
        protected Teleport GetTeleportLocation(GamePlayer player, string text, eRealm realm)
        {
            // Battlegrounds are specials, as the teleport location depends on
            // the level of the player, so let's deal with that first.
            if (text.ToLower() == "battlegrounds")
            {
                if (!ServerProperties.Properties.BG_ZONES_OPENED && player.Client.Account.PrivLevel == (uint)ePrivLevel.Player)
                {
                    SayTo(player, ServerProperties.Properties.BG_ZONES_CLOSED_MESSAGE);
                }
                else
                {
                    AbstractGameKeep portalKeep = GameServer.KeepManager.GetBGPK(player);
                    if (portalKeep != null)
                    {
                        Teleport teleport = new Teleport();
                        teleport.TeleportID = "battlegrounds";
                        teleport.Realm      = (byte)portalKeep.Realm;
                        teleport.RegionID   = portalKeep.Region;
                        teleport.X          = portalKeep.X;
                        teleport.Y          = portalKeep.Y;
                        teleport.Z          = portalKeep.Z;
                        teleport.Heading    = 0;
                        return(teleport);
                    }
                    else
                    {
                        if (player.Client.Account.PrivLevel > (uint)ePrivLevel.Player)
                        {
                            player.Out.SendMessage("No portal keep found.", eChatType.CT_Skill, eChatLoc.CL_SystemWindow);
                        }
                        return(null);
                    }
                }
            }

            // Another special case is personal house, as there is no location
            // that will work for every player.
            if (text.ToLower() == "personal")
            {
                House house = HouseMgr.GetHouseByPlayer(player);

                if (house == null)
                {
                    text = "entrance";                      // Fall through, port to housing entrance.
                }
                else
                {
                    IGameLocation location = house.OutdoorJumpPoint;
                    Teleport      teleport = new Teleport();
                    teleport.TeleportID = "personal";
                    teleport.Realm      = (int)player.Realm;
                    teleport.RegionID   = location.RegionID;
                    teleport.X          = (int)location.Position.X;
                    teleport.Y          = (int)location.Position.Y;
                    teleport.Z          = (int)location.Position.Z;
                    teleport.Heading    = location.Heading;
                    return(teleport);
                }
            }

            // Yet another special case the port to the 'hearth' what means
            // that the player will be ported to the defined house bindstone
            if (text.ToLower() == "hearth")
            {
                // Check if player has set a house bind
                if (!(player.BindHouseRegion > 0))
                {
                    SayTo(player, "Sorry, you haven't set any house bind point yet.");
                    return(null);
                }

                // Check if the house at the player's house bind location still exists
                ArrayList houses = (ArrayList)HouseMgr.GetHousesCloseToSpot((ushort)player.
                                                                            BindHouseRegion, player.BindHouseXpos, player.
                                                                            BindHouseYpos, 700);
                if (houses.Count == 0)
                {
                    SayTo(player, "I'm afraid I can't teleport you to your hearth since the house at your " +
                          "house bind location has been torn down.");
                    return(null);
                }

                // Check if the house at the player's house bind location contains a bind stone
                House targetHouse = (House)houses[0];
                IDictionary <uint, DBHouseHookpointItem> hookpointItems = targetHouse.HousepointItems;
                Boolean hasBindstone = false;

                foreach (KeyValuePair <uint, DBHouseHookpointItem> targetHouseItem in hookpointItems)
                {
                    if (((GameObject)targetHouseItem.Value.GameObject).GetName(0, false).ToLower().EndsWith("bindstone"))
                    {
                        hasBindstone = true;
                        break;
                    }
                }

                if (!hasBindstone)
                {
                    SayTo(player, "I'm sorry to tell that the bindstone of your current house bind location " +
                          "has been removed, so I'm not able to teleport you there.");
                    return(null);
                }

                // Check if the player has the permission to bind at the house bind stone
                if (!targetHouse.CanBindInHouse(player))
                {
                    SayTo(player, "You're no longer allowed to bind at the house bindstone you've previously " +
                          "chosen, hence I'm not allowed to teleport you there.");
                    return(null);
                }

                Teleport teleport = new Teleport();
                teleport.TeleportID = "hearth";
                teleport.Realm      = (int)player.Realm;
                teleport.RegionID   = player.BindHouseRegion;
                teleport.X          = player.BindHouseXpos;
                teleport.Y          = player.BindHouseYpos;
                teleport.Z          = player.BindHouseZpos;
                teleport.Heading    = player.BindHouseHeading;
                return(teleport);
            }

            if (text.ToLower() == "guild")
            {
                House house = HouseMgr.GetGuildHouseByPlayer(player);

                if (house == null)
                {
                    return(null);                     // no teleport when guild house not found
                }
                else
                {
                    IGameLocation location = house.OutdoorJumpPoint;
                    Teleport      teleport = new Teleport();
                    teleport.TeleportID = "guild house";
                    teleport.Realm      = (int)player.Realm;
                    teleport.RegionID   = location.RegionID;
                    teleport.X          = (int)location.Position.X;
                    teleport.Y          = (int)location.Position.Y;
                    teleport.Z          = (int)location.Position.Z;
                    teleport.Heading    = location.Heading;
                    return(teleport);
                }
            }

            // Find the teleport location in the database.
            return(WorldMgr.GetTeleportLocation(realm, String.Format(":{0}", text)));
        }
Exemple #5
0
 /// <summary>
 /// calculates distance between 2 points
 /// </summary>
 /// <param name="p1"></param>
 /// <param name="p2"></param>
 /// <returns></returns>
 public int GetDistance( IGameLocation location )
 {
     if (this.RegionID == location.RegionID)
     {
         return base.GetDistanceTo( location );
     }
     else
     {
         return -1;
     }
 }
Exemple #6
0
		/// <summary>
		/// Returns an IEnumerator of GamePlayers that are close to a certain
		/// spot in the region
		/// </summary>
		/// <param name="location">the game location to search from</param>
		/// <param name="radiusToCheck">Radius to sarch for GameClients</param>
		/// <returns>IEnumerator that can be used to go through all players</returns>
		public static IEnumerable GetPlayersCloseToSpot(IGameLocation location, ushort radiusToCheck)
		{
			return GetPlayersCloseToSpot(location.RegionID, location.X, location.Y, location.Z, radiusToCheck, false);
		}