Beispiel #1
0
        public bool FindFreeSlotInShop(BaseItem item, BagSlot bagSlot)
        {
            bool found = false;

            if (Shop.FindFreeSlot(item, bagSlot))
            {
                found = true;
                bagSlot.Bag = 6;
            }

            return found;
        }
 public static byte[] SendImbuedItem(BaseItem i)
 {
     Packet p = new Packet(500);
     p.WriteByte(i.Bag);
     p.WriteByte(i.Slot);
     p.WriteInt(i.ItemID);
     p.WriteShort(i.ReferenceID);
     p.WriteByte(i.bType);
     p.WriteByte(i.bKind);
     p.WriteShort(i.VisualID);
     p.WriteInt(i.Price);
     p.WriteHexString("00 00");
     Equipment e = i as Equipment;
     p.WriteByte(e.RequiredClass);
     p.WriteShort(e.Amount);
     p.WriteShort(e.RequiredLevel);
     p.WriteShort(e.RequiredDexterity);
     p.WriteShort(e.RequiredStrength);
     p.WriteShort(e.RequiredStamina);
     p.WriteShort(e.RequiredEnergy);
     p.WriteByte(e.MaxImbueTries);
     p.WriteShort(e.Durability);
     p.WriteShort(e.MaxDurability);
     p.WriteShort(e.Damage);
     p.WriteShort(e.Defence);
     p.WriteShort(e.AttackRating);
     p.WriteShort(e.AttackSpeed);
     p.WriteShort(e.AttackRange);
     p.WriteShort(e.IncMaxLife);
     p.WriteShort(e.IncMaxMana);
     p.WriteShort(e.IncLifeRegen);
     p.WriteShort(e.IncManaRegen);
     p.WriteShort(e.Critical);
     p.WriteByte(e.Plus);
     p.WriteByte(e.Slvl);
     p.WriteHexString("00"); // unknown
     p.WriteByte(e.ImbueTries);
     p.WriteHexString("00"); // unknown
     p.WriteShort(e.DragonSuccessImbueTries);
     p.WriteByte(e.DiscountRepairFee);
     p.WriteShort(e.TotalDragonImbueTries);
     p.WriteShort(e.DragonDamage);
     p.WriteShort(e.DragonDefence);
     p.WriteShort(e.DragonAttackRating);
     p.WriteShort(e.DragonLife);
     p.WriteByte(e.MappedData);
     if (!(e is Ring) && !(e is Necklace) && !(e is Cape))
         p.WriteByte(e.ForceSlot);
     p.WriteHexString("00 00"); // unknown
     if (e is Cape)
     {
         Cape c = e as Cape;
         p.WriteHexString("00 00"); // required guild position
         p.WriteHexString("00 00 00 00 00 00 00");
         p.WriteHexString("01 00"); // decrease times of durability
         p.WriteByte(c.PolishImbueTries); // polish imbue tries
         p.WriteShort(c.MaxPolishImbueTries); // polish max tries
         p.WriteShort(c.VigiStat1); // stat1
         p.WriteShort(c.VigiStat2); // stat2
         p.WriteShort(c.VigiStat3); // stat3
         p.WriteShort(c.VigiStat4); // stat4
         p.WriteHexString("00 00"); // stat5
         p.WriteShort(c.VigiStatAdd1); // stat1 increase
         p.WriteShort(c.VigiStatAdd2); // stat2 increase
         p.WriteShort(c.VigiStatAdd3); // stat3 increase
         p.WriteShort(c.VigiStatAdd4); // stat4 increase
         p.WriteHexString("00 00"); // stat5 increase
         p.WriteHexString("00 00"); // unknown
     }
     if (!(e is Ring) && !(e is Necklace) && !(e is Cape))
     {
         p.WriteByte(e.RebirthHole);
         p.WriteByte(e.RebirthHoleItem);
         p.WriteShort(e.RebirthHoleStat);
     }
     return p.GetWrittenBuffer(PacketIds.SendImbuedItem);
 }
        public void UpdateItem(BaseItem item)
        {
            //DbParameter ownerIdParameter = _db.CreateParameter(DbNames.UPDATEITEM_OWNERID_PARAMETER, item.OwnerID);
            //ownerIdParameter.DbType = DbType.Int32;

            //DbParameter costParameter = _db.CreateParameter(DbNames.UPDATEITEM_COST_PARAMETER, item.Price);
            //costParameter.DbType = DbType.Int32;

            //DbParameter reqClassParameter = _db.CreateParameter(DbNames.UPDATEITEM_REQCLASS_PARAMETER, item.RequiredClass);

            DbParameter OwnerIdParameter = _db.CreateParameter(DbNames.UPDATEITEM_OWNERID_PARAMETER, DbType.Int32);
            OwnerIdParameter.Value = item.OwnerID;

            DbParameter CostParameter = _db.CreateParameter(DbNames.UPDATEITEM_COST_PARAMETER, DbType.Int32);
            CostParameter.Value = item.Price;

            DbParameter ReqClassParameter = _db.CreateParameter(DbNames.UPDATEITEM_REQCLASS_PARAMETER, DbType.Byte);
            ReqClassParameter.Value = item.RequiredClass;

            DbParameter AmountParameter = _db.CreateParameter(DbNames.UPDATEITEM_AMOUNT_PARAMETER, DbType.Int16);
            AmountParameter.Value = item.Amount;

            DbParameter BagParameter = _db.CreateParameter(DbNames.UPDATEITEM_BAG_PARAMETER, DbType.Byte);
            BagParameter.Value = item.Bag;

            DbParameter SlotParameter = _db.CreateParameter(DbNames.UPDATEITEM_SLOT_PARAMETER, DbType.Byte);
            SlotParameter.Value = item.Slot;

            DbParameter ItemIdParameter = _db.CreateParameter(DbNames.UPDATEITEM_ITEMID_PARAMETER, DbType.Int32);
            ItemIdParameter.Value = item.ItemID;

            DbParameter ReqLevelParameter = _db.CreateParameter(DbNames.UPDATEITEM_REQLEVEL_PARAMETER, DbType.Int16);
            DbParameter ReqDexParameter = _db.CreateParameter(DbNames.UPDATEITEM_REQDEX_PARAMETER, DbType.Int16);
            DbParameter ReqStrParameter = _db.CreateParameter(DbNames.UPDATEITEM_REQSTR_PARAMETER, DbType.Int16);
            DbParameter ReqStaParameter = _db.CreateParameter(DbNames.UPDATEITEM_REQSTA_PARAMETER, DbType.Int16);
            DbParameter ReqEneParameter = _db.CreateParameter(DbNames.UPDATEITEM_REQENE_PARAMETER, DbType.Int16);
            DbParameter MaxImbueTriesParameter = _db.CreateParameter(DbNames.UPDATEITEM_MAXIMBUETRIES_PARAMETER, DbType.Byte);
            DbParameter MaxDuraParameter = _db.CreateParameter(DbNames.UPDATEITEM_MAXDURA_PARAMETER, DbType.Int16);
            DbParameter CurDuraParameter = _db.CreateParameter(DbNames.UPDATEITEM_CURDURA_PARAMETER, DbType.Int16);
            DbParameter DamageParameter = _db.CreateParameter(DbNames.UPDATEITEM_DAMAGE_PARAMETER, DbType.Int16);
            DbParameter DefenceParameter = _db.CreateParameter(DbNames.UPDATEITEM_DEFENCE_PARAMETER, DbType.Int16);
            DbParameter AttackRatingParameter = _db.CreateParameter(DbNames.UPDATEITEM_ATTACKRATING_PARAMETER, DbType.Int16);
            DbParameter AttackSpeedParameter = _db.CreateParameter(DbNames.UPDATEITEM_ATTACKSPEED_PARAMETER, DbType.Int16);
            DbParameter AttackRangeParameter = _db.CreateParameter(DbNames.UPDATEITEM_ATTACKRANGE_PARAMETER, DbType.Int16);
            DbParameter IncMaxLifeParameter = _db.CreateParameter(DbNames.UPDATEITEM_INCMAXLIFE_PARAMETER, DbType.Int16);
            DbParameter IncMaxManaParameter = _db.CreateParameter(DbNames.UPDATEITEM_INCMAXMANA_PARAMETER, DbType.Int16);
            DbParameter LifeRegenParameter = _db.CreateParameter(DbNames.UPDATEITEM_LIFEREGEN_PARAMETER, DbType.Int16);
            DbParameter ManaRegenParameter = _db.CreateParameter(DbNames.UPDATEITEM_MANAREGEN_PARAMETER, DbType.Int16);
            DbParameter CriticalHitParameter = _db.CreateParameter(DbNames.UPDATEITEM_CRITICALHIT_PARAMETER, DbType.Int16);
            DbParameter PlusParameter = _db.CreateParameter(DbNames.UPDATEITEM_PLUS_PARAMETER, DbType.Byte);
            DbParameter SlvlParameter = _db.CreateParameter(DbNames.UPDATEITEM_SLVL_PARAMETER, DbType.Byte);
            DbParameter ImbueTriesParameter = _db.CreateParameter(DbNames.UPDATEITEM_IMBUETRIES_PARAMETER, DbType.Byte);
            DbParameter DragonSuccessImbueTriesParameter = _db.CreateParameter(DbNames.UPDATEITEM_DRAGONSUCCESSIMBUETRIES_PARAMETER, DbType.Int16);
            DbParameter DiscountRepairFeeParameter = _db.CreateParameter(DbNames.UPDATEITEM_DISCOUNTREPAIRFEE_PARAMETER, DbType.Byte);
            DbParameter TotalDragonImbueTriesParameter = _db.CreateParameter(DbNames.UPDATEITEM_TOTALDRAGONIMBUETRIES_PARAMETER, DbType.Int16);
            DbParameter DragonDmgParameter = _db.CreateParameter(DbNames.UPDATEITEM_DRAGONDMG_PARAMETER, DbType.Int16);
            DbParameter DragonDefParameter = _db.CreateParameter(DbNames.UPDATEITEM_DRAGONDEF_PARAMETER, DbType.Int16);
            DbParameter DragonARParameter = _db.CreateParameter(DbNames.UPDATEITEM_DRAGONAR_PARAMETER, DbType.Int16);
            DbParameter DragonLifeParameter = _db.CreateParameter(DbNames.UPDATEITEM_DRAGONLIFE_PARAMETER, DbType.Int16);
            DbParameter MappedStuffParameter = _db.CreateParameter(DbNames.UPDATEITEM_MAPPEDSTUFF_PARAMETER, DbType.Byte);
            DbParameter ForceNumberParameter = _db.CreateParameter(DbNames.UPDATEITEM_FORCENUMBER_PARAMETER, DbType.Byte);
            DbParameter RebirthHoleParameter = _db.CreateParameter(DbNames.UPDATEITEM_REBIRTHHOLE_PARAMETER, DbType.Byte);
            DbParameter RebirthHoleItemParameter = _db.CreateParameter(DbNames.UPDATEITEM_REBIRTHHOLEITEM_PARAMETER, DbType.Byte);
            DbParameter RebirthHoleStatParameter = _db.CreateParameter(DbNames.UPDATEITEM_REBIRTHHOLESTAT_PARAMETER, DbType.Int16);

            DbParameter PolishStoneTriesParameter = _db.CreateParameter(DbNames.UPDATEITEM_POLISHSTONETRIES_PARAMETER, DbType.Byte);
            DbParameter VigiStat1Parameter = _db.CreateParameter(DbNames.UPDATEITEM_VIGISTAT1_PARAMETER, DbType.Int16);
            DbParameter VigiStat2Parameter = _db.CreateParameter(DbNames.UPDATEITEM_VIGISTAT2_PARAMETER, DbType.Int16);
            DbParameter VigiStat3Parameter = _db.CreateParameter(DbNames.UPDATEITEM_VIGISTAT3_PARAMETER, DbType.Int16);
            DbParameter VigiStat4Parameter = _db.CreateParameter(DbNames.UPDATEITEM_VIGISTAT4_PARAMETER, DbType.Int16);
            DbParameter VigiStatAdd1Parameter = _db.CreateParameter(DbNames.UPDATEITEM_VIGISTATADD1_PARAMETER, DbType.Int16);
            DbParameter VigiStatAdd2Parameter = _db.CreateParameter(DbNames.UPDATEITEM_VIGISTATADD2_PARAMETER, DbType.Int16);
            DbParameter VigiStatAdd3Parameter = _db.CreateParameter(DbNames.UPDATEITEM_VIGISTATADD3_PARAMETER, DbType.Int16);
            DbParameter VigiStatAdd4Parameter = _db.CreateParameter(DbNames.UPDATEITEM_VIGISTATADD4_PARAMETER, DbType.Int16);

            if (item is Equipment)
            {
                Equipment e = item as Equipment;
                ReqLevelParameter.Value = e.RequiredLevel;
                ReqDexParameter.Value = e.RequiredDexterity;
                ReqStrParameter.Value = e.RequiredStrength;
                ReqStaParameter.Value = e.RequiredStamina;
                ReqEneParameter.Value = e.RequiredEnergy;
                MaxImbueTriesParameter.Value = e.MaxImbueTries;
                MaxDuraParameter.Value = e.MaxDurability;
                CurDuraParameter.Value = e.Durability;
                DamageParameter.Value = e.Damage;
                DefenceParameter.Value = e.Defence;
                AttackRatingParameter.Value = e.AttackRating;
                AttackSpeedParameter.Value = e.AttackSpeed;
                AttackRangeParameter.Value = e.AttackRange;
                IncMaxLifeParameter.Value = e.IncMaxLife;
                IncMaxManaParameter.Value = e.IncMaxMana;
                LifeRegenParameter.Value = e.IncLifeRegen;
                ManaRegenParameter.Value = e.IncManaRegen;
                CriticalHitParameter.Value = e.Critical;
                PlusParameter.Value = e.Plus;
                SlvlParameter.Value = e.Slvl;
                ImbueTriesParameter.Value = e.ImbueTries;
                DragonSuccessImbueTriesParameter.Value = e.DragonSuccessImbueTries;
                DiscountRepairFeeParameter.Value = e.DiscountRepairFee;
                TotalDragonImbueTriesParameter.Value = e.TotalDragonImbueTries;
                DragonDmgParameter.Value = e.DragonDamage;
                DragonDefParameter.Value = e.DragonDefence;
                DragonARParameter.Value = e.DragonAttackRating;
                DragonLifeParameter.Value = e.DragonLife;
                MappedStuffParameter.Value = e.MappedData;
                ForceNumberParameter.Value = e.ForceSlot;
                RebirthHoleParameter.Value = e.RebirthHole;
                RebirthHoleItemParameter.Value = e.RebirthHoleItem;
                RebirthHoleStatParameter.Value = e.RebirthHoleStat;
                if (e is Cape)
                {
                    Cape c = e as Cape;
                    PolishStoneTriesParameter.Value = c.PolishImbueTries;
                    VigiStat1Parameter.Value = c.VigiStat1;
                    VigiStat2Parameter.Value = c.VigiStat2;
                    VigiStat3Parameter.Value = c.VigiStat3;
                    VigiStat4Parameter.Value = c.VigiStat4;
                    VigiStatAdd1Parameter.Value = c.VigiStatAdd1;
                    VigiStatAdd2Parameter.Value = c.VigiStatAdd2;
                    VigiStatAdd3Parameter.Value = c.VigiStatAdd3;
                    VigiStatAdd4Parameter.Value = c.VigiStatAdd4;
                }
            }

            DbParameter ImbueRateParameter = _db.CreateParameter(DbNames.UPDATEITEM_IMBUERATE_PARAMETER, DbType.Int16);
            DbParameter ImbueIncreaseParameter = _db.CreateParameter(DbNames.UPDATEITEM_IMBUEINCREASE_PARAMETER, DbType.Int16);

            if (item is ImbueItem)
            {
                ImbueItem i = item as ImbueItem;

                ImbueRateParameter.Value = i.ImbueChance;
                ImbueIncreaseParameter.Value = i.IncreaseValue;
            }

            _db.Open();

            _db.ExecuteNonQuery(DbNames.UPDATEITEM_STOREDPROC,
              System.Data.CommandType.StoredProcedure,
              OwnerIdParameter,
              CostParameter,
              ReqClassParameter,
              AmountParameter,
              BagParameter,
              SlotParameter,
              ItemIdParameter,
              ReqLevelParameter,
              ReqDexParameter,
              ReqStrParameter,
              ReqStaParameter,
              ReqEneParameter,
              MaxImbueTriesParameter,
              MaxDuraParameter,
              CurDuraParameter,
              DamageParameter,
              DefenceParameter,
              AttackRatingParameter,
              AttackSpeedParameter,
              AttackRangeParameter,
              IncMaxLifeParameter,
              IncMaxManaParameter,
              LifeRegenParameter,
              ManaRegenParameter,
              CriticalHitParameter,
              PlusParameter,
              SlvlParameter,
              ImbueTriesParameter,
              DragonSuccessImbueTriesParameter,
              DiscountRepairFeeParameter,
              TotalDragonImbueTriesParameter,
              DragonDmgParameter,
              DragonDefParameter,
              DragonARParameter,
              DragonLifeParameter,
              MappedStuffParameter,
              ForceNumberParameter,
              RebirthHoleParameter,
              RebirthHoleItemParameter,
              RebirthHoleStatParameter,
              PolishStoneTriesParameter,
              VigiStat1Parameter,
              VigiStat2Parameter,
              VigiStat3Parameter,
              VigiStat4Parameter,
              VigiStatAdd1Parameter,
              VigiStatAdd2Parameter,
              VigiStatAdd3Parameter,
              VigiStatAdd4Parameter,
              ImbueIncreaseParameter,
              ImbueRateParameter
              );

            _db.Close();
        }
        private bool MoveShopItem(Client c, MoveShopItemInfo m, BaseItem item)
        {
            BaseItem itemunder = null;
            if (m.ItemUnderID != 0)
                itemunder = c.MyCharacter.Shop.Items.First(x => x.ItemID == m.ItemUnderID);

            if (m.ToSlot <= 36)
            {
                if (c.MyCharacter.Shop.MoveItem(c.MyCharacter, item, m.ToSlot, out itemunder))
                {
                    if (itemunder == null)
                    {
                        item.Slot = (byte)(m.ToSlot);

                        itemDataManager.UpdateShopItemById(item);
                    }
                    else
                    {
                        int tempslot;
                        tempslot = item.Slot;
                        item.Slot = itemunder.Slot;
                        itemunder.Slot = (byte)tempslot;

                        itemDataManager.UpdateShopItemById(item);
                        itemDataManager.UpdateShopItemById(itemunder);
                    }

                    byte[] SendRemoveShopItem = PacketManager.SendRemoveShopItem(m.FromSlot, item.ItemID, item.Amount);
                    c.Send(SendRemoveShopItem);

                    if (itemunder != null)
                    {
                        byte[] SendRemoveShopItemUnder = PacketManager.SendRemoveShopItem(m.ToSlot, itemunder.ItemID, itemunder.Amount);
                        c.Send(SendRemoveShopItemUnder);

                        byte[] SendAddShopItemUnder = PacketManager.SendAddItemToShop(itemunder, itemunder.SellPrice);
                        c.Send(SendAddShopItemUnder);
                    }

                    byte[] SendAddShopItem = PacketManager.SendAddItemToShop(item, item.SellPrice);
                    c.Send(SendAddShopItem);
                    return true;
                }
            }

            return false;
        }
