Game


You are not connected. Please login or register

GunnyII - Hướng dẫn cách fix hợp thành

Go down  Message [Page 1 of 1]

Fenix

Fenix
Game Master
Game Master
Đang test cách cường hóa lên lv & biến hình liên tục giống trminhpc. Hiện được rồi nhưng bị lỗi ko biến hình nên ko build được. Share cho ae cách fix hợp thành này nhé. Ai xài nhớ cảm ơn.

Không tiện quay clip. Vì máy mình phân giải x1980 nên quay nặng lắm up online lâu GunnyII - Hướng dẫn cách fix hợp thành 59.

B1. Các bạn mở project GameServer.sln lên. Ở ô bên phải chọn Game.Server / Packets / Client / UserChangeItemPlaceHandler.cs
Xóa hết, sửa lại thành như vầy:



Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Game.Base.Packets;
using Bussiness;
using SqlDataProvider.Data;
using Game.Server.GameUtils;
using Game.Server.Managers;
using log4net;
using System.Reflection;

namespace Game.Server.Packets.Client
{
    [PacketHandler((byte)ePackageType.CHANGE_PLACE_GOODS, "改变物品位置")]
    public class UserChangeItemPlaceHandler:IPacketHandler
    {
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            eBageType bageType = (eBageType)packet.ReadByte();
            int slot = packet.ReadInt();
            eBageType toBageType = (eBageType)packet.ReadByte();
            int toSlot = packet.ReadInt();
            int count = packet.ReadInt();
            PlayerInventory bag = client.Player.GetInventory(bageType);
            PlayerInventory inventory = client.Player.GetInventory(toBageType);
            if (toSlot < 0)
            {
                if ((inventory.BagType == (int)eBageType.Bank) || (inventory.BagType == (int)eBageType.PropBag))
                {
                    toSlot = inventory.FindFirstEmptySlot(0);
                }
                else
                {
                    toSlot = inventory.FindFirstEmptySlot(31);
                }
            } 
            //==================================
            if (count > 0)
            {
                if ((bag == null) || (bag.GetItemAt(slot) == null))
                {
                    return 0;
                }
                if ((bageType == toBageType) && (slot != -1))
                {
                    if (bag.GetItemAt(slot).Count >= count)
                    {
                        Console.WriteLine("-----Stage 1 !");
                        bag.MoveItem(slot, toSlot, count);                       
                    }
                    else
                    {
                        Console.WriteLine("--" + client.Player.Account + " Hack = CE");
                        bag.MoveItem(slot, toSlot, bag.GetItemAt(slot).Count);
                    }
                    return 1;
                }

                if ((slot == -1) && (toSlot != -1))
                {
                    Console.WriteLine("-----Stage 2 !");
                    bag.RemoveItemAt(toSlot);                 
                    return 1;
                }

                if (((((slot != -1) && (toSlot == -1)) &&
                    ((bageType != eBageType.CaddyBag) &&
                    (toBageType != eBageType.Bank))) &&
                    (bageType != eBageType.Store)) &&
                    (toBageType != eBageType.Store))
                {
                    if (bageType == eBageType.MainBag)
                    {
                        Console.WriteLine("-----Stage 3 !");
                        bag.AddItem(client.Player.GetItemAt(bageType, slot), 31);

                    }
                    else
                    {
                        Console.WriteLine("-----Stage 4 !");
                        [You must be registered and logged in to see this link.] slot), 0);
                        client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Full"));
                    }
                    return 1;
                }

                if ((((slot != -1) && (toBageType != bageType)) && (toBageType != eBageType.Store)) && (toBageType != eBageType.MainBag))
                {
                    ConsortiaInfo info = ConsortiaMgr.FindConsortiaInfo(client.Player.PlayerCharacter.ConsortiaID);
                    if (info != null)
                    {
                        if (toBageType == eBageType.Store)
                        {
                        }
                        Console.WriteLine("-----Stage 5 !");
                        bag.MoveToStore(bag, slot, toSlot, inventory, info.StoreLevel * 10);                       
                        return 1;
                    }
                }

