Ejemplo n.º 1
0
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            GSPacketIn gSPacketIn = new GSPacketIn(61, client.Player.PlayerCharacter.ID);

            new StringBuilder();
            int      num            = 40000;
            bool     tranHole       = packet.ReadBoolean();
            bool     tranHoleFivSix = packet.ReadBoolean();
            ItemInfo itemInfo       = client.Player.StoreBag.GetItemAt(0);
            ItemInfo itemInfo2      = client.Player.StoreBag.GetItemAt(1);

            if (itemInfo != null && itemInfo2 != null && itemInfo.Template.CategoryID == itemInfo2.Template.CategoryID && itemInfo2.Count == 1 && itemInfo.Count == 1 && itemInfo.IsValidItem() && itemInfo2.IsValidItem())
            {
                if (client.Player.PlayerCharacter.Gold < num)
                {
                    client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("itemtransferhandler.nogold", new object[0]));
                    return(1);
                }
                client.Player.RemoveGold(num);
                if (itemInfo.Template.CategoryID == 7 || itemInfo2.Template.CategoryID == 7)
                {
                    ItemInfo itemInfo3   = null;
                    ItemInfo itemInfo4   = null;
                    int      templateID  = itemInfo.TemplateID;
                    int      templateID2 = itemInfo2.TemplateID;
                    this.GetWeaponID(ref templateID, ref templateID2);
                    ItemTemplateInfo itemTemplateInfo  = ItemMgr.FindItemTemplate(templateID);
                    ItemTemplateInfo itemTemplateInfo2 = ItemMgr.FindItemTemplate(templateID2);
                    if (itemTemplateInfo != null)
                    {
                        itemInfo3 = ItemInfo.CreateWeapon(itemTemplateInfo, itemInfo, 116);
                    }
                    itemInfo = itemInfo3;
                    if (itemTemplateInfo2 != null)
                    {
                        itemInfo4 = ItemInfo.CreateWeapon(itemTemplateInfo2, itemInfo2, 116);
                    }
                    itemInfo2 = itemInfo4;
                }
                StrengthenMgr.InheritTransferProperty(ref itemInfo, ref itemInfo2, tranHole, tranHoleFivSix);
                client.Player.StoreBag.ClearBag();
                client.Player.StoreBag.AddItemTo(itemInfo, 0);
                client.Player.StoreBag.AddItemTo(itemInfo2, 1);
                gSPacketIn.WriteByte(0);
                client.Out.SendTCP(gSPacketIn);
            }
            else
            {
                client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("itemtransferhandler.nocondition", new object[0]));
            }
            return(0);
        }