Beispiel #5
0
        public MapItem PlayerDropItem(BaseItem item,short x, short y, byte z, int mapId)
        {
            item.OwnerID = -1;
            item.Bag = 255;
            item.Slot = 255;

            MapItem m = new MapItem
            {
                MapID = mapId,
                MapX = x,
                MapY = y,
                MapZ = z,
                bType =item.bType,
                ItemID = item.ItemID,
                Amount = item.Amount,
                ReferenceID = item.ReferenceID,
                VisualID = item.VisualID
            };

            int mapItemId = mapItemManager.InsertMapItem(m.MapID, m.MapX, m.MapY, m.MapZ, m.bType, m.VisualID, m.ReferenceID, m.ItemID, m.Amount);

            m.MapItemID = mapItemId;

            itemDataManager.UpdateItem(item);
            mapItems.Add(m);

            return m;
        }
        private void HandleEquipItem(Client c, MoveItemInfo m, BaseItem item)
        {
            try
            {
                BaseItem conflict = null;
                MapEngine mapEngine = GetMapEngine(c.MyCharacter.MapId);
                Client[] clients = GetClientsForChars(mapEngine.GetCharactersInRange(c.MyCharacter.Position, 150).ToArray());

                switch (m.ToSlot)
                {
                    case (byte)Slot.Weapon: // Hand
                        conflict = c.MyCharacter.Hand;
                        if (conflict != null)
                        {
                            conflict.Slot = item.Slot;
                            conflict.Bag = item.Bag;
                        }
                        c.MyCharacter.Hand = (Hand)item;
                        break;

                    case (byte)Slot.Hat: // Hat
                        conflict = c.MyCharacter.Head;
                        if (conflict != null)
                        {
                            conflict.Slot = item.Slot;
                            conflict.Bag = item.Bag;
                        }
                        c.MyCharacter.Head = (Head)item;
                        break;

                    case (byte)Slot.Armor: // Armor
                        conflict = c.MyCharacter.Body;
                        if (conflict != null)
                        {
                            conflict.Slot = item.Slot;
                            conflict.Bag = item.Bag;
                        }
                        c.MyCharacter.Body = (Body)item;
                        break;

                    case (byte)Slot.Shoes: // Shoes
                        conflict = c.MyCharacter.Feet;
                        if (conflict != null)
                        {
                            conflict.Slot = item.Slot;
                            conflict.Bag = item.Bag;
                        }
                        c.MyCharacter.Feet = (Feet)item;
                        break;

                    case (byte)Slot.Ring:
                        conflict = c.MyCharacter.Ring;
                        if (conflict != null)
                        {
                            conflict.Slot = item.Slot;
                            conflict.Bag = item.Bag;
                        }
                        c.MyCharacter.Ring = (Ring)item;
                        break;

                    case (byte)Slot.Necklace:
                        conflict = c.MyCharacter.Necklace;
                        if (conflict != null)
                        {
                            conflict.Slot = item.Slot;
                            conflict.Bag = item.Bag;
                        }
                        c.MyCharacter.Necklace = (Necklace)item;
                        break;

                    case (byte)Slot.Cape:
                        conflict = c.MyCharacter.Cape;
                        if (conflict != null)
                        {
                            conflict.Slot = item.Slot;
                            conflict.Bag = item.Bag;
                        }
                        c.MyCharacter.Cape = (Cape)item;
                        break;

                    case (byte)Slot.Mirror:
                        conflict = c.MyCharacter.Mirror;
                        if (conflict != null)
                        {
                            conflict.Slot = item.Slot;
                            conflict.Bag = item.Bag;
                        }
                        c.MyCharacter.Mirror = (Mirror)item;
                        break;
                    default:
                        break;
                }

                if (conflict != null)
                {
                    c.MyCharacter.Bags[m.FromBag - 1].AddItem(conflict);
                    itemDataManager.UpdateItem(conflict);
                }

                c.MyCharacter.Bags[m.FromBag - 1].RemoveItem(item);
                itemDataManager.UpdateItem(item);

                byte[] SendEquipItem = PacketManager.SendMoveItem(m, 0);
                c.Send(SendEquipItem);

                byte[] SendNewStats = PacketManager.SendStats(c.MyCharacter);
                c.Send(SendNewStats);

                if (c.MyCharacter.ImperialSet != ImperialSet.None)
                {
                    SendCommandHelp(string.Format("Wearing set: {0}", c.MyCharacter.ImperialSet.ToString()), c);
                }

                byte[] SendNewVisuals = PacketManager.SendSpawnPlayers(c.MyCharacter);
                SendToClients(SendNewVisuals, clients);
            }
            catch (RequiredClassException)
            {
                byte[] SendEquipError = PacketManager.SendMoveItem(m, 3);
                c.Send(SendEquipError);
            }
        }
        private void HandleUnEquipItem(Client c, MoveItemInfo m, BaseItem item)
        {
            try
            {
                MapEngine mapEngine = GetMapEngine(c.MyCharacter.MapId);
                Client[] clients = GetClientsForChars(mapEngine.GetCharactersInRange(c.MyCharacter.Position, 150).ToArray());

                if (m.ToBag != 255 && m.ToSlot != 255)
                {
                    if (!c.MyCharacter.Bags[m.ToBag - 1].IsSlotValid(item, m.ToSlot))
                    {
                        throw new InvalidItemSlotException("NO PUT ON EDGE PUJJ");
                    }

                    if (!c.MyCharacter.Bags[m.ToBag - 1].CheckSlot(item, m.ToSlot))
                    {
                        switch (item.Slot)
                        {
                            case (byte)Slot.Weapon: // Hand
                                c.MyCharacter.Hand = null;
                                break;

                            case (byte)Slot.Hat: // Hat
                                c.MyCharacter.Head = null;
                                break;

                            case (byte)Slot.Armor: // Armor
                                c.MyCharacter.Body = null;
                                break;

                            case (byte)Slot.Shoes: // Shoes
                                c.MyCharacter.Feet = null;
                                break;

                            case (byte)Slot.Ring:
                                c.MyCharacter.Ring = null;
                                break;

                            case (byte)Slot.Necklace:
                                c.MyCharacter.Necklace = null;
                                break;

                            case (byte)Slot.Cape:
                                c.MyCharacter.Cape = null;
                                break;

                            case (byte)Slot.Mirror:
                                c.MyCharacter.Mirror = null;
                                break;

                            default:
                                break;
                        }

                        item.Bag = m.ToBag;
                        item.Slot = m.ToSlot;
                        c.MyCharacter.Bags[m.ToBag - 1].AddItem(item);
                        itemDataManager.UpdateItem(item);

                        byte[] SendMoveItem = PacketManager.SendMoveItem(m, 0);
                        c.Send(SendMoveItem);

                        byte[] SendNewStats = PacketManager.SendStats(c.MyCharacter);
                        c.Send(SendNewStats);

                        byte[] SendNewVisuals = PacketManager.SendSpawnPlayers(c.MyCharacter);
                        SendToClients(SendNewVisuals, clients);
                    }
                    else
                    {
                        byte[] SendError = PacketManager.SendMoveItem(m, 2);
                        c.Send(SendError);
                    }
                }
            }
            catch
            {
                byte[] SendError = PacketManager.SendMoveItem(m, 2);
                c.Send(SendError);
            }
        }
