コード例 #1
0
            private static void SendHouseRentRemindersToPlayer(GamePlayer player)
            {
                House house = HouseMgr.GetHouseByPlayer(player);

                if (house != null)
                {
                    TimeSpan due = (house.LastPaid.AddDays(Properties.RENT_DUE_DAYS).AddHours(1) - DateTime.Now);
                    if ((due.Days <= 0 || due.Days < Properties.RENT_DUE_DAYS) && house.KeptMoney < HouseMgr.GetRentByModel(house.Model))
                    {
                        player.Out.SendRentReminder(house);
                    }
                }

                if (player.Guild != null)
                {
                    House ghouse = HouseMgr.GetGuildHouseByPlayer(player);
                    if (ghouse != null)
                    {
                        TimeSpan due = (ghouse.LastPaid.AddDays(Properties.RENT_DUE_DAYS).AddHours(1) - DateTime.Now);
                        if ((due.Days <= 0 || due.Days < Properties.RENT_DUE_DAYS) && ghouse.KeptMoney < HouseMgr.GetRentByModel(ghouse.Model))
                        {
                            player.Out.SendRentReminder(ghouse);
                        }
                    }
                }
            }
コード例 #2
0
ファイル: jump.cs プロジェクト: towbes/DOLSharp
        public void OnCommand(GameClient client, string[] args)
        {
            try
            {
                #region Refresh
                if (args.Length == 2 && args[1].ToLower() == "refresh")
                {
                    client.Player.LeaveHouse();
                    client.Player.RefreshWorld();
                    return;
                }
                #endregion Refresh
                #region Jump to GT
                if (args.Length == 3 && args[1].ToLower() == "to" && args[2].ToLower() == "gt")
                {
                    client.Player.MoveTo(client.Player.CurrentRegionID, client.Player.GroundTarget.X, client.Player.GroundTarget.Y, client.Player.GroundTarget.Z, client.Player.Heading);
                    return;
                }
                #endregion Jump to GT
                #region Jump to house
                else if (args.Length >= 3 && args[1].ToLower() == "to" && (args[2].ToLower() == "house" || args[2].ToLower() == "myhouse"))
                {
                    House house = null;
                    if (args[2] == "myhouse")
                    {
                        house = HouseMgr.GetHouseByPlayer(client.Player);
                    }
                    else
                    {
                        house = HouseMgr.GetHouse(Convert.ToInt32(args[3]));
                    }
                    if (house != null)
                    {
                        client.Player.MoveTo(house.OutdoorJumpPoint);
                    }
                    else
                    {
                        client.Out.SendMessage("This house number is not owned by anyone!", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                    }
                    return;
                }
                #endregion Jump to house
                #region Jump t region #
                if (args.Length == 4 && args[1] == "to" && args[2] == "region")
                {
                    client.Player.MoveTo(Convert.ToUInt16(args[3]), client.Player.X, client.Player.Y, client.Player.Z, client.Player.Heading);
                    return;
                }
                #endregion Jump t region #
                #region Jump to PlayerName or ClientID
                if (args.Length == 3 && args[1] == "to")
                {
                    GameClient clientc = null;
                    if (args[2].StartsWith("#"))
                    {
                        try
                        {
                            var sessionID = Convert.ToUInt32(args[2].Substring(1));
                            clientc = WorldMgr.GetClientFromID(sessionID);
                        }
                        catch
                        {
                        }
                    }
                    else
                    {
                        clientc = WorldMgr.GetClientByPlayerName(args[2], false, true);
                    }

                    if (clientc == null)
                    {
                        GameNPC[] npcs = WorldMgr.GetNPCsByName(args[2], eRealm.None);

                        if (npcs.Length > 0)
                        {
                            // for multiple npc's first try to jump to the npc in the players current region
                            GameNPC jumpTarget = npcs[0];

                            foreach (GameNPC npc in npcs)
                            {
                                if (npc.CurrentRegionID == client.Player.CurrentRegionID)
                                {
                                    jumpTarget = npc;
                                    break;
                                }
                            }

                            client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Jump.JumpToX", npcs[0].CurrentRegion.Description), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                            if (jumpTarget.InHouse && jumpTarget.CurrentHouse != null)
                            {
                                jumpTarget.CurrentHouse.Enter(client.Player);
                            }
                            else
                            {
                                client.Player.MoveTo(jumpTarget.CurrentRegionID, jumpTarget.X, jumpTarget.Y, jumpTarget.Z, jumpTarget.Heading);
                            }
                            return;
                        }

                        client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Jump.CannotBeFound", args[2]), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        return;
                    }

                    if (CheckExpansion(client, clientc, clientc.Player.CurrentRegionID))
                    {
                        client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Jump.JumpToX", clientc.Player.CurrentRegion.Description), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        if (clientc.Player.CurrentHouse != null && clientc.Player.InHouse)
                        {
                            clientc.Player.CurrentHouse.Enter(client.Player);
                        }
                        else
                        {
                            client.Player.MoveTo(clientc.Player.CurrentRegionID, clientc.Player.X, clientc.Player.Y, clientc.Player.Z, client.Player.Heading);
                        }
                        return;
                    }

                    client.Out.SendMessage("You don't have an expansion needed to jump to this location.", eChatType.CT_System, eChatLoc.CL_SystemWindow);

                    return;
                }
                #endregion Jump to PlayerName
                #region Jump to Name Realm
                else if (args.Length == 4 && args[1] == "to")
                {
                    GameClient clientc;
                    clientc = WorldMgr.GetClientByPlayerName(args[2], false, true);
                    if (clientc == null)
                    {
                        int realm = 0;
                        int.TryParse(args[3], out realm);

                        GameNPC[] npcs = WorldMgr.GetNPCsByName(args[2], (eRealm)realm);

                        if (npcs.Length > 0)
                        {
                            // for multiple npc's first try to jump to the npc in the players current region
                            GameNPC jumpTarget = npcs[0];

                            foreach (GameNPC npc in npcs)
                            {
                                if (npc.CurrentRegionID == client.Player.CurrentRegionID)
                                {
                                    jumpTarget = npc;
                                    break;
                                }
                            }

                            client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Jump.JumpToX", npcs[0].CurrentRegion.Description), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                            client.Player.MoveTo(jumpTarget.CurrentRegionID, jumpTarget.X, jumpTarget.Y, jumpTarget.Z, jumpTarget.Heading);
                            return;
                        }

                        client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Jump.CannotBeFoundInRealm", args[2], realm), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        return;
                    }
                    if (CheckExpansion(client, clientc, clientc.Player.CurrentRegionID))
                    {
                        if (clientc.Player.InHouse)
                        {
                            client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Jump.CannotJumpToInsideHouse"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                            return;
                        }
                        client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Jump.JumpToX", clientc.Player.CurrentRegion.Description), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        if (clientc.Player.CurrentHouse != null && clientc.Player.InHouse)
                        {
                            clientc.Player.CurrentHouse.Enter(client.Player);
                        }
                        else
                        {
                            client.Player.MoveTo(clientc.Player.CurrentRegionID, clientc.Player.X, clientc.Player.Y, clientc.Player.Z, client.Player.Heading);
                        }
                        return;
                    }
                    return;
                }
                #endregion Jump to Name Realm
                #region Jump to X Y Z
                else if (args.Length == 5 && args[1] == "to")
                {
                    client.Player.MoveTo(client.Player.CurrentRegionID, Convert.ToInt32(args[2]), Convert.ToInt32(args[3]), Convert.ToInt32(args[4]), client.Player.Heading);
                    return;
                }
                #endregion Jump to X Y Z
                #region Jump rel +/-X +/-Y +/-Z
                else if (args.Length == 5 && args[1] == "rel")
                {
                    client.Player.MoveTo(client.Player.CurrentRegionID,
                                         client.Player.X + Convert.ToInt32(args[2]),
                                         client.Player.Y + Convert.ToInt32(args[3]),
                                         client.Player.Z + Convert.ToInt32(args[4]),
                                         client.Player.Heading);
                    return;
                }
                #endregion Jump rel +/-X +/-Y +/-Z
                #region Jump to X Y Z RegionID
                else if (args.Length == 6 && args[1] == "to")
                {
                    if (CheckExpansion(client, client, (ushort)Convert.ToUInt16(args[5])))
                    {
                        client.Player.MoveTo(Convert.ToUInt16(args[5]), Convert.ToInt32(args[2]), Convert.ToInt32(args[3]), Convert.ToInt32(args[4]), client.Player.Heading);
                        return;
                    }
                    return;
                }
                #endregion Jump to X Y Z RegionID
                #region Jump PlayerName to X Y Z
                else if (args.Length == 6 && args[2] == "to")
                {
                    GameClient clientc;
                    clientc = WorldMgr.GetClientByPlayerName(args[1], false, true);
                    if (clientc == null)
                    {
                        client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Jump.PlayerIsNotInGame", args[1]), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        return;
                    }
                    clientc.Player.MoveTo(clientc.Player.CurrentRegionID, Convert.ToInt32(args[3]), Convert.ToInt32(args[4]), Convert.ToInt32(args[5]), clientc.Player.Heading);
                    return;
                }
                #endregion Jump PlayerName to X Y Z
                #region Jump PlayerName to X Y Z RegionID
                else if (args.Length == 7 && args[2] == "to")
                {
                    GameClient clientc;
                    clientc = WorldMgr.GetClientByPlayerName(args[1], false, true);
                    if (clientc == null)
                    {
                        client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Jump.PlayerIsNotInGame", args[1]), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        return;
                    }
                    if (CheckExpansion(clientc, clientc, (ushort)Convert.ToUInt16(args[6])))
                    {
                        clientc.Player.MoveTo(Convert.ToUInt16(args[6]), Convert.ToInt32(args[3]), Convert.ToInt32(args[4]), Convert.ToInt32(args[5]), clientc.Player.Heading);
                        return;
                    }
                    return;
                }
                #endregion Jump PlayerName to X Y Z RegionID
                #region Jump PlayerName to PlayerCible
                else if (args.Length == 4 && args[2] == "to")
                {
                    GameClient clientc;
                    GameClient clientto;
                    clientc = WorldMgr.GetClientByPlayerName(args[1], false, true);
                    if (clientc == null)
                    {
                        client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Jump.PlayerIsNotInGame", args[1]), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        return;
                    }
                    if (args[3] == "me")
                    {
                        clientto = client;
                    }
                    else
                    {
                        clientto = WorldMgr.GetClientByPlayerName(args[3], false, false);
                    }

                    if (clientto == null)
                    {
                        client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Jump.PlayerIsNotInGame", args[3]), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        return;
                    }
                    else
                    {
                        if (CheckExpansion(clientto, clientc, clientto.Player.CurrentRegionID))
                        {
                            if (clientto.Player.CurrentHouse != null && clientto.Player.InHouse)
                            {
                                clientto.Player.CurrentHouse.Enter(clientc.Player);
                            }
                            else
                            {
                                clientc.Player.MoveTo(clientto.Player.CurrentRegionID, clientto.Player.X, clientto.Player.Y, clientto.Player.Z, client.Player.Heading);
                            }
                            return;
                        }
                        return;
                    }
                }
                #endregion Jump PlayerName to PlayerCible
                #region push/pop
                else if (args.Length > 1 && args[1] == "push")
                {
                    Stack <GameLocation> locations;

                    locations = client.Player.TempProperties.getProperty <object>(TEMP_KEY_JUMP, null) as Stack <GameLocation>;

                    if (locations == null)
                    {
                        locations = new Stack <GameLocation>(3);
                        client.Player.TempProperties.setProperty(TEMP_KEY_JUMP, locations);
                    }

                    locations.Push(new GameLocation("temploc", client.Player.CurrentRegionID, client.Player.X, client.Player.Y, client.Player.Z, client.Player.Heading));

                    string message = LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Jump.Pushed");

                    if (locations.Count > 1)
                    {
                        message += " " + LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Jump.PushedTotal", locations.Count);
                    }

                    message += " - " + LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Jump.PopInstructions");

                    client.Out.SendMessage(message, eChatType.CT_System, eChatLoc.CL_SystemWindow);
                }
                else if (args.Length > 1 && args[1] == "pop")
                {
                    Stack <GameLocation> locations;

                    locations = client.Player.TempProperties.getProperty <object>(TEMP_KEY_JUMP, null) as Stack <GameLocation>;

                    if (locations == null || locations.Count < 1)
                    {
                        client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Jump.NothingPushed"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        return;
                    }

                    GameLocation jumploc = locations.Pop();

                    // slight abuse of the stack principle, but convenient to always have your last popped loc jumpable
                    if (locations.Count < 1)
                    {
                        locations.Push(jumploc);
                    }

                    client.Player.MoveTo(jumploc.RegionID, jumploc.X, jumploc.Y, jumploc.Z, jumploc.Heading);
                }
                #endregion push/pop
                #region DisplaySyntax
                else
                {
                    DisplaySyntax(client);
                    return;
                }
                #endregion DisplaySyntax
            }

            catch (Exception ex)
            {
                DisplayMessage(client, ex.Message);
            }
        }
コード例 #3
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)));
        }
