public virtual bool AddItemTo(ItemInfo item, int place)
        {
            if (item == null || place >= this.m_capalility || place < 0)
            {
                return(false);
            }
            object @lock;

            Monitor.Enter(@lock = this.m_lock);
            try
            {
                if (this.m_items[place] != null)
                {
                    place = -1;
                }
                else
                {
                    this.m_items[place] = item;
                    if (item.IsBead())
                    {
                        RuneTemplateInfo runeTemplateInfo = RuneMgr.FindRuneTemplateID(item.TemplateID);
                        if (runeTemplateInfo == null)
                        {
                            Console.WriteLine("???RuneTemplate is Null");
                        }
                        else
                        {
                            if (item.Hole1 <= 0 && item.Hole2 <= 0)
                            {
                                int baseLevel = runeTemplateInfo.BaseLevel;
                                item.Hole1 = baseLevel;
                                item.Hole2 = RuneMgr.FindRuneExp(baseLevel - 1);
                            }
                        }
                    }
                    item.Place   = place;
                    item.BagType = this.m_type;
                }
            }
            finally
            {
                Monitor.Exit(@lock);
            }
            if (place != -1)
            {
                this.OnPlaceChanged(place);
            }
            return(place != -1);
        }
 public void EquipBuffer()
 {
     this.m_player.EquipEffect.Clear();
     for (int i = 0; i < 31; i++)
     {
         ItemInfo itemAt = this.m_player.BeadBag.GetItemAt(i);
         if (itemAt != null)
         {
             RuneTemplateInfo runeTemplateInfo = RuneMgr.FindRuneTemplateID(itemAt.TemplateID);
             if (runeTemplateInfo != null && (runeTemplateInfo.Type1 == 37 || runeTemplateInfo.Type1 == 39 || runeTemplateInfo.Type1 < 31))
             {
                 this.m_player.AddBeadEffect(itemAt);
             }
         }
     }
 }
Exemple #3
0
        public void InitBuffer(List <ItemInfo> equpedEffect)
        {
            base.EffectList.StopAllEffect();
            foreach (ItemInfo current in equpedEffect)
            {
                int num  = 0;
                int num2 = 0;
                RuneTemplateInfo runeTemplateInfo = RuneMgr.FindRuneTemplateID(current.TemplateID);
                string[]         array            = runeTemplateInfo.Attribute1.Split(new char[]
                {
                    '|'
                });
                string[] array2 = runeTemplateInfo.Attribute2.Split(new char[]
                {
                    '|'
                });
                if (current.Hole1 > runeTemplateInfo.BaseLevel)
                {
                    if (array.Length > 1)
                    {
                        num = 1;
                    }
                    if (array2.Length > 1)
                    {
                        num2 = 1;
                    }
                }
                int num3        = runeTemplateInfo.Type1;
                int num4        = Convert.ToInt32(array[num]);
                int probability = runeTemplateInfo.Rate1;
                if (num3 == 37 || num3 == 39)
                {
                    num3        = runeTemplateInfo.Type2;
                    num4        = Convert.ToInt32(array2[num2]);
                    probability = runeTemplateInfo.Rate2;
                }
                switch (num3)
                {
                case 1:
                    new AddAttackEffect(num4, probability).Start(this);
                    break;

                case 2:
                    new AddDefenceEffect(num4, probability).Start(this);
                    break;

                case 3:
                    new AddAgilityEffect(num4, probability).Start(this);
                    break;

                case 4:
                    new AddLuckyEffect(num4, probability).Start(this);
                    break;

                case 5:
                    new AddDamageEffect(num4, probability).Start(this);
                    break;

                case 6:
                    new ReduceDamageEffect(num4, probability).Start(this);
                    break;

                case 7:
                    new AddBloodEffect(num4, probability).Start(this);
                    break;

                case 8:
                    new FatalEffect(num4, probability).Start(this);
                    break;

                case 9:
                    new IceFronzeEquipEffect(num4, probability).Start(this);
                    break;

                case 10:
                    new NoHoleEquipEffect(num4, probability).Start(this);
                    break;

                case 11:
                    new AtomBombEquipEffect(num4, probability).Start(this);
                    break;

                case 12:
                    new ArmorPiercerEquipEffect(num4, probability).Start(this);
                    break;

                case 13:
                    new AvoidDamageEffect(num4, probability).Start(this);
                    break;

                case 14:
                    new MakeCriticalEffect(num4, probability).Start(this);
                    break;

                case 15:
                    new AssimilateDamageEffect(num4, probability).Start(this);
                    break;

                case 16:
                    new AssimilateBloodEffect(num4, probability).Start(this);
                    break;

                case 17:
                    new SealEquipEffect(num4, probability).Start(this);
                    break;

                case 18:
                    new AddTurnEquipEffect(num4, probability).Start(this);
                    break;

                case 19:
                    new AddDanderEquipEffect(num4, probability).Start(this);
                    break;

                case 20:
                    new ReflexDamageEquipEffect(num4, probability).Start(this);
                    break;

                case 21:
                    new ReduceStrengthEquipEffect(num4, probability).Start(this);
                    break;

                case 22:
                    new ContinueReduceBloodEquipEffect(num4, probability).Start(this);
                    break;

                case 23:
                    new LockDirectionEquipEffect(num4, probability).Start(this);
                    break;

                case 24:
                    new AddBombEquipEffect(num4, probability).Start(this);
                    break;

                case 25:
                    new ContinueReduceDamageEquipEffect(num4, probability).Start(this);
                    break;

                case 26:
                    new RecoverBloodEffect(num4, probability).Start(this);
                    break;

                default:
                    Console.WriteLine("??????????????????????????? Not Found Effect: " + num3);
                    break;
                }
            }
        }
        public void AddRuneProperty(ItemInfo item, ref int attack, ref int defence, ref int agility, ref int lucky, ref int hp)
        {
            RuneTemplateInfo runeTemplateInfo = RuneMgr.FindRuneTemplateID(item.TemplateID);

            if (runeTemplateInfo != null)
            {
                string[] array = runeTemplateInfo.Attribute1.Split(new char[]
                {
                    '|'
                });
                string[] array2 = runeTemplateInfo.Attribute2.Split(new char[]
                {
                    '|'
                });
                int num  = 0;
                int num2 = 0;
                if (item.Hole1 > runeTemplateInfo.BaseLevel)
                {
                    if (array.Length > 1)
                    {
                        num = 1;
                    }
                    if (array2.Length > 1)
                    {
                        num2 = 1;
                    }
                }
                int num3 = Convert.ToInt32(array[num]);
                int num4 = Convert.ToInt32(array2[num2]);
                switch (runeTemplateInfo.Type1)
                {
                case 31:
                    attack += num3;
                    hp     += num4;
                    return;

                case 32:
                    defence += num3;
                    hp      += num4;
                    return;

                case 33:
                    agility += num3;
                    hp      += num4;
                    return;

                case 34:
                    lucky += num3;
                    hp    += num4;
                    return;

                case 35:
                    hp += num4;
                    return;

                case 36:
                    hp += num4;
                    return;

                case 37:
                    hp += num3;
                    break;

                default:
                    return;
                }
            }
        }
