/// <summary> /// Handling the Use action from the ItemPacket. /// </summary> /// <param name="client">The client.</param> /// <param name="item">The item packet.</param> public static void Handle(Entities.GameClient client, ItemPacket packet) { uint uid = packet.UID; if (client.Inventory.ContainsByUID(uid)) { Data.ItemInfo useitem = client.Inventory[uid]; if (useitem.IsMisc()) { if (!Core.Kernel.ItemScriptEngine.Invoke(useitem.ItemID, new object[] { client, useitem })) { using (var fmsg = Packets.Message.MessageCore.CreateSystem(client.Name, string.Format(Core.MessageConst.INVALD_ITEM_USE, useitem.Name, useitem.ItemID))) client.Send(fmsg); } } else { if (!client.Alive) { return; } Enums.ItemLocation loc = (Enums.ItemLocation)packet.Data1; client.Equipments.Equip(useitem, loc, true); } } // else (Reason this is commented out is because it disconnected the client if switching equips too fast lmao. // client.NetworkClient.Disconnect("Using invalid item."); }
public static void Handle(Entities.GameClient client, ItemPacket packet) { uint uid = packet.UID; Data.Booth Booth = Data.Booth.FindBoothFromNPC(uid); if (Booth != null) { if (!Booth.ShopOwner.IsInMap(client)) { return; } if (!Core.Screen.ValidDistance(client.X, client.Y, Booth.ShopOwner.X, Booth.ShopOwner.Y)) { return; } foreach (Data.BoothItem boothItem in Booth.BoothItems.Values) { Data.ItemInfo item = boothItem.GetInfo(Booth.ShopOwner); var viewpacket = item.CreateViewPacket(uid, 1); if (boothItem.IsCP) { viewpacket.ViewType = 3; } viewpacket.Price = boothItem.Price; client.Send(viewpacket); } } }
public WarehousePacket(Data.ItemInfo item) : base((ushort)(24 + (72 * 1)), PacketType.WarehousePacket) { WhType = 20; Action = Enums.WarehouseAction.Add; //Unknown12 = 60; WriteItem(item); }
public void SendSingle(Data.ItemInfo item) { using (var warehouse = new Packets.WarehousePacket(item)) { warehouse.WarehouseID = WhID; Owner.Send(warehouse); } }
/// <summary> /// Processing the client through ranged attacks. /// </summary> /// <param name="client">The attacker.</param> /// <param name="interact">The interact packet.</param> /// <returns>Returns true if the client was handled successfully.</returns> public static bool ProcessClient(Entities.GameClient client, InteractionPacket interact, bool MAGIC_PACKET = false, int REQUIRED_ARROWS = 1) { if (!client.Equipments.Contains(Enums.ItemLocation.WeaponR)) { return(false); } if (!client.Equipments[Enums.ItemLocation.WeaponR].IsBow()) { return(false); } if (!client.Equipments.Contains(Enums.ItemLocation.WeaponL)) { return(false); } if (!client.Equipments[Enums.ItemLocation.WeaponL].IsArrow()) { return(false); } if (client.Equipments[Enums.ItemLocation.WeaponL].CurrentDura < REQUIRED_ARROWS) { uint arrowtype = client.Equipments[Enums.ItemLocation.WeaponL].ItemID; if (client.Inventory.ContainsByID(arrowtype)) { Data.ItemInfo arrow = client.Inventory.SearchForNonEmpty(arrowtype); if (arrow != null) { if (!client.Equipments.Equip(arrow, Enums.ItemLocation.WeaponL, true)) { using (var fmsg = Packets.Message.MessageCore.CreateSystem2(client.Name, Core.MessageConst.AUTO_RELOAD_ARROW_FAIL)) client.Send(fmsg); return(false); } } else { return(false); } } else if (!client.Equipments.Unequip(Enums.ItemLocation.WeaponL)) { using (var fmsg = Packets.Message.MessageCore.CreateSystem2(client.Name, Core.MessageConst.EMPTY_ARROWS)) client.Send(fmsg); return(false); } else { return(false); // no more arrows in inventory } } if (client.Battle != null) { if (!client.Battle.HandleBeginHit_Ranged(client)) { return(false); } } return(true); }
public static void Handle(Entities.GameClient client, ItemPacket packet) { uint uid = packet.UID; Data.Booth Booth = Data.Booth.FindBooth(uid); if (Booth != null) { if (!Booth.ShopOwner.IsInMap(client)) return; if (!Core.Screen.ValidDistance(client.X, client.Y, Booth.ShopOwner.X, Booth.ShopOwner.Y)) return; Data.BoothItem boothItem; if (Booth.BoothItems.TryGetValue(uid, out boothItem)) { if (boothItem.IsCP && client.CPs < boothItem.Price) { using (var msg = Packets.Message.MessageCore.CreateSystem(client.Name, Core.MessageConst.LOW_CPS)) client.Send(msg); return; } else if (client.Money < boothItem.Price) { using (var msg = Packets.Message.MessageCore.CreateSystem(client.Name, Core.MessageConst.LOW_MONEY2)) client.Send(msg); return; } if (Booth.BoothItems.TryRemove(uid, out boothItem)) { if (boothItem.IsCP) { client.CPs -= boothItem.Price; Booth.ShopOwner.CPs += boothItem.Price; } else { client.Money -= boothItem.Price; Booth.ShopOwner.Money += boothItem.Price; } client.Send(packet); packet.Action = Enums.ItemAction.BoothDelete; Booth.ShopOwner.Send(packet); Data.ItemInfo item = Booth.ShopOwner.Inventory.RemoveItemByUID(uid); client.Inventory.AddItem(item); using (var msg = Packets.Message.MessageCore.CreateSystem( Booth.ShopOwner.Name, string.Format(Core.MessageConst.BOOTH_BUY, client.Name, item.Name))) Booth.ShopOwner.Send(msg); Database.CharacterDatabase.SaveInventory(client, item, client.Inventory.GetPositionFromItemUID(uid)); } } } }
public static void Handle(Entities.GameClient client, DataPacket packet) { using (var warehouse = new WarehousePacket(packet)) { Data.Warehouse wh; if (client.Warehouses.TryGetValue((ushort)warehouse.WarehouseID, out wh)) { switch (warehouse.Action) { case Enums.WarehouseAction.Display: { wh.SendAll(); break; } case Enums.WarehouseAction.Add: { if (wh.FreeSpaces == 20) { return; } if (client.Inventory.ContainsByUID(warehouse.Identifier)) { Data.ItemInfo item = client.Inventory.RemoveItemByUID(warehouse.Identifier); if (item != null) { wh.AddItem(item); } } break; } case Enums.WarehouseAction.Remove: { if (client.Inventory.FreeSpaces == 40) { return; } if (wh.ContainsByUID(warehouse.Identifier)) { Data.ItemInfo item = wh.RemoveItemByUID(warehouse.Identifier); if (item != null) { client.Inventory.AddItem(item); //warehouse.WhType = 10; client.Send(warehouse); } } break; } } } } }
public static void DecreaseArrows(Entities.GameClient attackerclient, int amount = 1) { if (amount <= 0) { amount = 1; } Data.ItemInfo arrow = attackerclient.Equipments[Enums.ItemLocation.WeaponL]; arrow.CurrentDura -= (short)amount; Database.CharacterDatabase.SaveEquipment(attackerclient, arrow, Enums.ItemLocation.WeaponL); arrow.SendPacket(attackerclient, 3); }
/// <summary> /// Handling the Drop action from the ItemPacket. /// </summary> /// <param name="client">The client.</param> /// <param name="item">The item packet.</param> public static void Handle(Entities.GameClient client, ItemPacket packet) { if (client.Booth != null) { return; } if (!client.Alive) { return; } if (client.Map.MapType == Enums.MapType.Shared) { return; } if (client.Inventory.ContainsByUID(packet.UID)) { Maps.MapPoint Location = client.Map.CreateAvailableLocation <Data.GroundItem>(client.X, client.Y, 3); if (Location != null) { Data.ItemInfo dropitem = client.Inventory.GetItemByUID(packet.UID); if (dropitem != null) { if (!dropitem.IsValidOffItem()) { using (var fmsg = Message.MessageCore.CreateSystem(client.Name, Core.MessageConst.NO_PERMISSION_ITEM)) { client.Send(fmsg); } return; } client.Inventory.RemoveItemByUID(packet.UID); Data.GroundItem ground = new Data.GroundItem(dropitem); ground.PlayerDrop = true; 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); } } } }
public static void Handle(Entities.GameClient client, ItemPacket packet) { uint uid = packet.UID; if (client.Inventory.ContainsByUID(uid)) { Data.ItemInfo useitem = client.Inventory[uid]; if (!useitem.IsMountArmor()) { return; } client.Equipments.Equip(useitem, Enums.ItemLocation.SteedArmor, true); } }
/// <summary> /// Handles the AddItem subtype of the TradePacket. /// </summary> /// <param name="client">The client.</param> /// <param name="trade">The trade packet.</param> public static void Handle(Entities.GameClient client, TradePacket trade) { if (!client.Trade.Trading) { return; } if (!client.Trade.WindowOpen) { return; } uint itemuid = trade.TargetUID; if (client.Inventory.ContainsByUID(itemuid)) { Data.ItemInfo item = client.Inventory[itemuid]; if (!item.IsValidOffItem()) { using (var fmsg = Message.MessageCore.CreateSystem(client.Name, Core.MessageConst.NO_PERMISSION_ITEM)) { client.Send(fmsg); } return; } if ((client.Trade.Partner.Inventory.Count + client.Trade.Items.Count) >= 40) { using (var fmsg = Message.MessageCore.CreateSystem(client.Name, Core.MessageConst.TARGET_FULL_INVENTORY)) { client.Send(fmsg); } return; } client.Trade.Items.Add(item); item.SendPacket(client.Trade.Partner, 2); } }
/// <summary> /// Handling the Sell action from the ItemPacket. /// </summary> /// <param name="client">The client.</param> /// <param name="item">The item packet.</param> public static void Handle(Entities.GameClient client, ItemPacket packet) { if (client.Booth != null) { return; } if (!client.Alive) { return; } Data.Shop shop; if (Core.Kernel.Shops.TryGetValue(packet.UID, out shop)) { if (Core.Screen.GetDistance(shop.AssociatedNPC.X, shop.AssociatedNPC.Y, client.X, client.Y) >= Core.NumericConst.MaxNPCDistance) { using (var fmsg = Packets.Message.MessageCore.CreateSystem(client.Name, Core.MessageConst.TOO_FAR_NPC)) client.Send(fmsg); return; } Data.ItemInfo sellitem = client.Inventory.GetItemByUID(packet.Data1); if (!sellitem.IsValidOffItem()) { using (var fmsg = Message.MessageCore.CreateSystem(client.Name, Core.MessageConst.NO_PERMISSION_ITEM)) { client.Send(fmsg); } return; } uint giveback = (uint)(sellitem.Price / 3); if (client.Inventory.RemoveItemByUID(packet.Data1) != null) { client.Money += giveback; } } }
private void WriteItem(Data.ItemInfo item) { if (item == null) { return; } WriteByte(1, 20); WriteUInt32(item.UID, 24); WriteUInt32(item.ItemID, 28); WriteByte((byte)item.Gem1, 33); WriteByte((byte)item.Gem2, 34); WriteByte(item.Plus, 41); WriteByte(item.Bless, 42); WriteBool(item.Free, 43); WriteUInt16(item.Enchant, 44); WriteUInt16(item.RebornEffect, 46); WriteBool(item.Locked, 48); WriteBool(item.Suspicious, 49); WriteByte((byte)item.Color, 51); WriteUInt32(item.SocketAndRGB, 52); WriteUInt32(item.Composition, 56); /* WriteUInt32(item.UID, 24, buffer); * WriteUInt32(item.ID, 28, buffer); * WriteByte((byte)item.SocketOne, 33, buffer); * WriteByte((byte)item.SocketTwo, 34, buffer); * WriteByte(item.Plus, 41, buffer); * WriteByte(item.Bless, 42, buffer); * WriteByte((byte)(item.Bound == true ? 1 : 0), 43, buffer); * WriteUInt16(item.Enchant, 44, buffer); * WriteUInt16((ushort)item.Effect, 46, buffer); * WriteByte(item.Lock, 48, buffer); * WriteByte((byte)(item.Suspicious == true ? 1 : 0), 49, buffer); * WriteByte((byte)item.Color, 51, buffer); * WriteUInt32(item.SocketProgress, 52, buffer); * WriteUInt32(item.PlusProgress, 56, buffer);*/ //int loop = 0; //int Offset = 24; //foreach (Data.ItemInfo item in items) //{ //int Offset = 24 + (loop * 56); //WriteUInt32(item.UID, Offset); //Offset += 4; //WriteUInt32(item.ItemID, Offset); /*Offset += 4; * Offset++; * WriteByte((byte)item.Gem1, Offset); * Offset++; * WriteByte((byte)item.Gem2, Offset); * Offset++; * Offset += 6; * WriteByte(item.Plus, Offset); * Offset++; * WriteByte(item.Bless, Offset); * Offset++; * WriteBool(item.Free, Offset); * Offset++; * WriteByte(item.Enchant, Offset); * Offset++; * Offset++; * Offset += 2; * WriteBool(item.Suspicious, Offset); * Offset+= 2; * WriteBool(item.Locked, Offset); * Offset++; * WriteByte((byte)item.Color, Offset); * Offset++; * WriteUInt32(item.SocketAndRGB, Offset); * Offset += 4;*/ // loop++; // Offset += 56; /* * if (loop >= 19) * break; * int offset = 24 + (loop * 52); *((uint*)(ptr + offset)) = item.UniqueID; * offset += 4; *((uint*)(ptr + offset)) = item.StaticID; * offset += 4; * offset++; *((byte*)(ptr + offset)) = item.Gem1; * offset++; *((byte*)(ptr + offset)) = item.Gem2; * offset++; * offset += 6;//unknown info... Dura? *((byte*)(ptr + offset)) = item.Plus; * offset++; *((byte*)(ptr + offset)) = item.Bless; * offset++; * free *((byte*)(ptr + offset)) = 1; * offset++; *((byte*)(ptr + offset)) = item.Enchant; * offset++; * offset++; * offset += 2; * suspecious *((byte*)(ptr + offset)) = 1; * offset += 2; * locked *((byte*)(ptr + offset)) = 1; * offset++; *((byte*)(ptr + offset)) = item.Color; * offset++; *((uint*)(ptr + offset)) = item.SocketProgress; * offset += 4; * loop++;*/ //} }
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); } } }
public static void Handle(Entities.GameClient client, ItemPacket packet) { if (client.Booth != null) { return; } if (client.Inventory.ContainsByUID(packet.UID)) { Data.ItemInfo ToBless = client.Inventory.GetItemByUID(packet.UID); if (ToBless.CurrentDura < ToBless.MaxDura) { using (var msg = Packets.Message.MessageCore.CreateSystem(client.Name, Core.MessageConst.ITEM_LOW_DURA)) client.Send(msg); return; } if (ToBless.IsGarment() || ToBless.IsArrow() || ToBless.IsBottle() || ToBless.IsSteed() || ToBless.IsMisc()) { using (var msg = Packets.Message.MessageCore.CreateSystem(client.Name, Core.MessageConst.ITEM_INVALID_UPGRADE)) client.Send(msg); return; } if (ToBless != null) { byte RequiredTortoiseGems = 5; byte SetBless = 1; switch (ToBless.Bless) { case 0: RequiredTortoiseGems = 5; break; case 1: RequiredTortoiseGems = 1; SetBless = 3; break; case 3: RequiredTortoiseGems = 3; SetBless = 5; break; case 5: RequiredTortoiseGems = 5; SetBless = 7; break; default: return; } byte TortoiseAmount; if (!client.Inventory.ContainsByID(700073, out TortoiseAmount)) { using (var msg = Packets.Message.MessageCore.CreateSystem( client.Name, string.Format(Core.MessageConst.ITEM_AMOUNT_FAIL, "TortoiseGem's"))) client.Send(msg); return; } if (TortoiseAmount < RequiredTortoiseGems) { using (var msg = Packets.Message.MessageCore.CreateSystem( client.Name, string.Format(Core.MessageConst.ITEM_AMOUNT_FAIL, "TortoiseGem's"))) client.Send(msg); return; } byte Removed; client.Inventory.RemoveItem(700073, RequiredTortoiseGems, out Removed); Database.CharacterDatabase.SaveInventory(client, ToBless, client.Inventory.GetPositionFromItemUID(ToBless.UID)); ToBless.Bless = SetBless; ToBless.SendPacket(client, 3); client.Send(packet); } } }
public static void Handle(Entities.GameClient client, DataPacket packet) { using (var composition = new CompositionPacket(packet)) { if (!client.Inventory.ContainsByUID(composition.MainItem)) { using (var msg = Packets.Message.MessageCore.CreateSystem(client.Name, Core.MessageConst.ITEM_NOT_FOUND)) client.Send(msg); return; } if (!client.Inventory.ContainsByUID(composition.MinorItem)) { using (var msg = Packets.Message.MessageCore.CreateSystem(client.Name, Core.MessageConst.ITEM_NOT_FOUND)) client.Send(msg); return; } Data.ItemInfo MainItem = client.Inventory.GetItemByUID(composition.MainItem); if (MainItem.IsGarment() || MainItem.IsArrow() || MainItem.IsBottle() || MainItem.IsMisc() || MainItem.IsMountArmor()) { using (var msg = Packets.Message.MessageCore.CreateSystem(client.Name, Core.MessageConst.ITEM_INVALID_UPGRADE)) client.Send(msg); return; } if (MainItem.CurrentDura < MainItem.MaxDura) { using (var msg = Packets.Message.MessageCore.CreateSystem(client.Name, Core.MessageConst.ITEM_LOW_DURA)) client.Send(msg); return; } Data.ItemInfo MinorItem = client.Inventory.GetItemByUID(composition.MinorItem); if (MainItem.Plus >= Core.NumericConst.MaxPlus) { using (var msg = Packets.Message.MessageCore.CreateSystem(client.Name, Core.MessageConst.ITEM_MAX_PLUS)) client.Send(msg); return; } if (MinorItem.Plus == 0) { using (var msg = Packets.Message.MessageCore.CreateSystem(client.Name, Core.MessageConst.ITEM_NO_PLUS)) client.Send(msg); return; } if (MinorItem.Plus < MainItem.Plus) { using (var msg = Packets.Message.MessageCore.CreateSystem(client.Name, Core.MessageConst.ITEM_LOW_PLUS)) client.Send(msg); return; } //ushort[] CompositionPoints = new ushort[12] { 20, 20, 80, 240, 720, 2160, 6480, 19440, 58320, 2700, 5500, 9000 }; //ushort AddPoints = (CompositionPoints[MainItem.Plus] / 2); switch (composition.CompositionType) { case Enums.CompositionType.SteedComposition: { int color1 = (int)MainItem.SocketAndRGB; int color2 = (int)MinorItem.SocketAndRGB; int B1 = color1 & 0xFF; int B2 = color2 & 0xFF; int G1 = (color1 >> 8) & 0xFF; int G2 = (color2 >> 8) & 0xFF; int R1 = (color1 >> 16) & 0xFF; int R2 = (color2 >> 16) & 0xFF; int newB = (int)Math.Floor(0.9 * B1) + (int)Math.Floor(0.1 * B2); int newG = (int)Math.Floor(0.9 * G1) + (int)Math.Floor(0.1 * G2); int newR = (int)Math.Floor(0.9 * R1) + (int)Math.Floor(0.1 * R2); uint NewColor = (uint)(newB | (newG << 8) | (newR << 16)); if (NewColor == MainItem.SocketAndRGB) { return; } MainItem.SocketAndRGB = NewColor; goto case Enums.CompositionType.BonusCompositionA; } case Enums.CompositionType.BonusCompositionA: case Enums.CompositionType.BonusCompositionB: { //uint CompositionPoints = Calculations.BasicCalculations.CompositionPoints(MinorItem.Plus); client.Inventory.RemoveItemByUID(MinorItem.UID); if (MainItem.Composition > 0) { MainItem.Plus++; MainItem.Composition = 0; } else { MainItem.Composition = 1; } Database.CharacterDatabase.SaveInventory(client, MainItem, client.Inventory.GetPositionFromItemUID(MainItem.UID)); MainItem.SendPacket(client, 3); break; } } } }
public static void Handle(Entities.GameClient client, ItemPacket packet) { if (client.Booth != null) { return; } if (!client.Alive) { return; } if (!client.Inventory.ContainsByUID(packet.UID) && client.Inventory.ContainsByUID(packet.Data1)) { using (var msg = Packets.Message.MessageCore.CreateSystem(client.Name, Core.MessageConst.ITEM_NOT_FOUND)) client.Send(msg); return; } Data.ItemInfo ToUpgrade = client.Inventory.GetItemByUID(packet.UID); if (ToUpgrade.CurrentDura < ToUpgrade.MaxDura) { using (var msg = Packets.Message.MessageCore.CreateSystem(client.Name, Core.MessageConst.ITEM_LOW_DURA)) client.Send(msg); return; } Data.ItemInfo Dragonball = client.Inventory.GetItemByUID(packet.Data1); if (Dragonball == null || ToUpgrade == null) { using (var msg = Packets.Message.MessageCore.CreateSystem(client.Name, Core.MessageConst.ITEM_NOT_FOUND)) client.Send(msg); return; } if (ToUpgrade.IsGarment() || ToUpgrade.IsArrow() || ToUpgrade.IsBottle() || ToUpgrade.IsSteed() || ToUpgrade.IsMisc()) { using (var msg = Packets.Message.MessageCore.CreateSystem(client.Name, Core.MessageConst.ITEM_INVALID_UPGRADE)) client.Send(msg); return; } if (ToUpgrade.Quality >= 9) { using (var msg = Packets.Message.MessageCore.CreateSystem(client.Name, Core.MessageConst.ITEM_SUPER)) client.Send(msg); return; // super } if (Dragonball.ItemID != 1088000) { using (var msg = Packets.Message.MessageCore.CreateSystem( client.Name, string.Format(Core.MessageConst.ITEM_AMOUNT_FAIL, "Dragonball's"))) client.Send(msg); return; } uint NewID = ToUpgrade.ItemID; if (ToUpgrade.Quality >= 6) { NewID = (ToUpgrade.ItemID + 1); } else { while ((NewID % 10) < 6) { NewID++; } } if (Core.Kernel.ItemInfos.Contains(NewID)) { Data.ItemInfo newItem; if (Core.Kernel.ItemInfos.TrySelect(NewID, out newItem)) { if (newItem.Quality > ToUpgrade.Quality && newItem.Name == ToUpgrade.Name) { if (Calculations.BasicCalculations.ChanceSuccess(Core.NumericConst.QualityUpgradeChance)) { Data.ItemInfo NewUpgradedItem = newItem.Copy(); NewUpgradedItem.SetStats(ToUpgrade); client.Inventory.RemoveItemByUID(ToUpgrade.UID); client.Inventory.RemoveItemByUID(Dragonball.UID); if (Calculations.BasicCalculations.ChanceSuccess(Core.NumericConst.FirstSocketChance) && NewUpgradedItem.Gem1 == Enums.SocketGem.NoSocket) { NewUpgradedItem.Gem1 = Enums.SocketGem.EmptySocket; } else if (Calculations.BasicCalculations.ChanceSuccess(Core.NumericConst.SecondSocketChance) && NewUpgradedItem.Gem2 == Enums.SocketGem.NoSocket) { NewUpgradedItem.Gem2 = Enums.SocketGem.EmptySocket; } client.Inventory.AddItem(NewUpgradedItem); } } } } }
public static void Handle(Entities.GameClient client, ItemPacket packet) { if (client.Booth != null) { return; } if (!client.Alive) { return; } if (!client.Inventory.ContainsByUID(packet.UID) && client.Inventory.ContainsByUID(packet.Data1)) { using (var msg = Packets.Message.MessageCore.CreateSystem(client.Name, Core.MessageConst.ITEM_NOT_FOUND)) client.Send(msg); return; } Data.ItemInfo ToUpgrade = client.Inventory.GetItemByUID(packet.UID); if (ToUpgrade.CurrentDura < ToUpgrade.MaxDura) { return; } Data.ItemInfo Meteor = client.Inventory.GetItemByUID(packet.Data1); if (Meteor == null || ToUpgrade == null) { using (var msg = Packets.Message.MessageCore.CreateSystem(client.Name, Core.MessageConst.ITEM_NOT_FOUND)) client.Send(msg); return; } if (ToUpgrade.IsGarment() || ToUpgrade.IsArrow() || ToUpgrade.IsBottle() || ToUpgrade.IsSteed() || ToUpgrade.IsMisc()) { using (var msg = Packets.Message.MessageCore.CreateSystem(client.Name, Core.MessageConst.ITEM_INVALID_UPGRADE)) client.Send(msg); return; } if (ToUpgrade.RequiredLevel >= 120) { using (var msg = Packets.Message.MessageCore.CreateSystem(client.Name, Core.MessageConst.ITEM_MAX_LEVEL)) client.Send(msg); return; // max level } if (Meteor.ItemID != 1088001 && Meteor.ItemID != 1088002) { using (var msg = Packets.Message.MessageCore.CreateSystem( client.Name, string.Format(Core.MessageConst.ITEM_AMOUNT_FAIL, "Meteor- or Meteortear's"))) client.Send(msg); return; } uint NewID = ToUpgrade.ItemID + 10; int loop = 4; while (!Core.Kernel.ItemInfos.Contains(NewID)) { NewID += 10; loop--; if (loop <= 0) { break; } } if (Core.Kernel.ItemInfos.Contains(NewID)) { Data.ItemInfo newItem; if (Core.Kernel.ItemInfos.TrySelect(NewID, out newItem)) { if (newItem.RequiredLevel > ToUpgrade.RequiredLevel && newItem.TypeName == ToUpgrade.TypeName) { if (Calculations.BasicCalculations.ChanceSuccess(Core.NumericConst.LevelUpgradeChance)) { Data.ItemInfo NewUpgradedItem = newItem.Copy(); NewUpgradedItem.SetStats(ToUpgrade); client.Inventory.RemoveItemByUID(ToUpgrade.UID); client.Inventory.RemoveItemByUID(Meteor.UID); if (Calculations.BasicCalculations.ChanceSuccess(Core.NumericConst.FirstSocketChance) && NewUpgradedItem.Gem1 == Enums.SocketGem.NoSocket) { NewUpgradedItem.Gem1 = Enums.SocketGem.EmptySocket; } else if (Calculations.BasicCalculations.ChanceSuccess(Core.NumericConst.SecondSocketChance) && NewUpgradedItem.Gem2 == Enums.SocketGem.NoSocket) { NewUpgradedItem.Gem2 = Enums.SocketGem.EmptySocket; } client.Inventory.AddItem(NewUpgradedItem); } } } } }
public void LoadBot(Enums.BotType BotType, int botid, Maps.MapPoint location, Entities.GameClient Opponent) { switch (BotType) { #region afk bot case Enums.BotType.AFKBot: { using (var sql = new SqlHandler(Program.Config.ReadString("GameConnectionString"))) { using (var cmd = new SqlCommandBuilder(sql, SqlCommandType.SELECT, true)) { cmd.AddWhereValue("BotID", botid); cmd.Finish("DB_Bots"); } if (!sql.Read()) { return; } Original.Name = Core.NameGenerator.GetName(); if (string.IsNullOrEmpty(Original.Name) || string.IsNullOrWhiteSpace(Original.Name)) { return; } Original.Avatar = sql.ReadUInt16("BotAvatar"); Original.Model = sql.ReadUInt16("BotModel"); Original.HairStyle = sql.ReadUInt16("BotHairStyle"); Original.Transformation = sql.ReadUInt16("BotTransformation"); Original.Strength = sql.ReadUInt16("BotStrength"); Original.Agility = sql.ReadUInt16("BotAgility"); Original.Vitality = sql.ReadUInt16("BotVitality"); Original.Spirit = sql.ReadUInt16("BotSpirit"); Original.PKPoints = sql.ReadInt16("BotPKPoints"); Original.Level = sql.ReadByte("BotLevel"); Original.Class = (Enums.Class)Enum.Parse(typeof(Enums.Class), sql.ReadString("BotClass")); Original.PlayerTitle = (Enums.PlayerTitle)Enum.Parse(typeof(Enums.PlayerTitle), sql.ReadString("BotTitle")); Original.Reborns = sql.ReadByte("BotReborns"); Maps.Map map = location.Map; Original.Map = map; Original.LastMapID = Original.Map.MapID; Original.X = location.X; Original.Y = location.Y; Original.LastMapX = location.X; Original.LastMapY = location.Y; Original.LastX = location.X; Original.LastY = location.Y; Original.Action = Enums.ActionType.Sit; Original.Direction = (byte)ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next(8); uint entityuid = (uint)ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next(700000000, 999999999); Original.EntityUID = entityuid; if (!Original.Map.EnterMap(Original)) { return; } uint WeaponR = sql.ReadUInt32("BotWeaponR"); if (WeaponR > 0) { Data.ItemInfo item = Core.Kernel.ItemInfos[WeaponR].Copy(); Original.Equipments.Equip(item, Enums.ItemLocation.WeaponR, false, false); } uint WeaponL = sql.ReadUInt32("BotWeaponL"); if (WeaponL > 0) { Data.ItemInfo item = Core.Kernel.ItemInfos[WeaponL].Copy(); Original.Equipments.Equip(item, Enums.ItemLocation.WeaponL, false, false); } uint Armor = sql.ReadUInt32("BotArmor"); if (Armor > 0) { Data.ItemInfo item = Core.Kernel.ItemInfos[Armor].Copy(); Original.Equipments.Equip(item, Enums.ItemLocation.Armor, false, false); } uint Head = sql.ReadUInt32("BotHead"); if (Head > 0) { Data.ItemInfo item = Core.Kernel.ItemInfos[Head].Copy(); Original.Equipments.Equip(item, Enums.ItemLocation.Head, false, false); } bool UseSteed = sql.ReadBoolean("BotSteed"); if (UseSteed) { uint Steed = sql.ReadUInt32("BotSteedColor"); Data.ItemInfo item = Core.Kernel.ItemInfos[300000].Copy(); item.SocketAndRGB = Steed; Original.Equipments.Equip(item, Enums.ItemLocation.Steed, false, false); uint MountArmor = sql.ReadUInt32("BotMountArmor"); if (MountArmor > 0) { Data.ItemInfo item2 = Core.Kernel.ItemInfos[MountArmor].Copy(); Original.Equipments.Equip(item2, Enums.ItemLocation.SteedArmor, false, false); } Original.Action = Enums.ActionType.None; Original.AddStatusEffect1(Enums.Effect1.Riding); } uint Garment = sql.ReadUInt32("BotGarment"); if (Garment > 0) { Data.ItemInfo item = Core.Kernel.ItemInfos[Garment].Copy(); Original.Equipments.Equip(item, Enums.ItemLocation.Garment, false, false); } Original.LoggedIn = true; } break; } #endregion * #region duel bot case Enums.BotType.DuelBot: { if (Opponent == null) { return; } Original.Name = Core.NameGenerator.GetName(); if (string.IsNullOrEmpty(Original.Name) || string.IsNullOrWhiteSpace(Original.Name)) { return; } Original.Avatar = Opponent.Avatar; Original.Model = Opponent.Model; Original.HairStyle = Opponent.HairStyle; Original.Transformation = 0; Original.Strength = Opponent.Strength; Original.Agility = Opponent.Agility; Original.Vitality = Opponent.Vitality; Original.Spirit = Opponent.Spirit; Original.PKPoints = Opponent.PKPoints; Original.Level = Opponent.Level; Original.Class = Opponent.Class; Original.PlayerTitle = Opponent.PlayerTitle; Original.Reborns = Opponent.Reborns; Maps.Map map = Opponent.Map; Original.Map = map; Original.LastMapID = Original.Map.MapID; Original.X = Opponent.X; Original.Y = Opponent.Y; Original.LastMapX = Opponent.X; Original.LastMapY = Opponent.Y; Original.LastX = Opponent.X; Original.LastY = Opponent.Y; Original.Action = Enums.ActionType.None; Original.Direction = (byte)ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next(8); uint entityuid = (uint)ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next(700000000, 999999999); Original.EntityUID = entityuid; if (!Original.Map.EnterMap(Original)) { return; } Original.Equipments.ForceEquipments(Opponent.Equipments); Original.BaseEntity.CalculateBaseStats(); Original.HP = Original.MaxHP; Original.MP = Original.MaxMP; /* * uint WeaponR = sql.ReadUInt32("BotWeaponR"); * if (WeaponR > 0) * { * Data.ItemInfo item = Core.Kernel.ItemInfos[WeaponR].Copy(); * Original.Equipments.Equip(item, Enums.ItemLocation.WeaponR, false, false); * } * uint WeaponL = sql.ReadUInt32("BotWeaponL"); * if (WeaponL > 0) * { * Data.ItemInfo item = Core.Kernel.ItemInfos[WeaponL].Copy(); * Original.Equipments.Equip(item, Enums.ItemLocation.WeaponL, false, false); * } * uint Armor = sql.ReadUInt32("BotArmor"); * if (Armor > 0) * { * Data.ItemInfo item = Core.Kernel.ItemInfos[Armor].Copy(); * Original.Equipments.Equip(item, Enums.ItemLocation.Armor, false, false); * } * uint Head = sql.ReadUInt32("BotHead"); * if (Head > 0) * { * Data.ItemInfo item = Core.Kernel.ItemInfos[Head].Copy(); * Original.Equipments.Equip(item, Enums.ItemLocation.Head, false, false); * } * bool UseSteed = sql.ReadBoolean("BotSteed"); * if (UseSteed) * { * uint Steed = sql.ReadUInt32("BotSteedColor"); * Data.ItemInfo item = Core.Kernel.ItemInfos[300000].Copy(); * item.SocketAndRGB = Steed; * Original.Equipments.Equip(item, Enums.ItemLocation.Steed, false, false); * * uint MountArmor = sql.ReadUInt32("BotMountArmor"); * if (MountArmor > 0) * { * Data.ItemInfo item2 = Core.Kernel.ItemInfos[MountArmor].Copy(); * Original.Equipments.Equip(item2, Enums.ItemLocation.SteedArmor, false, false); * } * * Original.Action = Enums.ActionType.None; * Original.AddStatusEffect1(Enums.Effect1.Riding); * } * uint Garment = sql.ReadUInt32("BotGarment"); * if (Garment > 0) * { * Data.ItemInfo item = Core.Kernel.ItemInfos[Garment].Copy(); * Original.Equipments.Equip(item, Enums.ItemLocation.Garment, false, false); * }*/ Original.LoggedIn = true; break; } #endregion * } }
public static void Handle(Entities.IEntity attacker, InteractionPacket interact) { if (interact == null) { return; } Maps.IMapObject attackermap = attacker as Maps.IMapObject; if (!attackermap.Screen.ContainsEntity(interact.TargetUID)) { return; } Maps.IMapObject target = null; if (!attackermap.Screen.GetEntity(interact.TargetUID, out target)) { return; } if (target is Entities.NPC) { return; } if (target is Entities.GameClient) { if (!(target as Entities.GameClient).LoggedIn) { return; } if (target.Map.MapType == Enums.MapType.NoPK && (attacker is Entities.GameClient)) { return; } if (!(DateTime.Now >= (target as Entities.GameClient).LoginProtection.AddSeconds(10))) { return; } if (!(DateTime.Now >= (target as Entities.GameClient).ReviveProtection.AddSeconds(5))) { return; } } Entities.IEntity targetentity = target as Entities.IEntity; if (targetentity is Entities.BossMonster) { if (!(targetentity as Entities.BossMonster).CanBeAttacked) { return; } } if (!Combat.FixTarget(attacker, targetentity)) { return; } if (!Core.Screen.ValidDistance(attackermap.X, attackermap.Y, target.X, target.Y)) { return; } if (!attacker.Alive) { return; } if (!targetentity.Alive) { return; } if (attacker is Entities.GameClient) { if (!ProcessClient((attacker as Entities.GameClient), interact)) { return; } } uint damage = Calculations.Battle.GetRangedDamage(attacker, targetentity); Combat.ProcessDamage(attacker, targetentity, ref damage); interact.Data = damage; attacker.Screen.UpdateScreen(interact); if (attacker is Entities.GameClient) { Entities.GameClient attackerclient = attacker as Entities.GameClient; if (damage > 0) { if (!(target is Entities.GameClient)) { uint exp = (uint)ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next((int)(damage / 2), (int)damage); if (targetentity.Level > (attacker.Level + 10)) { exp *= 2; } else if (attacker.Level > (targetentity.Level + 10)) { exp = (uint)ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next(1, (int)targetentity.Level); } if (interact.WeaponTypeRight > 0) { attackerclient.AddProfExp(500, exp); // bow } } } Data.ItemInfo arrow = attackerclient.Equipments[Enums.ItemLocation.WeaponL]; arrow.CurrentDura--; Database.CharacterDatabase.SaveEquipment(attackerclient, arrow, Enums.ItemLocation.WeaponL); arrow.SendPacket(attackerclient, 3); attackerclient.Send(interact); //interact.Data = 0; interact.ActivationType = 0; interact.ActivationValue = 0; attackerclient.AttackPacket = interact; attackerclient.UseAutoAttack(interact); } }