コード例 #4
0
ファイル: house.cs プロジェクト: JVirant/DOLSharp
        public void OnCommand(GameClient client, string[] args)
        {
            try
            {
                if (client.Account.PrivLevel > (int)ePrivLevel.Player)
                {
                    if (args.Length > 1)
                    {
                        HouseAdmin(client.Player, args);
                        return;
                    }

                    if (client.Account.PrivLevel >= (int)ePrivLevel.GM)
                    {
                        DisplayMessage(client, "GM: info - Display house info for a nearby house");
                    }

                    if (client.Account.PrivLevel == (int)ePrivLevel.Admin)
                    {
                        DisplayMessage(client, "Admin: model <1 - 12> - change house model");
                        DisplayMessage(client, "Admin: restart - restart the housing manager");
                        DisplayMessage(client, "Admin: addhookpoints - allow adding of missing hookpoints");
                        DisplayMessage(client, "Admin: remove <YES> - remove this house!");
                    }
                }

                House house = HouseMgr.GetHouseByPlayer(client.Player);

                if (house != null)
                {
                    if (client.Player.Guild != null)
                    {
                        // check to see if guild emblem is current
                        if (house.Emblem != client.Player.Guild.Emblem)
                        {
                            house.Emblem = client.Player.Guild.Emblem;
                            house.SaveIntoDatabase();
                        }
                    }

                    if (house.RegionID == client.Player.CurrentRegionID && client.Player.InHouse == false)
                    {
                        // let's force update their house to make sure they can see it

                        client.Out.SendHouse(house);
                        client.Out.SendGarden(house);

                        if (house.IsOccupied)
                        {
                            client.Out.SendHouseOccupied(house, true);
                        }
                    }

                    // Send the house info dialog
                    house.SendHouseInfo(client.Player);
                }
                else
                {
                    DisplayMessage(client, "You do not own a house.");
                }

                // now check for a guild house and update emblem if needed, then force update

                if (client.Player.Guild != null && client.Player.Guild.GuildOwnsHouse && client.Player.Guild.GuildHouseNumber > 0)
                {
                    House guildHouse = HouseMgr.GetHouse(client.Player.Guild.GuildHouseNumber);

                    if (guildHouse != null)
                    {
                        if (guildHouse.Emblem != client.Player.Guild.Emblem)
                        {
                            guildHouse.Emblem = client.Player.Guild.Emblem;
                            guildHouse.SaveIntoDatabase();
                            guildHouse.SendUpdate();                             // forces refresh
                        }
                        else if (guildHouse.RegionID == client.Player.CurrentRegionID)
                        {
                            guildHouse.SendUpdate();                             // forces refresh
                        }
                    }
                }
            }
            catch
            {
                DisplaySyntax(client);
            }
        }