Exemple #5
0
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            byte            b         = packet.ReadByte();
            PlayerInventory inventory = client.Player.GetInventory(eBageType.BeadBag);
            string          text      = "";

            if (client.Player.PlayerCharacter.HasBagPassword && client.Player.PlayerCharacter.IsLocked)
            {
                client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked", new object[0]));
                return(0);
            }
            if (DateTime.Compare(client.Player.LastDrillUpTime.AddSeconds(2.0), DateTime.Now) > 0)
            {
                client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Quá nhiều thao tác!", new object[0]));
                return(1);
            }
            switch (b)
            {
            case 1:
            {
                int num  = packet.ReadInt();
                int num2 = packet.ReadInt();
                int num3 = 10;
                if (num2 == -1)
                {
                    num2 = inventory.FindFirstEmptySlot();
                }
                if (num <= 12 && num >= 4 && BeadHandle.canEquip(num2, client.Player.PlayerCharacter.Grade, ref num3))
                {
                    client.Out.SendMessage(eMessageType.Normal, string.Format("Cấp {0} mở", num3));
                    return(0);
                }
                if (!inventory.MoveItem(num, num2, 1))
                {
                    Console.WriteLine("????User move bead error");
                }
                client.Player.MainBag.UpdatePlayerProperties();
                break;
            }

            case 2:
            {
                new List <int>();
                ItemInfo itemAt = inventory.GetItemAt(31);
                if (itemAt == null)
                {
                    client.Player.SendMessage("Vật phẩm lạ không tìm thấy!!! Hack chăng???!!!");
                    return(0);
                }
                int arg_504_0 = itemAt.Hole1;
                int num4      = packet.ReadInt();
                int num5      = RuneMgr.MaxLv();
                for (int i = 0; i < num4; i++)
                {
                    int              num6             = packet.ReadInt();
                    ItemInfo         itemAt2          = inventory.GetItemAt(num6);
                    RuneTemplateInfo runeTemplateInfo = RuneMgr.FindRuneTemplateID(itemAt.TemplateID);
                    if (runeTemplateInfo == null)
                    {
                        inventory.RemoveItem(itemAt2);
                    }
                    else
                    {
                        if (itemAt2.Hole1 < itemAt.Hole1 && !itemAt2.IsUsed)
                        {
                            int hole  = itemAt2.Hole2;
                            int hole2 = itemAt.Hole2;
                            int hole3 = itemAt.Hole1;
                            int exp   = hole + hole2;
                            inventory.RemoveItemAt(num6);
                            if (BeadHandle.CanUpLv(exp, hole3))
                            {
                                itemAt.Hole2 += hole;
                                itemAt.Hole1++;
                            }
                            else
                            {
                                itemAt.Hole2 += hole;
                            }
                            int nextTemplateID = runeTemplateInfo.NextTemplateID;
                            RuneTemplateInfo runeTemplateInfo2 = RuneMgr.FindRuneTemplateID(nextTemplateID);
                            if (itemAt.Hole1 == runeTemplateInfo2.BaseLevel)
                            {
                                ItemInfo itemInfo = new ItemInfo(ItemMgr.FindItemTemplate(nextTemplateID));
                                itemAt.TemplateID = nextTemplateID;
                                itemInfo.Copy(itemAt);
                                inventory.RemoveItemAt(31);
                                inventory.AddItemTo(itemInfo, 31);
                            }
                            else
                            {
                                inventory.UpdateItem(itemAt);
                            }
                            if (itemAt.Hole1 == num5 + 1)
                            {
                                break;
                            }
                        }
                    }
                }
                break;
            }

            case 3:
            {
                string[] array = GameProperties.OpenRunePackageMoney.Split(new char[]
                    {
                        '|'
                    });
                int num7 = packet.ReadInt();
                packet.ReadBoolean();
                int num8 = Convert.ToInt32(array[num7]);
                if (client.Player.PlayerCharacter.Money < num8)
                {
                    client.Player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("DivorceApplyHandler.Msg1", new object[0]));
                    return(1);
                }
                if (inventory.FindFirstEmptySlot() == -1)
                {
                    client.Out.SendMessage(eMessageType.Normal, "Rương đã đầy không thể mở thêm!");
                    return(1);
                }
                List <RuneTemplateInfo> list = new List <RuneTemplateInfo>();
                switch (num7)
                {
                case 1:
                    list = RuneMgr.OpenPackageLv2();
                    break;

                case 2:
                    list = RuneMgr.OpenPackageLv3();
                    break;

                case 3:
                    list = RuneMgr.OpenPackageLv4();
                    break;

                default:
                    list = RuneMgr.OpenPackageLv1();
                    break;
                }
                int      index     = ThreadSafeRandom.NextStatic(list.Count);
                ItemInfo itemInfo2 = ItemInfo.CreateFromTemplate(ItemMgr.FindItemTemplate(list[index].TemplateID), 1, 105);
                inventory.AddItem(itemInfo2);
                client.Out.SendMessage(eMessageType.Normal, "Bạn nhận được " + RuneMgr.FindRuneTemplateID(itemInfo2.TemplateID).Name);
                client.Player.RemoveMoney(num8);
                int rand = BeadHandle.NextBeadIndex(client, num7);
                this.BeadIndexUpdate(client, num7);
                client.Out.SendRuneOpenPackage(client.Player, rand);
                break;
            }

            case 4:
            {
                int      num     = packet.ReadInt();
                ItemInfo itemAt2 = inventory.GetItemAt(num);
                if (itemAt2.IsUsed)
                {
                    itemAt2.IsUsed = false;
                }
                else
                {
                    itemAt2.IsUsed = true;
                }
                inventory.UpdateItem(itemAt2);
                break;
            }

            case 5:
            {
                int             num9       = packet.ReadInt();
                int             templateId = packet.ReadInt();
                PlayerInventory inventory2 = client.Player.GetInventory(eBageType.PropBag);
                inventory2.GetItemByTemplateID(0, templateId);
                int itemCount = inventory2.GetItemCount(templateId);
                if (itemCount <= 0)
                {
                    client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("Mủi khoan không đủ!", new object[0]));
                }
                else
                {
                    int num10 = BeadHandle.randomExp.Next(2, 6);
                    text = LanguageMgr.GetTranslation("OpenHoleHandler.GetExp", new object[]
                        {
                            num10
                        });
                    UserDrillInfo userDrillInfo = client.Player.UserDrills[num9];
                    userDrillInfo.HoleExp += num10;
                    if ((userDrillInfo.HoleExp >= GameProperties.HoleLevelUpExp(0) && userDrillInfo.HoleLv == 0) || (userDrillInfo.HoleExp >= GameProperties.HoleLevelUpExp(1) && userDrillInfo.HoleLv == 1) || (userDrillInfo.HoleExp >= GameProperties.HoleLevelUpExp(2) && userDrillInfo.HoleLv == 2) || (userDrillInfo.HoleExp >= GameProperties.HoleLevelUpExp(3) && userDrillInfo.HoleLv == 3) || (userDrillInfo.HoleExp >= GameProperties.HoleLevelUpExp(4) && userDrillInfo.HoleLv == 4))
                    {
                        userDrillInfo.HoleLv++;
                        userDrillInfo.HoleExp = 0;
                    }
                    client.Player.UpdateDrill(num9, userDrillInfo);
                    using (PlayerBussiness playerBussiness = new PlayerBussiness())
                    {
                        playerBussiness.UpdateUserDrillInfo(userDrillInfo);
                    }
                }
                if (text != "")
                {
                    client.Out.SendMessage(eMessageType.Normal, text);
                }
                client.Player.Out.SendPlayerDrill(client.Player.PlayerCharacter.ID, client.Player.UserDrills);
                inventory2.RemoveTemplate(templateId, 1);
                client.Player.LastDrillUpTime = DateTime.Now;
                break;
            }
            }
            inventory.SaveToDatabase();
            return(0);
        }