Ejemplo n.º 2
0
        public override bool Start()
        {
            if (m_isRunning)
            {
                return(false);
            }
            try
            {
                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

                Thread.CurrentThread.Priority = ThreadPriority.Normal;

                GameProperties.Refresh();


                if (!InitComponent(RecompileScripts(), "Recompile Scripts"))
                {
                    return(false);
                }

                if (!InitComponent(StartScriptComponents(), "Script components"))
                {
                    return(false);
                }

                if (!InitComponent((GameProperties.EDITION == Edition), "Edition:" + Edition))
                {
                    return(false);
                }

                if (!InitComponent(InitSocket(IPAddress.Parse(Configuration.Ip), Configuration.Port), "InitSocket Port:" + Configuration.Port))
                {
                    return(false);
                }

                if (!InitComponent(AllocatePacketBuffers(), "AllocatePacketBuffers()"))
                {
                    return(false);
                }

                if (!InitComponent(LogMgr.Setup(Configuration.GAME_TYPE, Configuration.ServerID, Configuration.AreaID), "LogMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(WorldMgr.Init(), "WorldMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(MapMgr.Init(), "MapMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(ItemMgr.Init(), "ItemMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(ItemBoxMgr.Init(), "ItemBox Init"))
                {
                    return(false);
                }

                if (!InitComponent(BallMgr.Init(), "BallMgr Init"))
                {
                    return(false);
                }
                if (!InitComponent(BallConfigMgr.Init(), "BallConfigMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(FusionMgr.Init(), "FusionMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(AwardMgr.Init(), "AwardMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(NPCInfoMgr.Init(), "NPCInfoMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(MissionInfoMgr.Init(), "MissionInfoMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(PveInfoMgr.Init(), "PveInfoMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(DropMgr.Init(), "Drop Init"))
                {
                    return(false);
                }

                if (!InitComponent(FightRateMgr.Init(), "FightRateMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(ConsortiaLevelMgr.Init(), "ConsortiaLevelMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(RefineryMgr.Init(), "RefineryMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(StrengthenMgr.Init(), "StrengthenMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(PropItemMgr.Init(), "PropItemMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(ShopMgr.Init(), "ShopMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(QuestMgr.Init(), "QuestMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(RoomMgr.Setup(Configuration.MaxRoomCount), "RoomMgr.Setup"))
                {
                    return(false);
                }

                if (!InitComponent(GameMgr.Setup(Configuration.ServerID, GameProperties.BOX_APPEAR_CONDITION), "GameMgr.Start()"))
                {
                    return(false);
                }

                if (!InitComponent(ConsortiaMgr.Init(), "ConsortiaMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(LanguageMgr.Setup(@""), "LanguageMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(RateMgr.Init(Configuration), "ExperienceRateMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(MacroDropMgr.Init(), "MacroDropMgr Init"))
                {
                    return(false);
                }

                if (!InitComponent(BattleMgr.Setup(), "BattleMgr Setup"))
                {
                    return(false);
                }

                if (!InitComponent(InitGlobalTimer(), "Init Global Timers"))
                {
                    return(false);
                }

                if (!InitComponent(MarryRoomMgr.Init(), "MarryRoomMgr Init"))
                {
                    return(false);
                }
                if (!InitComponent(LogMgr.Setup(1, 4, 4), "LogMgr Setup"))
                {
                    return(false);
                }
                GameEventMgr.Notify(ScriptEvent.Loaded);

                if (!InitComponent(InitLoginServer(), "Login To CenterServer"))
                {
                    return(false);
                }

                RoomMgr.Start();
                GameMgr.Start();
                BattleMgr.Start();
                MacroDropMgr.Start();

                if (!InitComponent(base.Start(), "base.Start()"))
                {
                    return(false);
                }



                GameEventMgr.Notify(GameServerEvent.Started, this);

                GC.Collect(GC.MaxGeneration);

                if (log.IsInfoEnabled)
                {
                    log.Info("GameServer is now open for connections!");
                }

                m_isRunning = true;
                return(true);
            }
            catch (Exception e)
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("Failed to start the server", e);
                }

                return(false);
            }
        }
Ejemplo n.º 3
0
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            int             num         = packet.ReadInt();
            int             bageType    = packet.ReadInt();
            int             templateId  = packet.ReadInt();
            int             place       = packet.ReadInt();
            int             bagType     = packet.ReadInt();
            int             templateId2 = packet.ReadInt();
            PlayerInventory inventory   = client.Player.GetInventory((eBageType)bageType);
            ItemInfo        itemInfo    = inventory.GetItemAt(num);

            client.Player.GetItemAt((eBageType)bagType, place);
            double num2 = 5.0;
            GoldEquipTemplateLoadInfo goldEquipTemplateLoadInfo = GoldEquipMgr.FindGoldEquipTemplate(templateId);
            GSPacketIn gSPacketIn = new GSPacketIn(106, client.Player.PlayerCharacter.ID);

            if (goldEquipTemplateLoadInfo == null && itemInfo.Template.CategoryID == 7)
            {
                gSPacketIn.WriteInt(5);
            }
            else
            {
                if (!itemInfo.IsGold)
                {
                    if (num2 > (double)WishBeadEquipHandler.random.Next(100))
                    {
                        itemInfo.StrengthenLevel++;
                        itemInfo.IsGold        = true;
                        itemInfo.goldBeginTime = DateTime.Now;
                        itemInfo.goldValidDate = 30;
                        itemInfo.IsBinds       = true;
                        if (goldEquipTemplateLoadInfo != null && itemInfo.Template.CategoryID == 7)
                        {
                            ItemTemplateInfo itemTemplateInfo = ItemMgr.FindItemTemplate(goldEquipTemplateLoadInfo.NewTemplateId);
                            if (itemTemplateInfo != null)
                            {
                                ItemInfo itemInfo2 = ItemInfo.CreateFromTemplate(itemTemplateInfo, 1, 116);
                                itemInfo2.StrengthenLevel = itemInfo.StrengthenLevel;
                                itemInfo2.IsGold          = itemInfo.IsGold;
                                itemInfo2.goldBeginTime   = itemInfo.goldBeginTime;
                                itemInfo2.goldValidDate   = itemInfo.goldValidDate;
                                itemInfo2.IsBinds         = itemInfo.IsBinds;
                                ItemInfo.OpenHole(ref itemInfo2);
                                StrengthenMgr.InheritProperty(itemInfo, ref itemInfo2);
                                inventory.RemoveItemAt(num);
                                inventory.AddItemTo(itemInfo2, num);
                                itemInfo = itemInfo2;
                            }
                        }
                        inventory.UpdateItem(itemInfo);
                        gSPacketIn.WriteInt(0);
                        inventory.SaveToDatabase();
                    }
                    else
                    {
                        gSPacketIn.WriteInt(1);
                    }
                    client.Player.RemoveTemplate(templateId2, 1);
                }
                else
                {
                    gSPacketIn.WriteInt(6);
                }
            }
            client.Out.SendTCP(gSPacketIn);
            return(0);
        }
Ejemplo n.º 4
0
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            GSPacketIn pkg = packet.Clone();

            pkg.ClearContext();

            StringBuilder str             = new StringBuilder();
            int           mustGold        = 40000;
            bool          _moveHole       = packet.ReadBoolean();
            bool          _moveFivSixHole = packet.ReadBoolean();

            ItemInfo transferBefore = client.Player.StoreBag2.GetItemAt(0);
            ItemInfo transferAfter  = client.Player.StoreBag2.GetItemAt(1);

            //未开始
            if (transferBefore != null && transferAfter != null &&
                transferBefore.Template.CategoryID == transferAfter.Template.CategoryID &&
                //transferBefore.Template.CategoryID < 10 &&
                transferAfter.Count == 1 && transferBefore.Count == 1 &&
                transferBefore.IsValidItem() && transferAfter.IsValidItem())
            {
                if (client.Player.PlayerCharacter.Gold < mustGold)
                {
                    client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("itemtransferhandler.nogold"));
                    return(1);
                }
                client.Player.RemoveGold(mustGold);

                if (transferBefore.Template.CategoryID == 7 || transferAfter.Template.CategoryID == 7)
                {
                    ItemTemplateInfo newTemp0 = null;
                    ItemTemplateInfo newTemp1 = null;
                    ItemInfo         newItem0 = null;
                    ItemInfo         newItem1 = null;
                    int _temID0 = transferBefore.TemplateID;
                    int _temID1 = transferAfter.TemplateID;

                    GetWeaponID(ref _temID0, ref _temID1);

                    newTemp0 = Bussiness.Managers.ItemMgr.FindItemTemplate(_temID0);
                    newTemp1 = Bussiness.Managers.ItemMgr.FindItemTemplate(_temID1);
                    if (newTemp0 != null)
                    {
                        newItem0 = ItemInfo.CreateWeapon(newTemp0, transferBefore, (int)ItemAddType.Strengthen);
                    }
                    transferBefore = newItem0;
                    if (newTemp1 != null)
                    {
                        newItem1 = ItemInfo.CreateWeapon(newTemp1, transferAfter, (int)ItemAddType.Strengthen);
                    }
                    transferAfter = newItem1;
                }

                StrengthenMgr.InheritTransferProperty(ref transferBefore, ref transferAfter, _moveHole, _moveFivSixHole);

                client.Player.StoreBag2.ClearBag();
                client.Player.StoreBag2.AddItemTo(transferBefore, 0);
                client.Player.StoreBag2.AddItemTo(transferAfter, 1);
                client.Player.SaveIntoDatabase();
                pkg.WriteByte(0);
                client.Out.SendTCP(pkg);
            }
            else
            {
                client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("itemtransferhandler.nocondition"));
            }

            return(0);
        }
Ejemplo n.º 5
0
        public override int HandlePacket(GamePlayer player, GSPacketIn packet)
        {
            int  pRICE_STRENGHTN_GOLD = AppConfig.AppSettings["StrengthenGold"].ConvertToInt(1000);
            bool flag = player.PlayerCharacter.Gold < pRICE_STRENGHTN_GOLD;
            int  num;
            int  result;

            if (flag)
            {
                player.Out.SendMessage(0, LanguageMgr.GetTranslation("ItemStrengthenHandler.NoMoney", new object[0]));
                num = 0;
            }
            else
            {
                GSPacketIn gSPacketIn = packet.Clone();
                gSPacketIn.ClearContext();
                ItemInfo itemInfo = player.HideBag.GetItemAt(5);
                bool     flag2    = itemInfo != null && itemInfo.Template.CanStrengthen && itemInfo.Count == 1;
                if (flag2)
                {
                    StrengthenInfo strengthenInfo = StrengthenMgr.FindStrengthenInfo(itemInfo.StrengthenLevel + 1);
                    bool           flag3          = strengthenInfo == null;
                    if (flag3)
                    {
                        bool flag4 = itemInfo.StrengthenLevel == 9 || itemInfo.StrengthenLevel == 15;
                        if (flag4)
                        {
                            player.Out.SendMessage(0, LanguageMgr.GetTranslation("ItemStrengthenHandler.FullStrengthLevel", new object[0]));
                        }
                        else
                        {
                            player.Out.SendMessage(0, LanguageMgr.GetTranslation("ItemStrengthenHandler.NoStrength", new object[0]));
                        }
                        num    = 0;
                        result = num;
                        return(result);
                    }
                    bool          flag5          = itemInfo.IsBinds;
                    bool          flag6          = packet.ReadBoolean();
                    StringBuilder stringBuilder  = new StringBuilder();
                    string        propertyString = itemInfo.GetPropertyString();
                    double        num2           = 0.0;
                    bool          flag7          = false;
                    ItemInfo      itemInfo2      = player.HideBag.GetItemAt(3);
                    bool          flag8          = itemInfo2 != null && itemInfo2.Template.CategoryID == 11 && itemInfo2.Template.Property1 == 7;
                    if (flag8)
                    {
                        flag5 |= itemInfo2.IsBinds;
                        stringBuilder.Append(itemInfo2.ToShortString());
                        flag7 = true;
                    }
                    else
                    {
                        itemInfo2 = null;
                    }
                    bool            flag9  = false;
                    List <ItemInfo> list   = new List <ItemInfo>();
                    ItemInfo        itemAt = player.HideBag.GetItemAt(0);
                    bool            flag10 = itemAt != null && itemAt.Template.CategoryID == 11 && (itemAt.Template.Property1 == 2 || itemAt.Template.Property1 == 35) && !list.Contains(itemAt);
                    if (flag10)
                    {
                        bool flag11 = itemInfo.StrengthenLevel >= 15 && itemAt.Template.Property8 == 2;
                        if (flag11)
                        {
                            player.Out.SendMessage(0, "不能使用[" + itemAt.Template.Name + "]来强化此装备.");
                            num    = 1;
                            result = num;
                            return(result);
                        }
                        flag5 |= itemAt.IsBinds;
                        flag9 |= (itemAt.Template.Property1 == 35 && itemAt.Template.CategoryID == 11);
                        num2  += (double)itemAt.Template.Property2;
                        stringBuilder.Append(itemAt.ToShortString());
                        list.Add(itemAt);
                    }
                    ItemInfo itemAt2 = player.HideBag.GetItemAt(1);
                    bool     flag12  = itemAt2 != null && itemAt2.Template.CategoryID == 11 && (itemAt2.Template.Property1 == 2 || itemAt2.Template.Property1 == 35) && !list.Contains(itemAt2);
                    if (flag12)
                    {
                        bool flag13 = itemInfo.StrengthenLevel >= 15 && itemAt2.Template.Property8 == 2;
                        if (flag13)
                        {
                            player.Out.SendMessage(0, "不能使用[" + itemAt2.Template.Name + "]来强化此装备.");
                            num    = 1;
                            result = num;
                            return(result);
                        }
                        flag5 |= itemAt2.IsBinds;
                        flag9 |= (itemAt2.Template.Property1 == 35 && itemAt2.Template.CategoryID == 11);
                        num2  += (double)itemAt2.Template.Property2;
                        stringBuilder.Append(itemAt2.ToShortString());
                        list.Add(itemAt2);
                    }
                    ItemInfo itemAt3 = player.HideBag.GetItemAt(2);
                    bool     flag14  = itemAt3 != null && itemAt3.Template.CategoryID == 11 && (itemAt3.Template.Property1 == 2 || itemAt3.Template.Property1 == 35) && !list.Contains(itemAt3);
                    if (flag14)
                    {
                        bool flag15 = itemInfo.StrengthenLevel >= 15 && itemAt3.Template.Property8 == 2;
                        if (flag15)
                        {
                            player.Out.SendMessage(0, "不能使用[" + itemAt3.Template.Name + "]来强化此装备.");
                            num    = 1;
                            result = num;
                            return(result);
                        }
                        flag5 |= itemAt3.IsBinds;
                        flag9 |= (itemAt3.Template.Property1 == 35 && itemAt3.Template.CategoryID == 11);
                        num2  += (double)itemAt3.Template.Property2;
                        stringBuilder.Append(itemAt3.ToShortString());
                        list.Add(itemAt3);
                    }
                    ItemInfo itemInfo3 = player.HideBag.GetItemAt(4);
                    bool     flag16    = itemInfo3 != null && itemInfo3.Template.CategoryID == 11 && itemInfo3.Template.Property1 == 3;
                    if (flag16)
                    {
                        flag5 |= itemInfo3.IsBinds;
                        num2  *= (double)(itemInfo3.Template.Property2 + 100);
                        stringBuilder.Append(itemInfo3.ToShortString());
                    }
                    else
                    {
                        num2     *= 100.0;
                        itemInfo3 = null;
                    }
                    bool          flag17        = false;
                    ConsortiaInfo consortiaInfo = null;
                    bool          flag18        = flag6;
                    if (flag18)
                    {
                        consortiaInfo = ConsortiaMgr.FindConsortiaInfo(player.PlayerCharacter.ConsortiaID);
                        bool flag19 = consortiaInfo == null;
                        if (flag19)
                        {
                            player.Out.SendMessage(0, LanguageMgr.GetTranslation("ItemStrengthenHandler.Fail", new object[0]));
                        }
                        else
                        {
                            using (ConsortiaBussiness consortiaBussiness = new ConsortiaBussiness())
                            {
                                ConsortiaEquipControlInfo consortiaEuqipRiches = consortiaBussiness.GetConsortiaEuqipRiches(player.PlayerCharacter.ConsortiaID, 0, 2);
                                bool flag20 = player.PlayerCharacter.Riches < consortiaEuqipRiches.Riches;
                                if (flag20)
                                {
                                    player.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("ItemStrengthenHandler.FailbyPermission", new object[0]));
                                    num    = 1;
                                    result = num;
                                    return(result);
                                }
                                flag17 = true;
                            }
                        }
                    }
                    bool flag21 = list.Count >= 1;
                    if (flag21)
                    {
                        StrengthenGoodsInfo strengthenGoodsInfo = StrengthenMgr.FindStrengthenGoodsInfo(itemInfo.StrengthenLevel + 1, itemInfo.TemplateID);
                        ItemInfo            itemInfo4           = null;
                        bool flag22 = strengthenGoodsInfo != null;
                        if (flag22)
                        {
                            itemInfo4 = ItemInfo.CreateFromTemplate(ItemMgr.FindItemTemplate(strengthenGoodsInfo.GainEquip), 1, 116);
                            bool flag23 = itemInfo4 == null;
                            if (flag23)
                            {
                                num    = 0;
                                result = num;
                                return(result);
                            }
                        }
                        string text = null;
                        player.HideBag.BeginChanges();
                        try
                        {
                            num2 /= (double)strengthenInfo.Rock;
                            int num3;
                            for (int i = 0; i < list.Count; i = num3 + 1)
                            {
                                player.HideBag.RemoveCountFromStack(list[i], 1, (eItemRemoveType)5);
                                num3 = i;
                            }
                            bool flag24 = itemInfo3 != null;
                            if (flag24)
                            {
                                player.HideBag.RemoveCountFromStack(itemInfo3, 1, (eItemRemoveType)5);
                            }
                            bool flag25 = itemInfo2 != null;
                            if (flag25)
                            {
                                player.HideBag.RemoveCountFromStack(itemInfo2, 1, (eItemRemoveType)5);
                            }
                            bool flag26 = flag17;
                            if (flag26)
                            {
                                num2 *= 1.0 + 0.1 * (double)consortiaInfo.SmithLevel;
                            }
                            itemInfo.IsBinds = flag5;
                            int  num4   = 1;
                            bool flag27 = num2 > (double)ItemStrengthenHandler.random.Next(10000);
                            if (flag27)
                            {
                                num4 = 0;
                                bool flag28 = strengthenGoodsInfo != null && itemInfo4 != null;
                                if (flag28)
                                {
                                    StrengthenMgr.InheritProperty(itemInfo, itemInfo4);
                                    itemInfo4.StrengthenLevel = (itemInfo.StrengthenLevel + 1);
                                    player.HideBag.RemoveItem(itemInfo, (eItemRemoveType)5);
                                    player.HideBag.AddItemTo(itemInfo4, 5);
                                    text     = string.Format("temp_place_{0}", itemInfo.ItemID);
                                    itemInfo = itemInfo4;
                                    bool flag29 = itemInfo.ItemID == 0;
                                    if (flag29)
                                    {
                                        using (PlayerBussiness playerBussiness = new PlayerBussiness())
                                        {
                                            playerBussiness.AddGoods(itemInfo);
                                        }
                                    }
                                }
                                else
                                {
                                    ItemInfo itemInfo5 = itemInfo;
                                    num3 = itemInfo5.StrengthenLevel;
                                    itemInfo5.StrengthenLevel = (num3 + 1);
                                }
                                player.OnItemStrengthen(itemInfo.Template.CategoryID, itemInfo.StrengthenLevel);
                                bool flag30 = itemInfo.StrengthenLevel >= 7;
                                if (flag30)
                                {
                                    string translation = LanguageMgr.GetTranslation("ItemStrengthenHandler.congratulation", new object[]
                                    {
                                        player.PlayerCharacter.NickName,
                                        itemInfo.StrengthenLevel
                                    });
                                    GSPacketIn packet2 = WorldMgr.SendSysNotice(translation, itemInfo, player);
                                    GameServer.Instance.LoginServer.SendPacket(packet2);
                                }
                            }
                            else
                            {
                                num4 = 1;
                                bool flag31 = !flag7;
                                if (flag31)
                                {
                                    StrengthenGoodsInfo strengthenGoodsInfo2 = StrengthenMgr.FindStrengthenFailGoodsInfo(itemInfo.StrengthenLevel, itemInfo.TemplateID);
                                    itemInfo.StrengthenLevel = ((itemInfo.StrengthenLevel == 0) ? 0 : (itemInfo.StrengthenLevel - 1));
                                    bool flag32 = strengthenGoodsInfo2 != null;
                                    if (flag32)
                                    {
                                        ItemInfo itemInfo6 = ItemInfo.CreateFromTemplate(ItemMgr.FindItemTemplate(strengthenGoodsInfo2.CurrentEquip), 1, 116);
                                        bool     flag33    = itemInfo6 == null;
                                        if (flag33)
                                        {
                                            num    = 0;
                                            result = num;
                                            return(result);
                                        }
                                        StrengthenMgr.InheritProperty(itemInfo, itemInfo6);
                                        itemInfo6.StrengthenLevel = (itemInfo.StrengthenLevel);
                                        player.HideBag.RemoveItem(itemInfo, (eItemRemoveType)5);
                                        player.HideBag.AddItemTo(itemInfo6, 5);
                                    }
                                }
                            }
                            player.HideBag.UpdateItem(itemInfo);
                            gSPacketIn.WriteByte((byte)num4);
                            gSPacketIn.WriteBoolean(itemInfo.IsOpenHole);
                            player.RemoveGold(pRICE_STRENGHTN_GOLD);
                            //LogMgr.LogItemAdd(player.PlayerCharacter.ID, 1, propertyString, itemInfo, stringBuilder.ToString(), (num4 == 1) ? 0 : 1);
                        }
                        finally
                        {
                            player.HideBag.CommitChanges();
                            player.Out.SendTCP(gSPacketIn);
                        }
                        player.SaveIntoDatabase();
                        bool flag34 = text != null && player.TempProperties.ContainsKey(text);
                        if (flag34)
                        {
                            int num5 = (int)player.TempProperties[text];
                            player.TempProperties.Remove(text);
                            text = string.Format("temp_place_{0}", itemInfo.ItemID);
                            player.TempProperties.Add(text, num5);
                        }
                    }
                    else
                    {
                        player.Out.SendMessage(0, LanguageMgr.GetTranslation("ItemStrengthenHandler.Content1", new object[0]) + 1 + LanguageMgr.GetTranslation("ItemStrengthenHandler.Content2", new object[0]));
                    }
                }
                else
                {
                    player.Out.SendMessage(0, LanguageMgr.GetTranslation("ItemStrengthenHandler.Success", new object[0]));
                }
                num = 0;
            }
            result = num;
            return(result);
        }
Ejemplo n.º 6
0
        //private static readonly double[] rateItems = new double[] { 0.75, 3, 12, 48, 240, 768 };
        //public static int countConnect = 0;
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            //if (countConnect >= 3000)
            //{
            //    client.Disconnect();
            //    return 0;
            //}
            StringBuilder str           = new StringBuilder();
            bool          isBinds       = false;
            bool          consortia     = packet.ReadBoolean();
            bool          MultiSelected = packet.ReadBoolean();

            GSPacketIn pkg = packet.Clone();

            pkg.ClearContext();

            List <ItemInfo> stones = new List <ItemInfo>();
            ItemInfo        stone  = client.Player.StoreBag2.GetItemAt(0);
            ItemInfo        item   = client.Player.StoreBag2.GetItemAt(1);

            //ItemInfo luck = null;
            //ItemInfo god = null;
            string BeginProperty = null;
            string AddItem       = "";

            using (ItemRecordBussiness db = new ItemRecordBussiness())
            {
                db.PropertyString(item, ref BeginProperty);
            }

            if (item != null && item.Template.CanStrengthen && item.Template.CategoryID < 18 && item.Count == 1)
            {
                isBinds = isBinds ? true : item.IsBinds;
                str.Append(item.ItemID + ":" + item.TemplateID + ",");
                double exp1     = 0;
                double exp2     = 0;
                double exp3     = 0;
                double totalExp = 0;

                if (stone != null && stone.Template.CategoryID == 11 && (stone.Template.Property1 == 2 || stone.Template.Property1 == 35))
                {
                    isBinds  = isBinds ? true : stone.IsBinds;
                    AddItem += "," + stone.ItemID.ToString() + ":" + stone.Template.Name;
                    stones.Add(stone);
                    exp1 += stone.Template.Property2;
                }

                bool          ConsortiaRate = false;
                ConsortiaInfo info          = ConsortiaMgr.FindConsortiaInfo(client.Player.PlayerCharacter.ConsortiaID);
                //判断是公会铁匠铺还是铁匠铺??
                if (consortia)
                {
                    ConsortiaBussiness        csbs    = new ConsortiaBussiness();
                    ConsortiaEquipControlInfo cecInfo = csbs.GetConsortiaEuqipRiches(client.Player.PlayerCharacter.ConsortiaID, 0, 2);

                    if (info == null)
                    {
                        client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemStrengthenHandler.Fail"));
                    }
                    else
                    {
                        if (client.Player.PlayerCharacter.Riches < cecInfo.Riches)
                        {
                            client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("ItemStrengthenHandler.FailbyPermission"));
                            return(1);
                        }
                        ConsortiaRate = true;
                    }
                }
                if (ConsortiaRate)
                {
                    //ConsortiaRateManager.instance.getConsortiaStrengthenEx(PlayerManager.Instance.Self.consortiaInfo.SmithLevel)
                    //"ConsortiaStrengthenEx" Value="10|20|30|40|50|60|70|80|90|100"
                    List <double> ConsortiaStrengthenEx = new List <double> {
                        10, 20, 30, 40, 50, 60, 70, 80, 90, 100
                    };
                    exp2 = ConsortiaStrengthenEx[info.SmithLevel - 1] / 100 * exp1;
                }
                if (client.Player.PlayerCharacter.VIPExpireDay >= DateTime.Now)
                {
                    //_loc_4 = VipController.instance.getVIPStrengthenEx(PlayerManager.Instance.Self.VIPLevel)
                    //"VIPStrengthenEx" Value="25|25|25|35|35|50|50|50|50|50|50|50"
                    List <double> VIPStrengthenEx = new List <double> {
                        25, 25, 25, 35, 35, 50, 50, 50, 50, 50, 50, 50
                    };
                    exp3 = VIPStrengthenEx[client.Player.PlayerCharacter.VIPLevel - 1] / 100 * exp1;
                }
                totalExp += Math.Floor(exp1 + exp2 + exp3);
                str.Append("true");
                List <int> StrengThenExp = new List <int> {
                    0, 10, 50, 150, 350, 700, 1500, 2300, 3300, 4500, 6000, 7500, 9000
                };

                //Console.WriteLine("-------Total: " + stone.Count.ToString() + "| Inject: " + MultiSelected);
                if (MultiSelected)// && stone.Count > 1)
                {
                    //for (int i = 0; i < stone.Count; i++)
                    //{
                    item.StrengthenExp += (int)totalExp * stone.Count;
                    client.Player.StoreBag2.RemoveTemplate(stone.TemplateID, stone.Count);
                    //}
                }
                else
                {
                    item.StrengthenExp += (int)totalExp;
                    client.Player.StoreBag2.RemoveTemplate(stone.TemplateID, 1);
                }

                if (item.StrengthenExp >= StrengThenExp[item.StrengthenLevel + 1])
                {
                    //for (int a = StrengThenExp[item.StrengthenLevel]; a < item.StrengthenExp; a++)
                    int a = StrengThenExp[item.StrengthenLevel];
                    do
                    {
                        if (item.StrengthenLevel < 13)
                        {
                            if (item.StrengthenExp >= StrengThenExp[item.StrengthenLevel + 1])
                            {
                                item.StrengthenLevel++;
                                item.StrengthenExp -= StrengThenExp[item.StrengthenLevel];
                                a = StrengThenExp[item.StrengthenLevel];
                            }
                            else
                            {
                                break;
                            }
                        }
                    }while (item.StrengthenExp > a);
                    if (item.StrengthenLevel == 12 && (item.StrengthenExp / totalExp) > 0)
                    {
                        stone.Count = (int)Math.Floor(item.StrengthenExp / totalExp);
                        client.Player.StoreBag2.AddItemTo(stone, 0);
                        client.Player.StoreBag2.UpdateItem(stone);
                        //if (item.StrengthenLevel == 12)
                        item.StrengthenExp = 0;
                    }
                    pkg.WriteByte(1);

                    StrengthenGoodsInfo strengthenGoodsInfo = StrengthenMgr.FindStrengthenGoodsInfo(item.StrengthenLevel, item.TemplateID);
                    if (strengthenGoodsInfo != null && item.Template.CategoryID == 7)
                    {
                        ItemTemplateInfo Temp = Bussiness.Managers.ItemMgr.FindItemTemplate(strengthenGoodsInfo.GainEquip);
                        if (Temp != null)
                        {
                            ItemInfo newItem = ItemInfo.CreateFromTemplate(Temp, 1, (int)ItemAddType.Strengthen);
                            newItem.StrengthenLevel = item.StrengthenLevel;
                            newItem.StrengthenExp   = item.StrengthenExp;
                            ItemInfo.OpenHole(ref newItem);
                            StrengthenMgr.InheritProperty(item, ref newItem);
                            client.Player.StoreBag2.RemoveItemAt(1);
                            client.Player.StoreBag2.AddItemTo(newItem, 1);
                            //client.Player.StoreBag2.UpdateItem(newItem);
                            item = newItem;
                            if ((item.StrengthenLevel == 3 || item.StrengthenLevel == 6 || item.StrengthenLevel == 9 || item.StrengthenLevel == 12) && item.Template.CategoryID != 17)
                            {
                                pkg.WriteBoolean(true);
                            }
                            else
                            {
                                pkg.WriteBoolean(false);
                            }
                        }
                    }
                    else
                    {
                        ItemInfo.OpenHole(ref item);
                        //client.Player.StoreBag2.AddItemTo(item, 1);
                        if ((item.StrengthenLevel == 3 || item.StrengthenLevel == 6 || item.StrengthenLevel == 9 || item.StrengthenLevel == 12) && item.Template.CategoryID != 17)
                        {
                            pkg.WriteBoolean(true);
                        }
                        else
                        {
                            pkg.WriteBoolean(false);
                        }
                    }

                    //系统广播
                    if (item.StrengthenLevel >= 7)
                    {
                        string     msg        = LanguageMgr.GetTranslation("ItemStrengthenHandler.congratulation", client.Player.PlayerCharacter.NickName, item.Template.Name, item.StrengthenLevel);
                        GSPacketIn sys_notice = WorldMgr.SendSysNotice(msg);
                        GameServer.Instance.LoginServer.SendPacket(sys_notice);
                    }
                }
                else
                {
                    pkg.WriteByte(1);
                    pkg.WriteBoolean(false);
                }

                client.Player.StoreBag2.UpdateItem(item);
                client.Player.OnItemStrengthen(item.Template.CategoryID, item.StrengthenLevel);                               //任务<强化>
                LogMgr.LogItemAdd(client.Player.PlayerCharacter.ID, LogItemType.Strengthen, BeginProperty, item, AddItem, 1); //强化日志

                //client.Player.SaveIntoDatabase();//保存到数据库
                client.Out.SendTCP(pkg);
                str.Append(item.StrengthenLevel);
                //client.Player.BeginChanges();
                //client.Player.CommitChanges();
            }
            else
            {
                client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemStrengthenHandler.Content1") + stone.Template.Name + LanguageMgr.GetTranslation("ItemStrengthenHandler.Content2"));
            }
            if (item.Place < 31)
            {
                client.Player.MainBag.UpdatePlayerProperties();
            }

            return(0);
        }
Ejemplo n.º 7
0
        public override int HandlePacket(GamePlayer player, GSPacketIn packet)
        {
            GSPacketIn pkg = packet.Clone();

            pkg.ClearContext();
            StringBuilder str      = new StringBuilder();
            int           mustGold = 10000;
            ItemInfo      fromItem = player.HideBag.GetItemAt(0);
            ItemInfo      toItem   = player.HideBag.GetItemAt(1);
            int           result;

            if (fromItem.StrengthenLevel < toItem.StrengthenLevel)
            {
                player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemTransferHandler.NoCondition1", new object[0]));
                result = 0;
            }
            else
            {
                if (fromItem != null && toItem != null && fromItem.Template.CategoryID == toItem.Template.CategoryID && fromItem.Template.CategoryID < 10 && toItem.Count == 1 && fromItem.Count == 1 && fromItem.IsValidItem() && toItem.IsValidItem())
                {
                    if (fromItem.StrengthenLevel == 0 && fromItem.DefendCompose == 0 && fromItem.LuckCompose == 0 && fromItem.AgilityCompose == 0 && fromItem.AttackCompose == 0)
                    {
                        result = 1;
                        return(result);
                    }
                    if (player.PlayerCharacter.Gold < mustGold)
                    {
                        player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("itemtransferhandler.nogold", new object[0]));
                        result = 1;
                        return(result);
                    }
                    player.BeginChanges();
                    player.MainBag.BeginChanges();
                    try
                    {
                        player.RemoveGold(mustGold);
                        str.Append(string.Concat(new object[]
                        {
                            fromItem.ItemID,
                            ":",
                            fromItem.TemplateID,
                            ","
                        }));
                        str.Append(fromItem.StrengthenLevel + ",");
                        str.Append(fromItem.AttackCompose + ",");
                        str.Append(fromItem.DefendCompose + ",");
                        str.Append(fromItem.LuckCompose + ",");
                        str.Append(fromItem.AgilityCompose + ",");
                        StrengthenGoodsInfo newGoodsInfo = StrengthenMgr.FindStrengthenGoodsInfo(fromItem.StrengthenLevel, toItem.TemplateID);
                        ItemInfo            toNewItem    = null;
                        if (newGoodsInfo != null)
                        {
                            toNewItem = ItemInfo.CreateFromTemplate(ItemMgr.FindItemTemplate(newGoodsInfo.GainEquip), 1, 115);
                            if (toNewItem == null)
                            {
                                result = 0;
                                return(result);
                            }
                        }
                        StrengthenGoodsInfo oldGoodsInfo = StrengthenMgr.FindStrengthenGoodsInfo(fromItem.TemplateID);
                        ItemInfo            fromOldItem  = null;
                        if (oldGoodsInfo != null)
                        {
                            fromOldItem = ItemInfo.CreateFromTemplate(ItemMgr.FindItemTemplate(oldGoodsInfo.OrginEquip), 1, 115);
                            if (fromOldItem == null)
                            {
                                result = 0;
                                return(result);
                            }
                        }
                        if (toNewItem != null)
                        {
                            StrengthenMgr.InheritProperty(toItem, toNewItem);
                            toNewItem.StrengthenLevel = fromItem.StrengthenLevel;
                            toNewItem.AttackCompose   = fromItem.AttackCompose;
                            toNewItem.DefendCompose   = fromItem.DefendCompose;
                            toNewItem.LuckCompose     = fromItem.LuckCompose;
                            toNewItem.AgilityCompose  = fromItem.AgilityCompose;
                            toNewItem.ValidDate       = toItem.ValidDate;
                            toNewItem.IsBinds         = true;
                            player.HideBag.RemoveItem(toItem, eItemRemoveType.ItemTransfer);
                            player.HideBag.AddItemTo(toNewItem, 1);
                            toItem = toNewItem;
                        }
                        else
                        {
                            toItem.StrengthenLevel = fromItem.StrengthenLevel;
                            toItem.AttackCompose   = fromItem.AttackCompose;
                            toItem.DefendCompose   = fromItem.DefendCompose;
                            toItem.LuckCompose     = fromItem.LuckCompose;
                            toItem.AgilityCompose  = fromItem.AgilityCompose;
                            toItem.IsBinds         = true;
                        }
                        if (fromOldItem != null)
                        {
                            fromItem.StrengthenLevel = 0;
                            fromItem.AttackCompose   = 0;
                            fromItem.DefendCompose   = 0;
                            fromItem.LuckCompose     = 0;
                            fromItem.AgilityCompose  = 0;
                            StrengthenMgr.InheritProperty(fromItem, fromOldItem);
                            fromOldItem.ValidDate = fromItem.ValidDate;
                            player.HideBag.RemoveItem(fromItem, eItemRemoveType.ItemTransfer);
                            player.HideBag.AddItemTo(fromOldItem, 0);
                            fromOldItem.IsBinds = true;
                            fromItem            = fromOldItem;
                        }
                        else
                        {
                            fromItem.StrengthenLevel = 0;
                            fromItem.AttackCompose   = 0;
                            fromItem.DefendCompose   = 0;
                            fromItem.LuckCompose     = 0;
                            fromItem.AgilityCompose  = 0;
                            fromItem.IsBinds         = true;
                        }
                        player.HideBag.UpdateItem(fromItem);
                        player.HideBag.UpdateItem(toItem);
                        str.Append(string.Concat(new object[]
                        {
                            toItem.ItemID,
                            ":",
                            toItem.TemplateID,
                            ","
                        }));
                        str.Append(toItem.StrengthenLevel + ",");
                        str.Append(toItem.AttackCompose + ",");
                        str.Append(toItem.DefendCompose + ",");
                        str.Append(toItem.LuckCompose + ",");
                        str.Append(toItem.AgilityCompose);
                        pkg.WriteByte(0);
                        player.Out.SendTCP(pkg);
                        //LogMgr.LogItemAdd(player.PlayerCharacter.ID, LogItemType.Move, str.ToString(), toItem, null, 1);
                    }
                    finally
                    {
                        player.CommitChanges();
                        player.MainBag.CommitChanges();
                    }
                }
                else
                {
                    player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemTransferHandler.NoCondition", new object[0]));
                }
                result = 0;
            }
            return(result);
        }
Ejemplo n.º 8
0
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            StringBuilder stringBuilder = new StringBuilder();
            bool          flag          = false;
            bool          flag2         = packet.ReadBoolean();
            bool          flag3         = packet.ReadBoolean();
            GSPacketIn    gSPacketIn    = new GSPacketIn(59, client.Player.PlayerCharacter.ID);
            ItemInfo      itemAt        = client.Player.StoreBag.GetItemAt(0);
            ItemInfo      itemInfo      = client.Player.StoreBag.GetItemAt(1);
            int           num           = 1;
            string        beginProperty = null;
            string        text          = "";

            using (ItemRecordBussiness itemRecordBussiness = new ItemRecordBussiness())
            {
                itemRecordBussiness.PropertyString(itemInfo, ref beginProperty);
            }
            if (itemInfo != null && itemInfo.Template.CanStrengthen && itemInfo.Template.CategoryID < 18 && itemInfo.Count == 1)
            {
                flag = (flag || itemInfo.IsBinds);
                stringBuilder.Append(string.Concat(new object[]
                {
                    itemInfo.ItemID,
                    ":",
                    itemInfo.TemplateID,
                    ","
                }));
                double num2            = 0.0;
                double num3            = 0.0;
                double num4            = 0.0;
                int    strengthenExp   = itemInfo.StrengthenExp;
                int    strengthenLevel = itemInfo.StrengthenLevel;
                if (strengthenLevel >= 12)
                {
                    client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("Level đã đạt cấp độ cao nhất, không thể cường hóa!", new object[0]));
                    return(0);
                }
                bool          flag4         = false;
                ConsortiaInfo consortiaInfo = ConsortiaMgr.FindConsortiaInfo(client.Player.PlayerCharacter.ConsortiaID);
                if (flag2)
                {
                    ConsortiaBussiness        consortiaBussiness   = new ConsortiaBussiness();
                    ConsortiaEquipControlInfo consortiaEuqipRiches = consortiaBussiness.GetConsortiaEuqipRiches(client.Player.PlayerCharacter.ConsortiaID, 0, 2);
                    if (consortiaInfo == null)
                    {
                        client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemStrengthenHandler.Fail", new object[0]));
                    }
                    else
                    {
                        if (client.Player.PlayerCharacter.Riches < consortiaEuqipRiches.Riches)
                        {
                            client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("ItemStrengthenHandler.FailbyPermission", new object[0]));
                            return(1);
                        }
                        flag4 = true;
                    }
                }
                if (itemAt != null && itemAt.Template.CategoryID == 11 && (itemAt.Template.Property1 == 2 || itemAt.Template.Property1 == 35))
                {
                    flag = (flag || itemAt.IsBinds);
                    string text2 = text;
                    text = string.Concat(new string[]
                    {
                        text2,
                        ",",
                        itemAt.ItemID.ToString(),
                        ":",
                        itemAt.Template.Name
                    });
                    int num5 = (itemAt.Template.Property2 < 10) ? 10 : itemAt.Template.Property2;
                    if (flag4)
                    {
                        int    smithLevel = consortiaInfo.SmithLevel;
                        double num6       = (double)GameProperties.ConsortiaStrengExp(smithLevel - 1);
                        num3 = num6 * (double)num5 / 100.0;
                    }
                    if (client.Player.PlayerCharacter.VIPExpireDay.Date >= DateTime.Now.Date)
                    {
                        int    vIPLevel = client.Player.PlayerCharacter.VIPLevel;
                        double num7     = (double)GameProperties.VIPStrengthenExp(vIPLevel - 1);
                        num4 = num7 * (double)num5 / 100.0;
                    }
                    num5 += (int)num3 + (int)num4;
                    if (flag3)
                    {
                        int needExp = StrengthenMgr.getNeedExp(strengthenExp, strengthenLevel);
                        num = this.CalculatorCount(needExp, num5);
                        if (num > itemAt.Count)
                        {
                            num = itemAt.Count;
                        }
                        num2 += (double)(num5 * num);
                    }
                    else
                    {
                        num2 += (double)num5;
                    }
                }
                stringBuilder.Append("true");
                int num8 = (int)num2 + strengthenExp;
                if (StrengthenMgr.canUpLv(num8, strengthenLevel))
                {
                    itemInfo.StrengthenLevel++;
                    itemInfo.StrengthenExp = num8 - StrengthenMgr.FindStrengthenExpInfo(strengthenLevel + 1).Exp;
                    gSPacketIn.WriteByte(1);
                    StrengthenGoodsInfo strengthenGoodsInfo = StrengthenMgr.FindStrengthenGoodsInfo(itemInfo.StrengthenLevel, itemInfo.TemplateID);
                    if (strengthenGoodsInfo != null && itemInfo.Template.CategoryID == 7 && strengthenGoodsInfo.GainEquip > itemInfo.TemplateID)
                    {
                        ItemTemplateInfo itemTemplateInfo = ItemMgr.FindItemTemplate(strengthenGoodsInfo.GainEquip);
                        if (itemTemplateInfo != null)
                        {
                            ItemInfo itemInfo2 = ItemInfo.CreateFromTemplate(itemTemplateInfo, 1, 116);
                            itemInfo2.StrengthenLevel = itemInfo.StrengthenLevel;
                            itemInfo2.StrengthenExp   = itemInfo.StrengthenExp;
                            StrengthenMgr.InheritProperty(itemInfo, ref itemInfo2);
                            client.Player.StoreBag.RemoveItemAt(1);
                            client.Player.StoreBag.AddItemTo(itemInfo2, 1);
                            itemInfo = itemInfo2;
                        }
                    }
                    if (itemInfo.StrengthenLevel == 10 || itemInfo.StrengthenLevel == 12)
                    {
                        string translation = LanguageMgr.GetTranslation("ItemStrengthenHandler.congratulation", new object[]
                        {
                            client.Player.PlayerCharacter.NickName,
                            itemInfo.Template.Name,
                            itemInfo.StrengthenLevel
                        });
                        client.Player.SendAllMessage(translation);
                    }
                }
                else
                {
                    itemInfo.StrengthenExp = num8;
                }
                client.Player.StoreBag.RemoveTemplate(itemAt.TemplateID, num);
                client.Player.StoreBag.UpdateItem(itemInfo);
                client.Player.OnItemStrengthen(itemInfo.Template.CategoryID, itemInfo.StrengthenLevel);
                LogMgr.LogItemAdd(client.Player.PlayerCharacter.ID, LogItemType.Strengthen, beginProperty, itemInfo, text, 1);
                gSPacketIn.WriteBoolean(false);
                client.Out.SendTCP(gSPacketIn);
                stringBuilder.Append(itemInfo.StrengthenLevel);
            }
            else
            {
                client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemStrengthenHandler.Content1", new object[0]) + itemAt.Template.Name + LanguageMgr.GetTranslation("ItemStrengthenHandler.Content2", new object[0]));
            }
            if (itemInfo.Place < 31)
            {
                client.Player.MainBag.UpdatePlayerProperties();
            }
            return(0);
        }