                if ((toBageType == eBageType.Store) || (bageType == eBageType.Store))
                {
                    SqlDataProvider.Data.ItemInfo itemAt = client.Player.GetItemAt(bageType, slot);
                    if ((itemAt != null) && (itemAt.Count > 1))
                    {
                        itemAt.Count -= count;
                        bag.UpdateItem(itemAt);
                        SqlDataProvider.Data.ItemInfo item = itemAt.Clone();
                        item.Count = count;
                        if (inventory.GetItemAt(toSlot) == null)
                        {
                            Console.WriteLine("-----Stage 6 !");
                            inventory.AddItemTo(item, toSlot);
                         
                        }
                        else
                        {
                            SqlDataProvider.Data.ItemInfo itemByTemplateID = bag.GetItemByTemplateID(0, inventory.GetItemAt(toSlot).TemplateID);
                            if (itemByTemplateID == null)
                            {
                                Console.WriteLine("-----Stage 7 !");
                                bag.MoveToStore(inventory, toSlot, bag.FindFirstEmptySlot(0), bag, 999);
                               
                            }
                            else
                            {
                                Console.WriteLine("-----Stage 8 !");
                                itemByTemplateID.Count++;
                                bag.UpdateItem(itemByTemplateID);
                                inventory.RemoveItemAt(toSlot);
                           
                            }
                            Console.WriteLine("-----Stage 9 !");
                            inventory.AddItemTo(item, toSlot);
                         
                        }
                    }
                    else
                    {
                        if ((((toBageType != eBageType.Store) && (toBageType != eBageType.MainBag)) && ((bag.GetItemAt(slot) != null) && (bag.GetItemAt(slot).Template.CategoryID == 7))) && (((toSlot > 0) && (toSlot < 31)) && (toSlot != 6)))
                        {
                            return 1;
                        }
                        try
                        {
                            Console.WriteLine("-----Stage 10 !");
                            bag.MoveToStore(bag, slot, toSlot, inventory, 50);
                           
                        }
                        catch (Exception)
                        {
                            LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).InfoFormat("ERROR USER CHANGEITEM placce: {0},toplace: {1},bagType: {2},ToBagType {3}", new object[] { slot, toSlot, bageType, toBageType });
                            LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).InfoFormat("item :{0}, toitem {1}", bag.GetItemAt(slot), inventory.GetItemAt(toSlot));
                        }
                    }
                    return 1;
                }
                if ((toBageType == eBageType.MainBag) && (bageType == eBageType.Bank))
                {
                    Console.WriteLine("-----Stage 11!");
                    bag.MoveToStore(bag, slot, toSlot, inventory, 50);
                    return 1;
                }
            }
            //==================================
            return 0;
        }
    }
}





B2: Vào Game.Server / Packets / Client / ItemComposeHandler.cs xóa hết sửa thành:


Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Game.Base.Packets;
using Bussiness;
using SqlDataProvider.Data;
using System.Configuration;
using Game.Server.Managers;
using Game.Server.Statics;
using Game.Logic;


namespace Game.Server.Packets.Client
{
    [PacketHandler((int)ePackageType.ITEM_COMPOSE, "物品合成")]
    public class ItemComposeHandler : IPacketHandler
    {

