public void DropItemByMonster(DropDTO drop, short mapX, short mapY) { Random rnd = new Random((int)DateTime.Now.Ticks & 0x0000FFFF); int random = 0; MapItem droppedItem = null; short MapX = (short)(rnd.Next(mapX - 1, mapX + 1)); short MapY = (short)(rnd.Next(mapY - 1, mapY + 1)); while (IsBlockedZone(MapX, MapY)) { MapX = (short)(rnd.Next(mapX - 1, mapX + 1)); MapY = (short)(rnd.Next(mapY - 1, mapY + 1)); } ItemInstance newInstance = InventoryList.CreateItemInstance(drop.ItemVNum, 0); newInstance.Amount = drop.Amount; droppedItem = new MapItem(MapX, MapY, true) { ItemInstance = newInstance }; while (ServerManager.GetMap(MapId).DroppedList.ContainsKey(random = rnd.Next(1, 999999))) { } droppedItem.ItemInstance.ItemInstanceId = random; ServerManager.GetMap(MapId).DroppedList.Add(random, droppedItem); Broadcast($"drop {droppedItem.ItemInstance.ItemVNum} {random} {droppedItem.PositionX} {droppedItem.PositionY} {droppedItem.ItemInstance.Amount} 0 0 -1"); }
public void DropItemByMonster(long?Owner, DropDTO drop, short mapX, short mapY) { try { MapItem droppedItem = null; short localMapX = (short)(_random.Next(mapX - 1, mapX + 1)); short localMapY = (short)(_random.Next(mapY - 1, mapY + 1)); List <MapCell> Possibilities = new List <MapCell>(); for (short x = -1; x < 2; x++) { for (short y = -1; y < 2; y++) { Possibilities.Add(new MapCell() { X = x, Y = y }); } } foreach (MapCell possibilitie in Possibilities.OrderBy(s => _random.Next())) { localMapX = (short)(mapX + possibilitie.X); localMapY = (short)(mapY + possibilitie.Y); if (!IsBlockedZone(localMapX, localMapY)) { break; } } ItemInstance newInstance = InventoryList.CreateItemInstance(drop.ItemVNum); newInstance.Amount = drop.Amount; droppedItem = new MapItem(localMapX, localMapY) { ItemInstance = newInstance, Owner = Owner }; // rarify if (droppedItem.ItemInstance.Item.EquipmentSlot == (byte)EquipmentType.Armor || droppedItem.ItemInstance.Item.EquipmentSlot == (byte)EquipmentType.MainWeapon || droppedItem.ItemInstance.Item.EquipmentSlot == (byte)EquipmentType.SecondaryWeapon) { droppedItem.Rarify(null); } DroppedList.TryAdd(droppedItem.ItemInstance.TransportId, droppedItem); // TODO: UseTransportId Broadcast($"drop {droppedItem.ItemInstance.ItemVNum} {droppedItem.ItemInstance.TransportId} {droppedItem.PositionX} {droppedItem.PositionY} {droppedItem.ItemInstance.Amount} 0 0 -1"); } catch (Exception e) { Logger.Error(e); } }
public void DropItemByMonster(long?Owner, DropDTO drop, short mapX, short mapY) { try { Random rnd = new Random((int)DateTime.Now.Ticks & 0x0000FFFF); MapItem droppedItem = null; short localMapX = (short)(rnd.Next(mapX - 1, mapX + 1)); short localMapY = (short)(rnd.Next(mapY - 1, mapY + 1)); while (IsBlockedZone(localMapX, localMapY)) { localMapX = (short)(rnd.Next(mapX - 1, mapX + 1)); localMapY = (short)(rnd.Next(mapY - 1, mapY + 1)); } ItemInstance newInstance = InventoryList.CreateItemInstance(drop.ItemVNum); newInstance.Amount = drop.Amount; droppedItem = new MapItem(localMapX, localMapY) { ItemInstance = newInstance, Owner = Owner }; //rarify if (droppedItem.ItemInstance.Item.EquipmentSlot == (byte)EquipmentType.Armor || droppedItem.ItemInstance.Item.EquipmentSlot == (byte)EquipmentType.MainWeapon || droppedItem.ItemInstance.Item.EquipmentSlot == (byte)EquipmentType.SecondaryWeapon) { droppedItem.Rarify(null); } DroppedList.TryAdd(droppedItem.ItemInstance.TransportId, droppedItem); Broadcast($"drop {droppedItem.ItemInstance.ItemVNum} {droppedItem.ItemInstance.TransportId} {droppedItem.PositionX} {droppedItem.PositionY} {droppedItem.ItemInstance.Amount} 0 0 -1");//TODO UseTransportId } catch (Exception e) { Logger.Error(e); } }
public static void NRun(ClientSession Session, byte type, short runner, short data3, short npcid) { MapNpc npc = Session.CurrentMap.Npcs.FirstOrDefault(s => s.MapNpcId == npcid); switch (runner) { case 1: if (Session.Character.Class != (byte)ClassType.Adventurer) { Session.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("NOT_ADVENTURER"), 0)); return; } if (Session.Character.Level < 15 || Session.Character.JobLevel < 20) { Session.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("LOW_LVL"), 0)); return; } if (type == Session.Character.Class) { return; } if (!Session.Character.EquipmentList.Inventory.Any()) { ItemInstance newItem1 = InventoryList.CreateItemInstance((short)(4 + type * 14)); Session.Character.EquipmentList.AddToInventoryWithSlotAndType(newItem1, InventoryType.Equipment, newItem1.Item.EquipmentSlot); ItemInstance newItem2 = InventoryList.CreateItemInstance((short)(81 + type * 13)); Session.Character.EquipmentList.AddToInventoryWithSlotAndType(newItem2, InventoryType.Equipment, newItem2.Item.EquipmentSlot); switch (type) { case 1: ItemInstance newItem68 = InventoryList.CreateItemInstance(68); Session.Character.EquipmentList.AddToInventoryWithSlotAndType(newItem68, InventoryType.Equipment, newItem68.Item.EquipmentSlot); Session.Character.InventoryList.AddNewItemToInventory(2082, 10); break; case 2: ItemInstance newItem78 = InventoryList.CreateItemInstance(78); Session.Character.EquipmentList.AddToInventoryWithSlotAndType(newItem78, InventoryType.Equipment, newItem78.Item.EquipmentSlot); Session.Character.InventoryList.AddNewItemToInventory(2083, 10); break; case 3: ItemInstance newItem86 = InventoryList.CreateItemInstance(86); Session.Character.EquipmentList.AddToInventoryWithSlotAndType(newItem86, InventoryType.Equipment, newItem86.Item.EquipmentSlot); break; } Session.CurrentMap?.Broadcast(Session.Character.GenerateEq()); Session.SendPacket(Session.Character.GenerateEquipment()); Session.Character.ChangeClass(Convert.ToByte(type)); } else { Session.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("EQ_NOT_EMPTY"), 0)); } break; case 2: Session.SendPacket($"wopen 1 0"); break; case 10: Session.SendPacket($"wopen 3 0"); break; case 12: Session.SendPacket($"wopen {type} 0"); break; case 14: Session.SendPacket($"wopen 27 0"); string recipelist = "m_list 2"; if (npc != null) { List <Recipe> tp = npc.Recipes; foreach (Recipe rec in tp.Where(s => s.Amount > 0)) { recipelist += String.Format(" {0}", rec.ItemVNum); } recipelist += " -100"; Session.SendPacket(recipelist); } break; case 16: if (npc != null) { TeleporterDTO tp = npc.Teleporters?.FirstOrDefault(s => s.Index == type); if (tp != null) { if (Session.Character.Gold >= 1000 * type) { ServerManager.Instance.MapOut(Session.Character.CharacterId); Session.Character.Gold -= 1000 * type; Session.SendPacket(Session.Character.GenerateGold()); Session.Character.MapY = tp.MapY; Session.Character.MapX = tp.MapX; Session.Character.MapId = tp.MapId; ServerManager.Instance.ChangeMap(Session.Character.CharacterId); } else { Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_ENOUGH_MONEY"), 10)); } } } break; case 26: if (npc != null) { TeleporterDTO tp = npc.Teleporters?.FirstOrDefault(s => s.Index == type); if (tp != null) { if (Session.Character.Gold >= 5000 * type) { ServerManager.Instance.MapOut(Session.Character.CharacterId); Session.Character.Gold -= 5000 * type; Session.SendPacket(Session.Character.GenerateGold()); Session.Character.MapY = tp.MapY; Session.Character.MapX = tp.MapX; Session.Character.MapId = tp.MapId; ServerManager.Instance.ChangeMap(Session.Character.CharacterId); } else { Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_ENOUGH_MONEY"), 10)); } } } break; case 45: if (npc != null) { TeleporterDTO tp = npc.Teleporters?.FirstOrDefault(s => s.Index == type); if (tp != null) { if (Session.Character.Gold >= 500) { ServerManager.Instance.MapOut(Session.Character.CharacterId); Session.Character.Gold -= 500; Session.SendPacket(Session.Character.GenerateGold()); Session.Character.MapY = tp.MapY; Session.Character.MapX = tp.MapX; Session.Character.MapId = tp.MapId; ServerManager.Instance.ChangeMap(Session.Character.CharacterId); } else { Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_ENOUGH_MONEY"), 10)); } } } break; case 132: if (npc != null) { TeleporterDTO tp = npc.Teleporters?.FirstOrDefault(s => s.Index == type); if (tp != null) { ServerManager.Instance.MapOut(Session.Character.CharacterId); Session.Character.MapY = tp.MapY; Session.Character.MapX = tp.MapX; Session.Character.MapId = tp.MapId; ServerManager.Instance.ChangeMap(Session.Character.CharacterId); } } break; case 301: if (npc != null) { TeleporterDTO tp = npc.Teleporters?.FirstOrDefault(s => s.Index == type); if (tp != null) { ServerManager.Instance.MapOut(Session.Character.CharacterId); Session.Character.MapY = tp.MapY; Session.Character.MapX = tp.MapX; Session.Character.MapId = tp.MapId; ServerManager.Instance.ChangeMap(Session.Character.CharacterId); } } break; case 5002: if (npc != null) { TeleporterDTO tp = npc.Teleporters?.FirstOrDefault(s => s.Index == type); if (tp != null) { ServerManager.Instance.MapOut(Session.Character.CharacterId); Session.Character.MapY = tp.MapY; Session.Character.MapX = tp.MapX; Session.Character.MapId = tp.MapId; ServerManager.Instance.ChangeMap(Session.Character.CharacterId); } } break; case 5012: if (npc != null) { TeleporterDTO tp = npc.Teleporters?.FirstOrDefault(s => s.Index == type); if (tp != null) { ServerManager.Instance.MapOut(Session.Character.CharacterId); Session.Character.MapY = tp.MapY; Session.Character.MapX = tp.MapX; Session.Character.MapId = tp.MapId; ServerManager.Instance.ChangeMap(Session.Character.CharacterId); } } break; default: Logger.Log.Warn(String.Format(Language.Instance.GetMessageFromKey("NO_NRUN_HANDLER"), runner)); break; } }