public void SetStats(ItemInfo fromItem) { Plus = fromItem.Plus; Bless = fromItem.Bless; Enchant = fromItem.Enchant; Gem1 = fromItem.Gem1; Gem2 = fromItem.Gem2; SocketAndRGB = fromItem.SocketAndRGB; CurrentDura = fromItem.CurrentDura; MaxDura = fromItem.MaxDura; RebornEffect = fromItem.RebornEffect; Free = fromItem.Free; GreenText = fromItem.GreenText; INS = fromItem.INS; Suspicious = fromItem.Suspicious; Locked = fromItem.Locked; Composition = fromItem.Composition; LockedTime = fromItem.LockedTime; Color = fromItem.Color; MaxDura = fromItem.MaxDura; CurrentDura = fromItem.CurrentDura; }
/// <summary> /// Drops the items and gold associated with the drop data. /// </summary> /// <param name="client">The client to receive cps if any. Put null if not a client drop.</param> /// <param name="MidLocation">The location to star the drop from.</param> public void Drop(Entities.GameClient client, Maps.MapPoint MidLocation) { if (Calculations.BasicCalculations.ChanceSuccess(CPsDropChance)) { // for cps bags just add them to the items // or copy the item drops already existing above and below if (client != null) { client.CPs += (uint)ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next((int)MinCPsDrop, (int)MaxCPsDrop); } } else { Maps.MapPoint Location = MidLocation.Map.CreateAvailableLocation <Data.GroundItem>(MidLocation.X, MidLocation.Y, 5); if (Location != null) { // perhaps some vip thing to loot gold in bag, rather than ground ?? uint DropMoney = (uint)ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next((int)MinGoldDrop, (int)MaxGoldDrop); if (DropMoney > 0) { uint ItemID = 1090000; if (DropMoney > 10000) { ItemID = 1091020; } else if (DropMoney > 5000) { ItemID = 1091010; } else if (DropMoney > 1000) { ItemID = 1091000; } else if (DropMoney > 100) { ItemID = 1090020; } else if (DropMoney > 50) { ItemID = 1090010; } Data.ItemInfo item; if (Core.Kernel.ItemInfos.TrySelect(ItemID, out item)) { item = item.Copy(); // necessary to not edit original data Data.GroundItem ground = new Data.GroundItem(item); if (client != null) { ground.PlayerDrop = false; ground.OwnerUID = client.EntityUID; ground.DropTime = DateTime.Now; } ground.DropType = Enums.DropItemType.Gold; ground.Money = DropMoney; ground.X = Location.X; ground.Y = Location.Y; Location.Map.EnterMap(ground); ground.TaskID = ProjectX_V3_Lib.Threading.DelayedTask.StartDelayedTask( () => { Location.Map.LeaveMap(ground); ground.Screen.ClearScreen(); }, Core.TimeIntervals.DroppedItemRemove); ground.Screen.UpdateScreen(null); } } } } // could use else if, however we do want to drop gold/cps and items at the same time if (Calculations.BasicCalculations.ChanceSuccess(33)) { if (ItemDrops.Count > 0) { uint[] itemids = ItemDrops.ToArray(); uint ItemID = itemids[ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next(0, itemids.Length - 1)]; Data.ItemInfo item; // check for chances between the different types of items ex. armor, bow etc. item.IsArmor() etc. if (Core.Kernel.ItemInfos.TrySelect(ItemID, out item)) { Maps.MapPoint Location = MidLocation.Map.CreateAvailableLocation <Data.GroundItem>(MidLocation.X, MidLocation.Y, 5); if (Location != null) { item = item.Copy(); // necessary if (item.IsArmor() || item.IsBow() || item.IsRing() || item.IsOneHand() || item.IsTwoHand() || item.IsBoots() || item.IsHeadgear() || item.IsShield() || item.IsNecklace()) { if (Calculations.BasicCalculations.ChanceSuccess(PlusChance)) { byte chance = (byte)(MaxPlus * (MaxPlus + 1)); byte offchance = (byte)(chance / MaxPlus); item.Plus = MinPlus; while (Calculations.BasicCalculations.ChanceSuccess(chance)) { item.Plus += 1; chance -= offchance; } } if (Calculations.BasicCalculations.ChanceSuccess(QualityChance)) { item = Core.Kernel.ItemInfos[item.ItemID + 3].Copy(); if (Calculations.BasicCalculations.ChanceSuccess(20)) { item = Core.Kernel.ItemInfos[item.ItemID + 1].Copy(); if (Calculations.BasicCalculations.ChanceSuccess(15)) { item = Core.Kernel.ItemInfos[item.ItemID + 1].Copy(); if (Calculations.BasicCalculations.ChanceSuccess(10)) { item = Core.Kernel.ItemInfos[item.ItemID + 1].Copy(); } } } } if (Calculations.BasicCalculations.ChanceSuccess(FirstSocketChance) || item.IsOneHand() && Calculations.BasicCalculations.ChanceSuccess(FirstSocketChance * 2) || item.IsTwoHand() && Calculations.BasicCalculations.ChanceSuccess(FirstSocketChance * 2)) { item.Gem1 = Enums.SocketGem.EmptySocket; if (Calculations.BasicCalculations.ChanceSuccess(SecondSocketChance)) { item.Gem2 = Enums.SocketGem.EmptySocket; } } if (Calculations.BasicCalculations.ChanceSuccess(BlessChance)) { item.Bless = 1; } } Data.GroundItem ground = new Data.GroundItem(item); if (client != null) { ground.PlayerDrop = false; ground.OwnerUID = client.EntityUID; ground.DropTime = DateTime.Now; } ground.DropType = Enums.DropItemType.Item; ground.X = Location.X; ground.Y = Location.Y; Location.Map.EnterMap(ground); ground.TaskID = ProjectX_V3_Lib.Threading.DelayedTask.StartDelayedTask( () => { Location.Map.LeaveMap(ground); ground.Screen.ClearScreen(); }, Core.TimeIntervals.DroppedItemRemove); ground.Screen.UpdateScreen(null); } } } } else if (Calculations.BasicCalculations.ChanceSuccess(MeteorChance)) { Data.ItemInfo item; if (Core.Kernel.ItemInfos.TrySelect(1088001, out item)) { Maps.MapPoint Location = MidLocation.Map.CreateAvailableLocation <Data.GroundItem>(MidLocation.X, MidLocation.Y, 5); if (Location != null) { item = item.Copy(); // necessary Data.GroundItem ground = new Data.GroundItem(item); if (client != null) { ground.PlayerDrop = false; ground.OwnerUID = client.EntityUID; ground.DropTime = DateTime.Now; } ground.DropType = Enums.DropItemType.Item; ground.X = Location.X; ground.Y = Location.Y; Location.Map.EnterMap(ground); ground.TaskID = ProjectX_V3_Lib.Threading.DelayedTask.StartDelayedTask( () => { Location.Map.LeaveMap(ground); ground.Screen.ClearScreen(); }, Core.TimeIntervals.DroppedItemRemove); ground.Screen.UpdateScreen(null); } } } else if (Calculations.BasicCalculations.ChanceBigSuccess(10, DragonballChance)) { Data.ItemInfo item; if (Core.Kernel.ItemInfos.TrySelect(1088000, out item)) { Maps.MapPoint Location = MidLocation.Map.CreateAvailableLocation <Data.GroundItem>(MidLocation.X, MidLocation.Y, 5); if (Location != null) { item = item.Copy(); // necessary Data.GroundItem ground = new Data.GroundItem(item); if (client != null) { ground.PlayerDrop = false; ground.OwnerUID = client.EntityUID; ground.DropTime = DateTime.Now; } ground.DropType = Enums.DropItemType.Item; ground.X = Location.X; ground.Y = Location.Y; Location.Map.EnterMap(ground); ground.TaskID = ProjectX_V3_Lib.Threading.DelayedTask.StartDelayedTask( () => { Location.Map.LeaveMap(ground); ground.Screen.ClearScreen(); }, Core.TimeIntervals.DroppedItemRemove); ground.Screen.UpdateScreen(null); } } } else if (Calculations.BasicCalculations.ChanceSuccess(NormalGemChance)) { Data.ItemInfo item; Enums.SocketGem gem = (Enums.SocketGem)ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.NextEnum(typeof(Enums.SocketGem)); switch (gem) { case Enums.SocketGem.NormalPhoenixGem: case Enums.SocketGem.RefinedPhoenixGem: case Enums.SocketGem.SuperPhoenixGem: gem = Enums.SocketGem.NormalPhoenixGem; break; case Enums.SocketGem.NormalDragonGem: case Enums.SocketGem.RefinedDragonGem: case Enums.SocketGem.SuperDragonGem: gem = Enums.SocketGem.NormalDragonGem; break; case Enums.SocketGem.NormalRainbowGem: case Enums.SocketGem.RefinedRainbowGem: case Enums.SocketGem.SuperRainbowGem: gem = Enums.SocketGem.NormalRainbowGem; break; case Enums.SocketGem.NormalVioletGem: case Enums.SocketGem.RefinedVioletGem: case Enums.SocketGem.SuperVioletGem: gem = Enums.SocketGem.NormalVioletGem; break; case Enums.SocketGem.NormalFuryGem: case Enums.SocketGem.RefinedFuryGem: case Enums.SocketGem.SuperFuryGem: gem = Enums.SocketGem.NormalFuryGem; break; case Enums.SocketGem.NormalKylinGem: case Enums.SocketGem.RefinedKylinGem: case Enums.SocketGem.SuperKylinGem: gem = Enums.SocketGem.NormalKylinGem; break; case Enums.SocketGem.NormalMoonGem: case Enums.SocketGem.RefinedMoonGem: case Enums.SocketGem.SuperMoonGem: gem = Enums.SocketGem.NormalMoonGem; break; default: return; } uint gemid = (uint)(((uint)gem) + 700000); if (Calculations.BasicCalculations.ChanceSuccess(RefinedGemChance)) { gemid += 1; if (Calculations.BasicCalculations.ChanceSuccess(SuperGemChance)) { gemid += 1; } } if (Core.Kernel.ItemInfos.TrySelect(gemid, out item)) { Maps.MapPoint Location = MidLocation.Map.CreateAvailableLocation <Data.GroundItem>(MidLocation.X, MidLocation.Y, 5); if (Location != null) { item = item.Copy(); // necessary Data.GroundItem ground = new Data.GroundItem(item); if (client != null) { ground.PlayerDrop = false; ground.OwnerUID = client.EntityUID; ground.DropTime = DateTime.Now; } ground.DropType = Enums.DropItemType.Item; ground.X = Location.X; ground.Y = Location.Y; Location.Map.EnterMap(ground); ground.TaskID = ProjectX_V3_Lib.Threading.DelayedTask.StartDelayedTask( () => { Location.Map.LeaveMap(ground); ground.Screen.ClearScreen(); }, Core.TimeIntervals.DroppedItemRemove); ground.Screen.UpdateScreen(null); } } } }
/// <summary> /// Gives an item to yourself. /// </summary> /// <param name="client"></param> /// <param name="FullCommand"></param> /// <param name="Command"></param> public static void Handle_Item(Entities.GameClient client, string FullCommand, string[] Command) { if (client.Inventory.Count >= 40) { return; } string Name = Command[1]; Data.ItemInfo item; if (Core.Kernel.ItemInfos.TrySelect(Name, out item)) { if (!item.IsMisc()) { if (item.Quality != 9) { byte q = item.Quality; uint id = item.ItemID; while (q != 9) { id++; q++; } Data.ItemInfo Titem; if (Core.Kernel.ItemInfos.TrySelect(id, out Titem)) { item = Titem; } } byte Plus = Command[2].ToByte(); if (Plus > 9) { return; } item.Plus = Plus; byte Bless = Command[3].ToByte(); if (Bless > 7) { return; } item.Bless = Bless; byte Enchant = Command[4].ToByte(); if (Command[5].IsNumericString()) { byte Gem1ID = Command[5].ToByte(); Enums.SocketGem Gem1 = (Enums.SocketGem)Gem1ID; item.Gem1 = Gem1; } else { Enums.SocketGem Gem1; if (Enum.TryParse <Enums.SocketGem>(Command[5], out Gem1)) { item.Gem1 = Gem1; } } if (Command[6].IsNumericString()) { byte Gem2ID = Command[6].ToByte(); Enums.SocketGem Gem2 = (Enums.SocketGem)Gem2ID; item.Gem2 = Gem2; } else { Enums.SocketGem Gem2; if (Enum.TryParse <Enums.SocketGem>(Command[6], out Gem2)) { item.Gem2 = Gem2; } } } client.Inventory.AddItem(item); client.Inventory.SendItemToClient(item); } else { // invalid item ... } }
/// <summary> /// Adds an item to the inventory. /// </summary> /// <param name="ItemID">The id of the item to add.</param> /// <param name="Plus">The plus stats of the item to add.</param> /// <param name="Bless">The bless stats of the item to add.</param> /// <param name="Enchant">The enchantment of the item to add.</param> /// <param name="Gem1">The first socket gem of the item to add.</param> /// <param name="Gem2">The second socket gem of the item to add.</param> /// <returns>Returns true if the item was added.</returns> public bool AddItem(uint ItemID, byte Plus = 0, byte Bless = 0, byte Enchant = 0, Enums.SocketGem Gem1 = 0, Enums.SocketGem Gem2 = 0) { ItemInfo original; Core.Kernel.ItemInfos.TrySelect(ItemID, out original); ItemInfo newitem = original.Copy(); newitem.Plus = Plus; newitem.Bless = Bless; newitem.Enchant = Enchant; newitem.Gem1 = Gem1; newitem.Gem2 = Gem2; return(AddItem(newitem)); }
/// <summary> /// Adds an item to the inventory. /// </summary> /// <param name="ItemID">The id of the item to add.</param> /// <param name="Plus">The plus stats of the item to add.</param> /// <param name="Bless">The bless stats of the item to add.</param> /// <param name="Enchant">The enchantment of the item to add.</param> /// <param name="Gem1">The first socket gem of the item to add.</param> /// <param name="Gem2">The second socket gem of the item to add.</param> /// <param name="amount">The amount to add.</param> /// <returns>Returns true if the item was added.</returns> public bool AddItem(uint ItemID, byte Plus = 0, byte Bless = 0, byte Enchant = 0, Enums.SocketGem Gem1 = 0, Enums.SocketGem Gem2 = 0, byte amount = 1) { if (amount == 0) { return(true); } ItemInfo original; Core.Kernel.ItemInfos.TrySelect(ItemID, out original); for (byte i = 0; i < amount; i++) { ItemInfo newitem = original.Copy(); newitem.Plus = Plus; newitem.Bless = Bless; newitem.Enchant = Enchant; newitem.Gem1 = Gem1; newitem.Gem2 = Gem2; if (!AddItem(newitem)) { return(false); } } return(true); }
public static void Handle(Entities.GameClient client, DataPacket packet) { if (client.Booth != null) { return; } using (var socket = new GemSocketingPacket(packet)) { if (!client.Inventory.ContainsByUID(socket.ItemUID) && !client.Inventory.ContainsByUID(socket.GemUID)) { return; } Data.ItemInfo SocketItem = client.Inventory.GetItemByUID(socket.ItemUID); if (SocketItem.CurrentDura < SocketItem.MaxDura) { return; } if (!socket.RemoveGem) { if (SocketItem.Gem1 != Enums.SocketGem.EmptySocket && socket.Socket == 1) { return; } else if (SocketItem.Gem2 != Enums.SocketGem.EmptySocket) { return; } Data.ItemInfo Gem = client.Inventory.GetItemByUID(socket.GemUID); if (Gem == null || SocketItem == null) { return; } if (SocketItem.IsGarment() || SocketItem.IsArrow() || SocketItem.IsBottle() || SocketItem.IsSteed() || SocketItem.IsMisc() || SocketItem.IsFan() || SocketItem.IsTower()) { return; } Enums.SocketGem gem = (Enums.SocketGem)(Gem.ItemID % 100); if (gem != Enums.SocketGem.NormalThunderGem && gem != Enums.SocketGem.RefinedThunderGem && gem != Enums.SocketGem.SuperThunderGem && gem != Enums.SocketGem.NormalGloryGem && gem != Enums.SocketGem.RefinedGloryGem && gem != Enums.SocketGem.SuperGloryGem) { if (socket.Socket == 1) { SocketItem.Gem1 = gem; } else { SocketItem.Gem2 = gem; } Database.CharacterDatabase.SaveInventory(client, SocketItem, client.Inventory.GetPositionFromItemUID(SocketItem.UID)); client.Inventory.RemoveItemByUID(Gem.UID); SocketItem.SendPacket(client, 3); } } else { if (SocketItem.Gem1 == Enums.SocketGem.EmptySocket && socket.Socket == 1 || SocketItem.Gem1 == Enums.SocketGem.NoSocket && socket.Socket == 1) { return; } else if (SocketItem.Gem2 == Enums.SocketGem.EmptySocket && socket.Socket != 1 || SocketItem.Gem2 == Enums.SocketGem.NoSocket && socket.Socket != 1) { return; } if (socket.Socket == 1) { SocketItem.Gem1 = Enums.SocketGem.EmptySocket; } else { SocketItem.Gem2 = Enums.SocketGem.EmptySocket; } Database.CharacterDatabase.SaveInventory(client, SocketItem, client.Inventory.GetPositionFromItemUID(SocketItem.UID)); SocketItem.SendPacket(client, 3); } } }