示例#1
0
        public int BlackImbue(Equipment Item, ref ImbueStat stat, ImbueItem imbueitem, int success)
        {
            int value = (int)(Item.RequiredLevel) + imbueitem.IncreaseValue;
            value += (int)(((value * 0.1) * Item.Plus) + ((imbueitem.ImbueChance / 5) * Item.Plus));
            value *= success;

            if (Item is Hand)
            {
                Item.Damage += (short)value;
                stat = ImbueStat.Damage;
            }
            if (Item is Cape)
            {
                if (Item.Damage > 0 && Item.Defence > 0)
                {
                    Item.Defence += (short)value;
                    Item.Damage += (short)value;
                    stat = ImbueStat.DefenseAndDamage;
                }
                else
                {
                    Item.Defence += (short)value;
                    stat = ImbueStat.Defense;
                }
            }
            if (Item is Head)
            {
                Item.AttackRating += (short)value;
                stat = ImbueStat.AttackRating;
            }
            if (Item is Body)
            {
                Item.Defence += (short)value;
                stat = ImbueStat.Defense;
            }
            if (Item is Feet)
            {
                value = (int)(Math.Round((double)(value / 50))) + 1;
                Item.Critical += (short)value;
                stat = ImbueStat.CriticalHit;
            }
            if (Item is Ring)
            {
                Item.IncMaxLife += (short)value;
                stat = ImbueStat.MaxLife;
            }
            if (Item is Necklace)
            {
                Item.IncMaxMana += (short)value;
                stat = ImbueStat.MaxMana;
            }

            return value;
        }
示例#2
0
        public BaseItem PickupItem(int mapItemId, Client c, short mapItemAmount)
        {
            MapItem m = null;

            try
            {
                m = mapItems.Where(x => x.MapItemID == mapItemId).First();
            }
            catch (Exception)
            {
                return null;
            }

            BaseItem item = null;

            if (m.DroppedByCharacterID == 0 || m.DroppedByCharacterID == c.MyCharacter.CharacterId)
            {
                if (m.bType != (byte)bType.Jeon)
                {
                    if (m.ItemID != 0)
                        item = itemDataManager.GetItemByItemID(m.ItemID);
                    else
                        item = itemDataManager.GetItemByReferenceID(m.ReferenceID);

                    BagSlot bagSlot = gameEngine.TryPickToBags(c.MyCharacter.Bags.ToArray(), item);

                    item.Slot = bagSlot.Slot;
                    item.Bag = bagSlot.Bag;

                    mapItemManager.DeleteMapItem(m.MapItemID, 0);
                    mapItems.Remove(m);
                    item.OwnerID = c.MyCharacter.CharacterId;

                    if (item.ItemID != 0)
                        itemDataManager.UpdateItem(item);
                    else
                    {
                        item.ItemID = itemDataManager.InsertItem(item);
                        if (item is Equipment)
                        {
                            // later add chance to get these items blabla
                            Equipment Item = item as Equipment;
                            ImbueStat stat = ImbueStat.None;
                            ImbueItem imbueitem = new ImbueItem
                            {
                                ImbueChance = 1,
                                IncreaseValue = 1,
                            };
                            // Possible plus for drop
                            if (XiahRandom.PercentSuccess(40))
                            {
                                int plus = gameEngine.RandomChance(0, 5);
                                for (int i = 0; i < plus; i++)
                                {
                                    gameEngine.BlackImbue(Item, ref stat, imbueitem, 1);
                                    Item.Plus++;
                                }
                            }

                            if (XiahRandom.PercentSuccess(40))
                            {
                                // Possible slvl for drop
                                int slvl = gameEngine.RandomChance(0, 5);
                                for (int i = 0; i < slvl && !(Item is Cape); i++)
                                {
                                    gameEngine.WhiteImbue(Item, ref stat, imbueitem);
                                    Item.Slvl++;
                                }
                            }

                            item = Item;
                            itemDataManager.UpdateItem(item);
                        }
                    }
                }
                else
                {
                    item = itemDataManager.GetItemByReferenceID(m.ReferenceID);
                    mapItemManager.DeleteMapItem(m.MapItemID, 0);
                    mapItems.Remove(m);

                    item.Amount = mapItemAmount;
                }
            }
            else
            {
                c.Send(PacketEngine.PacketManager.SendPickUpText(0, 0, 0));
                // send pickuperror blabal
            }

            return item;
        }