Beispiel #8
0
        public bool MoveItem(Character ch, BaseItem item, byte slot, out BaseItem swappedItem)
        {
            bool moved = false;
            List<BaseItem> conflictingItems = null;
            swappedItem = null;

            if (!IsSlotValid(item, slot))
            {
                throw new InvalidItemSlotException("NO PUT ON EDGE PUJJ");
            }

            if (!HasNoRoom(item, slot, out conflictingItems))
            {
                moved = true;
                //if (!this.items.Any(x => x.ItemID == item.ItemID))
                //    this.AddItem(item);
            }
            else //later add swapping
            {
                BaseItem conflict = null;

                if (conflictingItems.Count == 1)
                {
                    conflict = conflictingItems.First();

                    if (conflict == item)
                        moved = true;

                    if (conflict.Slot == slot)
                    {
                        if (conflict.SizeX == item.SizeX)
                        {
                            moved = true;
                            swappedItem = conflict;
                        }
                        else
                        {
                            moved = SwapDifferentSize(ch, item, conflict, slot);
                            swappedItem = conflict;
                        }
                    }
                    else
                    {
                        if (item.SizeX > 1)
                        {
                            if (slot + 1 != conflict.Slot && slot + 6 != conflict.Slot && slot + 7 != conflict.Slot && slot - 5 != conflict.Slot) // so it wont let you overlay stuff from left to right
                                moved = true;
                        }
                        else
                        {
                            if (slot - 1 != conflict.Slot && slot - 6 != conflict.Slot && slot - 7 != conflict.Slot) // so it wont let you overlay stuff from left to right
                                moved = true;

                            //    moved = false;
                            //no room plx
                        }
                    }
                }
                else
                {
                    var q = conflictingItems.Where(x => x.Slot == item.Slot ||
                                                                  x.Slot + 1 == item.Slot ||
                                                                  x.Slot + 6 == item.Slot ||
                                                                  x.Slot + 7 == item.Slot);

                    moved = false;

                    //if(conflict.SizeX == 1 && conflict.SizeX >1)
                    //{
                    //}
                    //else
                    //{
                    //    //no room plx
                    //}
                }

            }

            return moved;
        }
