private void _junkItem(short id, int amountRemoved, int amountRemaining, byte weight, byte maxWeight)
        {
            OldWorld.Instance.MainPlayer.ActiveCharacter.UpdateInventoryItem(id, amountRemaining, weight, maxWeight);

            var rec = OldWorld.Instance.EIF[id];

            m_game.Hud.AddChat(ChatTab.System, "",
                               $"{OldWorld.GetString(EOResourceID.STATUS_LABEL_ITEM_JUNK_YOU_JUNKED)} {amountRemoved} {rec.Name}", ChatIcon.DownArrow);
            m_game.Hud.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_INFORMATION, EOResourceID.STATUS_LABEL_ITEM_JUNK_YOU_JUNKED,
                                      $" {amountRemoved} {rec.Name}");
        }
        private void _dropItem(int characterAmount, byte weight, byte maxWeight, OldMapItem item)
        {
            OldWorld.Instance.ActiveMapRenderer.AddMapItem(item);
            if (characterAmount >= 0) //will be -1 when another player drops
            {
                OldWorld.Instance.MainPlayer.ActiveCharacter.UpdateInventoryItem(item.ItemID, characterAmount, weight, maxWeight);

                var rec = OldWorld.Instance.EIF[item.ItemID];
                m_game.Hud.AddChat(ChatTab.System, "",
                                   $"{OldWorld.GetString(EOResourceID.STATUS_LABEL_ITEM_DROP_YOU_DROPPED)} {item.Amount} {rec.Name}",
                                   ChatIcon.DownArrow);
                m_game.Hud.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_INFORMATION, EOResourceID.STATUS_LABEL_ITEM_DROP_YOU_DROPPED,
                                          $" {item.Amount} {rec.Name}");
            }
        }
        private void _getItemFromMap(short uid, short id, int amountTaken, byte weight, byte maxWeight)
        {
            if (uid != 0) //$si command has UniqueID of 0 since we're creating a new item from nothing
            {
                OldWorld.Instance.ActiveMapRenderer.UpdateMapItemAmount(uid, amountTaken);
            }

            OldWorld.Instance.MainPlayer.ActiveCharacter.UpdateInventoryItem(id, amountTaken, weight, maxWeight, true);

            var rec = OldWorld.Instance.EIF[id];

            m_game.Hud.AddChat(ChatTab.System, "",
                               $"{OldWorld.GetString(EOResourceID.STATUS_LABEL_ITEM_PICKUP_YOU_PICKED_UP)} {amountTaken} {rec.Name}", ChatIcon.UpArrow);
            m_game.Hud.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_INFORMATION, EOResourceID.STATUS_LABEL_ITEM_PICKUP_YOU_PICKED_UP,
                                      $" {amountTaken} {rec.Name}");
        }
        private void _tradeOpen(short p1, string p1name, short p2, string p2name)
        {
            TradeDialog dlg = new TradeDialog(m_packetAPI);

            dlg.InitPlayerInfo(p1, p1name, p2, p2name);

            string otherName;

            if (p1 == OldWorld.Instance.MainPlayer.ActiveCharacter.ID)
            {
                otherName = p2name;
            }
            else if (p2 == OldWorld.Instance.MainPlayer.ActiveCharacter.ID)
            {
                otherName = p1name;
            }
            else
            {
                throw new ArgumentException("Invalid player ID for this trade session!", nameof(p1));
            }

            m_game.Hud.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_ACTION, EOResourceID.STATUS_LABEL_TRADE_YOU_ARE_TRADING_WITH,
                                      otherName + " " + OldWorld.GetString(EOResourceID.STATUS_LABEL_DRAG_AND_DROP_ITEMS));
        }
示例#5
0
        public void UpdateInventoryItem(short id, int characterAmount, byte characterWeight, byte characterMaxWeight, bool addToExistingAmount = false)
        {
            InventoryItem rec;

            if ((rec = Inventory.Find(item => item.ItemID == id)).ItemID == id)
            {
                InventoryItem newRec = new InventoryItem
                                           (amount: addToExistingAmount ? characterAmount + rec.Amount : characterAmount,
                                           itemID: id);
                if (this == OldWorld.Instance.MainPlayer.ActiveCharacter)
                {
                    //false when AddItem fails to find a good spot
                    if (!EOGame.Instance.Hud.UpdateInventory(newRec))
                    {
                        EOMessageBox.Show(OldWorld.GetString(EOResourceID.STATUS_LABEL_ITEM_PICKUP_NO_SPACE_LEFT),
                                          OldWorld.GetString(EOResourceID.STATUS_LABEL_TYPE_WARNING),
                                          EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
                        return;
                    }
                }

                //if we can hold it, update local inventory and weight stats
                if (!Inventory.Remove(rec))
                {
                    throw new Exception("Unable to remove from inventory!");
                }
                if (newRec.Amount > 0)
                {
                    Inventory.Add(newRec);
                }
                Weight    = characterWeight;
                MaxWeight = characterMaxWeight;
                if (this == OldWorld.Instance.MainPlayer.ActiveCharacter)
                {
                    EOGame.Instance.Hud.RefreshStats();
                }
            }
            else
            {
                //for item_get/chest_get packets, the item may not be in the inventory yet
                InventoryItem newRec = new InventoryItem(amount: characterAmount, itemID: id);
                if (newRec.Amount <= 0)
                {
                    return;
                }

                Inventory.Add(newRec);
                if (this == OldWorld.Instance.MainPlayer.ActiveCharacter)
                {
                    //false when AddItem fails to find a good spot
                    if (!EOGame.Instance.Hud.UpdateInventory(newRec))
                    {
                        EOMessageBox.Show(OldWorld.GetString(EOResourceID.STATUS_LABEL_ITEM_PICKUP_NO_SPACE_LEFT),
                                          OldWorld.GetString(EOResourceID.STATUS_LABEL_TYPE_WARNING),
                                          EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
                        return;
                    }
                }
                Weight    = characterWeight;
                MaxWeight = characterMaxWeight;
                if (this == OldWorld.Instance.MainPlayer.ActiveCharacter)
                {
                    EOGame.Instance.Hud.RefreshStats();
                }
            }
        }