示例#3
0
        /// <summary>
        /// SELL ITEM PRICE FOR PLAIN ITEMS IS ITEM.PRICE / 2.5
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void c_ClientBuyItemInfo(object sender, ClientBuyItemEventArgs e)
        {
            Client c = (Client)sender;
            BuyItemInfo i = e.Info;
            BaseItem buyitem = null;
            BaseItem npcitem = null;
            Npc npc = null;

            MapEngine mapEngine = GetMapEngine(c.MyCharacter.MapId);
            try
            {
                npc = mapEngine.GetNpcByID(i.NpcID, c.MyCharacter.MapId);

                npcitem = npc.FindItem(i.ReferenceID, i.Slot);
                int price = npcitem.Price * i.Amount;

                if (c.MyCharacter.Money >= price)
                {
                    BagSlot bagSlot = new BagSlot();

                    if (!c.MyCharacter.FindFreeSlotInBags(npcitem, bagSlot))
                    {
                        throw new BagIsFullException("BAG FULL");
                        //Throw exception here
                    }

                    c.MyCharacter.Money -= price;
                    c.Send(PacketManager.SendMoneyLeft(c.MyCharacter.Money));
                    c.Send(PacketManager.SendBuyItemState(BuyItemState.Success));

                    MemoryStream stream = new MemoryStream();

                    BinaryFormatter formatter = new BinaryFormatter();

                    formatter.Serialize(stream, npcitem);

                    stream.Position = 0;

                    buyitem = (BaseItem)formatter.Deserialize(stream);

                    stream.Close();

                    buyitem.Bag = bagSlot.Bag;
                    buyitem.Slot = bagSlot.Slot;
                    buyitem.OwnerID = c.MyCharacter.CharacterId;
                    buyitem.Amount = i.Amount;

                    buyitem.ItemID = itemDataManager.InsertItem(buyitem);

                    if (npc.IsEliteShop)
                    {
                        if (buyitem is Equipment)
                        {
                            // later add chance to get these items blabla
                            Equipment Item = buyitem as Equipment;
                            ImbueStat stat = ImbueStat.None;
                            ImbueItem imbueitem = new ImbueItem
                            {
                                ImbueChance = 1,
                                IncreaseValue = 1,
                            };

                            if (XiahRandom.PercentSuccess(40))
                            {
                                // Possible plus for drop
                                int plus = gameEngine.RandomChance(0, 9);
                                for (int a = 0; a < plus; a++)
                                {
                                    gameEngine.BlackImbue(Item, ref stat, imbueitem, 1);
                                    Item.Plus++;
                                }
                            }

                            if (XiahRandom.PercentSuccess(40))
                            {
                                // Possible slvl for drop
                                int slvl = gameEngine.RandomChance(0, 9);
                                for (int a = 0; a < slvl && !(Item is Cape); a++)
                                {
                                    gameEngine.WhiteImbue(Item, ref stat, imbueitem);
                                    Item.Slvl++;
                                }
                                buyitem = Item;
                            }

                            itemDataManager.UpdateItem(buyitem);
                        }
                    }

                    c.MyCharacter.Bags[buyitem.Bag - 1].AddItem(buyitem);

                    characterManager.UpdateCharacter(c.MyCharacter);
                    c.Send(PacketManager.SendAddItem(buyitem));
                }
                else
                {
                    c.Send(PacketManager.SendBuyItemState(BuyItemState.NoMoney));
                }

            }
            catch (BagIsFullException)
            {
                c.Send(PacketManager.SendBuyItemState(BuyItemState.BagFull));
            }
        }
示例#4
0
        public int WhiteImbue(Equipment Item, ref ImbueStat stat, ImbueItem imbueitem)
        {
            int value = (int)(Item.RequiredLevel);
            value += (int)(((value * 0.1) * Item.Slvl) + ((imbueitem.ImbueChance / 5) * Item.Slvl));

            List<ImbueStat> WhiteStats = new List<ImbueStat>();
            WhiteStats.Add(ImbueStat.Damage);
            WhiteStats.Add(ImbueStat.Defense);
            WhiteStats.Add(ImbueStat.AttackRating);
            WhiteStats.Add(ImbueStat.MaxLife);
            WhiteStats.Add(ImbueStat.MaxMana);
            WhiteStats.Add(ImbueStat.LifeReg);
            WhiteStats.Add(ImbueStat.ManaReg);
            WhiteStats.Add(ImbueStat.CriticalHit);

            if (Item is Cape)
            {
                WhiteStats.Remove(ImbueStat.Damage);
                WhiteStats.Remove(ImbueStat.Defense);
            }
            if (Item is Hand)
            {
                Hand weapon = Item as Hand;
                WhiteStats.Remove(weapon.NotWithWhite);
            }
            if (Item is Head)
            {
                Head hat = Item as Head;
                WhiteStats.Remove(hat.NotWithWhite);
            }
            if (Item is Body)
            {
                Body armor = Item as Body;
                WhiteStats.Remove(armor.NotWithWhite);
            }
            if (Item is Ring)
            {
                Ring ring = Item as Ring;
                value *= (int)2.94;
            }
            if (Item is Necklace)
            {
                Necklace neck = Item as Necklace;
                value *= (int)1.85;
            }

            if (imbueitem.ImbueData == 0)
            {
                int randomStat = Random.Next(0, WhiteStats.Count);
                stat = WhiteStats[randomStat];
            }
            else
            {
                switch (imbueitem.ImbueData)
                {
                    case 2:
                        stat = ImbueStat.Damage;
                        break;
                    case 3:
                        stat = ImbueStat.Defense;
                        break;

                    case 4:
                        stat = ImbueStat.AttackRating;
                        break;

                    case 5:
                        stat = ImbueStat.CriticalHit;
                        break;

                    case 6:
                        stat = ImbueStat.MaxLife;
                        break;

                    case 7:
                        stat = ImbueStat.MaxMana;
                        break;

                    case 8:
                        stat = ImbueStat.LifeReg;
                        break;

                    case 9:
                        stat = ImbueStat.ManaReg;
                        break;

                    default:
                        stat = ImbueStat.CriticalHit;
                        break;
                }
            }
            switch (stat)
            {
                case ImbueStat.Damage:
                    Item.Damage += (short)value;
                    break;

                case ImbueStat.Defense:
                    Item.Defence += (short)value;
                    break;

                case ImbueStat.AttackRating:
                    Item.AttackRating += (short)value;
                    break;

                case ImbueStat.MaxLife:
                    Item.IncMaxLife += (short)value;
                    break;

                case ImbueStat.MaxMana:
                    Item.IncMaxMana += (short)value;
                    break;

                case ImbueStat.LifeReg:
                    Item.IncLifeRegen += (short)value;
                    break;

                case ImbueStat.ManaReg:
                    Item.IncManaRegen += (short)value;
                    break;

                case ImbueStat.CriticalHit:
                    value = (int)(Math.Round((double)(value / 50))) + 1;
                    Item.Critical += (short)value;
                    break;
            }

            return value;
        }