Beispiel #9
0
        private bool SwapDifferentSize(Character ch, BaseItem one, BaseItem two, int slot)
        {
            bool moved = false;
            int test = Math.Abs(one.Slot - slot);
            if (!IsOnEdge(one, one.Slot)) // so it wont let you stack it with the item
            {
                if (one.Bag == two.Bag)
                {
                    if (test != 1 && test != 6 && test != 7)
                    {
                        if (HasRoom(one))
                        {
                            moved = true;
                        }
                        else
                            moved = false;
                    }
                    else
                        moved = false;
                }
                else
                {
                    if (ch.Bags[one.Bag - 1].HasRoom(one) && ch.Bags[two.Bag - 1].HasRoom(two))
                    {
                        moved = true;
                    }
                    else
                        moved = false;
                }
            }

            return moved;
        }
Beispiel #10
0
        public bool FindFreeTradeSlot(BaseItem item, BagSlot newBagSlot)
        {
            bool found = false;

            newBagSlot.Slot = 255;

            for (byte i = 0; i < slotCount; i++)
            {
                if (!IsSlotValid(item, i))
                {
                    continue;
                }

                if (!CheckTradeSlot(item, i))
                {
                    newBagSlot.Slot = i;
                    found = true;
                    break;
                }

            }

            return found;
        }
