public void ThrowItems(Tuple <int, short, byte, int, int, short> parameter) { MapMonster mon = Monsters.Find(s => s.MapMonsterId == parameter.Item1) ?? Monsters.Find(s => s.MonsterVNum == parameter.Item1); if (mon == null) { return; } short originX = mon.MapX; short originY = mon.MapY; short destX; short destY; int amount = 1; Observable.Timer(TimeSpan.FromSeconds(parameter.Item6)).Subscribe(s => { for (int i = 0; i < parameter.Item3; i++) { amount = ServerManager.RandomNumber(parameter.Item4, parameter.Item5); destX = (short)(originX + ServerManager.RandomNumber(-10, 10)); destY = (short)(originY + ServerManager.RandomNumber(-10, 10)); if (Map.IsBlockedZone(destX, destY)) { destX = originX; destY = originY; } MonsterMapItem droppedItem = new MonsterMapItem(destX, destY, parameter.Item2, amount); DroppedList[droppedItem.TransportId] = droppedItem; Broadcast($"throw {droppedItem.ItemVNum} {droppedItem.TransportId} {originX} {originY} {droppedItem.PositionX} {droppedItem.PositionY} {(droppedItem.GoldAmount > 1 ? droppedItem.GoldAmount : droppedItem.Amount)}"); } }); }
public void DropItems(List <Tuple <short, int, short, short> > list) { foreach (Tuple <short, int, short, short> drop in list) { MonsterMapItem droppedItem = new MonsterMapItem(drop.Item3, drop.Item4, drop.Item1, drop.Item2); DroppedList[droppedItem.TransportId] = droppedItem; if (drop.Item1 == 99) { return; } if (drop.Item2 == 99) { return; } if (drop.Item3 == 99) { return; } if (drop.Item4 == 99) { return; } if (droppedItem == null) { return; } Broadcast($"drop {droppedItem.ItemVNum} {droppedItem.TransportId} {droppedItem.PositionX} {droppedItem.PositionY} {(droppedItem.GoldAmount > 1 ? droppedItem.GoldAmount : droppedItem.Amount)} 0 0 -1"); } }
public void DropItems(List <Tuple <short, int, short, short> > list) { foreach (Tuple <short, int, short, short> drop in list) { MonsterMapItem droppedItem = new MonsterMapItem(drop.Item3, drop.Item4, drop.Item1, drop.Item2); DroppedList[droppedItem.TransportId] = droppedItem; Broadcast($"drop {droppedItem.ItemVNum} {droppedItem.TransportId} {droppedItem.PositionX} {droppedItem.PositionY} {(droppedItem.GoldAmount > 1 ? droppedItem.GoldAmount : droppedItem.Amount)} 0 {droppedItem.OwnerId ?? -1}"); } }
public void DropItems(List <Tuple <short, int, short, short> > list) { // TODO: Parallelize, if possible. foreach (Tuple <short, int, short, short> drop in list) { MonsterMapItem droppedItem = new MonsterMapItem(drop.Item3, drop.Item4, drop.Item1, drop.Item2); DroppedList[droppedItem.TransportId] = droppedItem; Broadcast($"drop {droppedItem.ItemVNum} {droppedItem.TransportId} {droppedItem.PositionX} {droppedItem.PositionY} {(droppedItem.GoldAmount > 1 ? droppedItem.GoldAmount : droppedItem.Amount)} 0 0 -1"); } }
public void DropItemByMonster(long?owner, DropDTO drop, short mapX, short mapY) { try { short localMapX = mapX; short localMapY = mapY; 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 possibility in possibilities.OrderBy(s => ServerManager.RandomNumber())) { localMapX = (short)(mapX + possibility.X); localMapY = (short)(mapY + possibility.Y); if (!Map.IsBlockedZone(localMapX, localMapY)) { break; } } MonsterMapItem droppedItem = new MonsterMapItem(localMapX, localMapY, drop.ItemVNum, drop.Amount, owner ?? -1); DroppedList[droppedItem.TransportId] = droppedItem; if (drop.Amount == 99) { return; } if (droppedItem == null) { return; } 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 ThrowItems(Tuple <int, short, byte, int, int> parameter) { MapMonster mon = Monsters.FirstOrDefault(s => s.MapMonsterId == parameter.Item1); short originX = mon.MapX; short originY = mon.MapY; short destX; short destY; int amount = ServerManager.Instance.RandomNumber(parameter.Item4, parameter.Item5); for (int i = 0; i < parameter.Item3; i++) { destX = (short)(originX + ServerManager.Instance.RandomNumber(-10, 10)); destY = (short)(originY + ServerManager.Instance.RandomNumber(-10, 10)); MonsterMapItem droppedItem = new MonsterMapItem(destX, destY, parameter.Item2, amount); DroppedList[droppedItem.TransportId] = droppedItem; Broadcast($"throw {droppedItem.ItemVNum} {droppedItem.TransportId} {originX} {originY} {droppedItem.PositionX} {droppedItem.PositionY} {(droppedItem.GoldAmount > 1 ? droppedItem.GoldAmount : droppedItem.Amount)}"); } }
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[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, bool hideOwnerId = false, bool isQuestItem = false) { try { short localMapX = mapX; short localMapY = mapY; 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 possibility in possibilities.OrderBy(s => ServerManager.RandomNumber())) { localMapX = (short)(mapX + possibility.X); localMapY = (short)(mapY + possibility.Y); if (!Map.IsBlockedZone(localMapX, localMapY)) { break; } } MonsterMapItem droppedItem = new MonsterMapItem(localMapX, localMapY, drop.ItemVNum, drop.Amount, owner ?? -1, isQuestItem) { IsDroppedByMonster = true }; DroppedList[droppedItem.TransportId] = droppedItem; Broadcast($"drop {droppedItem.ItemVNum} {droppedItem.TransportId} {droppedItem.PositionX} {droppedItem.PositionY} {(droppedItem.GoldAmount > 1 ? droppedItem.GoldAmount : droppedItem.Amount)} {(droppedItem.IsQuestItem ? 1 : 0)} {(droppedItem.OwnerId != -1 ? (!hideOwnerId ? droppedItem.OwnerId : -1) : -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[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); } }