Ejemplo n.º 9
0
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            if (countConnect >= 3000)
            {
                client.Disconnect();
                return(0);
            }

            GSPacketIn pkg = packet.Clone();

            pkg.ClearContext();

            StringBuilder str      = new StringBuilder();
            bool          isBinds  = false;
            int           mustGold = GameProperties.PRICE_STRENGHTN_GOLD;

            if (client.Player.PlayerCharacter.Gold < mustGold)
            {
                client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemStrengthenHandler.NoMoney"));
                return(0);
            }

            int luckPlace = 0;
            int godPlace  = 0;

            //int itemPlace = client.Player.TempBag.GetItemAt(0).ItemID ;
            //int luckPlace = packet.ReadInt();
            //int godPlace = packet.ReadInt();
            //int stone1Place = packet.ReadInt();
            //int stone2Place = packet.ReadInt();
            //int stone3Place = packet.ReadInt();
            bool consortia = packet.ReadBoolean();

            List <ItemInfo> stones        = new List <ItemInfo>();
            ItemInfo        item          = client.Player.StoreBag2.GetItemAt(5);
            ItemInfo        luck          = null;
            ItemInfo        god           = null;
            string          BeginProperty = null;
            string          AddItem       = "";

            using (ItemRecordBussiness db = new ItemRecordBussiness())
            {
                db.PropertyString(item, ref BeginProperty);
            }

            if (item != null && item.Template.CanStrengthen && item.Template.CategoryID < 18 && item.Count == 1)
            {
                isBinds = isBinds ? true : item.IsBinds;
                str.Append(item.ItemID + ":" + item.TemplateID + ",");
                ThreadSafeRandom random = new ThreadSafeRandom();
                int    result           = 1;
                double probability      = 0;
                bool   isGod            = false;

                StrengthenInfo      strengthenInfo;
                StrengthenGoodsInfo strengthenGoodsInfo = null;
                if (item.Template.RefineryLevel > 0)
                {
                    strengthenInfo = StrengthenMgr.FindRefineryStrengthenInfo(item.StrengthenLevel + 1);
                }
                else
                {
                    strengthenGoodsInfo = StrengthenMgr.FindStrengthenGoodsInfo(item.StrengthenLevel, item.TemplateID);
                    strengthenInfo      = StrengthenMgr.FindStrengthenInfo(item.StrengthenLevel + 1);
                }
                if (strengthenInfo == null)
                {
                    client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemStrengthenHandler.NoStrength"));
                    return(0);
                }

                if (client.Player.StoreBag2.GetItemAt(3) != null)
                {
                    god      = client.Player.StoreBag2.GetItemAt(3);
                    AddItem += "," + god.ItemID.ToString() + ":" + god.Template.Name;
                    if (god != null && god.Template.CategoryID == 11 && god.Template.Property1 == 7)
                    {
                        isBinds = isBinds ? true : god.IsBinds;
                        str.Append(god.ItemID + ":" + god.TemplateID + ",");
                        isGod = true;
                    }
                    else
                    {
                        god = null;
                    }
                }

                ItemInfo stone1 = client.Player.StoreBag2.GetItemAt(0);
                if (stone1 != null && stone1.Template.CategoryID == 11 && (stone1.Template.Property1 == 2 || stone1.Template.Property1 == 35) && !stones.Contains(stone1))
                {
                    isBinds  = isBinds ? true : stone1.IsBinds;
                    AddItem += "," + stone1.ItemID.ToString() + ":" + stone1.Template.Name;
                    stones.Add(stone1);
                    probability += stone1.Template.Property2;
                }

                ItemInfo stone2 = client.Player.StoreBag2.GetItemAt(1);
                if (stone2 != null && stone2.Template.CategoryID == 11 && (stone2.Template.Property1 == 2 || stone2.Template.Property1 == 35) && !stones.Contains(stone2))
                {
                    isBinds  = isBinds ? true : stone2.IsBinds;
                    AddItem += "," + stone2.ItemID.ToString() + ":" + stone2.Template.Name;
                    stones.Add(stone2);
                    probability += stone2.Template.Property2;
                }

                ItemInfo stone3 = client.Player.StoreBag2.GetItemAt(2);
                if (stone3 != null && stone3.Template.CategoryID == 11 && (stone3.Template.Property1 == 2 || stone3.Template.Property1 == 35) && !stones.Contains(stone3))
                {
                    isBinds  = isBinds ? true : stone3.IsBinds;
                    AddItem += "," + stone3.ItemID + ":" + stone3.Template.Name;
                    stones.Add(stone3);
                    probability += stone3.Template.Property2;
                }
                bool RefineryStrengthen = false;

                foreach (ItemInfo stoneinfo in stones)
                {
                    if (stoneinfo.Template.Property1 == 35 && stoneinfo.Template.CategoryID == 11)
                    {
                        RefineryStrengthen = true;
                    }
                    else
                    {
                        RefineryStrengthen = false;
                    }
                }

                //if (!RefineryStrengthen && item.Template.RefineryLevel > 0)
                //{
                //    client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemStrengthenHandler.StoneMatch"));
                //    return 1;
                //}
                if (client.Player.StoreBag2.GetItemAt(4) != null)
                {
                    luck     = client.Player.StoreBag2.GetItemAt(4);
                    AddItem += "," + luck.ItemID.ToString() + ":" + luck.Template.Name;
                    if (luck != null && luck.Template.CategoryID == 11 && luck.Template.Property1 == 3)
                    {
                        isBinds = isBinds ? true : luck.IsBinds;
                        str.Append(luck.ItemID + ":" + luck.TemplateID + ",");
                        probability = probability * (luck.Template.Property2 + 100);
                    }
                    else
                    {
                        probability *= 100;
                        luck         = null;
                    }
                }
                else
                {
                    probability *= 100;
                }
                bool          CanUpdate = false;
                ConsortiaInfo info      = ConsortiaMgr.FindConsortiaInfo(client.Player.PlayerCharacter.ConsortiaID);
                //判断是公会铁匠铺还是铁匠铺??
                if (consortia)
                {
                    ConsortiaBussiness        csbs    = new ConsortiaBussiness();
                    ConsortiaEquipControlInfo cecInfo = csbs.GetConsortiaEuqipRiches(client.Player.PlayerCharacter.ConsortiaID, 0, 2);

                    if (info == null)
                    {
                        client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemStrengthenHandler.Fail"));
                    }
                    else
                    {
                        if (client.Player.PlayerCharacter.Riches < cecInfo.Riches)
                        {
                            client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("ItemStrengthenHandler.FailbyPermission"));
                            return(1);
                        }
                        CanUpdate = true;
                    }
                }

                if (stones.Count >= 1)
                {
                    probability = probability / strengthenInfo.Rock;
                    for (int i = 0; i < stones.Count; i++)
                    {
                        str.Append(stones[i].ItemID + ":" + stones[i].TemplateID + ",");

                        AbstractInventory bg = client.Player.GetItemInventory(stones[i].Template);
                        stones[i].Count--;
                        bg.UpdateItem(stones[i]);
                    }

                    if (luck != null)
                    {
                        AbstractInventory bg = client.Player.GetItemInventory(luck.Template);
                        bg.RemoveItem(luck);
                    }

                    if (god != null)
                    {
                        AbstractInventory bg = client.Player.GetItemInventory(god.Template);
                        bg.RemoveItem(god);
                    }
                    if (CanUpdate)
                    {
                        probability *= (1 + 0.1 * info.SmithLevel);
                    }
                    item.IsBinds = isBinds;

                    client.Player.StoreBag2.ClearBag();
                    if (probability > random.Next(10000))
                    {
                        str.Append("true");
                        pkg.WriteByte(0);
                        if (strengthenGoodsInfo != null)
                        {
                            ItemTemplateInfo Temp = Bussiness.Managers.ItemMgr.FindItemTemplate(strengthenGoodsInfo.GainEquip);
                            if (Temp != null)
                            {
                                ItemInfo Item = ItemInfo.CreateFromTemplate(Temp, 1, (int)ItemAddType.Strengthen);
                                Item.StrengthenLevel = item.StrengthenLevel + 1;


                                ItemInfo.OpenHole(ref Item);
                                StrengthenMgr.InheritProperty(item, ref Item);

                                client.Player.RemoveItem(item);
                                client.Player.AddTemplate(Item, Item.Template.BagType, Item.Count);
                                item = Item;
                                pkg.WriteBoolean(false);
                            }
                        }
                        else
                        {
                            pkg.WriteBoolean(true);
                            item.StrengthenLevel++;
                            ItemInfo.OpenHole(ref item);
                            //client.Player.MainBag.AddItem(item);
                            client.Player.StoreBag2.AddItemTo(item, 5);
                        }



                        client.Player.OnItemStrengthen(item.Template.CategoryID, item.StrengthenLevel);                               //任务<强化>
                        LogMgr.LogItemAdd(client.Player.PlayerCharacter.ID, LogItemType.Strengthen, BeginProperty, item, AddItem, 1); //强化日志
                        client.Player.SaveIntoDatabase();                                                                             //保存到数据库
                        //系统广播
                        if (item.StrengthenLevel >= 7)
                        {
                            string msg = LanguageMgr.GetTranslation("ItemStrengthenHandler.congratulation", client.Player.PlayerCharacter.NickName, item.Template.Name, item.StrengthenLevel);

                            GSPacketIn pkg1 = new GSPacketIn((byte)ePackageType.SYS_NOTICE);
                            pkg1.WriteInt(1);
                            pkg1.WriteString(msg);

                            GameServer.Instance.LoginServer.SendPacket(pkg1);

                            GamePlayer[] players = Game.Server.Managers.WorldMgr.GetAllPlayers();

                            foreach (GamePlayer p in players)
                            {
                                p.Out.SendTCP(pkg1);
                            }
                        }
                    }
                    else
                    {
                        str.Append("false");
                        pkg.WriteByte(1);
                        pkg.WriteBoolean(false);
                        if (isGod == false)
                        {
                            if (item.Template.Level == 3)
                            {
                                item.StrengthenLevel = item.StrengthenLevel == 0 ? 0 : item.StrengthenLevel - 1;
                                // client.Player.MainBag.AddItem(item);
                                client.Player.StoreBag2.AddItemTo(item, 5);
                            }
                            else
                            {
                                item.Count--;
                                // client.Player.MainBag.AddItem(item);
                                client.Player.StoreBag2.AddItemTo(item, 5);
                            }
                        }
                        else
                        {
                            //client.Player.MainBag.AddItem(item);
                            client.Player.StoreBag2.AddItemTo(item, 5);
                        }
                        LogMgr.LogItemAdd(client.Player.PlayerCharacter.ID, LogItemType.Strengthen, BeginProperty, item, AddItem, 0);

                        client.Player.SaveIntoDatabase();//保存到数据库
                    }

                    client.Out.SendTCP(pkg);
                    str.Append(item.StrengthenLevel);
                    client.Player.BeginChanges();
                    client.Player.RemoveGold(mustGold);
                    client.Player.CommitChanges();
                }
                else
                {
                    client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemStrengthenHandler.Content1") + result + LanguageMgr.GetTranslation("ItemStrengthenHandler.Content2"));
                }
                if (item.Place < 31)
                {
                    client.Player.MainBag.UpdatePlayerProperties();
                }
            }
            else
            {
                client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemStrengthenHandler.Success"));
            }

            return(0);
        }
Ejemplo n.º 10
0
        public override bool Start()
        {
            bool result = true;

            try
            {
                IsRunning = 0;
                Thread.CurrentThread.Priority = ThreadPriority.Normal;
                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(this.CurrentDomain_UnhandledException);


                if (!this.StartScriptComponents())
                {
                    result = false;
                    GameServer.log.Error("初始化脚本失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化脚本成功!");

                if (!this.InitSocket(IPAddress.Parse(this.Config.GameIP), this.Config.GamePort))
                {
                    result = false;
                    GameServer.log.Error("初始化监听端口失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化监听端口成功!");

                if (!this.AllocatePacketBuffers())
                {
                    result = false;
                    GameServer.log.Error("分配数据包缓冲区失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("分配数据包缓冲区成功!");

                //LogMgr.Setup

                if (!WorldMgr.Init())
                {
                    result = false;
                    GameServer.log.Error("初始化世界场景失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化世界场景成功!");



                if (!FusionMgr.Init())
                {
                    result = false;
                    GameServer.log.Error("初始化熔炼失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化熔炼成功!");

                if (!AwardMgr.Init())
                {
                    result = false;
                    GameServer.log.Error("初始化奖励失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化奖励成功!");


                if (!MissionInfoMgr.Init())
                {
                    result = false;
                    GameServer.log.Error("初始化关卡失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化关卡成功!");

                if (!PveInfoMgr.Init())
                {
                    result = false;
                    GameServer.log.Error("初始化pve失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化pve成功!");



                if (!FightRateMgr.Init())
                {
                    result = false;
                    GameServer.log.Error("初始化战斗倍率失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化战斗倍率成功!");

                if (!ConsortiaLevelMgr.Init())
                {
                    result = false;
                    GameServer.log.Error("初始化公会等级失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化公会等级成功!");

                if (!StrengthenMgr.Init())
                {
                    result = false;
                    GameServer.log.Error("初始化强化失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化强化成功!");

                if (!ShopMgr.Init())
                {
                    result = false;
                    GameServer.log.Error("初始化商店失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化商店成功!");

                if (!BoxMgr.Init())
                {
                    result = false;
                    GameServer.log.Error("初始化时间宝箱失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化时间宝箱成功!");

                if (!QuestMgr.Init())
                {
                    result = false;
                    GameServer.log.Error("初始化任务失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化任务成功!");

                if (!AchievementMgr.Init())
                {
                    result = false;
                    GameServer.log.Error("初始化成就失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化成就成功!");

                if (!AchievementMgr.Init())
                {
                    result = false;
                    GameServer.log.Error("初始化成就失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化成就成功!");

                if (!RoomMgr.Setup(this.Config.MaxRoomCount))
                {
                    result = false;
                    GameServer.log.Error("初始化房间管理服务失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化房间管理服务成功!");

                if (!GameMgr.Setup(1, 4))
                {
                    result = false;
                    GameServer.log.Error("初始化游戏管理服务失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化游戏管理服务成功!");

                if (!ConsortiaMgr.Init())
                {
                    result = false;
                    GameServer.log.Error("初始化公会失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化公会成功!");


                if (!Game.Server.Managers.RateMgr.Init(this.Config))
                {
                    result = false;
                    GameServer.log.Error("初始化经验倍率管理服务失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化经验倍率管理服务成功!");

                if (!MacroDropMgr.Init())
                {
                    result = false;
                    GameServer.log.Error("初始化宏观掉落失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化宏观掉落成功!");


                if (!BattleMgr.Setup(this.Config))
                {
                    result = false;
                    GameServer.log.Error("加载战斗管理服务失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("加载战斗管理服务成功!");

                if (!this.InitGlobalTimer())
                {
                    result = false;
                    GameServer.log.Error("初始化全局Timers失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化全局Timers成功!");

                if (!this.InitLoginServer())
                {
                    result = false;
                    GameServer.log.Error("登陆到中心服务器失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("登陆到中心服务器成功!");

                if (!MarryRoomMgr.Init())
                {
                    result = false;
                    GameServer.log.Error("初始化礼堂失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化礼堂成功!");

                if (!SpaRoomMgr.Init())
                {
                    result = false;
                    GameServer.log.Error("初始化温泉失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化温泉成功!");

                if (!ActiveMgr.Init())
                {
                    result = false;
                    GameServer.log.Error("初始化活动失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化活动成功!");
                if (!VIPMgr.Init())
                {
                    result = false;
                    GameServer.log.Error("初始化VIP失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化VIP成功!");
                if (!LevelMgr.Init())
                {
                    result = false;
                    GameServer.log.Error("初始化等级失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("初始化等级成功!");

                /*  if (!WorldBossMgr.Init())
                 * {
                 *    result = false;
                 *    GameServer.log.Error("初始化世界Boss失败,请检查!");
                 *    return result;
                 * }
                 * GameServer.log.Info("初始化世界Boss成功!");
                 */
                RoomMgr.Start();
                GameMgr.Start();
                BattleMgr.Start();
                MacroDropMgr.Start();

                if (!base.Start())
                {
                    result = false;
                    GameServer.log.Error("启动基础服务失败,请检查!");
                    return(result);
                }
                GameServer.log.Info("启动基础服务成功!");

                GameEventMgr.Notify(ScriptEvent.Loaded);
                GC.Collect(GC.MaxGeneration);
                //LogMgr.Setup(1, 1, 1);
                GameServer.log.Warn("游戏服务器启动成功!");
                IsRunning = 1;
            }
            catch (Exception e)
            {
                GameServer.log.Error("Failed to start the server", e);
                // throw e;
                result = false;
            }
            return(result);
        }