Beispiel #11
0
        public bool HasRoom(BaseItem item)
        {
            IEnumerable<BaseItem> q = null;

            q = items.Where(x => x.Slot == item.Slot && x != item ||
                                   (x.Slot == item.Slot + 1 && x != item) ||                //  _ _ _ _ _
                                   (x.Slot == item.Slot + 5 && x != item && x.SizeX > 1) || // | | | | | |
                                   (x.Slot == item.Slot + 6 && x != item) ||                // | |o|x|o| | // x being item
                                   (x.Slot == item.Slot + 7 && x != item) ||                // | |o|o|o| |
                                   (x.Slot == item.Slot - 1 && x != item && x.SizeX > 1));// | | | | | |
            if (q.Count() > 0)
                return false;

            return true;
        }
Beispiel #12
0
        public bool CheckTradeSlot(BaseItem item, byte itemSlot)
        {
            if (IsSlotValid(item, itemSlot))
            {
                IEnumerable<BaseItem> q = null;

                if (item.SizeX > 1)
                {
                    q = items.Where(x => x.TradeSlot == itemSlot && x != item ||
                                           (x.TradeSlot == itemSlot + 1 && x != item) ||                //  _ _ _ _ _
                                           (x.TradeSlot == itemSlot + 5 && x != item && x.SizeX > 1) || // | |o|o|o| |
                                           (x.TradeSlot == itemSlot + 6 && x != item) ||                // | |o|x|o| | // x being item
                                           (x.TradeSlot == itemSlot + 7 && x != item) ||                // | |o|o|o| |
                                           (x.TradeSlot == itemSlot - 1 && x != item && x.SizeX > 1) ||  // | | | | | |
                                           (x.TradeSlot == itemSlot - 7 && x != item && x.SizeX > 1) ||
                                           (x.TradeSlot == itemSlot - 6 && x != item && x.SizeX > 1) ||
                                           (x.TradeSlot == itemSlot - 5 && x != item && x.SizeX > 1));
                    if (q.Count() > 0)
                        return true;
                }
                else
                {
                    q = items.Where(x => x.TradeSlot == itemSlot && x != item ||
                                        (x.TradeSlot == itemSlot - 1 && x.SizeX > 1 && x != item) ||
                                        (x.TradeSlot == itemSlot - 6 && x.SizeX > 1 && x != item) ||
                                        (x.TradeSlot == itemSlot - 7 && x.SizeX > 1 && x != item));
                    if (q.Count() > 0)
                        return true;
                }

                return false;
            }

            return true;
        }
Beispiel #13
0
        public bool FindFreeSlotInWarehouse(BaseItem item, BagSlot bagSlot)
        {
            bool found = false;

            if (Warehouse.FindFreeSlot(item, bagSlot))
            {
                found = true;
                bagSlot.Bag = 5;
            }

            return found;
        }
Beispiel #14
0
        public bool FindFreeSlotInTradeWindow(BaseItem item, BagSlot bagSlot)
        {
            bool found = false;

            if (TradeWindow.FindFreeTradeSlot(item, bagSlot))
            {
                found = true;
                bagSlot.Bag = 3;
            }

            return found;
        }
Beispiel #15
0
        private bool HasNoRoom(BaseItem item, byte itemSlot, out List<BaseItem> conflictingItems)
        {
            bool full = false;

            conflictingItems = null;
            IEnumerable<BaseItem> q = null;
            if (item.SizeX > 1)
            {
                q = items.Where(x => x.Slot == itemSlot ||
                                    (x.Slot == itemSlot - 7 && x.SizeX > 1) ||
                                    (x.Slot == itemSlot - 6 && x.SizeX > 1) ||
                                    (x.Slot == itemSlot - 5 && x.SizeX > 1) ||
                                    (x.Slot == itemSlot - 1 && x.SizeX > 1) ||
                                    (x.Slot == itemSlot + 1 && x.SizeX > 1) ||
                                    (x.Slot == itemSlot + 5 && x.SizeX > 1) ||
                                    (x.Slot == itemSlot + 6 && x.SizeX > 1) ||
                                    (x.Slot == itemSlot + 7 && x.SizeX > 1));
                if (q.Count() > 0)
                    full = true;
            }
            else
            {
                q = items.Where(x => x.Slot == itemSlot ||
                                    (x.Slot == itemSlot - 1 && x.SizeX > 1) ||
                                    (x.Slot == itemSlot - 6 && x.SizeX > 1) ||
                                    (x.Slot == itemSlot - 7 && x.SizeX > 1));

                if (q.Count() > 0)
                    full = true;
            }

            conflictingItems = q.ToList();

            return full;
        }
