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, int gold = 0) { try { MonsterMapItem 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; } } droppedItem = new MonsterMapItem(localMapX, localMapY, drop.ItemVNum, drop.Amount, Owner ?? -1); DroppedList.TryAdd(droppedItem.TransportId, droppedItem); Broadcast($"drop {droppedItem.ItemVNum} {droppedItem.TransportId} {droppedItem.PositionX} {droppedItem.PositionY} {(droppedItem.GoldAmount > 1 ? droppedItem.GoldAmount : droppedItem.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); } }