Exemplo n.º 1
0
        public void OnCommand(GameClient client, string[] args)
        {
            int housenumber = 0;

            if (args.Length > 1)
            {
                try
                {
                    housenumber = int.Parse(args[1]);
                }
                catch
                {
                    DisplaySyntax(client);
                    return;
                }
            }
            else
            {
                HouseMgr.GetHouseNumberByPlayer(client.Player);
            }

            if (housenumber == 0)
            {
                DisplayMessage(client, "No house found.");
                return;
            }

            House house = HouseMgr.GetHouse(housenumber);

            ushort direction = client.Player.GetHeading(house.Position);

            client.Player.Heading = direction;
            client.Out.SendPlayerJump(true);
            DisplayMessage(client, "You face house " + housenumber);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Check all items that belong to this ownerid and fix the OwnerLot if needed
        /// </summary>
        public virtual bool CheckInventory()
        {
            House house = HouseMgr.GetHouse(CurrentRegionID, HouseNumber);

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

            bool isFixed = false;

            String sqlWhere = String.Format("OwnerID = '{0}' and SlotPosition >= {1} and SlotPosition <= {2} and OwnerLot = 0", house.OwnerID, FirstDBSlot, LastDBSlot);

            var items = GameServer.Database.SelectObjects <InventoryItem>(sqlWhere);

            foreach (InventoryItem item in items)
            {
                item.OwnerLot = (ushort)HouseNumber;
                GameServer.Database.SaveObject(item);
                MarketCache.AddItem(item);
                if (ServerProperties.Properties.MARKET_ENABLE_LOG)
                {
                    log.DebugFormat("CM: Fixed OwnerLot for item '{0}' on CM for lot {1}", item.Name, HouseNumber);
                }
                isFixed = true;
            }

            return(isFixed);
        }
Exemplo n.º 3
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);
                        }
                    }
                }
            }
Exemplo n.º 4
0
        /// <summary>
        /// Not Livelike but looks better - adds the owners guild emblem to the consignment merchants cloak
        /// </summary>
        public virtual void SetEmblem()
        {
            if (Inventory == null)
            {
                return;
            }

            House house = HouseMgr.GetHouse(HouseNumber);

            if (house == null)
            {
                return;
            }

            if (house.DatabaseItem.GuildHouse)
            {
                var guild  = GameServer.Database.SelectObject <DBGuild>("GuildName = '" + house.DatabaseItem.GuildName + "'");
                int emblem = guild.Emblem;

                InventoryItem cloak = Inventory.GetItem(eInventorySlot.Cloak);
                if (cloak != null)
                {
                    cloak.Emblem = emblem;
                    BroadcastLivingEquipmentUpdate();
                }
            }
        }
