public static void DoHammer(MapleItem hammer, MapleEquip equip, MapleCharacter chr) { if (!CanHammer(equip)) { chr.SendPopUpMessage("You cannot use that on this item."); chr.EnableActions(); return; } switch (hammer.ItemId) { case 2470000: case 2470003: case 2470007: case 2470011: case 5570000: { equip.RemainingUpgradeCount++; equip.HammersApplied++; chr.Inventory.RemoveItemsFromSlot(hammer.InventoryType, hammer.Position, 1); chr.Client.SendPacket(MapleInventory.Packets.AddItem(equip, MapleInventoryType.Equip, equip.Position)); chr.Client.SendPacket(Packets.HammerEffect(true)); chr.Client.SendPacket(Packets.HammerResult(false, true, equip.HammersApplied)); PacketWriter finishPacket = Packets.HammerResult(true, true, 0); Scheduler.ScheduleDelayedAction(() => chr.Client.SendPacket(finishPacket), 1500); break; } default: { chr.SendPopUpMessage("You cannot use this hammer."); chr.EnableActions(); return; } } }
public static void DropItem(string[] split, MapleClient c) { int itemId; if (int.TryParse(split[1], out itemId)) { MapleCharacter chr = c.Account.Character; short quantity; if (split.Length > 2) { if (!short.TryParse(split[2], out quantity)) { quantity = 1; } } else { quantity = 1; } MapleItem item = MapleItemCreator.CreateItem(itemId, "!dropitem by " + chr.Name, quantity); if (item == null) { c.Account.Character.SendBlueMessage(String.Format("This item does not exist: {0}", itemId)); } else { Point targetPosition = chr.Map.GetDropPositionBelow(new Point(chr.Position.X, chr.Position.Y - 50), chr.Position); chr.Map.SpawnMapItem(item, chr.Position, targetPosition, true, 0, chr); } } }
//todo //response to join trade room if the owner disconnected or closed it //response packet if character is busy //"enabled actions" needs worked on, such as after adding an item to the trade the client expects its actions enabled. private static void HandleAddItem(PacketReader pr, MapleCharacter chr) { MapleInventoryType inventoryType = (MapleInventoryType)pr.ReadByte(); short fromSlot = pr.ReadShort(); short quantity = pr.ReadShort(); byte tradeSlot = pr.ReadByte(); MapleItem item = chr.Inventory.GetItemSlotFromInventory(inventoryType, fromSlot); if (item != null) { if (chr.Trade.AddItem(item, tradeSlot, quantity, chr)) { if (item.Quantity == quantity) { chr.Client.SendPacket(MapleInventory.Packets.RemoveItem(inventoryType, fromSlot)); } else { short newVal = (short)(item.Quantity - quantity); chr.Client.SendPacket(MapleInventory.Packets.UpdateItemQuantity(inventoryType, fromSlot, newVal)); } } } }
public bool AddItem(MapleItem item, byte tradeSlot, short quantity, MapleCharacter itemOwner) { if (Partners.Count == 0) return false; //Partner hasn't accepted trade if (item.Tradeable) return false; //theyre probably hacking if they put in an untradable item too foreach (TradeItem[] arr in items) { if (arr.Any(t => t != null && t.Item == item)) //item is already added { return false; } } if (Type == TradeType.Trade) { if (tradeSlot > 9 || tradeSlot < 1) return false;//hacking if (Owner == itemOwner) { items[0][tradeSlot] = new TradeItem(item, quantity); } else { items[1][tradeSlot] = new TradeItem(item, quantity); } bool isOwner = Owner == itemOwner; Owner.Client.SendPacket(GenerateTradeItemAdd(item, !isOwner, tradeSlot)); Partners[0].Client.SendPacket(GenerateTradeItemAdd(item, isOwner, tradeSlot)); return true; } return false; }
public static void GetItem(string[] split, MapleClient c) { int itemId; if (int.TryParse(split[1], out itemId)) { short quantity; if (split.Length > 2) { if (!short.TryParse(split[2], out quantity)) { quantity = 1; } } else { quantity = 1; } MapleItem item = MapleItemCreator.CreateItem(itemId, "!getitem by " + c.Account.Character.Name, quantity); if (item == null) { c.Account.Character.SendBlueMessage(String.Format("This item does not exist: {0}", itemId)); } else { c.Account.Character.Inventory.AddItem(item, item.InventoryType, true); } } }
public static void Handle(MapleClient c, PacketReader pr) { MapleCharacter chr = c.Account.Character; if (!chr.DisableActions()) { return; } int tickCount = pr.ReadInt(); int hammerSlot = pr.ReadInt(); int hammerItemId = pr.ReadInt(); MapleItem hammer = chr.Inventory.GetItemSlotFromInventory(MapleInventoryType.Use, (short)hammerSlot); if (hammer == null || hammer.ItemId != hammerItemId) { return; } pr.Skip(4); //Integer, inventory type? int equipSlot = pr.ReadInt(); MapleEquip equip = chr.Inventory.GetItemSlotFromInventory(MapleInventoryType.Equip, (short)equipSlot) as MapleEquip; if (equip == null) { return; } DoHammer(hammer, equip, chr); chr.EnableActions(false); }
public PacketWriter GenerateTradeItemAdd(MapleItem item, bool mine, byte TradeSlot) { PacketWriter pw = new PacketWriter(); pw.WriteHeader(SendHeader.Trade); pw.WriteByte(0); pw.WriteBool(mine); pw.WriteByte(TradeSlot); MapleItem.AddItemInfo(pw, item); return pw; }
public MapleMapItem(int objectId, MapleItem item, Point position, int ownerId, MapleDropType dropType, bool playerDrop, int meso = 0, int ffa = 30000, int expiration = 120000) { ObjectId = objectId; Item = item; Position = position; OwnerId = ownerId > 0 ? ownerId : 0; DropType = dropType; PlayerDrop = playerDrop; Meso = meso; ExpireTime = DateTime.UtcNow.AddMilliseconds(expiration); FFATime = DateTime.UtcNow.AddMilliseconds(ffa); }
private static bool TransferItems(TradeItem[] list, MapleCharacter owner, MapleCharacter partner) { if (!CanTransferItems(list, partner)) return false; foreach (var item in list) { if (item == null) continue; MapleItem mitem = item.Item; MapleItem newItem; if (mitem.InventoryType == MapleInventoryType.Equip) newItem = mitem; else newItem = new MapleItem(mitem, item.Item.Source) {Quantity = item.Count}; owner.Inventory.RemoveItemsFromSlot(mitem.InventoryType, mitem.Position, item.Count, false); partner.Inventory.AddItem(newItem, newItem.InventoryType); } return true; }
public MapleItem TryGetStealableItem(int characterId, string characterName) { List <int> alreadyStolenItems; if (!stolenItems.TryGetValue(characterId, out alreadyStolenItems)) { alreadyStolenItems = new List <int>(); } int potionId = IsBoss ? 2431835 : 2431835; //TODO: correct potion id string source = string.Format("Steal skill from mob {0} by player {1}", WzInfo.MobId, characterName); if (!alreadyStolenItems.Contains(potionId)) { MapleItem item = new MapleItem(potionId, source); AddStolenItem(characterId, potionId); return(item); } if (!IsBoss) { List <MobDrop> drops = DataBuffer.GetMobDropsById(WzInfo.MobId); foreach (MobDrop mobDrop in drops) { if (mobDrop.QuestId > 0 || alreadyStolenItems.Contains(mobDrop.ItemId)) { continue; } int chance = (int)(mobDrop.DropChance); if (Functions.Random(0, 999999) <= chance) { int amount = Functions.Random(mobDrop.MinQuantity, mobDrop.MaxQuantity); MapleItem item = MapleItemCreator.CreateItem(mobDrop.ItemId, source, (short)amount, true); AddStolenItem(characterId, item.ItemId); return(item); } } } return(null); }
public void packetAction(Client c, PacketReader packet) { try { if (packet.Length > 7) { byte identifier = packet.Read(); if (identifier == 0x00) //Gained item { MapleItem mapleEquip; short items = packet.ReadShort(); for (short y = 0; y < items; y++) { byte miniID = packet.Read(); if (miniID == 0x01) { byte invent = packet.Read(); short slotz = packet.ReadShort(); short amtt = packet.ReadShort(); if (amtt > 0) { c.myCharacter.Inventorys[c.myCharacter.Inventorys[InventoryType.EQUIP].getInvenType(invent)].updateItemCount((byte)slotz, amtt); MapleItem item = c.myCharacter.Inventorys[c.myCharacter.Inventorys[InventoryType.EQUIP].getInvenType(invent)].getItem((byte)slotz); if (item != null) { c.updateLog("[Inventory] Slot " + slotz.ToString() + ": " + item.quantity + " " + Database.getItemName(item.ID) + "s"); } } continue; } else if (miniID == 0x03) { byte invent = packet.Read(); short slotz = packet.ReadShort(); c.myCharacter.Inventorys[c.myCharacter.Inventorys[InventoryType.EQUIP].getInvenType(invent)].removeSlot((byte)slotz); if (c.clientMode != ClientMode.WBMESOEXPLOIT) { c.updateLog("[Inventory] Slot " + slotz.ToString() + " freed."); } } else // miniID == 0x00 { byte itemType = packet.Read(); byte slot = packet.Read(); packet.Read(); packet.Read(); //?????? switch (itemType) { case 1: { mapleEquip = new MapleEquip(packet.ReadInt(), slot); break; } case 2: { mapleEquip = new MapleItem(packet.ReadInt(), slot, 1); break; } case 3: { mapleEquip = null; packet.ReadInt(); break; } default: { return; } } InventoryType type = c.myCharacter.Inventorys[InventoryType.EQUIP].getInvenTypeByID(mapleEquip.ID); if (mapleEquip != null) { if (!c.myCharacter.Inventorys[type].inventory.ContainsKey(mapleEquip.position)) { c.myCharacter.Inventorys[type].inventory.Add(mapleEquip.position, mapleEquip); } if (mapleEquip.type == 1) { while (true) { while (true) { if (packet.Read() == 0x4) { int x = 0; byte bytes = 0; bool complete = false; while (true) { bytes = packet.Read(); if (bytes == 0) { x++; } else if (bytes == 4) { x = 0; } else { break; } if (x >= 3) { complete = true; break; } } if (complete) { packet.Read(); break; } } Thread.Sleep(1); } mapleEquip.craftedBy = packet.ReadMapleString(); mapleEquip.potLevel = packet.Read(); mapleEquip.enhancements = packet.Read(); int potLine1 = packet.ReadShort(); int potLine2 = packet.ReadShort(); int potLine3 = packet.ReadShort(); short bonuspotline1 = packet.ReadShort(); short bonuspotline2 = packet.ReadShort(); short bonuspotline3 = packet.ReadShort(); packet.ReadShort(); mapleEquip.bonuspotLevel = packet.Read(); packet.Read(); short nebulite = packet.ReadShort(); while (true) { while (packet.Read() != 0x40) { } if (packet.Read() == 0xE0) { break; } Thread.Sleep(1); } while (packet.Read() != 0xFF) { Thread.Sleep(1); } packet.Skip(3); while (true) { while (packet.Read() != 0x40) { Thread.Sleep(1); } if (packet.Read() == 0xE0) { break; } Thread.Sleep(1); } while (packet.Read() != 0x01) { Thread.Sleep(1); } packet.Skip(16); break; } } else { packet.Skip(13); mapleEquip.quantity = packet.ReadShort(); packet.ReadInt(); } if (c.clientMode == ClientMode.CASSANDRA) { if (mapleEquip.ID == 2431042 || mapleEquip.ID == 2049402 || mapleEquip.ID == 1122221) { continue; } } c.updateLog("[Inventory] Gained " + mapleEquip.quantity + " " + Database.getItemName(mapleEquip.ID)); } } } } else if (identifier == 0x01) //Drop { packet.ReadShort(); byte action = packet.Read(); byte invenType = packet.Read(); byte slotNum = packet.Read(); packet.Read(); InventoryType type = c.myCharacter.Inventorys[InventoryType.EQUIP].getInvenType(invenType); if (action == 0x01) //D { short remaining = packet.ReadShort(); c.myCharacter.Inventorys[type].updateItemCount(slotNum, remaining); } else if (action == 0x03) { c.myCharacter.Inventorys[type].removeSlot(slotNum); } } /* * * byte inventoryType = packet.Read(); * if (inventoryType != 0) * { * short slot = packet.ReadShort(); * try * { * packet.Read(); * int itemID = packet.ReadInt(); * short itemCount = packet.ReadShort(); * string itemName = ""; * switch (inventoryType) * { * case 1: * c.myCharacter.Inventorys[InventoryType.EQUIP].updateItemCount((byte)slot, itemCount, itemID); * itemName = Database.getItemName(c.myCharacter.Inventorys[InventoryType.EQUIP].getItem((byte)slot).ID); * break; * case 2: * c.myCharacter.Inventorys[InventoryType.USE].updateItemCount((byte)slot, itemCount, itemID); * itemName = Database.getItemName(c.myCharacter.Inventorys[InventoryType.USE].getItem((byte)slot).ID); * break; * case 3: * c.myCharacter.Inventorys[InventoryType.SETUP].updateItemCount((byte)slot, itemCount, itemID); * itemName = Database.getItemName(c.myCharacter.Inventorys[InventoryType.SETUP].getItem((byte)slot).ID); * break; * case 4: * c.myCharacter.Inventorys[InventoryType.ETC].updateItemCount((byte)slot, itemCount, itemID); * itemName = Database.getItemName(c.myCharacter.Inventorys[InventoryType.ETC].getItem((byte)slot).ID); * break; * case 5: * c.myCharacter.Inventorys[InventoryType.CASH].updateItemCount((byte)slot, itemCount, itemID); * itemName = Database.getItemName(c.myCharacter.Inventorys[InventoryType.CASH].getItem((byte)slot).ID); * break; * } * c.updateAccountStatus(itemCount.ToString() + " " + itemName + "s"); * c.updateLog("[Inventory] " + itemCount.ToString() + " " + itemName + "s"); * } * catch * { * string itemName = ""; * switch (inventoryType) * { * case 1: * c.myCharacter.Inventorys[InventoryType.EQUIP].removeSlot((byte)slot); * itemName = Database.getItemName(c.myCharacter.Inventorys[InventoryType.EQUIP].getItem((byte)slot).ID); * break; * case 2: * c.myCharacter.Inventorys[InventoryType.USE].removeSlot((byte)slot); * itemName = Database.getItemName(c.myCharacter.Inventorys[InventoryType.USE].getItem((byte)slot).ID); * break; * case 3: * c.myCharacter.Inventorys[InventoryType.SETUP].removeSlot((byte)slot); * itemName = Database.getItemName(c.myCharacter.Inventorys[InventoryType.SETUP].getItem((byte)slot).ID); * break; * case 4: * c.myCharacter.Inventorys[InventoryType.ETC].removeSlot((byte)slot); * itemName = Database.getItemName(c.myCharacter.Inventorys[InventoryType.ETC].getItem((byte)slot).ID); * break; * case 5: * c.myCharacter.Inventorys[InventoryType.CASH].removeSlot((byte)slot); * itemName = Database.getItemName(c.myCharacter.Inventorys[InventoryType.CASH].getItem((byte)slot).ID); * break; * } * c.updateLog("[Inventory] " + "You now have 0 " + itemName + "s"); * } * } * else //Item Gained * { * } * * */ } } catch (Exception e) { c.updateLog("INVEN UPDATE ERROR " + e.ToString()); } }
public static void Handle(MapleClient c, PacketReader pr) { int tickCount = pr.ReadInt(); short slot = pr.ReadShort(); int id = pr.ReadInt(); MapleCharacter chr = c.Account.Character; MapleItem item = chr.Inventory.GetItemSlotFromInventory(MapleInventoryType.Use, slot); if (item != null && item.ItemId == id) { WzConsume consume = DataBuffer.GetItemById(id) as WzConsume; if (consume != null) { chr.Inventory.RemoveItemsFromSlot(MapleInventoryType.Use, slot, 1, true); if (!chr.Map.PotionLimit) { if (consume.Hp != 0) { chr.AddHP((int)((chr.Stats.PotionEffectR / 100.0) * consume.Hp)); } if (consume.Mp != 0) { chr.AddMP((int)((chr.Stats.PotionEffectR / 100.0) * consume.Mp)); } if (consume.HpR != 0) { chr.AddHP((int)(chr.Stats.MaxHp * (consume.HpR / 100.0))); } if (consume.MpR != 0) { chr.AddMP((int)(chr.Stats.MaxMp * (consume.MpR / 100.0))); } } if (consume.MoveTo != 0 && !chr.Map.PortalScrollLimit) { chr.ChangeMap(consume.MoveTo); } if (consume.CharismaExp != 0) { chr.AddTraitExp(consume.CharismaExp, MapleCharacterStat.Charisma); } if (consume.CharmExp != 0) { chr.AddTraitExp(consume.CharmExp, MapleCharacterStat.Charm); } if (consume.CraftExp != 0) { chr.AddTraitExp(consume.CraftExp, MapleCharacterStat.Craft); } if (consume.InsightExp != 0) { chr.AddTraitExp(consume.InsightExp, MapleCharacterStat.Insight); } if (consume.SenseExp != 0) { chr.AddTraitExp(consume.SenseExp, MapleCharacterStat.Sense); } if (consume.WillExp != 0) { chr.AddTraitExp(consume.WillExp, MapleCharacterStat.Will); } return; } } chr.EnableActions(); }
private void parseItems(Client c, PacketReader packet, MapleFMShop mapleShop, int i, string ign) { try { MapleItem mapleItem = new MapleItem(); mapleItem.owner = ign; mapleItem.quantity = packet.ReadShort(); mapleItem.bundle = packet.ReadShort(); if (mapleItem.bundle == 0) { packet.ReadInt(); mapleItem.quantity = packet.ReadShort(); mapleItem.bundle = packet.ReadShort(); } if (mapleItem.quantity < -1 || mapleItem.quantity > 20000) { packet.Skip(4); mapleItem.quantity = packet.ReadShort(); mapleItem.bundle = packet.ReadShort(); } mapleItem.price = packet.ReadLong(); mapleItem.position = (byte)(i + 1); packet.Skip(1); mapleItem.ID = packet.ReadInt(); mapleShop.addItem(mapleItem); if (mapleItem.ID < 2000000) { bool flag = packet.Read() > 0; if (flag) { mapleItem.cashOID = packet.ReadLong(); } packet.Skip(8); packet.Skip(4); packet.ReadInt(); int Level = 1; if (Database.items.ContainsKey(mapleItem.ID)) { if (Database.items[mapleItem.ID].itemLevel == 0) { //Database.items[mapleItem.ID].itemLevel = Database.getItemLevel(mapleItem.ID); Database.items[mapleItem.ID].itemLevel = Database.getItemLevel(mapleItem.ID); if (Database.items[mapleItem.ID].itemLevel == 0) { Database.items[mapleItem.ID].itemLevel = 10; } } Level = Database.items[mapleItem.ID].itemLevel / 10; } while (true) { if (packet.Read() == 0x4) { int x = 0; byte bytes = 0; bool complete = false; while (true) { bytes = packet.Read(); if (bytes == 0) { x++; } else if (bytes == 4) { x = 0; } else { break; } if (x >= 3) { complete = true; break; } } if (complete) { packet.Read(); break; } } Thread.Sleep(1); } mapleItem.craftedBy = packet.ReadMapleString(); mapleItem.potLevel = packet.Read(); mapleItem.enhancements = packet.Read(); short potLine1 = packet.ReadShort(); short potLine2 = packet.ReadShort(); short potLine3 = packet.ReadShort(); int potline1 = potLine1; if (potline1 < 0) { potline1 = 32767 - potline1; } int potline2 = potLine2; if (potline2 < 0) { potline2 = 32767 - potline2; } int potline3 = potLine3; if (potline3 < 0) { potline3 = 32767 - potline3; } if (mapleItem.potLevel > 0 & mapleItem.potLevel <= 20 && potLine1 > 0) { if (potLine1 < 20000 && potLine2 < 10000 && potLine3 < 10000) { mapleItem.potline0 = "Rare"; } else if (potLine1 < 30000 && potLine2 < 20000 && potLine3 < 20000) { mapleItem.potline0 = "Epic"; } else if (potline1 < 40000 && potLine2 < 30000 && potLine3 < 30000) { mapleItem.potline0 = "Unique"; } else if (potline1 < 50000 && potline2 < 40000 && potline3 < 40000) { mapleItem.potline0 = "Legendary"; } mapleItem.potline1 = c.getPotentialLines(potLine1, Level); mapleItem.potline1 = mapleItem.potline1.Replace(".", ""); mapleItem.potline2 = c.getPotentialLines(potLine2, Level); mapleItem.potline2 = mapleItem.potline2.Replace(".", ""); mapleItem.potline3 = c.getPotentialLines(potLine3, Level); mapleItem.potline3 = mapleItem.potline3.Replace(".", ""); } short bonuspotline1 = packet.ReadShort(); short bonuspotline2 = packet.ReadShort(); short bonuspotline3 = packet.ReadShort(); packet.ReadShort(); mapleItem.bonuspotLevel = packet.Read(); packet.Read(); int BPL1 = bonuspotline1; if (BPL1 < 0) { BPL1 = 32767 - BPL1; } int BPL2 = bonuspotline2; if (BPL2 < 0) { BPL2 = 32767 - BPL2; } int BPL3 = bonuspotline3; if (BPL3 < 0) { BPL3 = 32767 - BPL3; } if (mapleItem.bonuspotLevel > 0 & mapleItem.bonuspotLevel <= 20) { if (BPL1 < 20000 && BPL2 < 10000 && BPL3 < 10000) { mapleItem.bonuspotline0 = "Rare"; } else if (BPL1 < 30000 && BPL2 < 20000 && BPL3 < 20000) { mapleItem.bonuspotline0 = "Epic"; } else if (BPL1 < 40000 && BPL2 < 30000 && BPL3 < 30000) { mapleItem.bonuspotline0 = "Unique"; } else if (BPL1 < 50000 && BPL2 < 40000 && BPL3 < 40000) { mapleItem.bonuspotline0 = "Legendary"; } mapleItem.bonuspotline1 = c.getPotentialLines(bonuspotline1, Level); mapleItem.bonuspotline1 = mapleItem.bonuspotline1.Replace(".", ""); mapleItem.bonuspotline2 = c.getPotentialLines(bonuspotline2, Level); mapleItem.bonuspotline2 = mapleItem.bonuspotline2.Replace(".", ""); mapleItem.bonuspotline3 = c.getPotentialLines(bonuspotline3, Level); mapleItem.bonuspotline3 = mapleItem.bonuspotline3.Replace(".", ""); } short nebulite = packet.ReadShort(); if (nebulite >= 0 & nebulite <= 9999) { if (nebulite == 0) { if (packet.Read() == 0xFF) { mapleItem.nebulite = c.getNebuliteLine(nebulite); } } else { mapleItem.nebulite = c.getNebuliteLine(nebulite); } } /*if ((mapleItem.potLevel > 0 & mapleItem.potLevel <= 20) || (mapleItem.bonuspotLevel > 0 & mapleItem.bonuspotLevel <= 20)) * { * MessageBox.Show( * storeTitle + "\n" + * mapleItem.potLevel.ToString() + "\n" + * mapleItem.potline1 + "\n" + * mapleItem.potline2 + "\n" + * mapleItem.potline3 + "\n" + * mapleItem.bonuspotLevel.ToString() + "\n" + * mapleItem.bonuspotline1 + "\n" + * mapleItem.bonuspotline2 + "\n" + * mapleItem.bonuspotline3 + "\n" + * mapleItem.nebulite + "\n"); * } * int y = 0; * //c.updateLog(mapleItem.ID.ToString() + ", " + mapleItem.price.ToString() + ", " + mapleItem.quantity.ToString() + ", " + "Equip"); * * while (true) * { * while (packet.Read() != 255) * { * } * y++; * if (y == 1) * { * packet.Skip(33); * } * else if (y != 1 & y < 3) * packet.Skip(6); * else * { * packet.Skip(3); * break; * } * } * */ while (true) { while (packet.Read() != 0x40) { Thread.Sleep(1); } if (packet.Read() == 0xE0) { break; } Thread.Sleep(1); } while (packet.Read() != 0xFF) { Thread.Sleep(1); } packet.Skip(3); while (true) { while (packet.Read() != 0x40) { Thread.Sleep(1); } if (packet.Read() == 0xE0) { break; } Thread.Sleep(1); } while (packet.Read() != 0x01) { Thread.Sleep(1); } packet.Skip(16); } else { //c.updateLog(mapleItem.ID.ToString() + ", " + mapleItem.price.ToString() + ", " + mapleItem.quantity.ToString() + ", " + "nEquip"); packet.Skip(8); while (true) { if (packet.Read() == 255) { packet.Skip(9); if (isRechargableFamiliar(mapleItem.ID)) { packet.Skip(8); } break; } Thread.Sleep(1); } } } catch (Exception e) { //MessageBox.Show(e.ToString() + "\n\n\n\n" + packet.ToString()); c.updateLog("Error Code: 108"); } }
public IActionResult itemSearch(int itemId) { MapleItem eq = ItemFactory.Search(itemId); return(Json(eq)); }
public void Recalculate(MapleCharacter chr) { int mhpX = 0, mmpX = 0; int mhpR = 0, mmpR = 0; int lv2mhp = 0, lv2mmp = 0; int strR = 0, dexR = 0, intR = 0, lukR = 0; int watk = 0, matk = 9; int damR = 100, pdR = 0; Str = chr.Str + 5; Dex = chr.Dex + 5; Int = chr.Int + 5; Luk = chr.Luk + 5; MinDamage = 0; MaxDamage = 0; AsrR = 0; RecoveryHp = 0; RecoveryMp = 0; RecoveryHpR = 0; RecoveryMpR = 0; RecoveryTime = 0; watk = 3; matk = 3; LifeStealR = 0; LifeStealProp = 0; MpEaterR = 0; MpEaterProp = 0; DoTTimeInc = 0; CostMpR = 0; ExpR = 100; MesoR = 100; DropR = 100; PickPocketR = 0; StunR = 0; AmmoInc = 0; MasteryR = 0; BuffTimeR = 100; PotionEffectR = 100; ElixirEffectR = 100; CritRate = 5; ExpLossReductionR = 0; #region PassiveSkills IEnumerable <Skill> passiveSkills = chr.GetSkillList().Where(x => x.SkillId % 10000 < 1000); foreach (Skill skill in passiveSkills) { if (skill.Level < 1) { continue; } WzCharacterSkill skillInfo = DataBuffer.GetCharacterSkillById(skill.SkillId); if (skillInfo == null) { continue; } SkillEffect effect = skillInfo.GetEffect(skill.Level); if (effect == null) { continue; } foreach (var kvp in effect.Info) { switch (kvp.Key) { case CharacterSkillStat.mhpX: mhpX += kvp.Value; break; case CharacterSkillStat.mmpX: mmpX += kvp.Value; break; case CharacterSkillStat.mhpR: mhpR += kvp.Value; break; case CharacterSkillStat.mmpR: mmpR += kvp.Value; break; case CharacterSkillStat.lv2mhp: lv2mhp += kvp.Value; break; case CharacterSkillStat.lv2mmp: lv2mmp += kvp.Value; break; case CharacterSkillStat.strX: Str += kvp.Value; break; case CharacterSkillStat.dexX: Dex += kvp.Value; break; case CharacterSkillStat.intX: Int += kvp.Value; break; case CharacterSkillStat.lukX: Luk += kvp.Value; break; case CharacterSkillStat.asrR: AsrR += kvp.Value; break; case CharacterSkillStat.mastery: MasteryR = Math.Max(MasteryR, kvp.Value); break; case CharacterSkillStat.costmpR: CostMpR += kvp.Value; break; case CharacterSkillStat.bufftimeR: BuffTimeR += kvp.Value; break; case CharacterSkillStat.padX: watk += kvp.Value; break; case CharacterSkillStat.madX: matk += kvp.Value; break; case CharacterSkillStat.pdR: pdR += kvp.Value; break; case CharacterSkillStat.damR: damR += kvp.Value; break; case CharacterSkillStat.cr: CritRate += kvp.Value; break; } } } #region Specific passive skill handling byte skillLevel; if (chr.IsWarrior) { if ((skillLevel = chr.GetSkillLevel(Swordman.IRON_BODY)) > 0) { mhpR += DataBuffer.CharacterSkillBuffer[Swordman.IRON_BODY].GetEffect(skillLevel).Info[CharacterSkillStat.mhpR]; } if (chr.IsFighter) { if ((skillLevel = chr.GetSkillLevel(Crusader.SELF_RECOVERY)) > 0) { var info = DataBuffer.CharacterSkillBuffer[Crusader.SELF_RECOVERY].GetEffect(skillLevel).Info; RecoveryHp += info[CharacterSkillStat.hp]; RecoveryMp += info[CharacterSkillStat.mp]; } } else if (chr.IsSpearman) { if ((skillLevel = chr.GetSkillLevel(Berserker.LORD_OF_DARKNESS)) > 0) { var info = DataBuffer.CharacterSkillBuffer[Berserker.LORD_OF_DARKNESS].GetEffect(skillLevel).Info; LifeStealProp += info[CharacterSkillStat.prop]; LifeStealR += info[CharacterSkillStat.x]; } } } else if (chr.IsMagician) { if (chr.IsFirePoisonMage) { if ((skillLevel = chr.GetSkillLevel(FirePoison2.SPELL_MASTERY)) > 0) { matk += DataBuffer.CharacterSkillBuffer[FirePoison2.SPELL_MASTERY].GetEffect(skillLevel).Info[CharacterSkillStat.x]; } if ((skillLevel = chr.GetSkillLevel(FirePoison2.MP_EATER)) > 0) { var info = DataBuffer.CharacterSkillBuffer[FirePoison2.MP_EATER].GetEffect(skillLevel).Info; MpEaterProp += info[CharacterSkillStat.prop]; MpEaterR += info[CharacterSkillStat.x]; } } if (chr.IsIceLightningMage) { if ((skillLevel = chr.GetSkillLevel(IceLightning2.MP_EATER)) > 0) { var info = DataBuffer.CharacterSkillBuffer[IceLightning2.MP_EATER].GetEffect(skillLevel).Info; MpEaterProp += info[CharacterSkillStat.prop]; MpEaterR += info[CharacterSkillStat.x]; } if ((skillLevel = chr.GetSkillLevel(IceLightning2.SPELL_MASTERY)) > 0) { matk += DataBuffer.CharacterSkillBuffer[IceLightning2.SPELL_MASTERY].GetEffect(skillLevel).Info[CharacterSkillStat.x]; } } if (chr.IsCleric) { if ((skillLevel = chr.GetSkillLevel(Cleric.MP_EATER)) > 0) { var info = DataBuffer.CharacterSkillBuffer[Cleric.MP_EATER].GetEffect(skillLevel).Info; MpEaterProp += info[CharacterSkillStat.prop]; MpEaterR += info[CharacterSkillStat.x]; } if ((skillLevel = chr.GetSkillLevel(Cleric.SPELL_MASTERY)) > 0) { matk += DataBuffer.CharacterSkillBuffer[Cleric.SPELL_MASTERY].GetEffect(skillLevel).Info[CharacterSkillStat.x]; } if ((skillLevel = chr.GetSkillLevel(Priest.DIVINE_PROTECTION)) > 0) { AsrR += DataBuffer.CharacterSkillBuffer[Priest.DIVINE_PROTECTION].GetEffect(skillLevel).Info[CharacterSkillStat.asrR]; } } } else if (chr.IsArcher) { if (chr.IsHunter) { if ((skillLevel = chr.GetSkillLevel(Bowmaster.BOW_EXPERT)) > 0) { watk += DataBuffer.CharacterSkillBuffer[Bowmaster.BOW_EXPERT].GetEffect(skillLevel).Info[CharacterSkillStat.x]; } } else if (chr.IsCrossbowman) { if ((skillLevel = chr.GetSkillLevel(Marksman.CROSSBOW_EXPERT)) > 0) { watk += DataBuffer.CharacterSkillBuffer[Marksman.CROSSBOW_EXPERT].GetEffect(skillLevel).Info[CharacterSkillStat.x]; } } } else if (chr.IsThief) { if (chr.IsAssassin) { if ((skillLevel = chr.GetSkillLevel(Assassin.CLAW_MASTERY)) > 0) { AmmoInc += DataBuffer.CharacterSkillBuffer[Assassin.CLAW_MASTERY].GetEffect(skillLevel).Info[CharacterSkillStat.y]; } if ((skillLevel = chr.GetSkillLevel(Hermit.ALCHEMIC_ADRENALINE)) > 0) { PotionEffectR += DataBuffer.CharacterSkillBuffer[Hermit.ALCHEMIC_ADRENALINE].GetEffect(skillLevel).Info[CharacterSkillStat.x] - 100; } if ((skillLevel = chr.GetSkillLevel(NightLord.CLAW_EXPERT)) > 0) { watk += DataBuffer.CharacterSkillBuffer[NightLord.CLAW_EXPERT].GetEffect(skillLevel).Info[CharacterSkillStat.x]; } } else if (chr.IsBandit) { if ((skillLevel = chr.GetSkillLevel(Bandit.SHIELD_MASTERY)) > 0) { watk += DataBuffer.CharacterSkillBuffer[Bandit.SHIELD_MASTERY].GetEffect(skillLevel).Info[CharacterSkillStat.y]; } if ((skillLevel = chr.GetSkillLevel(ChiefBandit.MESO_MASTERY)) > 0) { var info = DataBuffer.CharacterSkillBuffer[ChiefBandit.MESO_MASTERY].GetEffect(skillLevel).Info; MesoR += info[CharacterSkillStat.mesoR]; PickPocketR += info[CharacterSkillStat.u]; } if ((skillLevel = chr.GetSkillLevel(Shadower.DAGGER_EXPERT)) > 0) { watk += DataBuffer.CharacterSkillBuffer[Shadower.DAGGER_EXPERT].GetEffect(skillLevel).Info[CharacterSkillStat.x]; } } } else if (chr.IsDualBlade) { if ((skillLevel = chr.GetSkillLevel(DualBlade3p.LIFE_DRAIN)) > 0) { var info = DataBuffer.CharacterSkillBuffer[DualBlade3p.LIFE_DRAIN].GetEffect(skillLevel).Info; LifeStealR += info[CharacterSkillStat.x]; LifeStealProp += info[CharacterSkillStat.prop]; } if ((skillLevel = chr.GetSkillLevel(DualBlade4.KATARA_EXPERT)) > 0) { watk += DataBuffer.CharacterSkillBuffer[DualBlade4.KATARA_EXPERT].GetEffect(skillLevel).Info[CharacterSkillStat.x]; } } else if (chr.IsPirate) { if (chr.IsBrawler) { if ((skillLevel = chr.GetSkillLevel(Brawler.PERSEVERANCE)) > 0) { var info = DataBuffer.CharacterSkillBuffer[Brawler.PERSEVERANCE].GetEffect(skillLevel).Info; int x = info[CharacterSkillStat.x]; RecoveryHpR += x; RecoveryMpR += x; RecoveryTime = info[CharacterSkillStat.y]; } if ((skillLevel = chr.GetSkillLevel(Marauder.STUN_MASTERY)) > 0) { StunR += DataBuffer.CharacterSkillBuffer[Marauder.STUN_MASTERY].GetEffect(skillLevel).Info[CharacterSkillStat.subProp]; } } else if (chr.IsGunslinger) { if ((skillLevel = skillLevel = chr.GetSkillLevel(Gunslinger.GUN_MASTERY)) > 0) { AmmoInc += DataBuffer.CharacterSkillBuffer[Gunslinger.GUN_MASTERY].GetEffect(skillLevel).Info[CharacterSkillStat.y]; } } } else if (chr.IsCannonneer) { if ((skillLevel = chr.GetSkillLevel(Cannoneer3.BARREL_ROULETTE)) > 0) { damR += DataBuffer.CharacterSkillBuffer[Cannoneer3.BARREL_ROULETTE].GetEffect(skillLevel).Info[CharacterSkillStat.damR]; } } else if (chr.IsJett) { /*if ((skillLevel = chr.GetSkillLevel(Jett2.PERSEVERANCE)) > 0) * { * var info = DataBuffer.CharacterSkillBuffer[Jett2.PERSEVERANCE].GetSkillEffect(skillLevel).Info; * int x = info[CharacterSkillStat.x]; * RecoveryHpR += x; * RecoveryMpR += x; * RecoveryTime = info[CharacterSkillStat.y] * 1000; * } */ } #endregion #endregion #region Buffs foreach (Buff buff in chr.GetBuffs()) { var buffInfo = buff.Effect.BuffInfo; foreach (var pair in buffInfo) { //if (pair.Key == MapleBuffStat.ENHANCED_MAXHP || pair.Key == MapleBuffStat.STACKING_MAXHP) //mhpX += pair.Value; if (pair.Key == MapleBuffStat.MAXHP_R || pair.Key == MapleBuffStat.STACKING_MAXHP_R) { mhpR += pair.Value; } //else if (pair.Key == MapleBuffStat.ENHANCED_MAXMP || pair.Key == MapleBuffStat.STACKING_MAXMP) //mmpX += pair.Value; else if (pair.Key == MapleBuffStat.MAXMP_R || pair.Key == MapleBuffStat.STACKING_MAXMP_R) { mmpR += pair.Value; } //else if (pair.Key == MapleBuffStat.WATK || pair.Key == MapleBuffStat.ENHANCED_WATK || pair.Key == MapleBuffStat.STACKING_WATK) //watk += pair.Value; //else if (pair.Key == MapleBuffStat.MATK || pair.Key == MapleBuffStat.ENHANCED_MATK || pair.Key == MapleBuffStat.STACKING_MATK) //matk += pair.Value; //else if (pair.Key == MapleBuffStat.CRIT || pair.Key == MapleBuffStat.STACKING_CRIT) //CritRate += pair.Value; else if (pair.Key == MapleBuffStat.STACKING_STATS) { Str += pair.Value; Dex += pair.Value; Int += pair.Value; Luk += pair.Value; } else if (pair.Key == MapleBuffStat.STACKING_STATS_R) { Str += (int)(chr.Str * (pair.Value / 100.0)); //todo: check if this isnt math.ceil Dex += (int)(chr.Dex * (pair.Value / 100.0)); Int += (int)(chr.Int * (pair.Value / 100.0)); Luk += (int)(chr.Luk * (pair.Value / 100.0)); } //else if (pair.Key == MapleBuffStat.HOLY_SYMBOL) { // ExpR += pair.Value; } } } #endregion #region Equips foreach (MapleItem item in chr.Inventory.GetItemsFromInventory(MapleInventoryType.Equipped)) { MapleEquip equip = item as MapleEquip; if (equip == null) { continue; } mhpX += equip.IncMhp; mmpX += equip.IncMmp; Str += equip.Str; Dex += equip.Dex; Int += equip.Int; Luk += equip.Luk; watk += equip.Pad; matk += equip.Mad; //todo: potential stuff from here } #endregion MaxHp = chr.MaxHp; MaxHp += lv2mhp * chr.Level; MaxHp += (int)((MaxHp) * (mhpR / 100.0)); MaxHp += mhpX; if (chr.Hp > MaxHp) { chr.AddHP(-(chr.Hp - MaxHp)); } MaxMp = chr.MaxMp; MaxMp += (int)(chr.MaxMp * (double)(mmpR / 100.0)); MaxMp += lv2mmp * chr.Level; MaxMp += mhpX; if (chr.Mp > MaxMp) { chr.AddMP(-(chr.Mp - MaxMp)); } Str += (short)(chr.Str * (double)(strR / 100.0)); Dex += (short)(chr.Dex * (double)(dexR / 100.0)); Int += (short)(chr.Int * (double)(intR / 100.0)); Luk += (short)(chr.Luk * (double)(lukR / 100.0)); bool mage = false; int primaryStat = 0; int secondaryStat = 0; MapleItem weapon = chr.Inventory.GetEquippedItem((short)MapleEquipPosition.Weapon); if (weapon == null) { MinDamage = 1; MaxDamage = 1; return; } MapleItemType weaponItemType = ItemConstants.GetMapleItemType(weapon.ItemId); switch ((chr.Job % 1000) / 100) { case 1: //Warrior-type primaryStat = Str; secondaryStat = Dex; break; case 2: //Magician-type case 7: //Luminous primaryStat = Int; secondaryStat = Luk; mage = true; break; case 3: //Archer-type primaryStat = Dex; secondaryStat = Str; break; case 4: //Thief-type primaryStat = Luk; secondaryStat = Dex; break; case 5: //Pirate-type if (weaponItemType == MapleItemType.Gun || weaponItemType == MapleItemType.SoulShooter) { primaryStat = Dex; secondaryStat = Str; } else //counts for cannons too { primaryStat = Str; secondaryStat = Dex; } break; case 6: //Xenon primaryStat = (Str + Dex + Luk); break; } if (!mage) { damR += pdR; //TODO: check, Not sure about this } CalculateDamageRange(weaponItemType, primaryStat, secondaryStat, mage ? matk : watk, damR, chr.IsFighter); }
//Returns false if character doensn't have ammo public static bool HandleRangedAttackAmmoUsage(MapleCharacter chr, int bulletCon) { if (!chr.IsMechanic && !chr.IsMercedes) // Don't use ammo { MapleEquip weapon = chr.Inventory.GetEquippedItem((short)MapleEquipPosition.Weapon) as MapleEquip; MapleItemType weaponType = weapon.ItemType; int ammoItemId = 0; switch (weaponType) { case MapleItemType.Bow: if (!chr.HasBuff(Hunter.SOUL_ARROW_BOW) && !chr.HasBuff(WindArcher2.SOUL_ARROW)) { MapleItem ammoItem = chr.Inventory.GetFirstItemFromInventory(MapleInventoryType.Use, item => item.IsBowArrow && item.Quantity > 0); if (ammoItem == null) { return(false); //player has no bow arrows } ammoItemId = ammoItem.ItemId; } break; case MapleItemType.Crossbow: if (!chr.HasBuff(Crossbowman.SOUL_ARROW_CROSSBOW) && !chr.HasBuff(WildHunter2.SOUL_ARROW_CROSSBOW)) { MapleItem ammoItem = chr.Inventory.GetFirstItemFromInventory(MapleInventoryType.Use, item => item.IsCrossbowArrow && item.Quantity > 0); if (ammoItem == null) { return(false); //player has no xbow arrows } ammoItemId = ammoItem.ItemId; } break; case MapleItemType.Claw: if (!chr.HasBuff(Hermit.SHADOW_STARS) && !chr.HasBuff(NightWalker3.SHADOW_STARS)) { MapleItem ammoItem = chr.Inventory.GetFirstItemFromInventory(MapleInventoryType.Use, item => item.IsThrowingStar && item.Quantity > 0); if (ammoItem == null) { return(false); //player has no bullets } ammoItemId = ammoItem.ItemId; } break; case MapleItemType.Gun: if (!chr.HasBuff(Gunslinger.INFINITY_BLAST)) { MapleItem ammoItem = chr.Inventory.GetFirstItemFromInventory(MapleInventoryType.Use, item => item.IsBullet && item.Quantity > 0); if (ammoItem == null) { return(false); //player has no bullets } ammoItemId = ammoItem.ItemId; } break; } if (ammoItemId > 0) { chr.Inventory.RemoveItemsById(ammoItemId, bulletCon, false); //Even if player only has 1 bullet left and bulletCon is > 1, we'll allow it since it removes the item or stack anyway } } return(true); }
private static void HandleAttackInfo(MapleClient c, AttackInfo attackInfo, SendHeader type, SkillEffect effect) { //Anti-cheat //c.CheatTracker.Trigger(AntiCheat.TriggerType.Attack); WzCharacterSkill wzSkill = effect != null ? effect.Parent : null; MapleCharacter chr = c.Account.Character; if (attackInfo.SkillId > 0) { if (!SkillEffect.CheckAndApplySkillEffect(c.Account.Character, attackInfo.SkillId, wzSkill, -1, attackInfo.Targets, attackInfo.Attacks)) { return; } } chr.Map.BroadcastPacket(GenerateAttackInfo(type, c.Account.Character, attackInfo), c.Account.Character, false); long totalDamage = 0; #region DoTs and Pickpocket int pickPocketProp = 0; int dotSkillId = 0; int dotChance = 0; int dotDamage = 0; int dotTimeMS = 0; int dotMaxStacks = 1; #region Thief if (chr.IsThief) { byte venomSkillLevel = 0; if (chr.IsBandit) { Buff pickPocket = chr.GetBuff(ChiefBandit.PICKPOCKET); if (pickPocket != null) { pickPocketProp = pickPocket.Effect.Info[CharacterSkillStat.prop]; } venomSkillLevel = chr.GetSkillLevel(ChiefBandit.VENOM); if (venomSkillLevel > 0) { dotSkillId = ChiefBandit.VENOM; byte toxicVenomSkillLevel = chr.GetSkillLevel(Shadower.TOXIC_VENOM); if (toxicVenomSkillLevel > 0) { venomSkillLevel = toxicVenomSkillLevel; dotSkillId = Shadower.TOXIC_VENOM; } } } else if (chr.IsAssassin) { #region Assassin venomSkillLevel = chr.GetSkillLevel(Hermit.VENOM); if (venomSkillLevel > 0) { dotSkillId = Hermit.VENOM; byte toxicVenomSkillLevel = chr.GetSkillLevel(NightLord.TOXIC_VENOM); if (toxicVenomSkillLevel > 0) { venomSkillLevel = toxicVenomSkillLevel; dotSkillId = NightLord.TOXIC_VENOM; } } #endregion } else if (chr.IsDualBlade) { #region DualBlade venomSkillLevel = chr.GetSkillLevel(DualBlade3.VENOM); if (venomSkillLevel > 0) { dotSkillId = DualBlade3.VENOM; byte toxicVenomSkillLevel = chr.GetSkillLevel(DualBlade4.TOXIC_VENOM); if (toxicVenomSkillLevel > 0) { venomSkillLevel = toxicVenomSkillLevel; dotSkillId = DualBlade4.TOXIC_VENOM; } } #endregion } if (venomSkillLevel > 0) { SkillEffect venomEffect = DataBuffer.GetCharacterSkillById(dotSkillId).GetEffect(venomSkillLevel); dotChance = venomEffect.Info[CharacterSkillStat.prop]; dotDamage = (int)(chr.Stats.GetDamage() * (venomEffect.Info[CharacterSkillStat.dot] / 100.0)); dotTimeMS = venomEffect.Info[CharacterSkillStat.dotTime] * 1000; if (!venomEffect.Info.TryGetValue(CharacterSkillStat.dotSuperpos, out dotMaxStacks)) { dotMaxStacks = 1; } } } #endregion if (attackInfo.SkillId > 0 && effect.Info.TryGetValue(CharacterSkillStat.dot, out dotDamage)) //Skill has/is dot { dotTimeMS = effect.Info[CharacterSkillStat.dotTime] * 1000; if (!effect.Info.TryGetValue(CharacterSkillStat.prop, out dotChance)) { dotChance = 100; } dotSkillId = attackInfo.SkillId; dotDamage = (int)(chr.Stats.GetDamage() * (dotDamage / 100.0)); if (!effect.Info.TryGetValue(CharacterSkillStat.dotSuperpos, out dotMaxStacks)) { dotMaxStacks = 1; } } #endregion foreach (AttackPair ap in attackInfo.TargetDamageList) { MapleMonster mob = chr.Map.GetMob(ap.TargetObjectId); if (mob != null && mob.Alive) { long totalMobDamage = 0; foreach (int damage in ap.Damage) { totalMobDamage += damage; } if (totalMobDamage > 0) { totalDamage += totalMobDamage; if (totalDamage > int.MaxValue) { totalDamage = int.MaxValue; } #region Status effects if (effect != null) { foreach (MonsterBuffApplication mba in effect.MonsterBuffs) { if (Functions.MakeChance(mba.Prop)) { foreach (var kvp in mba.Buffs) { mob.ApplyStatusEffect(attackInfo.SkillId, kvp.Key, kvp.Value, mba.Duration, chr); } } } } #endregion #region MP Eater if (chr.Stats.MpEaterProp > 0) { if (Functions.MakeChance(chr.Stats.MpEaterProp)) { int mpSteal = (int)((chr.Stats.MpEaterR / 100.0) * mob.WzInfo.MP); chr.AddMP(mpSteal); } } #endregion #region Bandit if (chr.IsBandit) { if (Functions.MakeChance(pickPocketProp)) { chr.Map.SpawnMesoMapItem(1, mob.Position, chr.Map.GetDropPositionBelow(mob.Position, mob.Position), false, MapleDropType.Player, chr); } if (attackInfo.SkillId == Bandit.STEAL) { int prop = DataBuffer.GetCharacterSkillById(Bandit.STEAL).GetEffect(chr.GetSkillLevel(Bandit.STEAL)).Info[CharacterSkillStat.prop]; if (Functions.MakeChance(prop)) { MapleItem item = mob.TryGetStealableItem(chr.Id, chr.Name); if (item != null) { chr.Map.SpawnMapItem(item, mob.Position, chr.Map.GetDropPositionBelow(chr.Position, mob.Position), false, Map.MapleDropType.Player, chr); } } } } #endregion if (Functions.MakeChance(dotChance)) { mob.ApplyPoison(dotSkillId, dotTimeMS, dotDamage, 1000, chr, dotMaxStacks); } mob.Damage(chr, (int)totalDamage); } } } #region special skill handling if (type == SendHeader.RangedAttack) { if (attackInfo.Targets > 0 && chr.IsHunter) { #region QuiverCartridge QuiverCartridgeSystem qcs = chr.Resource as QuiverCartridgeSystem; if (qcs != null && qcs.ChosenArrow > -1) { int usedArrow = qcs.HandleUse(c); switch (usedArrow) { case 0: // Blood if (Functions.MakeChance(50)) //50% chance to heal 20% of damage as hp { chr.AddHP((int)(totalDamage * 0.2)); } break; case 1: // Poison //TODO: poison, 90% damage, 8 seconds, stacks 3 times break; case 2: // Magic, don't need handling I think break; } } #endregion } } if (totalDamage > 0) { BuffedCharacterStats stats = chr.Stats; if (stats.LifeStealProp > 0 && stats.LifeStealR > 0) { if (Functions.MakeChance(stats.LifeStealProp)) { int lifesteal = (int)((stats.LifeStealR / 100.0) * totalDamage); chr.AddHP(lifesteal); } } if (chr.IsMagician) { #region ArcaneAim int arcaneAimId = 0; if (chr.Job == JobConstants.FIREPOISON4) { arcaneAimId = FirePoison4.ARCANE_AIM; } else if (chr.Job == JobConstants.ICELIGHTNING4) { arcaneAimId = IceLightning4.ARCANE_AIM; } else if (chr.Job == JobConstants.BISHOP) { arcaneAimId = Bishop.ARCANE_AIM; } if (arcaneAimId > 0) { byte skillLevel = chr.GetSkillLevel(arcaneAimId); if (skillLevel > 0) { if ((DateTime.UtcNow.Subtract(chr.LastAttackTime).TotalMilliseconds) < 5000) { Buff oldBuff = chr.GetBuff(arcaneAimId); if (oldBuff != null) { int prop = oldBuff.Effect.Info[CharacterSkillStat.prop]; if (Functions.MakeChance(prop)) { Buff newBuff = new Buff(arcaneAimId, oldBuff.Effect, oldBuff.Duration, chr); int oldStacks = oldBuff.Stacks / 6; newBuff.Stacks = Math.Min(30, (oldStacks + 1) * 6); chr.GiveBuff(newBuff); } } else { SkillEffect arcaneAimEffect = DataBuffer.GetCharacterSkillById(arcaneAimId).GetEffect(skillLevel); int prop = arcaneAimEffect.Info[CharacterSkillStat.prop]; if (Functions.MakeChance(prop)) { Buff newBuff = new Buff(arcaneAimId, arcaneAimEffect, 5000, chr); newBuff.Stacks = 6; chr.GiveBuff(newBuff); } } } } } #endregion } else if (chr.IsThief) { if (chr.IsBandit) { chr.IncreaseCriticalGrowth(true); byte skillLevel = chr.GetSkillLevel(Shadower.SHADOWER_INSTINCT); if (skillLevel > 0) { ((BodyCountSystem)chr.Resource).IncreaseBodyCount(c); } } } } #endregion chr.LastAttackTime = DateTime.UtcNow; }
public TradeItem(MapleItem item, short count) { Count = count; Item = item; }
public static void HandleCraftDone(MapleClient c, PacketReader pr) { int craftId = pr.ReadInt(); MapleCharacter Chr = c.Account.Character; int skillId = (int)(10000 * Math.Floor((decimal)craftId / 10000)); WzRecipe recipeInfo = DataBuffer.GetCraftRecipeById(craftId); if (recipeInfo == null) { return; //Recipe not found, wierd, can happen due to packet edit } if (!EffectList.ContainsValue(skillId)) { return; //Should not happen unless if theres a packet edit or an update to the info compared to the code } if (!Chr.HasSkill(skillId) && Chr.HasSkill(recipeInfo.ReqSkill)) { return; //Obviously packet edit } if (Chr.Map.MapId != 910001000 && (craftId % 92049000 > 7)) { return; //Not in ardentmill, nor placing an extractor/fusing } if (Chr.GetSkillLevel(skillId) < recipeInfo.ReqSkillLevel) { return; //Not the correct level } if ((200 - Chr.Fatigue - recipeInfo.IncFatigue) < 0) { return; //Todo: show a message? } skillId = recipeInfo.ReqSkill; //Just to be sure Chr.Fatigue += recipeInfo.IncFatigue; if (craftId % 92049000 > 0 && craftId % 92049000 < 7) { //Todo: Add code for disassembling/fusing //Todo: Figure out what CraftId % 92049000 >= 2 do switch (craftId % 92049000) { case 0: int ExtractorId = pr.ReadInt(); int ItemId = pr.ReadInt(); long InventoryId = pr.ReadLong(); break; //disassembling case 1: ItemId = pr.ReadInt(); InventoryId = pr.ReadLong(); long InventoryId2 = pr.ReadLong(); break; //fusing } return; } if (recipeInfo.CreateItems.Count == 0) { return; } //Remove items bool HasItems = true; foreach (WzRecipe.Item Item in recipeInfo.ReqItems) { HasItems &= Chr.Inventory.HasItem(Item.ItemId, Item.Count); } if (!HasItems) { return; //Todo: show message? "not enough items", though this smells like PE } foreach (WzRecipe.Item Item in recipeInfo.ReqItems) { Chr.Inventory.RemoveItemsById(Item.ItemId, Item.Count); } //Calculate what items to get //Todo: check with older sources to check if proccess aint missing any orignal functionality int TotalChance = recipeInfo.CreateItems.Where(x => x.Chance != 100).Sum(x => x.Chance); List <WzRecipe.Item> SuccesedItems = new List <WzRecipe.Item>(); SuccesedItems.AddRange(recipeInfo.CreateItems.Where(x => x.Chance == 100)); if (TotalChance == 0) { SuccesedItems.AddRange(recipeInfo.CreateItems.Where(x => x.Chance != 100)); } else { Dictionary <int, int> ChanceCalc = new Dictionary <int, int>(); int Last = 0; foreach (WzRecipe.Item Item in recipeInfo.CreateItems.Where(x => x.Chance != 100)) { if (ChanceCalc.ContainsKey(Item.ItemId)) { continue; } ChanceCalc.Add(Item.ItemId, Item.Chance + Last); Last += Item.Chance; } Random RandomCalc = new Random(); int PickItem = RandomCalc.Next(TotalChance); SuccesedItems.Add(recipeInfo.CreateItems.FirstOrDefault(x => x.ItemId == ChanceCalc.FirstOrDefault(cc => cc.Value >= PickItem).Key)); } if (SuccesedItems.Count == 0) { return; //Something went wrong } //Give character the new item(s) foreach (WzRecipe.Item Item in SuccesedItems) { MapleItem CreateItem = MapleItemCreator.CreateItem(Item.ItemId, "Crafting with skill " + skillId, Item.Count, true); Chr.Inventory.AddItem(CreateItem, CreateItem.InventoryType, true); } //Give character his Exp //Todo: check if character is given a junk item and lower the exp gained Skill CraftSkill = Chr.GetSkill(skillId); int ReqLvlExp = 50 * CraftSkill.Level ^ 2 + 200 * CraftSkill.Level; if (ReqLvlExp < CraftSkill.SkillExp + recipeInfo.IncProficiency) { int ExpLeft = (CraftSkill.SkillExp + recipeInfo.IncProficiency) % ReqLvlExp; Chr.SetSkillLevel(skillId, (byte)(CraftSkill.Level + 1)); Chr.SetSkillExp(skillId, (short)ExpLeft); //Todo: broadcast levelup message } else { Chr.SetSkillExp(skillId, (short)(CraftSkill.SkillExp + recipeInfo.IncProficiency)); } //Todo: figure out craftrankings MapleCharacter.UpdateSingleStat(c, MapleCharacterStat.Fatigue, recipeInfo.IncFatigue); Chr.Map.BroadcastPacket(ShowCraftComplete(Chr.Id, craftId, 23, SuccesedItems[0].ItemId, SuccesedItems[0].Count, recipeInfo.IncProficiency)); }
public static void Handle(MapleClient c, PacketReader pr) { try { if (c.NpcEngine != null && c.NpcEngine.IsShop) { byte mode = pr.ReadByte(); int NpcId = c.NpcEngine.NpcId; switch (mode) { case 0: { short shopIndex = pr.ReadShort(); int itemId = pr.ReadInt(); short amount = pr.ReadShort(); c.NpcEngine.BuyItem(itemId, shopIndex, amount); break; } case 1: //sell { short inventoryIndex = pr.ReadShort(); int itemId = pr.ReadInt(); short qty = pr.ReadShort(); MapleInventoryType invType = ItemConstants.GetInventoryType(itemId); switch (invType) { case MapleInventoryType.Equip: case MapleInventoryType.Etc: case MapleInventoryType.Setup: case MapleInventoryType.Use: break; default: return; // Not a valid item } WzItem wzitem = DataBuffer.GetItemById(itemId); if (wzitem == null) { wzitem = DataBuffer.GetEquipById(itemId); } if (wzitem == null) // Item doesnt exist (anymore?) { return; } if (wzitem.NotSale || wzitem.IsCashItem || wzitem.IsQuestItem) { return; } byte response = 0; if (!wzitem.IsQuestItem) { MapleInventory inventory = c.Account.Character.Inventory; MapleItem item = inventory.GetItemSlotFromInventory(invType, inventoryIndex); if (item?.ItemId == itemId && item.Quantity >= qty) { if (inventory.Mesos + wzitem.Price > GameConstants.MAX_MESOS) { response = 2; // You do not have enough mesos } else { inventory.RemoveItemsFromSlot(item.InventoryType, item.Position, qty, true); inventory.GainMesos(wzitem.Price * qty, false, false); } // TODO: buyback } } PacketWriter pw = new PacketWriter(); pw.WriteHeader(SendHeader.NpcTransaction); pw.WriteByte(response); pw.WriteByte(0); pw.WriteByte(0); c.SendPacket(pw); break; } case 3: { c.NpcEngine.Dispose(); break; } default: { c.NpcEngine.ScriptInstance = null; ServerConsole.Warning("Unkown NpcShopActionHandler mode:" + mode); ServerConsole.Info(Functions.ByteArrayToStr(pr.ToArray())); break; } } } } catch (Exception ex) { ServerConsole.Error("NpcShopActionHandler Failure"); ServerConsole.Error(ex.Message); if (c.NpcEngine != null) { c.NpcEngine.Dispose(); } } }
public static void Handle(MapleClient c, PacketReader pr) { MapleCharacter chr = c.Account.Character; if (!chr.DisableActions()) { return; } int tickCount = pr.ReadInt(); short slot = pr.ReadShort(); int itemId = pr.ReadInt(); MapleItem item = chr.Inventory.GetItemSlotFromInventory(ItemConstants.GetInventoryType(itemId), slot); bool removeItem = true; if (item == null || item.ItemId != itemId) { return; } switch (itemId) { case 5062006: //Platinum Miracle Cube { int equipSlot = pr.ReadInt(); if (equipSlot < 0) { return; } MapleEquip equip = chr.Inventory.GetItemSlotFromInventory(MapleInventoryType.Equip, (short)equipSlot) as MapleEquip; if (equip == null) { return; } if (!MapleEquipEnhancer.CubeItem(equip, CubeType.PlatinumMiracle, chr)) { removeItem = false; } break; } case 5072000: //Super Megaphone case 5072001: //Super Megaphone { if (!CanMegaPhone(c.Account.Character)) { chr.EnableActions(); break; } string message = pr.ReadMapleString(); if (message.Length > 60) { return; } bool whisperIcon = pr.ReadBool(); message = string.Format("{0} : {1}", c.Account.Character.Name, message); Program.BroadCastWorldPacket(MapleCharacter.ServerNotice(message, 3, c.Channel, whisperIcon)); break; } case 5570000: //Vicious hammer { removeItem = false; //Handled in UseGoldenHammerHandler pr.Skip(4); short equipSlot = (short)pr.ReadInt(); MapleEquip equip = chr.Inventory.GetItemSlotFromInventory(MapleInventoryType.Equip, equipSlot) as MapleEquip; if (equip != null) { UseGoldenHammerHandler.DoHammer(item, equip, chr); } break; } default: { ServerConsole.Warning("Unhandled UseSpecialItem: {0}", itemId); removeItem = false; chr.SendPopUpMessage("You cannot use this item"); chr.EnableActions(); break; } } if (removeItem) { chr.Inventory.RemoveItemsFromSlot(item.InventoryType, item.Position, 1); } chr.EnableActions(false); }
public static void Handle(MapleClient c, PacketReader pr) { MapleCharacter chr = c.Account.Character; pr.ReadInt();//timestamp int characterId = pr.ReadInt(); MapleCharacter target = chr.Map.GetCharacter(characterId); if (target != null && !target.Hidden) { PacketWriter pw = new PacketWriter(SendHeader.CharacterInfo); pw.WriteInt(target.Id); pw.WriteByte(0); //v158 pw.WriteByte(target.Level); pw.WriteShort(target.Job); pw.WriteShort(target.SubJob); pw.WriteByte(10);//pvpRank pw.WriteInt(target.Fame); pw.WriteByte(0); pw.WriteByte(0); //count of professions stats for (int i = 0; i < 0; i++) //count of professions stats { pw.WriteShort(0); //profession value } if (target.Guild != null) { pw.WriteMapleString(target.Guild.Name); } else { pw.WriteMapleString("-"); } pw.WriteShort(0); //alliance name pw.WriteByte(0xFF); //pet stuff pw.WriteByte(0); pw.WriteByte(0); /* * for (MaplePet pet : chr.getPets()) { * if (pet.getSummoned()) { * mplew.write(index); * mplew.writeInt(pet.getPetItemId()); * mplew.writeMapleAsciiString(pet.getName()); * mplew.write(30); * mplew.writeShort(30000); * mplew.write(100); * // mplew.write(pet.getLevel()); * // mplew.writeShort(pet.getCloseness()); * // mplew.write(pet.getFullness()); * mplew.writeShort(0); * Item inv = chr.getInventory(MapleInventoryType.EQUIPPED).getItem((short) (byte) (index == 1 ? -114 : index == 2 ? -130 : -138)); * mplew.writeInt(inv == null ? 0 : inv.getItemId()); * mplew.writeInt(-1); * index = (byte) (index + 1); * } * }*/ pw.WriteByte(0); /* * if ((chr.getInventory(MapleInventoryType.EQUIPPED).getItem((byte) -18) != null) && (chr.getInventory(MapleInventoryType.EQUIPPED).getItem((byte) -19) != null)) { * MapleMount mount = chr.getMount(); * mplew.write(1); * mplew.writeInt(mount.getLevel()); * mplew.writeInt(mount.getExp()); * mplew.writeInt(mount.getFatigue()); * } else { * mplew.write(0);//no mount * }*/ pw.WriteByte(0); //no mount /*int wishlistSize = 0; * pw.WriteByte((byte)wishlistSize); * for (int i = 0; i < wishlistSize; i++) * { * // mplew.writeInt(wishlist[x]); * }*/ MapleItem item = chr.Inventory.GetEquippedItem(0xD2); //medal if (item == null) { pw.WriteInt(0); } else { pw.WriteInt(item.ItemId); } pw.WriteShort(0);//medals size /* * mplew.writeShort(medalQuests.size()); * for (Pair<Integer, Long> x : medalQuests) { * mplew.writeShort(x.left); * mplew.writeLong(x.right); // Gain Filetime * } */ pw.WriteZeroBytes(6);//each byte is a level of a trait pw.WriteInt(target.AccountId); pw.WriteMapleString("Creating..."); //name of farm, creating... = not made yet pw.WriteInt(0); //coins pw.WriteInt(0); //level pw.WriteInt(0); //exp pw.WriteInt(0); //clovers pw.WriteInt(0); //diamonds nx currency pw.WriteByte(0); //kitty power pw.WriteZeroBytes(20); List <MapleItem> chairs = chr.Inventory.GetItemsFromInventory(MapleInventoryType.Setup, x => x.ItemType == MapleItemType.Chair); List <int> chairIds = new List <int>(); foreach (MapleItem chair in chairs) { if (!chairIds.Contains(chair.ItemId)) { chairIds.Add(chair.ItemId); } } pw.WriteInt(chairIds.Count); foreach (var id in chairIds) { pw.WriteInt(id); } c.SendPacket(pw); pw = new PacketWriter(SendHeader.CharacterInfoFarmImage); pw.WriteInt(chr.AccountId); pw.WriteInt(0); //image data here c.SendPacket(pw); } }
public MapleItem Search(int id, Func <int, int[]> getDroppedBy) { WZProperty stringWz = WZ.Resolve("String"); string idString = id.ToString(); MapleItem result = null; WZProperty item = (stringWz.Resolve("Eqp/Eqp") ?? stringWz.Resolve("Item/Eqp")).Children.FirstOrDefault(c => c.Children.Any(b => b.NameWithoutExtension.Equals(idString)))?.Resolve(idString); if (item != null) { result = Equip.Parse(item); } if (result == null) { item = (stringWz.Resolve("Etc/Etc") ?? stringWz.Resolve("Item/Etc"))?.Resolve(idString); if (item != null) { result = Etc.Parse(item); } } if (result == null) { item = (stringWz.Resolve("Ins") ?? stringWz.Resolve("Item/Ins")).Resolve(idString); if (item != null) { result = Install.Parse(item); } } if (result == null) { item = (stringWz.Resolve("Cash") ?? stringWz.Resolve("Item/Cash")).Resolve(idString); if (item != null) { result = Cash.Parse(item); } } if (result == null) { item = (stringWz.Resolve("Consume") ?? stringWz.Resolve("Item/Con")).Resolve(idString); if (item != null) { result = Consume.Parse(item); } } if (result == null) { item = (stringWz.Resolve("Pet") ?? stringWz.Resolve("Item/Pet")).Resolve(idString); if (item != null) { result = Pet.Parse(item); } } MobFactory mobs = new MobFactory(); mobs.CloneWZFrom(this); if (result != null && result.MetaInfo != null) { result.MetaInfo.DroppedBy = getDroppedBy(id)?.Join(mobs.GetMobs().Where(c => c != null), c => c, c => c.Id, (a, b) => b)?.ToArray(); } return(result); }
private static bool GetAndCheckItemsFromInventory(MapleInventory inventory, short equipSlot, short scrollSlot, out MapleEquip equip, out MapleItem scroll) { MapleInventoryType equipInventory = equipSlot < 0 ? MapleInventoryType.Equipped : MapleInventoryType.Equip; equip = inventory.GetItemSlotFromInventory(equipInventory, equipSlot) as MapleEquip; scroll = inventory.GetItemSlotFromInventory(MapleInventoryType.Use, scrollSlot); return(equip != null && scroll != null); }
public static void Handle(MapleClient c, PacketReader pr) { MapleCharacter chr = c.Account.Character; if (!chr.DisableActions()) { return; } int tickCount = pr.ReadInt(); short magnifySlot = pr.ReadShort(); short equipSlot = pr.ReadShort(); MapleItem magnifyer = null; MapleEquip equip = c.Account.Character.Inventory.GetItemSlotFromInventory(MapleInventoryType.Equip, equipSlot) as MapleEquip; if (magnifySlot != 0x7F) // Using magnify button in inventory sends 0x007F as the slot { magnifyer = chr.Inventory.GetItemSlotFromInventory(MapleInventoryType.Use, magnifySlot); if (magnifyer == null) { return; //todo: check if it's a magnifying glass } } if (equip == null) { return; } WzEquip equipInfo = DataBuffer.GetEquipById(equip.ItemId); if (equipInfo == null) { return; } if (equip.PotentialState >= MaplePotentialState.HiddenRare && equip.PotentialState <= MaplePotentialState.HiddenLegendary) { long price = equipInfo.RevealPotentialCost; ServerConsole.Debug("pot cost: " + price); if (chr.Mesos < price) { chr.SendPopUpMessage(string.Format("You do not have {0} mesos", price)); chr.EnableActions(); } else { chr.Inventory.RemoveMesos(price); equip.PotentialState += 16; if (magnifyer != null) { chr.Inventory.RemoveItemsFromSlot(magnifyer.InventoryType, magnifyer.Position, 1); } c.SendPacket(MapleInventory.Packets.AddItem(equip, equip.InventoryType, equip.Position)); chr.Map.BroadcastPacket(MagnifyEffectPacket(chr.Id, equip.Position, true), chr, true); chr.EnableActions(false); } } else { chr.SendPopUpMessage("You cannot use that on this item"); chr.EnableActions(); } }