Beispiel #16
0
        public bool FindFreeSlotInBags(BaseItem item, BagSlot bagSlot)
        {
            bool found = false;

            for (int i = 0; i < Bags.Count; i++)
            {
                if (Bags[i].FindFreeSlot(item, bagSlot))
                {
                    found = true;
                    bagSlot.Bag = (byte)(i + 1);
                    break;
                }
            }

            return found;
        }
Beispiel #17
0
        private bool IsSlotValid(BaseItem item, byte itemSlot)
        {
            if (item.SizeX > 1)
            {
                int invalidSlotsCount = 6 + ((slotCount / 6) - 1);

                int[] invalidSlots = new int[invalidSlotsCount];

                invalidSlots[0] = slotCount - 1;
                invalidSlots[1] = slotCount - 2;
                invalidSlots[2] = slotCount - 3;
                invalidSlots[3] = slotCount - 4;
                invalidSlots[4] = slotCount - 5;
                invalidSlots[5] = slotCount - 6;

                int invalidSlotNum = 5;

                for (int i = 6; i < invalidSlots.Length; i++)
                {
                    invalidSlots[i] = invalidSlotNum;
                    invalidSlotNum += 6;
                }

                var q = invalidSlots.Where(x => x == itemSlot);

                if (q.Count() > 0)
                {
                    return false;
                }
            }

            return true;
        }
Beispiel #18
0
 public void AddItem(BaseItem item)
 {
     items.Add(item);
 }
        private bool HandleItemMove(Client c, MoveItemInfo m, BaseItem item)
        {
            BaseItem test;

            try
            {
                if (m.ItemIDUnder != 0)
                    test = c.MyCharacter.Bags[m.ToBag - 1].Items.First(x => x.ItemID == m.ItemIDUnder);

                if (m.ToSlot != 255)
                {
                    if (c.MyCharacter.Bags[m.ToBag - 1].MoveItem(c.MyCharacter, item, m.ToSlot, out test))
                    {
                        if (test == null)
                        {
                            item.Slot = (byte)(m.ToSlot);
                            item.Bag = (byte)(m.ToBag);

                            itemDataManager.UpdateItem(item);
                        }
                        else
                        {
                            int tempslot, tempbag;
                            tempslot = item.Slot;
                            tempbag = item.Bag;
                            item.Slot = test.Slot;
                            item.Bag = test.Bag;
                            test.Slot = (byte)tempslot;
                            test.Bag = (byte)tempbag;

                            //if (m.FromBag != m.ToBag && m.FromBag > 0)
                            //{
                            //    c.MyCharacter.Bags[m.FromBag - 1].RemoveItem(item);
                            //    c.MyCharacter.Bags[m.ToBag - 1].RemoveItem(test);
                            //    c.MyCharacter.Bags[m.ToBag - 1].AddItem(item);
                            //    c.MyCharacter.Bags[m.FromBag - 1].AddItem(test);
                            //}

                            itemDataManager.UpdateItem(item);
                            itemDataManager.UpdateItem(test);
                        }

                        if (m.FromBag != m.ToBag && m.FromBag > 0)
                        {
                            c.MyCharacter.Bags[m.FromBag - 1].RemoveItem(item);
                            c.MyCharacter.Bags[m.ToBag - 1].AddItem(item);

                            if (test != null)
                            {
                                c.MyCharacter.Bags[m.ToBag - 1].RemoveItem(test);
                                c.MyCharacter.Bags[m.FromBag - 1].AddItem(test);
                            }
                        }

                        return true;
                    }
                }

                return false;
            }
            catch
            {
                return false;
            }
        }
Beispiel #20
0
        public bool CheckSlot(BaseItem item, byte slot)
        {
            bool empthy = false;

            List<BaseItem> conflictingItems = null;

            if (!HasNoRoom(item, slot, out conflictingItems))
                empthy = true;

            return empthy;
        }
        private bool LearnSkill(Client c, BaseItem item, bool removeItem, BaseSkill skill, BookItem book)
        {
            short test = 0;

            if (!c.MyCharacter.ContainSkill(skill.SkillID, skill.SkillLevel) && c.MyCharacter.TrainingPoint >= skill.RequiredTraining && c.MyCharacter.Level >= skill.RequiredLevel && c.MyCharacter.Strength >= skill.RequiredStrength && c.MyCharacter.Stamina >= skill.RequiredStamina && c.MyCharacter.Dexterity >= skill.RequiredDexterity && c.MyCharacter.Energy >= skill.RequiredEnergy)
            {
                if (item.RequiredClass == 0 || c.MyCharacter.Class == item.RequiredClass)
                {
                    if (book.SkillLevel == 1)
                    {
                        characterManager.LearnSkill(c.MyCharacter.CharacterId, skill.SkillID, skill.SkillLevel, ref test);
                        c.MyCharacter.TrainingPoint = test;

                        characterManager.UpdateCharacter(c.MyCharacter);

                        c.MyCharacter.SkillList.Add(skill);

                        byte[] LearnSkill = PacketManager.SendLearnSkill(0, skill.SkillID, skill.SkillLevel, skill.RequiredTraining, c.MyCharacter.TrainingPoint);
                        c.Send(LearnSkill);

                        c.Send(PacketManager.SendSkillSomething());

                        removeItem = true;
                    }
                    else
                    {
                        if (c.MyCharacter.ContainSkill(skill.SkillID, skill.SkillLevel - 1))
                        {
                            characterManager.LearnSkill(c.MyCharacter.CharacterId, skill.SkillID, skill.SkillLevel, ref test);
                            c.MyCharacter.UpdateSkill(skill);
                            c.MyCharacter.TrainingPoint = test;

                            characterManager.UpdateCharacter(c.MyCharacter);

                            byte[] LearnSkill = PacketManager.SendLearnSkill(0, skill.SkillID, skill.SkillLevel, skill.RequiredTraining, c.MyCharacter.TrainingPoint);
                            c.Send(LearnSkill);

                            c.Send(PacketManager.SendSkillSomething());

                            removeItem = true;
                        }
                        else
                        {
                            c.Send(PacketManager.SendSkillError(SkillLearnError.NeedMartialArts));
                        }
                    }
                }
                else
                {
                    c.Send(PacketManager.SendSkillError(SkillLearnError.WrongClass));
                }
            }
            else
            {
                byte error = 0;

                if (c.MyCharacter.TrainingPoint <= skill.RequiredTraining)
                    error = 9;
                if (c.MyCharacter.Level <= skill.RequiredLevel)
                    error = 5;
                if (c.MyCharacter.Strength <= skill.RequiredStrength)
                    error = 2;
                if (c.MyCharacter.Dexterity <= skill.RequiredDexterity)
                    error = 1;
                if (c.MyCharacter.Stamina <= skill.RequiredStamina)
                    error = 3;
                if (c.MyCharacter.Energy <= skill.RequiredEnergy)
                    error = 4;
                if (c.MyCharacter.Class != item.RequiredClass && item.RequiredClass != 0)
                    error = 8;
                if (c.MyCharacter.ContainSkill(skill.SkillID, skill.SkillLevel))
                    error = 6;

                c.Send(PacketManager.SendSkillError((SkillLearnError)error));
                // send not enought stats/tps
            }
            return removeItem;
        }