Exemplo n.º 5
0
        public override bool AddToWorld()
        {
            House house = HouseMgr.GetHouse(HouseNumber);

            if (house == null)
            {
                log.ErrorFormat("CM: Can't find house #{0}!", HouseNumber);
                return(false);
            }

            SetInventoryTemplate();

            var houseCM = GameServer.Database.SelectObject <HouseConsignmentMerchant>("HouseNumber = '" + HouseNumber + "'");

            if (houseCM != null)
            {
                TotalMoney = houseCM.Money;
            }
            else
            {
                log.ErrorFormat("CM: Can't find HouseConsignmentMerchant entry for CM on lot {0}!", HouseNumber);
                return(false);
            }

            base.AddToWorld();

            house.ConsignmentMerchant = this;
            SetEmblem();

            CheckInventory();

            return(true);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Not Livelike but looks better - adds the owners guild emblem to the consignment merchants cloak
        /// </summary>
        public virtual void SetEmblem()
        {
            if (Inventory == null)
            {
                return;
            }

            House house = HouseMgr.GetHouse(HouseNumber);

            if (house == null)
            {
                return;
            }

            if (house.DatabaseItem.GuildHouse)
            {
                var guild = DOLDB <DBGuild> .SelectObject(DB.Column(nameof(DBGuild.GuildName)).IsEqualTo(house.DatabaseItem.GuildName));

                int emblem = guild.Emblem;

                InventoryItem cloak = Inventory.GetItem(eInventorySlot.Cloak);
                if (cloak != null)
                {
                    cloak.Emblem = emblem;
                    BroadcastLivingEquipmentUpdate();
                }
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Not Livelike but looks better - adds the owners guild emblem to the consignment merchants cloak
        /// </summary>
        public virtual void SetEmblem()
        {
            if (Inventory == null)
            {
                return;
            }

            House house = HouseMgr.GetHouse(HouseNumber);

            if (house == null)
            {
                return;
            }

            if (house.DatabaseItem.GuildHouse)
            {
                var guild  = GameServer.Database.SelectObjects <DBGuild>("`GuildName` = @GuildName", new QueryParameter("@GuildName", house.DatabaseItem.GuildName)).FirstOrDefault();
                int emblem = guild.Emblem;

                InventoryItem cloak = Inventory.GetItem(eInventorySlot.Cloak);
                if (cloak != null)
                {
                    cloak.Emblem = emblem;
                    BroadcastLivingEquipmentUpdate();
                }
            }
        }
        public void HandlePacket(GameClient client, GSPacketIn packet)
        {
            int    unk1        = packet.ReadByte();
            int    unk2        = packet.ReadByte();
            ushort houseNumber = packet.ReadShort();

            // house is null, return
            var house = HouseMgr.GetHouse(houseNumber);

            if (house == null)
            {
                return;
            }

            // player is null, return
            if (client.Player == null)
            {
                return;
            }

            // player has no owner permissions and isn't a GM or admin, return
            if (!house.HasOwnerPermissions(client.Player) && client.Account.PrivLevel <= 1)
            {
                return;
            }

            // build the packet
            client.Out.SendHouseUsersPermissions(house);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Check all items that belong to this ownerid and fix the OwnerLot if needed
        /// </summary>
        public virtual bool CheckInventory()
        {
            House house = HouseMgr.GetHouse(CurrentRegionID, HouseNumber);

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

            bool isFixed = false;

            var items = GameServer.Database.SelectObjects <InventoryItem>("`OwnerID` = @OwnerID AND `SlotPosition` >= @SlotPositionMin AND `SlotPosition` <= @SlotPositionMax AND `OwnerLot` = @OwnerLot", new[] { new QueryParameter("@OwnerID", house.OwnerID), new QueryParameter("@SlotPositionMin", FirstDBSlot), new QueryParameter("@SlotPositionMax", LastDBSlot), new QueryParameter("@OwnerLot", 0) });

            foreach (InventoryItem item in items)
            {
                item.OwnerLot = (ushort)HouseNumber;
                MarketCache.AddItem(item);
                if (ServerProperties.Properties.MARKET_ENABLE_LOG)
                {
                    log.DebugFormat("CM: Fixed OwnerLot for item '{0}' on CM for lot {1}", item.Name, HouseNumber);
                }
                isFixed = true;
            }
            GameServer.Database.SaveObject(items);

            return(isFixed);
        }
Exemplo n.º 10
0
        public override bool AddToWorld()
        {
            House house = HouseMgr.GetHouse(HouseNumber);

            if (house == null)
            {
                log.ErrorFormat("CM: Can't find house #{0}!", HouseNumber);
                return(false);
            }

            SetInventoryTemplate();

            var houseCM = DOLDB <HouseConsignmentMerchant> .SelectObject(DB.Column(nameof(HouseConsignmentMerchant.HouseNumber)).IsEqualTo(HouseNumber));

            if (houseCM != null)
            {
                TotalMoney = houseCM.Money;
            }
            else
            {
                log.ErrorFormat("CM: Can't find HouseConsignmentMerchant entry for CM on lot {0}!", HouseNumber);
                return(false);
            }

            base.AddToWorld();

            house.ConsignmentMerchant = this;
            SetEmblem();

            CheckInventory();

            return(true);
        }
Exemplo n.º 11
0
        private static void HouseUpgradeDialog(GamePlayer player, byte response)
        {
            if (response != 0x01)
            {
                return;
            }

            var itemWeak = player.TempProperties.getProperty <WeakReference>(DeedWeak, new WeakRef(null));

            player.TempProperties.removeProperty(DeedWeak);

            var item  = (InventoryItem)itemWeak.Target;
            var house = (House)player.TempProperties.getProperty <object>(TargetHouse, null);

            player.TempProperties.removeProperty(TargetHouse);

            if (house == null)
            {
                ChatUtil.SendSystemMessage(player, "No House selected!");
                return;
            }

            if (item == null || item.SlotPosition == (int)eInventorySlot.Ground ||
                item.OwnerID == null || item.OwnerID != player.InternalID)
            {
                ChatUtil.SendSystemMessage(player, "This does not work without a House Deed.");
                return;
            }

            if (HouseMgr.UpgradeHouse(house, item))
            {
                player.Inventory.RemoveItem(item);
                InventoryLogging.LogInventoryAction(player, $"(HOUSE;{house.HouseNumber})", eInventoryActionType.Other, item.Template, item.Count);
            }
        }
Exemplo n.º 12
0
        private void OpenWindow(GameClient client, House house, eMerchantWindowType type)
        {
            switch (type)
            {
            case eMerchantWindowType.HousingOutsideShop:
            case eMerchantWindowType.HousingOutsideMenu:
                if (!house.CanChangeGarden(client.Player, DecorationPermissions.Add))
                {
                    return;
                }
                HouseMgr.SendHousingMerchantWindow(client.Player, type);
                break;

            case eMerchantWindowType.HousingDeedMenu:
            case eMerchantWindowType.HousingVaultHookpoint:
            case eMerchantWindowType.HousingCraftingHookpoint:
            case eMerchantWindowType.HousingBindstoneHookpoint:
            case eMerchantWindowType.HousingNPCHookpoint:
            case eMerchantWindowType.HousingInsideShop:
            case eMerchantWindowType.HousingInsideMenu:
                if (!house.CanChangeInterior(client.Player, DecorationPermissions.Add))
                {
                    return;
                }
                HouseMgr.SendHousingMerchantWindow(client.Player, type);
                break;

            case (eMerchantWindowType)0xFF:
                house.SendHouseInfo(client.Player);
                break;
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// Check all items that belong to this ownerid and fix the OwnerLot if needed
        /// </summary>
        public virtual bool CheckInventory()
        {
            House house = HouseMgr.GetHouse(CurrentRegionID, HouseNumber);

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

            bool isFixed = false;

            var items = DOLDB <InventoryItem> .SelectObjects(DB.Column(nameof(InventoryItem.OwnerID)).IsEqualTo(house.OwnerID).And(DB.Column(nameof(InventoryItem.SlotPosition)).IsGreaterOrEqualTo(FirstDBSlot)).And(DB.Column(nameof(InventoryItem.SlotPosition)).IsLessOrEqualTo(LastDBSlot)).And(DB.Column(nameof(InventoryItem.OwnerLot)).IsEqualTo(0)));

            foreach (InventoryItem item in items)
            {
                item.OwnerLot = (ushort)HouseNumber;
                MarketCache.AddItem(item);
                if (ServerProperties.Properties.MARKET_ENABLE_LOG)
                {
                    log.DebugFormat("CM: Fixed OwnerLot for item '{0}' on CM for lot {1}", item.Name, HouseNumber);
                }
                isFixed = true;
            }
            GameServer.Database.SaveObject(items);

            return(isFixed);
        }
Exemplo n.º 14
0
        public void HandlePacket(GameClient client, GSPacketIn packet)
        {
            packet.ReadShort(); // pid
            ushort housenumber = packet.ReadShort();

            // house is null, return
            var house = HouseMgr.GetHouse(housenumber);

            if (house == null)
            {
                return;
            }

            // player is null, return
            if (client.Player == null)
            {
                return;
            }

            // player has no owner permissions and isn't a GM or admin, return
            if (!house.HasOwnerPermissions(client.Player) && client.Account.PrivLevel <= 1)
            {
                return;
            }

            // send out the house permissions
            using (var pak = new GSTCPPacketOut(client.Out.GetPacketCode(eServerPackets.HousingPermissions)))
            {
                pak.WriteByte(HousingConstants.MaxPermissionLevel); // number of permissions ?
                pak.WriteByte(0x00);                                // unknown
                pak.WriteShort((ushort)house.HouseNumber);

                foreach (var entry in house.PermissionLevels)
                {
                    var level      = entry.Key;
                    var permission = entry.Value;

                    pak.WriteByte((byte)level);
                    pak.WriteByte(permission.CanEnterHouse ? (byte)1 : (byte)0);
                    pak.WriteByte(permission.Vault1);
                    pak.WriteByte(permission.Vault2);
                    pak.WriteByte(permission.Vault3);
                    pak.WriteByte(permission.Vault4);
                    pak.WriteByte(permission.CanChangeExternalAppearance ? (byte)1 : (byte)0);
                    pak.WriteByte(permission.ChangeInterior);
                    pak.WriteByte(permission.ChangeGarden);
                    pak.WriteByte(permission.CanBanish ? (byte)1 : (byte)0);
                    pak.WriteByte(permission.CanUseMerchants ? (byte)1 : (byte)0);
                    pak.WriteByte(permission.CanUseTools ? (byte)1 : (byte)0);
                    pak.WriteByte(permission.CanBindInHouse ? (byte)1 : (byte)0);
                    pak.WriteByte(permission.ConsignmentMerchant);
                    pak.WriteByte(permission.CanPayRent ? (byte)1 : (byte)0);
                    pak.WriteByte(0x00); // ??
                }

                client.Out.SendTCP(pak);
            }
        }
        public void HandlePacket(GameClient client, GSPacketIn packet)
        {
            // player is null, return

            // active consignment merchant is null, return
            if (!(client.Player?.ActiveInventoryObject is GameConsignmentMerchant conMerchant))
            {
                return;
            }

            // current house is null, return
            House house = HouseMgr.GetHouse(conMerchant.HouseNumber);

            if (house == null)
            {
                return;
            }

            // make sure player has permissions to withdraw from the consignment merchant
            if (!house.CanUseConsignmentMerchant(client.Player, ConsignmentPermissions.Withdraw))
            {
                client.Player.Out.SendMessage("You don't have permission to withdraw money from this merchant!", eChatType.CT_Important, eChatLoc.CL_ChatWindow);
                return;
            }

            lock (conMerchant.LockObject())
            {
                long totalConMoney = conMerchant.TotalMoney;

                if (totalConMoney > 0)
                {
                    if (ServerProperties.Properties.CONSIGNMENT_USE_BP)
                    {
                        client.Player.Out.SendMessage($"You withdraw {totalConMoney} BountyPoints from your Merchant.", eChatType.CT_Important, eChatLoc.CL_ChatWindow);
                        client.Player.BountyPoints += totalConMoney;
                        client.Player.Out.SendUpdatePoints();
                    }
                    else
                    {
                        ChatUtil.SendMerchantMessage(client, "GameMerchant.OnPlayerWithdraw", Money.GetString(totalConMoney));
                        client.Player.AddMoney(totalConMoney);
                        InventoryLogging.LogInventoryAction(conMerchant, client.Player, eInventoryActionType.Merchant, totalConMoney);
                    }

                    conMerchant.TotalMoney -= totalConMoney;

                    if (ServerProperties.Properties.MARKET_ENABLE_LOG)
                    {
                        Log.Debug($"CM: [{client.Player.Name}:{client.Account.Name}] withdraws {totalConMoney} from CM on lot {conMerchant.HouseNumber}.");
                    }

                    client.Out.SendConsignmentMerchantMoney(conMerchant.TotalMoney);
                }
            }
        }
Exemplo n.º 16
0
        public void HandlePacket(GameClient client, GSPacketIn packet)
        {
            int level = packet.ReadByte();

            packet.ReadByte(); // unk1
            ushort housenumber = packet.ReadShort();

            // make sure permission level is within bounds
            if (level < HousingConstants.MinPermissionLevel || level > HousingConstants.MaxPermissionLevel)
            {
                return;
            }

            // house is null, return
            var house = HouseMgr.GetHouse(housenumber);

            if (house == null)
            {
                return;
            }

            // player is null, return
            if (client.Player == null)
            {
                return;
            }

            // player has no owner permissions and isn't a GM or admin, return
            if (!house.HasOwnerPermissions(client.Player) && client.Account.PrivLevel <= 1)
            {
                return;
            }

            // read in the permission values
            DBHousePermissions permission = house.PermissionLevels[level];

            permission.CanEnterHouse = packet.ReadByte() != 0;
            permission.Vault1        = (byte)packet.ReadByte();
            permission.Vault2        = (byte)packet.ReadByte();
            permission.Vault3        = (byte)packet.ReadByte();
            permission.Vault4        = (byte)packet.ReadByte();
            permission.CanChangeExternalAppearance = packet.ReadByte() != 0;
            permission.ChangeInterior      = (byte)packet.ReadByte();
            permission.ChangeGarden        = (byte)packet.ReadByte();
            permission.CanBanish           = packet.ReadByte() != 0;
            permission.CanUseMerchants     = packet.ReadByte() != 0;
            permission.CanUseTools         = packet.ReadByte() != 0;
            permission.CanBindInHouse      = packet.ReadByte() != 0;
            permission.ConsignmentMerchant = (byte)packet.ReadByte();
            permission.CanPayRent          = packet.ReadByte() != 0;
            packet.ReadByte(); // unk2

            // save the updated permission
            GameServer.Database.SaveObject(permission);
        }
Exemplo n.º 17
0
        /// <summary>
        /// List of items in the Consignment Merchants Inventory
        /// </summary>
        public virtual IList <InventoryItem> DBItems(GamePlayer player = null)
        {
            House house = HouseMgr.GetHouse(CurrentRegionID, HouseNumber);

            if (house == null)
            {
                return(null);
            }

            return(MarketCache.Items.Where(item => item.OwnerID == house.OwnerID).ToList());
        }
Exemplo n.º 18
0
        /// <summary>
        /// What to do after an item is added.  For consignment merchants this is called after price is set
        /// </summary>
        /// <param name="player"></param>
        /// <param name="clientSlot"></param>
        /// <param name="price"></param>
        /// <returns></returns>
        public virtual bool SetSellPrice(GamePlayer player, ushort clientSlot, uint price)
        {
            GameConsignmentMerchant conMerchant = player.ActiveInventoryObject as GameConsignmentMerchant;

            if (conMerchant == null)
            {
                return(false);
            }
            House house = HouseMgr.GetHouse(conMerchant.HouseNumber);

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

            if (house.HasOwnerPermissions(player) == false)
            {
                return(false);
            }

            InventoryItem item = player.TempProperties.getProperty <InventoryItem>(GameInventoryObjectExtensions.ITEM_BEING_ADDED, null);

            if (item != null)
            {
                if (item.IsTradable)
                {
                    item.SellPrice = (int)price;
                }
                else
                {
                    // Unique DOL feature
                    item.SellPrice = 0;
                    player.Out.SendCustomDialog("This item is not tradable. You can store it here but cannot sell it.", null);
                }

                item.OwnerLot = conMerchant.HouseNumber;
                item.OwnerID  = conMerchant.GetOwner(player);
                GameServer.Database.SaveObject(item);
                ChatUtil.SendDebugMessage(player, item.Name + " SellPrice=" + price + ", OwnerLot=" + item.OwnerLot + ", OwnerID=" + item.OwnerID);
                player.Out.SendMessage("Price set!", eChatType.CT_System, eChatLoc.CL_SystemWindow);

                if (ServerProperties.Properties.MARKET_ENABLE_LOG)
                {
                    log.DebugFormat("CM: {0}:{1} set sell price of '{2}' to {3} for consignment merchant on lot {4}.", player.Name, player.Client.Account.Name, item.Name, item.SellPrice, HouseNumber);
                }

                NotifyObservers(player, null);
            }


            return(true);
        }
        public void HandlePacket(GameClient client, GSPacketIn packet)
        {
            if (client.Player == null)
            {
                return;
            }

            packet.ReadInt();   // X
            packet.ReadInt();   // Y
            packet.ReadShort(); // id
            ushort itemSlot  = packet.ReadShort();
            byte   itemCount = (byte)packet.ReadByte();
            byte   menuId    = (byte)packet.ReadByte();

            switch ((eMerchantWindowType)menuId)
            {
            case eMerchantWindowType.HousingInsideShop:
            case eMerchantWindowType.HousingOutsideShop:
            case eMerchantWindowType.HousingBindstoneHookpoint:
            case eMerchantWindowType.HousingCraftingHookpoint:
            case eMerchantWindowType.HousingNPCHookpoint:
            case eMerchantWindowType.HousingVaultHookpoint:
            case eMerchantWindowType.HousingDeedMenu:
            {
                HouseMgr.BuyHousingItem(client.Player, itemSlot, itemCount, (eMerchantWindowType)menuId);
                break;
            }

            default:
            {
                if (client.Player.TargetObject == null)
                {
                    return;
                }

                // Forward the buy process to the merchant
                if (client.Player.TargetObject is GameMerchant merchant)
                {
                    // Let merchant choose what happens
                    merchant.OnPlayerBuy(client.Player, itemSlot, itemCount);
                }
                else
                {
                    (client.Player.TargetObject as GameLotMarker)?.OnPlayerBuy(client.Player, itemSlot, itemCount);
                }

                break;
            }
            }
        }
Exemplo n.º 20
0
        /// <summary>
        /// Checks if the Player is allowed to move an Item
        /// </summary>
        /// <param name="player"></param>
        /// <returns></returns>
        public virtual bool HasPermissionToMove(GamePlayer player)
        {
            House house = HouseMgr.GetHouse(CurrentRegionID, HouseNumber);

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

            if (house.HasOwnerPermissions(player))
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 21
0
        public void HandlePacket(GameClient client, GSPacketIn packet)
        {
            int pid         = packet.ReadShort();
            int housenumber = packet.ReadShort();
            int enter       = packet.ReadByte();

            // house is null, return
            House house = HouseMgr.GetHouse(housenumber);

            if (house == null)
            {
                return;
            }

            new EnterLeaveHouseAction(client.Player, house, enter).Start(1);
        }
Exemplo n.º 22
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);
            }
        }
Exemplo n.º 23
0
        private static void HouseRemovalDialog(GamePlayer player, byte response)
        {
            if (response != 0x01)
            {
                return;
            }

            var itemWeak = player.TempProperties.getProperty <WeakReference>(DeedWeak, new WeakRef(null));

            player.TempProperties.removeProperty(DeedWeak);

            var item  = (InventoryItem)itemWeak.Target;
            var house = player.TempProperties.getProperty <House>(TargetHouse, null);

            player.TempProperties.removeProperty(TargetHouse);

            if (house == null)
            {
                ChatUtil.SendSystemMessage(player, "No house selected!");
                return;
            }

            if (item == null || item.SlotPosition == (int)eInventorySlot.Ground ||
                item.OwnerID == null || item.OwnerID != player.InternalID)
            {
                ChatUtil.SendSystemMessage(player, "You need a House Removal Deed for this.");
                return;
            }

            // Demand any consignment merchant inventory is removed before allowing a removal
            // Again, note that sometimes checks are done here, sometimes in housemgr. In this case, at least,
            // player will get remove item back if they answer no! - tolakram
            var consignmentMerchant = house.ConsignmentMerchant;

            if (consignmentMerchant != null && (consignmentMerchant.DBItems(player).Count > 0 || consignmentMerchant.TotalMoney > 0))
            {
                ChatUtil.SendSystemMessage(player, "All items and money must be removed from your consignment merchant in order to remove this house!");
                return;
            }

            player.Inventory.RemoveItem(item);
            Log.Warn($"HOUSING: {player.Name}:{player.Client.Account.Name} is removing house from lot {house.HouseNumber} owned by {house.OwnerID}");
            InventoryLogging.LogInventoryAction(player, $"(HOUSE;{house.HouseNumber})", eInventoryActionType.Other, item.Template, item.Count);
            HouseMgr.RemoveHouse(house);

            ChatUtil.SendSystemMessage(player, "Your house has been removed!");
        }
Exemplo n.º 24
0
        /// <summary>
        /// Player interacting with this Merchant.
        /// </summary>
        /// <param name="player"></param>
        /// <returns></returns>
        public override bool Interact(GamePlayer player)
        {
            if (!base.Interact(player))
            {
                return(false);
            }

            CheckInventory();

            if (player.ActiveInventoryObject != null)
            {
                player.ActiveInventoryObject.RemoveObserver(player);
                player.ActiveInventoryObject = null;
            }

            player.ActiveInventoryObject = this;

            AddObserver(player);

            House house = HouseMgr.GetHouse(CurrentRegionID, HouseNumber);

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

            if (house.CanUseConsignmentMerchant(player, ConsignmentPermissions.Any))
            {
                player.Out.SendInventoryItemsUpdate(GetClientInventory(player), eInventoryWindowType.ConsignmentOwner);

                long amount = m_totalMoney;
                player.Out.SendConsignmentMerchantMoney(amount);

                if (ServerProperties.Properties.CONSIGNMENT_USE_BP)
                {
                    player.Out.SendMessage("Your merchant currently holds " + amount + " BountyPoints.", eChatType.CT_Important, eChatLoc.CL_ChatWindow);
                }
            }
            else
            {
                player.Out.SendInventoryItemsUpdate(GetClientInventory(player), eInventoryWindowType.ConsignmentViewer);
            }

            return(true);
        }
Exemplo n.º 25
0
        public virtual void BuyItem(InventoryItem item, GamePlayer player)
        {
            GameConsignmentMerchant cm = HouseMgr.GetConsignmentByHouseNumber((int)item.OwnerLot);

            if (cm == null)
            {
                player.Out.SendMessage("I can't find the consigmnent merchant for this item!", eChatType.CT_Merchant, eChatLoc.CL_ChatWindow);
                log.ErrorFormat("ME: Error finding consignment merchant for lot {0}; {1}:{2} trying to buy {3}", item.OwnerLot, player.Name, player.Client.Account.Name, item.Name);
                return;
            }

            if (player.ActiveInventoryObject != null)
            {
                player.ActiveInventoryObject.RemoveObserver(player);
            }

            player.ActiveInventoryObject = cm;             // activate the target con merchant
            player.Out.SendInventoryItemsUpdate(cm.GetClientInventory(player), eInventoryWindowType.ConsignmentViewer);
            cm.AddObserver(player);
        }
Exemplo n.º 26
0
        public void HandlePacket(GameClient client, GSPacketIn packet)
        {
            ushort housenumber = packet.ReadShort();
            var    index       = (byte)packet.ReadByte();

            packet.ReadByte(); // unk1

            // house is null, return
            var house = HouseMgr.GetHouse(housenumber);

            if (house == null)
            {
                return;
            }

            // player is null, return
            if (client.Player == null)
            {
                return;
            }

            // rotation only works for inside items
            if (!client.Player.InHouse)
            {
                return;
            }

            // no permission to change the interior, return
            if (!house.CanChangeInterior(client.Player, DecorationPermissions.Add))
            {
                return;
            }

            var pak = new GSTCPPacketOut(client.Out.GetPacketCode(eServerPackets.HouseDecorationRotate));

            pak.WriteShort(housenumber);
            pak.WriteByte(index);
            pak.WriteByte(0x01);
            client.Out.SendTCP(pak);
        }
Exemplo n.º 27
0
        public void HandlePacket(GameClient client, GSPacketIn packet)
        {
            int    permissionSlot     = packet.ReadByte();
            int    newPermissionLevel = packet.ReadByte();
            ushort houseNumber        = packet.ReadShort();

            // house is null, return
            var house = HouseMgr.GetHouse(houseNumber);

            if (house == null)
            {
                return;
            }

            // player is null, return
            if (client.Player == null)
            {
                return;
            }

            // can't set permissions unless you're the owner.
            if (!house.HasOwnerPermissions(client.Player) && client.Account.PrivLevel <= 1)
            {
                return;
            }

            // check if we're setting or removing permissions
            if (newPermissionLevel == 100)
            {
                house.RemovePermission(permissionSlot);
            }
            else
            {
                house.AdjustPermissionSlot(permissionSlot, newPermissionLevel);
            }
        }
Exemplo n.º 28
0
        public void HandlePacket(GameClient client, GSPacketIn packet)
        {
            int housenumber = packet.ReadShort();
            int menuid      = packet.ReadByte();
            int flag        = packet.ReadByte();

            var house = HouseMgr.GetHouse(client.Player.CurrentRegionID, housenumber);

            if (house == null)
            {
                return;
            }

            if (client.Player == null)
            {
                return;
            }

            client.Player.CurrentHouse = house;

            var menu = _menu168;

            if (client.Version >= GameClient.eClientVersion.Version1127)
            {
                menu = _menu1127;
            }

            if (menu.TryGetValue(menuid, out var type))
            {
                OpenWindow(client, house, type);
            }
            else
            {
                client.Out.SendMessage("Invalid menu id " + menuid + " (hookpoint?).", eChatType.CT_System, eChatLoc.CL_SystemWindow);
            }
        }
Exemplo n.º 29
0
        public override void SendUpdatePlayer()
        {
            GamePlayer player = m_gameClient.Player;

            if (player == null)
            {
                return;
            }

            using (GSTCPPacketOut pak = new GSTCPPacketOut(GetPacketCode(eServerPackets.VariousUpdate)))
            {
                pak.WriteByte(0x03);                 //subcode
                pak.WriteByte(0x0e);                 //number of entry
                pak.WriteByte(0x00);                 //subtype
                pak.WriteByte(0x00);                 //unk
                //entry :

                pak.WriteByte(player.GetDisplayLevel(m_gameClient.Player));                 //level
                pak.WritePascalString(player.Name);

                pak.WriteByte((byte)(player.MaxHealth >> 8));                        // maxhealth high byte ?
                pak.WritePascalString(player.CharacterClass.Name);                   // class name
                pak.WriteByte((byte)(player.MaxHealth & 0xFF));                      // maxhealth low byte ?

                pak.WritePascalString(/*"The "+*/ player.CharacterClass.Profession); // Profession

                pak.WriteByte(0x00);                                                 //unk

                pak.WritePascalString(player.CharacterClass.GetTitle(player, player.Level));

                //todo make function to calcule realm rank
                //client.Player.RealmPoints
                //todo i think it s realmpoint percent not realrank
                pak.WriteByte((byte)player.RealmLevel);                                //urealm rank
                pak.WritePascalString(player.RealmRankTitle(player.Client.Account.Language));
                pak.WriteByte((byte)player.RealmSpecialtyPoints);                      // realm skill points

                pak.WritePascalString(player.CharacterClass.BaseName);                 // base class

                pak.WriteByte((byte)(HouseMgr.GetHouseNumberByPlayer(player) >> 8));   // personal house high byte
                pak.WritePascalString(player.GuildName);
                pak.WriteByte((byte)(HouseMgr.GetHouseNumberByPlayer(player) & 0xFF)); // personal house low byte

                pak.WritePascalString(player.LastName);

                pak.WriteByte(0x0);                 // ML Level
                pak.WritePascalString(player.RaceName);

                pak.WriteByte(0x0);
                if (player.GuildRank != null)
                {
                    pak.WritePascalString(player.GuildRank.Title);
                }
                else
                {
                    pak.WritePascalString("");
                }
                pak.WriteByte(0x0);

                AbstractCraftingSkill skill = CraftingMgr.getSkillbyEnum(player.CraftingPrimarySkill);
                if (skill != null)
                {
                    pak.WritePascalString(skill.Name);                     //crafter guilde: alchemist
                }
                else
                {
                    pak.WritePascalString("None");                     //no craft skill at start
                }
                pak.WriteByte(0x0);
                pak.WritePascalString(player.CraftTitle);                 //crafter title: legendary alchemist

                pak.WriteByte(0x0);
                pak.WritePascalString("None");                 //ML title

                // new in 1.75
                pak.WriteByte(0x0);
                string title = "None";
                if (player.CurrentTitle != PlayerTitleMgr.ClearTitle)
                {
                    title = GameServer.ServerRules.GetPlayerTitle(player, player);
                }
                pak.WritePascalString(title);                 // new in 1.74
                SendTCP(pak);
            }
        }
Exemplo n.º 30
0
        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);
            }
        }