        private static readonly double[] composeRate = new double[] { 0.8, 0.5, 0.3, 0.1, 0.05 };        
        public static int countConnect = 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();
            int mustGold = GameProperties.PRICE_COMPOSE_GOLD;
            if (client.Player.PlayerCharacter.HasBagPassword && client.Player.PlayerCharacter.IsLocked)
            {

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

            int itemPlace = - 1;
            int godPlace = -1;
            bool isBinds = false;
            bool consortia = packet.ReadBoolean();
            //bool MultiStrengthen = packet.ReadBoolean();

            ItemInfo item = client.Player.StoreBag2.GetItemAt(1);
            ItemInfo stone = client.Player.StoreBag2.GetItemAt(2);
            ItemInfo luck = null;
            ItemInfo god = null;

            string BeginProperty = null;
            string AddItem = null;
            using (ItemRecordBussiness db = new ItemRecordBussiness())
            {
                db.PropertyString(item, ref BeginProperty);
            }
            if (item != null && stone != null && item.Template.CanCompose && (item.Template.CategoryID < 10 || stone.Template.CategoryID == 11 && stone.Template.Property1 == 1))
            {

                isBinds = isBinds ? true : item.IsBinds;
                isBinds = isBinds ? true : stone.IsBinds;
                str.Append(item.ItemID + ":" + item.TemplateID + "," + stone.ItemID + ":" + stone.TemplateID + ",");
                ThreadSafeRandom random = new ThreadSafeRandom();
                bool result = false;
                byte isSuccess = 1;
                //bool isGod = false;                
                double probability = composeRate[(stone.Template.Quality - 1)] * 100;//stone.Template.Property2;
                if (client.Player.StoreBag2.GetItemAt(0)!=null)
                {
                    luck = client.Player.StoreBag2.GetItemAt(0);
                    if (luck != null && luck.Template.CategoryID == 11 && luck.Template.Property1 == 3)
                    {
                        isBinds = isBinds ? true : luck.IsBinds;
                        AddItem += "|" + luck.ItemID + ":" + luck.Template.Name + "|" + stone.ItemID + ":" + stone.Template.Name;
                        str.Append(luck.ItemID + ":" + luck.TemplateID + ",");
                        probability += probability * luck.Template.Property2 / 100;
                    }
                   
                }
                else
                {
                    probability += probability * 1 / 100;
                }
                if (godPlace != -1)
                {
                    god = client.Player.PropBag.GetItemAt(godPlace);
                    if (god != null && god.Template.CategoryID == 11 && god.Template.Property1 == 7)
                    {
                        isBinds = isBinds ? true : god.IsBinds;
                        //isGod = true;
                        str.Append(god.ItemID + ":" + god.TemplateID + ",");
                        AddItem += "," + god.ItemID + ":" + god.Template.Name;
                    }
                    else
                    {
                        god = null;
                    }
                }
                //判断是公会铁匠铺还是铁匠铺
                if (consortia)
                {

                    ConsortiaInfo info = ConsortiaMgr.FindConsortiaInfo(client.Player.PlayerCharacter.ConsortiaID);
                    //这里添加公会权限限制的判断
                    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;
                        }
                        else
                        {
                            probability *= (1 + 0.1 * info.SmithLevel);

                        }
                    }

                }
                probability = Math.Floor(probability * 10) / 10;
                //client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Probability: " + probability.ToString()));
                int rand = random.Next(100);
                switch (stone.Template.Property3)
                {
                    case 1:
                        if (stone.Template.Property4 > item.AttackCompose)
                        {
                            result = true;
                            if (probability > rand)
                            {
                                isSuccess = 0;
                                item.AttackCompose = stone.Template.Property4;
                            }
                     
                        }
                        break;
                    case 2:
                        if (stone.Template.Property4 > item.DefendCompose)
                        {
                            result = true;
                            if (probability > rand)
                            {
                                isSuccess = 0;
                                item.DefendCompose = stone.Template.Property4;
                            }
                        
                        }
                        break;
                    case 3:
                        if (stone.Template.Property4 > item.AgilityCompose)
                        {
                            result = true;
                            if (probability > rand)
                            {
                                isSuccess = 0;
                                item.AgilityCompose = stone.Template.Property4;
                            }
                           
                        }
                        break;
                    case 4:
                        if (stone.Template.Property4 > item.LuckCompose)
                        {
                            result = true;
                            if (probability > rand)
                            {
                                isSuccess = 0;
                                item.LuckCompose = stone.Template.Property4;
                            }
                          
                        }
                        break;
                }

                if (result)
                {
                    item.IsBinds = isBinds;
                    if (isSuccess != 0)
                    {
                        str.Append("false!");
                        result = false;
                       
                    }
                    else
                    {
                        str.Append("true!");
                        result = true;
                        client.Player.OnItemCompose(stone.TemplateID);
                    }
                    LogMgr.LogItemAdd(client.Player.PlayerCharacter.ID, LogItemType.Compose, BeginProperty, item, AddItem, Convert.ToInt32(result));
                    client.Player.SaveIntoDatabase();//保存到数据库
                    if (luck != null)
                    {
                        client.Player.RemoveItem(luck);
                    }
                    if (god != null)
                    {
                        client.Player.RemoveItem(god);
                    }
                    client.Player.RemoveGold(mustGold);
                    client.Player.StoreBag2.ClearBag();
                    client.Player.StoreBag2.AddItemTo(item,1);
                    if (stone.Count > 1)
                    {
                        ItemInfo Temp;
                        stone.Count--;
                        Temp = stone;
                        client.Player.StoreBag2.AddItemTo(Temp, 2);
                    }
                    pkg.WriteByte(isSuccess);
                    client.Out.SendTCP(pkg);
                    if (itemPlace < 31)
                    {
                        client.Player.MainBag.UpdatePlayerProperties();
                    }
                }
                else
                {
                    client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemComposeHandler.NoLevel"));
                }
            }
            else
            {
                client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemComposeHandler.Fail"));
            }

            return 0;
        }
    }

}  



Done! Chúc ae vui vẻ GunnyII - Hướng dẫn cách fix hợp thành 59

http://www.devgame.ga

Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum