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> /// 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); } }
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.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); } }
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); } } }