Beispiel #22
0
        public bool FindFreeSlot(BaseItem item, BagSlot newBagSlot)
        {
            bool found = false;

            newBagSlot.Slot = 255;

            List<BaseItem> conflictingItems = null;

            for (byte i = 0; i < slotCount; i++)
            {
                if (!IsSlotValid(item, i))
                {
                    continue;
                }

                if (!HasNoRoom(item, i, out conflictingItems))
                {
                    newBagSlot.Slot = i;
                    found = true;
                    break;
                }

            }

            return found;
        }
        private bool MoveWarehouseItem(Client c, MoveWarehouseItemInfo m, BaseItem item)
        {
            BaseItem itemunder = null;
            if (m.ItemUnderID != 0)
                itemunder = c.MyCharacter.Warehouse.Items.First(x => x.ItemID == m.ItemUnderID);

            if (m.ToSlot <= 65)
            {
                if (c.MyCharacter.Warehouse.MoveItem(c.MyCharacter, item, m.ToSlot, out itemunder))
                {
                    if (itemunder == null)
                    {
                        item.Slot = (byte)(m.ToSlot);

                        itemDataManager.UpdateItem(item);
                    }
                    else
                    {
                        int tempslot;
                        tempslot = item.Slot;
                        item.Slot = itemunder.Slot;
                        itemunder.Slot = (byte)tempslot;

                        itemDataManager.UpdateItem(item);
                        itemDataManager.UpdateItem(itemunder);
                    }

                    byte[] SendRemoveWarehouseItem = PacketManager.SendWarehouseRemoveItem(m.FromSlot, item.ItemID);
                    c.Send(SendRemoveWarehouseItem);

                    byte[] SendAddWarehouseItem = PacketManager.SendAddItemToWarehouse(2, item);
                    c.Send(SendAddWarehouseItem);

                    if (itemunder != null)
                    {
                        byte[] SendRemoveWarehouseItemUnder = PacketManager.SendWarehouseRemoveItem(m.ToSlot, itemunder.ItemID);
                        c.Send(SendRemoveWarehouseItemUnder);

                        byte[] SendAddWarehouseItemUnder = PacketManager.SendAddItemToWarehouse(2, itemunder);
                        c.Send(SendAddWarehouseItemUnder);
                    }

                    return true;
                }
            }

            return false;
        }
Beispiel #24
0
        public bool MoveItem(BaseItem item, byte bag, byte slot, out BaseItem swappedItem)
        {
            bool moved = false;
            List<BaseItem> conflictingItems = null;
            swappedItem = null;

            if (!IsSlotValid(item, slot))
            {
                throw new InvalidItemSlotException("NO PUT ON EDGE PUJJ");
            }

            if (!HasNoRoom(item, slot, out conflictingItems))
            {
                moved = true;
                if (!this.items.Any(x => x.ItemID == item.ItemID))
                    this.AddItem(item);
            }
            else //later add swapping
            {
                BaseItem conflict = null;

                if (conflictingItems.Count == 1)
                {
                    conflict = conflictingItems.First();

                    if (conflict.Slot == slot)
                    {
                        if (conflict.SizeX == item.SizeX)
                        {
                            this.AddItem(item);
                            this.RemoveItem(conflict);

                            swappedItem = conflict;
                        }
                        else if(item.SizeX > 1 && item.Slot == conflict.Slot)
                        {
                            this.AddItem(item);
                            this.RemoveItem(conflict);

                            swappedItem = conflict;
                        }
                        else if(item.SizeX==1)
                        {
                            this.AddItem(item);
                            this.RemoveItem(conflict);

                            swappedItem = conflict;
                        }
                    }
                    else
                    {
                        if (item.SizeX > 1)
                        {

                        }
                        else
                        {
                            //no room plx
                        }
                    }
                }
                else
                {
                    var q = conflictingItems.Where(x=>x.Slot == item.Slot ||
                                                                  x.Slot+1 == item.Slot ||
                                                                  x.Slot+6 == item.Slot ||
                                                                  x.Slot+7 == item.Slot);

                    if(conflict.SizeX == 1 && conflict.SizeX >1)
                    {
                    }
                    else
                    {
                        //no room plx
                    }
                }

            }

            return moved;
        }
        public static byte[] SendAddItem(BaseItem i)
        {
            Packet p = new Packet(500);
            p.WriteByte(i.Bag);
            p.WriteByte(i.Slot);
            p.WriteInt(i.ItemID);
            p.WriteShort(i.ReferenceID);
            p.WriteByte(i.bType);
            p.WriteByte(i.bKind);
            p.WriteShort(i.VisualID);
            p.WriteInt(i.Price);
            p.WriteHexString("00 00");
            if (i is Equipment)
            {
                Equipment e = i as Equipment;
                p.WriteByte(e.RequiredClass);
                p.WriteShort(e.Amount);
                p.WriteShort(e.RequiredLevel);
                p.WriteShort(e.RequiredDexterity);
                p.WriteShort(e.RequiredStrength);
                p.WriteShort(e.RequiredStamina);
                p.WriteShort(e.RequiredEnergy);
                p.WriteByte(e.MaxImbueTries);
                p.WriteShort(e.Durability);
                p.WriteShort(e.MaxDurability);
                p.WriteShort(e.Damage);
                p.WriteShort(e.Defence);
                p.WriteShort(e.AttackRating);
                p.WriteShort(e.AttackSpeed);
                p.WriteShort(e.AttackRange);
                p.WriteShort(e.IncMaxLife);
                p.WriteShort(e.IncMaxMana);
                p.WriteShort(e.IncLifeRegen);
                p.WriteShort(e.IncManaRegen);
                p.WriteShort(e.Critical);
                p.WriteByte(e.Plus);
                p.WriteByte(e.Slvl);
                p.WriteHexString("00"); // unknown
                p.WriteByte(e.ImbueTries);
                p.WriteHexString("00"); // unknown
                p.WriteShort(e.DragonSuccessImbueTries);
                p.WriteByte(e.DiscountRepairFee);
                p.WriteShort(e.TotalDragonImbueTries);
                p.WriteShort(e.DragonDamage);
                p.WriteShort(e.DragonDefence);
                p.WriteShort(e.DragonAttackRating);
                p.WriteShort(e.DragonLife);
                p.WriteByte(e.MappedData);
                if (!(e is Ring) && !(e is Necklace) && !(e is Cape))
                    p.WriteByte(e.ForceSlot);
                p.WriteHexString("00 00"); // unknown
                if (e is Cape)
                {
                    Cape c = e as Cape;
                    p.WriteHexString("00 00"); // required guild position
                    p.WriteHexString("00 00 00 00 00 00 00");
                    p.WriteHexString("01 00"); // decrease times of durability
                    p.WriteByte(c.PolishImbueTries); // polish imbue tries
                    p.WriteShort(c.MaxPolishImbueTries); // polish max tries
                    p.WriteShort(c.VigiStat1); // stat1
                    p.WriteShort(c.VigiStat2); // stat2
                    p.WriteShort(c.VigiStat3); // stat3
                    p.WriteShort(c.VigiStat4); // stat4
                    p.WriteHexString("00 00"); // stat5
                    p.WriteShort(c.VigiStatAdd1); // stat1 increase
                    p.WriteShort(c.VigiStatAdd2); // stat2 increase
                    p.WriteShort(c.VigiStatAdd3); // stat3 increase
                    p.WriteShort(c.VigiStatAdd4); // stat4 increase
                    p.WriteHexString("00 00"); // stat5 increase
                    p.WriteHexString("00 00"); // unknown
                }
                if (!(e is Ring) && !(e is Necklace) && !(e is Cape))
                {
                    p.WriteByte(e.RebirthHole);
                    p.WriteByte(e.RebirthHoleItem);
                    p.WriteShort(e.RebirthHoleStat);
                }
            }
            if (i is ImbueItem)
            {
                ImbueItem im = i as ImbueItem;
                p.WriteByte(im.RequiredClass);
                p.WriteShort(i.Amount);
                p.WriteHexString("00"); // imbuestat, eg dec level, increase value etc
                p.WriteShort(im.ImbueChance);
                p.WriteShort(im.IncreaseValue);
                p.WriteHexString("00 00"); // could be lowest lvl who knows
                p.WriteHexString("00 00"); // maxlevel of usage, for dragon stones
                p.WriteHexString("00 00"); // unknown
            }
            if (i is PotionItem)
            {
                PotionItem pot = i as PotionItem;
                p.WriteByte(pot.RequiredClass);
                p.WriteShort(pot.Amount);
                p.WriteHexString("00 00 00 00");
                p.WriteShort(pot.HealHp);
                p.WriteShort(pot.HealMana);
                p.WriteHexString("00 20 4E 00 00 00 00");
            }
            if (i is BookItem)
            {
                BookItem book = i as BookItem;
                p.WriteByte(book.RequiredClass);
                p.WriteShort(book.Amount);
                p.WriteShort(book.RequiredLevel);
                p.WriteInt(book.SkillID);
                p.WriteByte(book.SkillLevel);
                p.WriteInt(book.SkillData);
            }
            if (i is BeadItem)
            {
                BeadItem bead = i as BeadItem;
                p.WriteByte(bead.RequiredClass);
                p.WriteShort(bead.Amount);
                p.WriteInt(bead.ToMapID);
                p.WriteHexString("01 00 00 00 00 00 00");
            }

            return p.GetWrittenBuffer(PacketIds.SendAddItem);
        }
Beispiel #26
0
        public bool PickItem(BaseItem item, BagSlot newBagSlot)
        {
            bool added = false;

            if (FindFreeSlot(item, newBagSlot))
            {
                added = true;
                items.Add(item);
            }

            return added;
        }
        public int InsertItem(BaseItem item)
        {
            DbParameter refIdParameter = _db.CreateParameter(DbNames.INSERTITEM_REFERENCEID_PARAMETER, item.ReferenceID);
            refIdParameter.DbType = DbType.Int16;

            DbParameter characterIdParameter = _db.CreateParameter(DbNames.INSERTITEM_CHARACTERID_PARAMETER, item.OwnerID);
            characterIdParameter.DbType = DbType.Int32;

            DbParameter amountParameter = _db.CreateParameter(DbNames.INSERTITEM_AMOUNT_PARAMETER, item.Amount);
            amountParameter.DbType = DbType.Int16;

            DbParameter bagParameter = _db.CreateParameter(DbNames.INSTERITEM_BAG_PARAMETER, item.Bag);
            bagParameter.DbType = DbType.Byte;

            DbParameter slotParameter = _db.CreateParameter(DbNames.INSERTITEM_SLOT_PARAMETER, item.Slot);
            slotParameter.DbType = DbType.Byte;

            int itemID = -1;

            DbParameter newIdParameter = _db.CreateParameter(DbNames.INSERTITEM_ITEMID_PARAMETER, itemID);
            newIdParameter.Direction = ParameterDirection.Output;

            _db.Open();

            _db.ExecuteNonQuery(DbNames.INSERTITEM_STOREDPROC,
              System.Data.CommandType.StoredProcedure,
              refIdParameter,
              characterIdParameter,
              amountParameter,
              bagParameter,
              slotParameter,
              newIdParameter);

            _db.Close();

            itemID = (int)newIdParameter.Value;

            return itemID;
        }
Beispiel #28
0
 public void RemoveItem(BaseItem item)
 {
     items.Remove(item);
 }
Beispiel #29
0
        //public Map GetMapById(int mapId)
        //{
        //    return maps.Where(x => x.MapID == mapId).First();
        //}
        //public Map[] Maps { get { return maps; } }
        public MapItem PlayerDropItem(int droppedByCharId ,BaseItem item,short x, short y, byte z, int mapId)
        {
            item.OwnerID = -1;
            item.Bag = 255;
            item.Slot = 255;

            MapItem m = new MapItem
            {
                DropTime = DateTime.Now,
                MapID = mapId,
                MapX = x,
                MapY = y,
                MapZ = z,
                bType =item.bType,
                ItemID = item.ItemID,
                Amount = item.Amount,
                ReferenceID = item.ReferenceID,
                VisualID = item.VisualID,
                DroppedByCharacterID = droppedByCharId
            };

            int mapItemId = mapItemManager.InsertMapItem(m.MapID, m.MapX, m.MapY, m.MapZ, m.bType, m.VisualID, m.ReferenceID, m.ItemID, m.Amount, droppedByCharId);

            m.MapItemID = mapItemId;

            if (item.ItemID != 0)
                itemDataManager.UpdateItem(item);
            mapItems.Add(m);

            return m;
        }
        public void UpdateShopItemById(BaseItem item)
        {
            DbParameter slotParameter = _db.CreateParameter(DbNames.INSERTSHOPITEM_SLOT_PARAMETER, item.Slot);
            slotParameter.DbType = DbType.Byte;

            DbParameter itemIdParameter = _db.CreateParameter(DbNames.INSERTSHOPITEM_ITEMID_PARAMETER, item.ItemID);
            itemIdParameter.DbType = DbType.Int32;

            DbParameter pricedParameter = _db.CreateParameter(DbNames.INSERTSHOPITEM_PRICE_PARAMETER, item.SellPrice);
            pricedParameter.DbType = DbType.Int32;

            _db.Open();

            _db.ExecuteNonQuery(DbNames.UPDATESHOPITEM_STOREDPROC,
              System.Data.CommandType.StoredProcedure,
              slotParameter,
              itemIdParameter,
              pricedParameter);

            _db.Close();
        }