ItemStrengthenHandler.cs này
UserChangeItemPlaceHandler.cs Cái này fix bỏ 999 viên này
[/ltr]
- 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.Server.GameObjects;
using Game.Server.GameUtils;
namespace Game.Server.Packets.Client
{
[PacketHandler(0x3b, "物品强化")]
public class ItemStrengthenHandler : IPacketHandler
{
// Fields
public static int countConnect = 0;
private static readonly double[] rateItems = new double[] { 0.75, 3.0, 12.0, 48.0, 240.0, 768.0 };
// Methods
public int HandlePacket(GameClient client, GSPacketIn packet)
{
if (countConnect >= 0xbb8)
{
client.Disconnect();
return 0;
}
GSPacketIn @in = packet.Clone();
@in.ClearContext();
StringBuilder builder = new StringBuilder();
bool flag = false;
bool flag2 = packet.ReadBoolean();
bool flag3 = packet.ReadBoolean();
double num = 0.0;
double num2 = 0.0;
double num3 = 0.0;
double num4 = 0.0;
ItemInfo itemAt = client.Player.StoreBag2.GetItemAt(1);
ItemInfo item = client.Player.StoreBag2.GetItemAt(0);
if (((item != null) && (item.Template.CategoryID == 11)) && ((item.Template.Property1 == 2) || (item.Template.Property1 == 0x23)))
{
if (flag3)
{
flag = flag || item.IsBinds;
num += item.Template.Property2 * item.Count;
}
else
{
flag = flag || item.IsBinds;
num += item.Template.Property2;
}
}
bool flag4 = false;
ConsortiaInfo info3 = ConsortiaMgr.FindConsortiaInfo(client.Player.PlayerCharacter.ConsortiaID);
if (flag2)
{
ConsortiaEquipControlInfo info4 = new ConsortiaBussiness().GetConsortiaEuqipRiches(client.Player.PlayerCharacter.ConsortiaID, 0, 2);
if (info3 == null)
{
client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemStrengthenHandler.Fail", new object[0]));
}
else
{
if (client.Player.PlayerCharacter.Riches < info4.Riches)
{
client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("ItemStrengthenHandler.FailbyPermission", new object[0]));
return 1;
}
flag4 = true;
}
}
if (flag4)
{
List<double> list = new List<double> { 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0 };
num2 = (list[info3.SmithLevel - 1] / 100.0) * num;
}
if (client.Player.PlayerCharacter.VIPExpireDay >= DateTime.Now)
{
List<double> list3 = new List<double> { 25.0, 25.0, 25.0, 35.0, 35.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0 };
num3 = (list3[client.Player.PlayerCharacter.VIPLevel - 1] / 100.0) * num;
}
num4 = Math.Floor((double)((num + num2) + num3));
List<int> list5 = new List<int> { 0, 10, 50, 150, 350, 700, 0x5dc, 0x8fc, 0xce4, 0x1194, 0x1770, 0x1d4c, 0x2328 };
@in.WriteByte(1);
int num5 = 0;
int num7 = list5[itemAt.StrengthenLevel + 1];
num5 = (num7 - itemAt.StrengthenExp) / 10;
int num8 = num7 - itemAt.StrengthenExp;
if (num4 < num8)
{
itemAt.StrengthenExp += (int)num4;
}
else
{
itemAt.StrengthenLevel++;
itemAt.StrengthenExp = 0;
ItemInfo.OpenHole(ref itemAt);
client.Player.StoreBag2.AddItemTo(itemAt, 1);
if ((((itemAt.StrengthenLevel == 3) || (itemAt.StrengthenLevel == 6)) || ((itemAt.StrengthenLevel == 9) || (itemAt.StrengthenLevel == 12))) && (itemAt.Template.CategoryID != 0x11))
{
@in.WriteBoolean(true);
}
else
{
@in.WriteBoolean(false);
}
}
if (flag3)
{
if ((num5 < item.Count) && (num5 != 0))
{
int count = item.Count;
item.Count -= num5;
client.Player.StoreBag2.UpdateItem(item);
}
else if ((num5 == item.Count) && (num5 != 0))
{
client.Player.StoreBag2.RemoveItem(item);
}
else
{
client.Player.StoreBag2.RemoveItem(item);
}
}
else
{
item.Count--;
client.Player.StoreBag2.UpdateItem(item);
}
StrengthenGoodsInfo info5 = StrengthenMgr.FindStrengthenGoodsInfo(itemAt.StrengthenLevel, itemAt.TemplateID);
if (StrengthenMgr.FindStrengthenInfo(itemAt.StrengthenLevel + 1) == null)
{
client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemStrengthenHandler.NoStrength", new object[0]));
return 0;
}
builder.Append("true");
@in.WriteByte(1);
if (info5 != null)
{
ItemTemplateInfo goods = Bussiness.Managers.ItemMgr.FindItemTemplate(info5.GainEquip);
if (goods != null)
{
ItemInfo info7 = ItemInfo.CreateFromTemplate(goods, 1, 0x74);
info7.StrengthenLevel = itemAt.StrengthenLevel + 1;
ItemInfo.OpenHole(ref info7);
StrengthenMgr.InheritProperty(itemAt, ref info7);
client.Player.StoreBag2.RemoveItem(itemAt);
client.Player.StoreBag2.AddItem(info7);
}
}
client.Player.StoreBag2.UpdateItem(itemAt);
client.Out.SendTCP(@in);
builder.Append(itemAt.StrengthenLevel);
client.Player.BeginChanges();
client.Player.CommitChanges();
return 0;
}
}
}
UserChangeItemPlaceHandler.cs Cái này fix bỏ 999 viên này
[/ltr]
- 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;
}
}
}