protected override bool GetTeleportLocation(GamePlayer player, string text)
        {
            // special cases
            if (text.ToLower() == "battlegrounds" || text.ToLower() == "personal")
            {
                return(base.GetTeleportLocation(player, text));
            }

            // Find the teleport location in the database.  For Djinns use the player realm to match Interact list given.
            Teleport port = WorldMgr.GetTeleportLocation(player.Realm, String.Format("{0}:{1}", Type, text));

            if (port != null)
            {
                if (port.RegionID == 0 && port.X == 0 && port.Y == 0 && port.Z == 0)
                {
                    OnSubSelectionPicked(player, port);
                }
                else
                {
                    OnDestinationPicked(player, port);
                }
                return(false);
            }

            return(true);               // Needs further processing.
        }
        /// <summary>
        /// Add a new teleport destination in memory and save to database, if
        /// successful.
        /// </summary>
        /// <param name="client"></param>
        /// <param name="teleportID"></param>
        /// <param name="type"></param>
        private void AddTeleport(GameClient client, String teleportID, String type)
        {
            GamePlayer player = client.Player;
            eRealm     realm  = player.Realm;

            if (WorldMgr.GetTeleportLocation(realm, String.Format("{0}:{1}", type, teleportID)) != null)
            {
                client.Out.SendMessage(String.Format("Teleport ID [{0}] already exists!", teleportID),
                                       eChatType.CT_System, eChatLoc.CL_SystemWindow);
                return;
            }

            Teleport teleport = new Teleport();

            teleport.TeleportID = teleportID;
            teleport.Realm      = (int)realm;
            teleport.RegionID   = player.CurrentRegion.ID;
            teleport.X          = player.X;
            teleport.Y          = player.Y;
            teleport.Z          = player.Z;
            teleport.Heading    = player.Heading;
            teleport.Type       = type;

            if (!WorldMgr.AddTeleportLocation(teleport))
            {
                client.Out.SendMessage(String.Format("Failed to add teleport ID [{0}] in memory!", teleportID),
                                       eChatType.CT_System, eChatLoc.CL_SystemWindow);
                return;
            }

            GameServer.Database.AddObject(teleport);
            client.Out.SendMessage(String.Format("Teleport ID [{0}] successfully added.", teleportID),
                                   eChatType.CT_System, eChatLoc.CL_SystemWindow);
        }
