示例#1
0
        public void OnCommand(GameClient client, string[] args)
        {
            if (client.Player.CurrentHouse != null)
            {
                DisplayMessage(client, "You can't knock while your in a house!");
                return;
            }

            long KnockTick = client.Player.TempProperties.getProperty <long>(PLAYER_KNOCKED);

            if (KnockTick > 0 && KnockTick - client.Player.CurrentRegion.Time <= 0)
            {
                client.Player.TempProperties.removeProperty(PLAYER_KNOCKED);
            }

            long changeTime = client.Player.CurrentRegion.Time - KnockTick;

            if (changeTime < 30000 && KnockTick > 0)
            {
                client.Player.Out.SendMessage("You must wait " + ((30000 - changeTime) / 1000).ToString() + " more seconds before knocking again!", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                return;
            }

            bool done = false;

            foreach (House house in HouseMgr.GetHousesCloseToSpot(client.Player.CurrentRegionID, client.Player.X, client.Player.Y, 650))
            {
                client.Player.Emote(eEmote.Knock);
                foreach (GamePlayer player in house.GetAllPlayersInHouse())
                {
                    string message = client.Player.Name + " is at your door";
                    player.Out.SendMessage(message + "!", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                }

                done = true;
            }

            if (done)
            {
                client.Out.SendMessage("You knock on the door.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                client.Player.TempProperties.setProperty(PLAYER_KNOCKED, client.Player.CurrentRegion.Time);
            }
            else
            {
                client.Out.SendMessage("You must go to the house you wish to knock on!", eChatType.CT_System, eChatLoc.CL_SystemWindow);
            }
        }
示例#2
0
        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)));
        }
示例#3
0
文件: house.cs 项目: JVirant/DOLSharp
        public void HouseAdmin(GamePlayer player, string [] args)
        {
            if (player.Client.Account.PrivLevel == (int)ePrivLevel.Admin)
            {
                if (args[1].ToLower() == "restart")
                {
                    HouseMgr.Start(player.Client);
                    return;
                }

                if (args[1].ToLower() == "addhookpoints")
                {
                    if (player.TempProperties.getProperty <bool>(HousingConstants.AllowAddHouseHookpoint, false))
                    {
                        player.TempProperties.removeProperty(HousingConstants.AllowAddHouseHookpoint);
                        DisplayMessage(player.Client, "Add hookpoints turned off!");
                    }
                    else
                    {
                        player.TempProperties.setProperty(HousingConstants.AllowAddHouseHookpoint, true);
                        DisplayMessage(player.Client, "Add hookpoints turned on!");
                    }

                    return;
                }
            }

            ArrayList houses = (ArrayList)HouseMgr.GetHousesCloseToSpot(player.CurrentRegionID, (int)player.Position.X, (int)player.Position.Y, 700);

            if (houses.Count != 1)
            {
                DisplayMessage(player.Client, "You need to stand closer to a house!");
                return;
            }

            if (args[1].ToLower() == "info")
            {
                (houses[0] as House).SendHouseInfo(player);
                return;
            }

            // The following commands are for Admins only

            if (player.Client.Account.PrivLevel != (int)ePrivLevel.Admin)
            {
                return;
            }

            if (args[1].ToLower() == "model")
            {
                int newModel = Convert.ToInt32(args[2]);

                if (newModel < 1 || newModel > 12)
                {
                    DisplayMessage(player.Client, "Valid house models are 1 - 12!");
                    return;
                }

                if (houses.Count == 1 && newModel != (houses[0] as House).Model)
                {
                    HouseMgr.RemoveHouseItems(houses[0] as House);
                    (houses[0] as House).Model = newModel;
                    (houses[0] as House).SaveIntoDatabase();
                    (houses[0] as House).SendUpdate();

                    DisplayMessage(player.Client, "House model changed to " + newModel + "!");
                    GameServer.Instance.LogGMAction(player.Name + " changed house #" + (houses[0] as House).HouseNumber + " model to " + newModel);
                }

                return;
            }

            if (args[1].ToLower() == "remove")
            {
                string confirm = "";

                if (args.Length > 2)
                {
                    confirm = args[2];
                }

                if (confirm != "YES")
                {
                    DisplayMessage(player.Client, "You must confirm this removal with 'YES'");
                    return;
                }

                if (houses.Count == 1)
                {
                    HouseMgr.RemoveHouse(houses[0] as House);
                    DisplayMessage(player.Client, "House removed!");
                    GameServer.Instance.LogGMAction(player.Name + " removed house #" + (houses[0] as House).HouseNumber);
                }

                return;
            }
        }