Exemple #3
0
        public override void OnPlayerEnter(GamePlayer player)
        {
            base.OnPlayerEnter(player);
            Teleport destination = WorldMgr.GetTeleportLocation(player.Realm, String.Format("{0}:{1}", this.GetType(), this.Description));

            if (destination != null)
            {
                OnTeleport(player, destination);
            }
            else
            {
                player.Out.SendMessage("This destination is not available : " + String.Format("{0}:{1}", this.GetType(), this.Description) + ".", eChatType.CT_System, eChatLoc.CL_SystemWindow);
            }
        }
        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)));
        }
        /// <summary>
        /// Talk to the teleporter.
        /// </summary>
        /// <param name="source"></param>
        /// <param name="text"></param>
        /// <returns></returns>
        public override bool WhisperReceive(GameLiving source, string text)
        {
            GamePlayer player = source as GamePlayer;

            if (player == null)
            {
                return(false);
            }

            eRealm realmTarget;

            switch (text.ToLower())
            {
            // Realm specific menus
            case "albion":
                SayTo(player, DisplayTeleportDestinations(eRealm.Albion));
                return(true);

            case "midgard":
                SayTo(player, DisplayTeleportDestinations(eRealm.Midgard));
                return(true);

            case "hibernia":
                SayTo(player, DisplayTeleportDestinations(eRealm.Hibernia));
                return(true);

            case "albion shrouded isles":
                String sReplyASI = String.Format("The isles of Avalon are an excellent choice. {0} {1}",
                                                 "Would you prefer the harbor of [Gothwaite] or perhaps one of the outlying towns",
                                                 "like [Wearyall] Village, Fort [Gwyntell], or Caer [Diogel]?");
                SayTo(player, sReplyASI);
                return(true);

            case "midgard shrouded isles":
                String sReplyMSI = String.Format("The isles of Aegir are an excellent choice. {0} {1}",
                                                 "Would you prefer the city of [Aegirhamn] or perhaps one of the outlying towns",
                                                 "like [Bjarken], [Hagall], or [Knarr]?");
                SayTo(player, sReplyMSI);
                return(true);

            case "hibernia shrouded isles":
                String sReplyHSI = String.Format("The isles of Hy Brasil are an excellent choice. {0} {1}",
                                                 "Would you prefer the grove of [Domnann] or perhaps one of the outlying towns",
                                                 "like [Droighaid], [Aalid Feie], or [Necht]?");
                SayTo(player, sReplyHSI);
                return(true);

            case "housing":
                String sReplyH = String.Format("I can send you to your [personal] house. If you do {0} {1} {2} {3}",
                                               "not have a personal house or wish to be sent to the housing [entrance] then you will",
                                               "arrive just inside the housing area. I can also send you to your [guild] house. If your",
                                               "guild does not own a house then you will not be transported. You may go to your [Hearth] bind",
                                               "as well if you are bound inside a house.");
                SayTo(player, sReplyH);
                return(true);

            // Albion destinations
            case "albion oceanus":
                if (player.Client.Account.PrivLevel < ServerProperties.Properties.ATLANTIS_TELEPORT_PLVL)
                {
                    SayTo(player, "I'm sorry, but you are not authorized to enter Atlantis at this time.");
                    return(true);
                }
                SayTo(player, "You will soon arrive in the Haven of Oceanus.");
                realmTarget = eRealm.Albion;
                text        = "Oceanus";
                break;

            case "avalon marsh":
                SayTo(player, "You shall soon arrive in the Avalon Marsh.");
                realmTarget = eRealm.Albion;
                break;

            case "camelot":
                SayTo(player, "The great city awaits!");
                realmTarget = eRealm.Albion;
                break;

            case "castle sauvage":
                SayTo(player, "Castle Sauvage is what you seek, and Castle Sauvage is what you shall find.");
                realmTarget = eRealm.Albion;
                break;

            case "diogel":
                realmTarget = eRealm.Albion;
                break;                          // No text?

            case "forest sauvage":
                SayTo(player, "Now to the Frontiers for the glory of the realm!");
                realmTarget = eRealm.Albion;
                break;

            case "gothwaite":
                SayTo(player, "The Shrouded Isles await you.");
                realmTarget = eRealm.Albion;
                break;

            case "gwyntell":
                realmTarget = eRealm.Albion;
                break;                          // No text?

            case "inconnu crypt":
                //if (player.HasFinishedQuest(typeof(InconnuCrypt)) <= 0)
                //{
                //	SayTo(player, String.Format("I may only send those who know the way to this {0} {1}",
                //	                            "city. Seek out the path to the city and in future times I will aid you in",
                //	                            "this journey."));
                //	return;
                //}
                realmTarget = eRealm.Albion;
                break;

            case "snowdonia fortress":
                SayTo(player, "Snowdonia Fortress is what you seek, and Snowdonia Fortress is what you shall find.");
                realmTarget = eRealm.Albion;
                break;

            // text for the following ?
            case "wearyall":
                realmTarget = eRealm.Albion;
                break;

            case "holtham":
                if (ServerProperties.Properties.DISABLE_TUTORIAL)
                {
                    SayTo(player, "Sorry, this place is not available for now !");
                    return(true);
                }
                if (player.Level > 15)
                {
                    SayTo(player, "Sorry, you are far too experienced to enjoy this place !");
                    return(true);
                }
                realmTarget = eRealm.Albion;
                break;

            // Midgard
            case "midgard oceanus":
                if (player.Client.Account.PrivLevel < ServerProperties.Properties.ATLANTIS_TELEPORT_PLVL)
                {
                    SayTo(player, "I'm sorry, but you are not authorized to enter Atlantis at this time.");
                    return(true);
                }
                SayTo(player, "You will soon arrive in the Haven of Oceanus.");
                realmTarget = eRealm.Midgard;
                text        = "Oceanus";
                break;

            case "bjarken":
                realmTarget = eRealm.Midgard;
                break;                          // No text?

            case "city of aegirhamn":
                SayTo(player, "The Shrouded Isles await you.");
                realmTarget = eRealm.Midgard;
                break;

            case "gotar":
                SayTo(player, "You shall soon arrive in the Gotar.");
                realmTarget = eRealm.Midgard;
                break;

            case "hagall":
                realmTarget = eRealm.Midgard;
                break;                          // No text?

            case "jordheim":
                SayTo(player, "The great city awaits!");
                realmTarget = eRealm.Midgard;
                break;

            case "knarr":
                realmTarget = eRealm.Midgard;
                break;                          // No text?

            case "kobold undercity":
                //if (player.HasFinishedQuest(typeof(KoboldUndercity)) <= 0)
                //{
                //	SayTo(player, String.Format("I may only send those who know the way to this {0} {1}",
                //	                            "city. Seek out the path to the city and in future times I will aid you in",
                //	                            "this journey."));
                //	return;
                //}
                realmTarget = eRealm.Midgard;
                break;

            case "svasud faste":
                SayTo(player, "Svasud Faste is what you seek, and Svasud Faste is what you shall find.");
                realmTarget = eRealm.Midgard;
                break;

            case "uppland":
                SayTo(player, "Now to the Frontiers for the glory of the realm!");
                realmTarget = eRealm.Midgard;
                break;

            case "vindsaul faste":
                SayTo(player, "Vindsaul Faste is what you seek, and Vindsaul Faste is what you shall find.");
                realmTarget = eRealm.Midgard;
                break;

            case "hafheim":
                if (ServerProperties.Properties.DISABLE_TUTORIAL)
                {
                    SayTo(player, "Sorry, this place is not available for now !");
                    return(true);
                }
                if (player.Level > 15)
                {
                    SayTo(player, "Sorry, you are far too experienced to enjoy this place !");
                    return(true);
                }
                realmTarget = eRealm.Midgard;
                break;

            // Hibernia
            case "hibernia oceanus":
                if (player.Client.Account.PrivLevel < ServerProperties.Properties.ATLANTIS_TELEPORT_PLVL)
                {
                    SayTo(player, "I'm sorry, but you are not authorized to enter Atlantis at this time.");
                    return(true);
                }
                SayTo(player, "You will soon arrive in the Haven of Oceanus.");
                realmTarget = eRealm.Hibernia;
                text        = "Oceanus";
                break;

            case "aalid feie":
                realmTarget = eRealm.Hibernia;
                break;                          // No text?

            case "cruachan gorge":
                SayTo(player, "Now to the Frontiers for the glory of the realm!");
                realmTarget = eRealm.Hibernia;
                break;

            case "domnann":
                SayTo(player, "The Shrouded Isles await you.");
                realmTarget = eRealm.Hibernia;
                break;

            case "droighaid":
                realmTarget = eRealm.Hibernia;
                break;                          // No text?

            case "druim cain":
                SayTo(player, "Druim Cain is what you seek, and Druim Cain is what you shall find.");
                realmTarget = eRealm.Hibernia;
                break;

            case "druim ligen":
                SayTo(player, "Druim Ligen is what you seek, and Druim Ligen is what you shall find.");
                realmTarget = eRealm.Hibernia;
                break;

            case "necht":
                realmTarget = eRealm.Hibernia;
                break;                          // No text?

            case "shannon estuary":
                SayTo(player, "You shall soon arrive in the Shannon Estuary.");
                realmTarget = eRealm.Hibernia;
                break;

            case "shar labyrinth":
                //if (player.HasFinishedQuest(typeof(SharLabyrinth)) <= 0)
                //{
                //	SayTo(player, String.Format("I may only send those who know the way to this {0} {1}",
                //	                            "city. Seek out the path to the city and in future times I will aid you in",
                //	                            "this journey."));
                //	return;
                //}
                realmTarget = eRealm.Hibernia;
                break;

            case "tir na nog":
                SayTo(player, "The great city awaits!");
                realmTarget = eRealm.Hibernia;
                break;

            case "fintain":
                if (ServerProperties.Properties.DISABLE_TUTORIAL)
                {
                    SayTo(player, "Sorry, this place is not available for now !");
                    return(true);
                }
                if (player.Level > 15)
                {
                    SayTo(player, "Sorry, you are far too experienced to enjoy this place !");
                    return(true);
                }
                realmTarget = eRealm.Hibernia;
                break;

            // All realms
            case "battlegrounds":
                if (!ServerProperties.Properties.BG_ZONES_OPENED && player.Client.Account.PrivLevel == (uint)ePrivLevel.Player)
                {
                    SayTo(player, ServerProperties.Properties.BG_ZONES_CLOSED_MESSAGE);
                    return(true);
                }
                SayTo(player, "I will teleport you to the appropriate battleground for your level and Realm Rank. If you exceed the Realm Rank for a battleground, you will not teleport. Please gain more experience to go to the next battleground.");
                realmTarget = eRealm.Hibernia;
                break;

            case "entrance":
            case "personal":
            case "hearth":
                realmTarget = player.Realm;
                break;

            default:
                SayTo(player, "This destination is not yet supported.");
                return(true);
            }             // switch (text.ToLower())

            // Find the teleport location in the database.
            Teleport port = WorldMgr.GetTeleportLocation(realmTarget, String.Format(":{0}", text));

            if (port != null)
            {
                OnTeleportSpell(player, port);
                return(true);
            }

            return(GetTeleportLocation(player, text));
        }