public void RenderSetPiece(World world, IntPoint pos) { var dat = world.Manager.GameData; for (int x = 0; x < Size; x++) for (int y = 0; y < Size; y++) { double dx = x - (Size / 2.0); double dy = y - (Size / 2.0); double r = Math.Sqrt(dx * dx + dy * dy) + rand.NextDouble() * 4 - 2; if (r <= 10) { var tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Floor]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; } } Entity lord = Entity.Resolve(world.Manager, "Phoenix Lord"); lord.Move(pos.X + 15.5f, pos.Y + 15.5f); world.EnterWorld(lord); Container container = new Container(world.Manager, 0x0501, null, false); Item[] items = chest.GetLoots(world.Manager, 5, 8).ToArray(); for (int i = 0; i < items.Length; i++) container.Inventory[i] = items[i]; container.Move(pos.X + 15.5f, pos.Y + 15.5f); world.EnterWorld(container); }
public void RenderSetPiece(World world, IntPoint pos) { for (int x = 0; x < Size; x++) for (int y = 0; y < Size; y++) { double dx = x - (Size / 2.0); double dy = y - (Size / 2.0); double r = Math.Sqrt(dx * dx + dy * dy) + rand.NextDouble() * 4 - 2; if (r <= 10) { var tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = Floor; tile.ObjType = 0; world.Obstacles[x + pos.X, y + pos.Y] = 0; world.Map[x + pos.X, y + pos.Y] = tile; } } Entity lord = Entity.Resolve(0x675); lord.Move(pos.X + 15.5f, pos.Y + 15.5f); world.EnterWorld(lord); Container container = new Container(0x0501, null, false); int count = rand.Next(5, 8); List<Item> items = new List<Item>(); while (items.Count < count) { Item item = chest.GetRandomLoot(rand); if (item != null) items.Add(item); } for (int i = 0; i < items.Count; i++) container.Inventory[i] = items[i]; container.Move(pos.X + 15.5f, pos.Y + 15.5f); world.EnterWorld(container); }
public void DropBag(Item i) { short bagId = 0x0500; bool soulbound = false; if (i.Soulbound) { bagId = 0x0503; soulbound = true; } else if (i.Undead) { bagId = 0xffe; soulbound = true; } else if (i.SUndead) { bagId = 0xfff; soulbound = true; } else if (i.PUndead) { bagId = 0xffd; } Container container = new Container(bagId, 1000 * 60, true); if (soulbound) container.BagOwner = AccountId; container.Inventory[0] = i; container.Move(X + (float)((invRand.NextDouble() * 2 - 1) * 0.5), Y + (float)((invRand.NextDouble() * 2 - 1) * 0.5)); container.Size = 75; Owner.EnterWorld(container); }
public void AddChest(VaultChest chest, Entity original) { Container con = new Container(client.Manager, 0x0504, null, false); var inv = chest.Items.Select(_ => _ == -1 ? null : Manager.GameData.Items[(ushort)_]).ToArray(); for (int j = 0; j < 8; j++) con.Inventory[j] = inv[j]; con.Move(original.X, original.Y); LeaveWorld(original); EnterWorld(con); vaultChests[new Tuple<Container, VaultChest>(con, chest)] = con.UpdateCount; }
public void AddChest(VaultChest chest, Entity original) { Container con = new Container(0x0504, null, false); var inv = chest.Items.Select(_ => _ == -1 ? null : (XmlDatas.ItemDescs.ContainsKey((short)_) ? XmlDatas.ItemDescs[(short)_] : null)).ToArray(); for (int j = 0; j < 8; j++) con.Inventory[j] = inv[j]; con.Move(original.X, original.Y); LeaveWorld(original); EnterWorld(con); vaultChests[new Tuple<Container, VaultChest>(con, chest)] = con.UpdateCount; }
void Init(ClientProcessor psr) { this.psr = psr; List<IntPoint> vaultChestPosition = new List<IntPoint>(); IntPoint spawn = new IntPoint(0, 0); int w = Map.Width; int h = Map.Height; for (int y = 0; y < h; y++) for (int x = 0; x < w; x++) { var tile = Map[x, y]; if (tile.Region == TileRegion.Spawn) spawn = new IntPoint(x, y); else if (tile.Region == TileRegion.Vault) vaultChestPosition.Add(new IntPoint(x, y)); } vaultChestPosition.Sort((x, y) => Comparer<int>.Default.Compare( (x.X - spawn.X) * (x.X - spawn.X) + (x.Y - spawn.Y) * (x.Y - spawn.Y), (y.X - spawn.X) * (y.X - spawn.X) + (y.Y - spawn.Y) * (y.Y - spawn.Y))); var chests = psr.Account.Vault.Chests; for (int i = 0; i < chests.Count; i++) { Container con = new Container(0x0504, null, false); var inv = chests[i].Items.Select(_ => _ == -1 ? null : XmlDatas.ItemDescs[(short)_]).ToArray(); for (int j = 0; j < 8; j++) con.Inventory[j] = inv[j]; con.Move(vaultChestPosition[0].X + 0.5f, vaultChestPosition[0].Y + 0.5f); EnterWorld(con); vaultChestPosition.RemoveAt(0); vaultChests[new Tuple<Container, VaultChest>(con, chests[i])] = con.UpdateCount; } foreach (var i in vaultChestPosition) { SellableObject x = new SellableObject(0x0505); x.Move(i.X + 0.5f, i.Y + 0.5f); EnterWorld(x); } }
public void Countdown(int s) { if (s == 5) { foreach (var i in Players) { BroadcastPacket(new NotificationPacket() { Color = new ARGB(0xffff00ff), ObjectId = i.Value.Id, Text = "Wave " + Wave.ToString() + " - 5 Seconds" }, null); if (Wave % 20 == 0 && Wave != 0) { Container c = new Container(0xffe, 1000 * 120, true); c.BagOwner = i.Value.AccountId; c.Inventory[0] = XmlDatas.ItemDescs[0x193e]; c.Move(27.5f, 30.5f); c.Size = 120; EnterWorld(c); } } } else if (s > 0) { foreach (var i in Players) { BroadcastPacket(new NotificationPacket() { Color = new ARGB(0xffff00ff), ObjectId = i.Value.Id, Text = s.ToString() + " Second" + (s == 1 ? "" : "s") }, null); } } else { SpawnEnemies(); } }
public void InventoryDrop(RealmTime time, InvDropPacket pkt) { //TODO: locker again const short NORM_BAG = 0x0500; const short SOUL_BAG = 0x0503; Entity entity = Owner.GetEntity(pkt.Slot.ObjectId); IContainer con = entity as IContainer; if (con.Inventory[pkt.Slot.SlotId] == null) return; Item item = con.Inventory[pkt.Slot.SlotId]; con.Inventory[pkt.Slot.SlotId] = null; entity.UpdateCount++; Container container; if (item.Soulbound) { container = new Container(SOUL_BAG, 1000 * 60, true); container.BagOwner = AccountId; } else container = new Container(NORM_BAG, 1000 * 60, true); container.Inventory[0] = item; container.Move(entity.X + (float)((invRand.NextDouble() * 2 - 1) * 0.5), entity.Y + (float)((invRand.NextDouble() * 2 - 1) * 0.5)); container.Size = 75; Owner.EnterWorld(container); if (entity is Player) { (entity as Player).CalcBoost(); (entity as Player).Client.SendPacket(new InvResultPacket() { Result = 0 }); } }
public override void RenderSetPiece(World world, IntPoint pos) { var t = new int[Size, Size]; var o = new int[Size, Size]; for (var x = 0; x < 60; x++) //Flooring for (var y = 0; y < 60; y++) { if (Math.Abs(x - Size/2)/(Size/2.0) + rand.NextDouble()*0.3 < 0.9 && Math.Abs(y - Size/2)/(Size/2.0) + rand.NextDouble()*0.3 < 0.9) { var dist = Math.Sqrt(((x - Size/2)*(x - Size/2) + (y - Size/2)*(y - Size/2))/((Size/2.0)*(Size/2.0))); t[x, y] = rand.NextDouble() < (1 - dist)*(1 - dist) ? 2 : 1; } } for (var x = 0; x < Size; x++) //Corruption for (var y = 0; y < Size; y++) if (rand.Next()%50 == 0) t[x, y] = 0; const int bas = 16; //Walls for (var x = 0; x < 23; x++) { if (x > 9 && x < 13) continue; o[bas + x, bas] = 2; o[bas + x, bas + 1] = 2; o[bas + x, bas + 21] = 2; o[bas + x, bas + 22] = 2; } for (var y = 0; y < 23; y++) { if (y > 9 && y < 13) continue; o[bas, bas + y] = 2; o[bas + 1, bas + y] = 2; o[bas + 21, bas + y] = 2; o[bas + 22, bas + y] = 2; } o[bas - 1, bas + 7] = o[bas - 1, bas + 8] = o[bas - 1, bas + 9] = o[bas - 1, bas + 13] = o[bas - 1, bas + 14] = o[bas - 1, bas + 15] = 1; o[bas + 23, bas + 7] = o[bas + 23, bas + 8] = o[bas + 23, bas + 9] = o[bas + 23, bas + 13] = o[bas + 23, bas + 14] = o[bas + 23, bas + 15] = 1; o[bas + 7, bas - 1] = o[bas + 8, bas - 1] = o[bas + 9, bas - 1] = o[bas + 13, bas - 1] = o[bas + 14, bas - 1] = o[bas + 15, bas - 1] = 1; o[bas + 7, bas + 23] = o[bas + 8, bas + 23] = o[bas + 9, bas + 23] = o[bas + 13, bas + 23] = o[bas + 14, bas + 23] = o[bas + 15, bas + 23] = 1; for (var y = 0; y < 4; y++) //Columns for (var x = 0; x < 4; x++) o[bas + 5 + x*4, bas + 5 + y*4] = 3; for (var x = 0; x < Size; x++) //Plants for (var y = 0; y < Size; y++) { if (((x > 5 && x < bas) || (x < Size - 5 && x > Size - bas) || (y > 5 && y < bas) || (y < Size - 5 && y > Size - bas)) && o[x, y] == 0 && t[x, y] == 1) { var r = rand.NextDouble(); if (r > 0.6) //0.4 o[x, y] = 4; else if (r > 0.35) //0.25 o[x, y] = 5; else if (r > 0.33) //0.02 o[x, y] = 6; } } var rotation = rand.Next(0, 4); //Rotation for (var i = 0; i < rotation; i++) { t = SetPieces.rotateCW(t); o = SetPieces.rotateCW(o); } Render(this, world, pos, t, o); //Boss & Chest var container = new Container(0x0501, null, false); var count = rand.Next(3, 8); var items = new List<Item>(); while (items.Count < count) { var item = chest.GetRandomLoot(rand); if (item != null) items.Add(item); } for (var i = 0; i < items.Count; i++) container.Inventory[i] = items[i]; container.Move(pos.X + bas + 11.5f, pos.Y + bas + 11.5f); world.EnterWorld(container); var snake = Entity.Resolve(0x0dc2); snake.Move(pos.X + bas + 11.5f, pos.Y + bas + 11.5f); world.EnterWorld(snake); }
public void RenderSetPiece(World world, IntPoint pos) { int[,] p = new int[Size, Size]; const double SCALE = 5.5; for (int x = 0; x < Size; x++) //Lava { double t = (double)x / Size * Math.PI; double x_ = t / Math.Sqrt(2) - Math.Sin(t) / (SCALE * Math.Sqrt(2)); double y1 = t / Math.Sqrt(2) - 2 * Math.Sin(t) / (SCALE * Math.Sqrt(2)); double y2 = t / Math.Sqrt(2) + Math.Sin(t) / (SCALE * Math.Sqrt(2)); y1 /= Math.PI / Math.Sqrt(2); y2 /= Math.PI / Math.Sqrt(2); int y1_ = (int)Math.Ceiling(y1 * Size); int y2_ = (int)Math.Floor(y2 * Size); for (int i = y1_; i < y2_; i++) p[x, i] = 1; } for (int x = 0; x < Size; x++) //Floor for (int y = 0; y < Size; y++) { if (p[x, y] == 1 && rand.Next() % 5 == 0) p[x, y] = 2; } int r = rand.Next(0, 4); //Rotation for (int i = 0; i < r; i++) p = SetPieces.rotateCW(p); p[20, 20] = 2; var dat = world.Manager.GameData; for (int x = 0; x < Size; x++) //Rendering for (int y = 0; y < Size; y++) { if (p[x, y] == 1) { var tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Lava]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; } else if (p[x, y] == 2) { var tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Lava]; tile.ObjType = dat.IdToObjectType[Floor]; if (tile.ObjId == 0) tile.ObjId = world.GetNextEntityId(); world.Map[x + pos.X, y + pos.Y] = tile; } } Entity demon = Entity.Resolve(world.Manager, "Red Demon"); demon.Move(pos.X + 20.5f, pos.Y + 20.5f); world.EnterWorld(demon); Container container = new Container(world.Manager, 0x0501, null, false); Item[] items = chest.GetLoots(world.Manager, 5, 8).ToArray(); for (int i = 0; i < items.Length; i++) container.Inventory[i] = items[i]; container.Move(pos.X + 20.5f, pos.Y + 20.5f); world.EnterWorld(container); }
public void RenderSetPiece(World world, IntPoint pos) { int[,] t = new int[23, 35]; for (int x = 0; x < 23; x++) //Floor for (int y = 0; y < 35; y++) t[x, y] = rand.Next() % 3 == 0 ? 0 : 1; for (int y = 0; y < 35; y++) //Perimeters t[0, y] = t[22, y] = 2; for (int x = 0; x < 23; x++) t[x, 0] = t[x, 34] = 2; List<IntPoint> pts = new List<IntPoint>(); for (int y = 0; y < 11; y++) //Crosses for (int x = 0; x < 7; x++) { if (rand.Next() % 3 > 0) t[2 + 3 * x, 2 + 3 * y] = 4; else pts.Add(new IntPoint(2 + 3 * x, 2 + 3 * y)); } for (int x = 0; x < 23; x++) //Corruption for (int y = 0; y < 35; y++) { if (t[x, y] == 1 || t[x, y] == 0 || t[x, y] == 4) continue; double p = rand.NextDouble(); if (p < 0.1) t[x, y] = 1; else if (p < 0.4) t[x, y]++; } //Boss & Chest IntPoint pt = pts[rand.Next(0, pts.Count)]; t[pt.X, pt.Y] = 5; t[pt.X + 1, pt.Y] = 6; int r = rand.Next(0, 4); for (int i = 0; i < r; i++) //Rotation t = SetPieces.rotateCW(t); int w = t.GetLength(0), h = t.GetLength(1); XmlData dat = world.Manager.GameData; for (int x = 0; x < w; x++) //Rendering for (int y = 0; y < h; y++) { if (t[x, y] == 1) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Floor]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; } else if (t[x, y] == 2) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Floor]; tile.ObjType = dat.IdToObjectType[WallA]; if (tile.ObjId == 0) tile.ObjId = world.GetNextEntityId(); world.Map[x + pos.X, y + pos.Y] = tile; } else if (t[x, y] == 3) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Floor]; world.Map[x + pos.X, y + pos.Y] = tile; Entity wall = Entity.Resolve(world.Manager, dat.IdToObjectType[WallB]); wall.Move(x + pos.X + 0.5f, y + pos.Y + 0.5f); world.EnterWorld(wall); } else if (t[x, y] == 4) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Floor]; tile.ObjType = dat.IdToObjectType[Cross]; if (tile.ObjId == 0) tile.ObjId = world.GetNextEntityId(); world.Map[x + pos.X, y + pos.Y] = tile; } else if (t[x, y] == 5) { Container container = new Container(world.Manager, 0x0501, null, false); Item[] items = chest.GetLoots(world.Manager, 3, 8).ToArray(); for (int i = 0; i < items.Length; i++) container.Inventory[i] = items[i]; container.Move(pos.X + x + 0.5f, pos.Y + y + 0.5f); world.EnterWorld(container); } else if (t[x, y] == 6) { Entity mage = Entity.Resolve(world.Manager, "Deathmage"); mage.Move(pos.X + x, pos.Y + y); world.EnterWorld(mage); } } }
public void ShowBagsW(Random rand, IEnumerable<Item> loots, Player owner, World entWorld) { int bagType = 0; Item[] items = new Item[8]; int idx = 0; short bag; Container container; foreach (var i in loots) { if (i.BagType > bagType) bagType = i.BagType; items[idx] = i; idx++; if (idx == 8) { bag = 0x0500; switch (bagType) { case 0: bag = 0x0500; break; case 1: bag = 0x0503; break; case 2: bag = 0x0507; break; case 3: bag = 0x0508; break; case 4: bag = 0x0509; break; case 5: bag = 0xffd; break; case 6: bag = 0xffe; break; case 7: bag = 0xfff; break; } container = new Container(bag, 1000 * 60, true); for (int j = 0; j < 8; j++) container.Inventory[j] = items[j]; container.BagOwner = owner == null ? (int?)null : owner.AccountId; container.Move( Host.Self.X, Host.Self.Y); container.Size = 80; entWorld.EnterWorld(container); bagType = 0; items = new Item[8]; idx = 0; } } if (idx > 0) { bag = 0x0500; switch (bagType) { case 0: bag = 0x0500; break; case 1: bag = 0x0503; break; case 2: bag = 0x0507; break; case 3: bag = 0x0508; break; case 4: bag = 0x0509; break; case 5: bag = 0xffd; break; case 6: bag = 0xffe; break; case 7: bag = 0xfff; break; } container = new Container(bag, 1000 * 60, true); for (int j = 0; j < idx; j++) container.Inventory[j] = items[j]; container.BagOwner = owner == null ? (int?)null : owner.AccountId; container.Move( Host.Self.X, Host.Self.Y); container.Size = 80; if (entWorld != null) //was null sometimes { entWorld.EnterWorld(container); } } }
public void RenderSetPiece(World world, IntPoint pos) { var p = new int[Size, Size]; const double SCALE = 5.5; for (var x = 0; x < Size; x++) //Lava { var t = (double) x/Size*Math.PI; var x_ = t/Math.Sqrt(2) - Math.Sin(t)/(SCALE*Math.Sqrt(2)); var y1 = t/Math.Sqrt(2) - 2*Math.Sin(t)/(SCALE*Math.Sqrt(2)); var y2 = t/Math.Sqrt(2) + Math.Sin(t)/(SCALE*Math.Sqrt(2)); y1 /= Math.PI/Math.Sqrt(2); y2 /= Math.PI/Math.Sqrt(2); var y1_ = (int) Math.Ceiling(y1*Size); var y2_ = (int) Math.Floor(y2*Size); for (var i = y1_; i < y2_; i++) p[x, i] = 1; } for (var x = 0; x < Size; x++) //Floor for (var y = 0; y < Size; y++) { if (p[x, y] == 1 && rand.Next()%5 == 0) p[x, y] = 2; } var r = rand.Next(0, 4); //Rotation for (var i = 0; i < r; i++) p = SetPieces.rotateCW(p); p[20, 20] = 2; for (var x = 0; x < Size; x++) //Rendering for (var y = 0; y < Size; y++) { if (p[x, y] == 1) { var tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = Lava; tile.ObjType = 0; world.Obstacles[x + pos.X, y + pos.Y] = 0; world.Map[x + pos.X, y + pos.Y] = tile; } else if (p[x, y] == 2) { var tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = Lava; tile.ObjType = Floor; if (tile.ObjId == 0) tile.ObjId = world.GetNextEntityId(); world.Obstacles[x + pos.X, y + pos.Y] = 0; world.Map[x + pos.X, y + pos.Y] = tile; } } var demon = Entity.Resolve(0x668); demon.Move(pos.X + 20.5f, pos.Y + 20.5f); world.EnterWorld(demon); var container = new Container(0x0501, null, false); var count = rand.Next(5, 8); var items = new List<Item>(); while (items.Count < count) { var item = chest.GetRandomLoot(rand); if (item != null) items.Add(item); } for (var i = 0; i < items.Count; i++) container.Inventory[i] = items[i]; container.Move(pos.X + 20.5f, pos.Y + 20.5f); world.EnterWorld(container); }
public void RenderSetPiece(World world, IntPoint pos) { int outerRadius = 13; int waterRadius = 10; int islandRadius = 3; List<IntPoint> border = new List<IntPoint>(); int[,] t = new int[Size, Size]; for (int y = 0; y < Size; y++) //Outer for (int x = 0; x < Size; x++) { double dx = x - (Size / 2.0); double dy = y - (Size / 2.0); double r = Math.Sqrt(dx * dx + dy * dy); if (r <= outerRadius) t[x, y] = 1; } for (int y = 0; y < Size; y++) //Water for (int x = 0; x < Size; x++) { double dx = x - (Size / 2.0); double dy = y - (Size / 2.0); double r = Math.Sqrt(dx * dx + dy * dy); if (r <= waterRadius) { t[x, y] = 2; if (waterRadius - r < 1) border.Add(new IntPoint(x, y)); } } for (int y = 0; y < Size; y++) //Island for (int x = 0; x < Size; x++) { double dx = x - (Size / 2.0); double dy = y - (Size / 2.0); double r = Math.Sqrt(dx * dx + dy * dy); if (r <= islandRadius) { t[x, y] = 1; if (islandRadius - r < 1) border.Add(new IntPoint(x, y)); } } HashSet<IntPoint> trees = new HashSet<IntPoint>(); while (trees.Count < border.Count * 0.5) trees.Add(border[rand.Next(0, border.Count)]); foreach (var i in trees) t[i.X, i.Y] = 3; for (int x = 0; x < Size; x++) for (int y = 0; y < Size; y++) { if (t[x, y] == 1) { var tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = Floor; tile.ObjType = 0; world.Obstacles[x + pos.X, y + pos.Y] = 0; world.Map[x + pos.X, y + pos.Y] = tile; } else if (t[x, y] == 2) { var tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = Water; tile.ObjType = 0; world.Obstacles[x + pos.X, y + pos.Y] = 0; world.Map[x + pos.X, y + pos.Y] = tile; } else if (t[x, y] == 3) { var tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = Floor; tile.ObjType = Tree; tile.Name = "size:" + (rand.Next() % 2 == 0 ? 120 : 140); if (tile.ObjId == 0) tile.ObjId = world.GetNextEntityId(); world.Obstacles[x + pos.X, y + pos.Y] = 2; world.Map[x + pos.X, y + pos.Y] = tile; } } Entity giant = Entity.Resolve(0x678); giant.Move(pos.X + 15.5f, pos.Y + 15.5f); world.EnterWorld(giant); Container container = new Container(0x0501, null, false); int count = rand.Next(5, 8); List<Item> items = new List<Item>(); while (items.Count < count) { Item item = chest.GetRandomLoot(rand); if (item != null) items.Add(item); } for (int i = 0; i < items.Count; i++) container.Inventory[i] = items[i]; container.Move(pos.X + 15.5f, pos.Y + 15.5f); world.EnterWorld(container); }
private void InitVault() { var vaultChestPosition = new List<IntPoint>(); var spawn = new IntPoint(0, 0); int w = Map.Width; int h = Map.Height; for (int y = 0; y < h; y++) for (int x = 0; x < w; x++) { WmapTile tile = Map[x, y]; if (tile.Region == TileRegion.Spawn) spawn = new IntPoint(x, y); else if (tile.Region == TileRegion.Vault) { vaultChestPosition.Add(new IntPoint(x, y)); } } vaultChestPosition.Sort((x, y) => Comparer<int>.Default.Compare( (x.X - spawn.X) * (x.X - spawn.X) + (x.Y - spawn.Y) * (x.Y - spawn.Y), (y.X - spawn.X) * (y.X - spawn.X) + (y.Y - spawn.Y) * (y.Y - spawn.Y))); List<VaultChest> chests = client.Account.Vault.Chests; for (int i = 0; i < chests.Count; i++) { var con = new Container(client.Manager, 0x0504, null, false); Item[] inv = chests[i].Items.Select(_ => _ == 0xffff ? null : client.Manager.GameData.Items[_]).ToArray(); ItemData[] dats = chests[i].Datas; for (int j = 0; j < 8; j++) { con.Inventory[j] = inv[j]; con.Inventory.Data[j] = dats[j]; } con.Move(vaultChestPosition[0].X + 0.5f, vaultChestPosition[0].Y + 0.5f); EnterWorld(con); vaultChestPosition.RemoveAt(0); vaultChests[new Tuple<Container, VaultChest>(con, chests[i])] = con.UpdateCount; } foreach (IntPoint i in vaultChestPosition) { var x = new SellableObject(client.Manager, 0x0505); x.Move(i.X + 0.5f, i.Y + 0.5f); EnterWorld(x); } }
private void Init(ClientProcessor psr) { this.psr = psr; acc = psr.Account; var vaultChestPosition = new List<IntPoint>(); var spawn = new IntPoint(0, 0); var w = Map.Width; var h = Map.Height; for (var y = 0; y < h; y++) for (var x = 0; x < w; x++) { var tile = Map[x, y]; if (tile.Region == TileRegion.Spawn) spawn = new IntPoint(x, y); else if (tile.Region == TileRegion.Vault) vaultChestPosition.Add(new IntPoint(x, y)); } vaultChestPosition.Sort((x, y) => Comparer<int>.Default.Compare( (x.X - spawn.X) * (x.X - spawn.X) + (x.Y - spawn.Y) * (x.Y - spawn.Y), (y.X - spawn.X) * (y.X - spawn.X) + (y.Y - spawn.Y) * (y.Y - spawn.Y))); var chests = psr.Account.Vault.Chests; foreach (var t in chests) { var con = new Container(0x0504, null, false); var inv = t.Items.Select( _ => _ == -1 ? null : (XmlData.Items.ContainsKey((short)_) ? XmlData.Items[(short)_] : null)) .ToArray(); for (var j = 0; j < 8; j++) con.Inventory[j] = inv[j]; con.Move(vaultChestPosition[0].X + 0.5f, vaultChestPosition[0].Y + 0.5f); EnterWorld(con); vaultChestPosition.RemoveAt(0); _vaultChests[new Tuple<Container, VaultChest>(con, t)] = con.UpdateCount; } foreach (var i in vaultChestPosition) { var x = new SellableObject(0x0505); x.Move(i.X + 0.5f, i.Y + 0.5f); EnterWorld(x); } }
public void InventoryDrop(RealmTime time, InvDropPacket pkt) { //TODO: locker again const short NORM_BAG = 0x0500; const short SOUL_BAG = 0x0503; const short PDEM_BAG = 0xffd; const short DEM_BAG = 0xffe; const short SDEM_BAG = 0xfff; Entity entity = Owner.GetEntity(pkt.Slot.ObjectId); IContainer con = entity as IContainer; if (con.Inventory[pkt.Slot.SlotId] == null) return; if ((entity is Player) && (entity as Player).Decision == 1) { (entity as Player).Client.SendPacket(new InvResultPacket() { Result = 1 }); return; } Item item = con.Inventory[pkt.Slot.SlotId]; con.Inventory[pkt.Slot.SlotId] = null; entity.UpdateCount++; Container container; if (item.Soulbound) { container = new Container(SOUL_BAG, 1000 * 60, true); container.BagOwner = AccountId; } else if (item.Undead) { container = new Container(DEM_BAG, 1000 * 60, true); container.BagOwner = AccountId; } else if (item.PUndead) { container = new Container(PDEM_BAG, 1000 * 60, true); } else if (item.SUndead) { container = new Container(SDEM_BAG, 1000 * 60, true); container.BagOwner = AccountId; } else { container = new Container(NORM_BAG, 1000 * 60, true); } float bagx = entity.X + (float)((invRand.NextDouble() * 2 - 1) * 0.5); float bagy = entity.Y + (float)((invRand.NextDouble() * 2 - 1) * 0.5); try { container.Inventory[0] = item; container.Move(bagx, bagy); container.Size = 75; Owner.EnterWorld(container); if (entity is Player) { (entity as Player).CalcBoost(); (entity as Player).Client.SendPacket(new InvResultPacket() { Result = 0 }); (entity as Player).Client.Save(); } } catch { Console.Out.WriteLine(Name + " just attempted to dupe."); } }
public void RenderSetPiece(World world, IntPoint pos) { int outerRadius = 13; int waterRadius = 10; int islandRadius = 3; List<IntPoint> border = new List<IntPoint>(); int[,] t = new int[Size, Size]; for (int y = 0; y < Size; y++) //Outer for (int x = 0; x < Size; x++) { double dx = x - (Size / 2.0); double dy = y - (Size / 2.0); double r = Math.Sqrt(dx * dx + dy * dy); if (r <= outerRadius) t[x, y] = 1; } for (int y = 0; y < Size; y++) //Water for (int x = 0; x < Size; x++) { double dx = x - (Size / 2.0); double dy = y - (Size / 2.0); double r = Math.Sqrt(dx * dx + dy * dy); if (r <= waterRadius) { t[x, y] = 2; if (waterRadius - r < 1) border.Add(new IntPoint(x, y)); } } for (int y = 0; y < Size; y++) //Island for (int x = 0; x < Size; x++) { double dx = x - (Size / 2.0); double dy = y - (Size / 2.0); double r = Math.Sqrt(dx * dx + dy * dy); if (r <= islandRadius) { t[x, y] = 1; if (islandRadius - r < 1) border.Add(new IntPoint(x, y)); } } HashSet<IntPoint> trees = new HashSet<IntPoint>(); while (trees.Count < border.Count * 0.5) trees.Add(border[rand.Next(0, border.Count)]); foreach (var i in trees) t[i.X, i.Y] = 3; var dat = world.Manager.GameData; for (int x = 0; x < Size; x++) for (int y = 0; y < Size; y++) { if (t[x, y] == 1) { var tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Floor]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; } else if (t[x, y] == 2) { var tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Water]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; } else if (t[x, y] == 3) { var tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Floor]; tile.ObjType = dat.IdToObjectType[Tree]; tile.Name = "size:" + (rand.Next() % 2 == 0 ? 120 : 140); if (tile.ObjId == 0) tile.ObjId = world.GetNextEntityId(); world.Map[x + pos.X, y + pos.Y] = tile; } } Entity giant = Entity.Resolve(world.Manager, "Oasis Giant"); giant.Move(pos.X + 15.5f, pos.Y + 15.5f); world.EnterWorld(giant); Container container = new Container(world.Manager, 0x0501, null, false); Item[] items = chest.GetLoots(world.Manager, 5, 8).ToArray(); for (int i = 0; i < items.Length; i++) container.Inventory[i] = items[i]; container.Move(pos.X + 15.5f, pos.Y + 15.5f); world.EnterWorld(container); }
private void Init(string accId) { Manager.Database.DoActionAsync(db => { this.AccountId = accId; MySqlCommand cmd = db.CreateQuery(); cmd.CommandText = "SELECT name FROM accounts WHERE id=@accId"; cmd.Parameters.AddWithValue("@accId", accId); using (MySqlDataReader rdr = cmd.ExecuteReader()) while (rdr.Read()) PlayerOwnerName = rdr.GetString("name"); List<IntPoint> vaultChestPosition = new List<IntPoint>(); IntPoint spawn = new IntPoint(0, 0); int w = Map.Width; int h = Map.Height; for (int y = 0; y < h; y++) for (int x = 0; x < w; x++) { WmapTile tile = Map[x, y]; if (tile.Region == TileRegion.Spawn) spawn = new IntPoint(x, y); else if (tile.Region == TileRegion.Vault) vaultChestPosition.Add(new IntPoint(x, y)); } vaultChestPosition.Sort((x, y) => Comparer<int>.Default.Compare( (x.X - spawn.X) * (x.X - spawn.X) + (x.Y - spawn.Y) * (x.Y - spawn.Y), (y.X - spawn.X) * (y.X - spawn.X) + (y.Y - spawn.Y) * (y.Y - spawn.Y))); List<VaultChest> chests = new List<VaultChest>(); cmd = db.CreateQuery(); cmd.CommandText = "SELECT items, chestId FROM vaults WHERE accId=@accId"; cmd.Parameters.AddWithValue("@accId", accId); using (MySqlDataReader rdr = cmd.ExecuteReader()) { while (rdr.Read()) { chests.Add(new VaultChest { _Items = rdr.GetString("items"), ChestId = rdr.GetInt32("chestId") }); } } foreach (VaultChest t in chests) { Container con = new Container(Manager, 0x0504, null, false); Item[] inv = t.Items.Select( _ => _ == -1 ? null : (Manager.GameData.Items.ContainsKey((ushort)_) ? Manager.GameData.Items[(ushort)_] : null)) .ToArray(); for (int j = 0; j < 8; j++) con.Inventory[j] = inv[j]; con.Move(vaultChestPosition[0].X + 0.5f, vaultChestPosition[0].Y + 0.5f); EnterWorld(con); vaultChestPosition.RemoveAt(0); _vaultChests[new Tuple<Container, VaultChest>(con, t)] = con.UpdateCount; } foreach (IntPoint i in vaultChestPosition) { SellableObject x = new SellableObject(Manager, 0x0505); x.Move(i.X + 0.5f, i.Y + 0.5f); EnterWorld(x); } }); }
private void Init(Client psr) { AccountId = psr.Account.AccountId; PlayerOwnerName = psr.Account.Name; List<IntPoint> vaultChestPosition = new List<IntPoint>(); List<IntPoint> giftChestPosition = new List<IntPoint>(); IntPoint spawn = new IntPoint(0, 0); int w = Map.Width; int h = Map.Height; for (int y = 0; y < h; y++) for (int x = 0; x < w; x++) { WmapTile tile = Map[x, y]; if (tile.Region == TileRegion.Spawn) spawn = new IntPoint(x, y); else if (tile.Region == TileRegion.Vault) vaultChestPosition.Add(new IntPoint(x, y)); else if (tile.Region == TileRegion.Gifting_Chest) giftChestPosition.Add(new IntPoint(x, y)); } vaultChestPosition.Sort((x, y) => Comparer<int>.Default.Compare( (x.X - spawn.X) * (x.X - spawn.X) + (x.Y - spawn.Y) * (x.Y - spawn.Y), (y.X - spawn.X) * (y.X - spawn.X) + (y.Y - spawn.Y) * (y.Y - spawn.Y))); List<VaultChest> chests = psr.Account.Vault.Chests; if (psr.Account.Gifts != null) { List<GiftChest> giftChests = new List<GiftChest>(); GiftChest c = new GiftChest(); c.Items = new List<Item>(8); bool wasLastElse = false; int[] gifts = psr.Account.Gifts.ToArray(); gifts.Shuffle(); for (int i = 0; i < gifts.Count(); i++) { if (Manager.GameData.Items.ContainsKey((ushort)gifts[i])) { if (c.Items.Count < 8) { c.Items.Add(Manager.GameData.Items[(ushort)gifts[i]]); wasLastElse = false; } else { giftChests.Add(c); c = new GiftChest(); c.Items = new List<Item>(8); c.Items.Add(Manager.GameData.Items[(ushort)gifts[i]]); wasLastElse = true; } } } if (!wasLastElse) giftChests.Add(c); foreach (GiftChest chest in giftChests) { if (giftChestPosition.Count == 0) break; while (chest.Items.Count < 8) chest.Items.Add(null); OneWayContainer con = new OneWayContainer(Manager, 0x0744, null, false); List<Item> inv = chest.Items; for (int j = 0; j < 8; j++) con.Inventory[j] = inv[j]; con.Move(giftChestPosition[0].X + 0.5f, giftChestPosition[0].Y + 0.5f); EnterWorld(con); giftChestPosition.RemoveAt(0); } } foreach (VaultChest t in chests) { if (vaultChestPosition.Count == 0) break; Container con = new Container(Manager, 0x0504, null, false); Item[] inv = t.Items.Select( _ => _ == -1 ? null : (Manager.GameData.Items.ContainsKey((ushort)_) ? Manager.GameData.Items[(ushort)_] : null)) .ToArray(); for (int j = 0; j < 8; j++) con.Inventory[j] = inv[j]; con.Move(vaultChestPosition[0].X + 0.5f, vaultChestPosition[0].Y + 0.5f); EnterWorld(con); vaultChestPosition.RemoveAt(0); _vaultChests[new Tuple<Container, VaultChest>(con, t)] = con.UpdateCount; } foreach (IntPoint i in giftChestPosition) { StaticObject x = new StaticObject(Manager, 0x0743, null, true, false, false); x.Move(i.X + 0.5f, i.Y + 0.5f); EnterWorld(x); } foreach (IntPoint i in vaultChestPosition) { SellableObject x = new SellableObject(Manager, 0x0505); x.Move(i.X + 0.5f, i.Y + 0.5f); EnterWorld(x); } }
public override void RenderSetPiece(World world, IntPoint pos) { int[,] t = new int[Size, Size]; int[,] o = new int[Size, Size]; for (int x = 0; x < 60; x++) //Flooring for (int y = 0; y < 60; y++) { if (Math.Abs(x - Size / 2) / (Size / 2.0) + rand.NextDouble() * 0.3 < 0.9 && Math.Abs(y - Size / 2) / (Size / 2.0) + rand.NextDouble() * 0.3 < 0.9) { var dist = Math.Sqrt(((x - Size / 2) * (x - Size / 2) + (y - Size / 2) * (y - Size / 2)) / ((Size / 2.0) * (Size / 2.0))); t[x, y] = rand.NextDouble() < (1 - dist) * (1 - dist) ? 2 : 1; } } for (int x = 0; x < Size; x++) //Corruption for (int y = 0; y < Size; y++) if (rand.Next() % 50 == 0) t[x, y] = 0; const int bas = 17; //Walls for (int x = 0; x < 20; x++) { o[bas + x, bas] = x == 19 ? 2 : 1; o[bas + x, bas + 1] = 2; } for (int y = 0; y < 20; y++) { o[bas, bas + y] = y == 19 ? 2 : 1; if (y != 0) o[bas + 1, bas + y] = 2; } for (int x = 0; x < 19; x++) { o[bas + 8 + x, bas + 25] = 2; o[bas + 8 + x, bas + 26] = x == 0 ? 2 : 1; } for (int y = 0; y < 19; y++) { if (y != 18) o[bas + 25, bas + 8 + y] = 2; o[bas + 26, bas + 8 + y] = y == 0 ? 2 : 1; } o[bas + 5, bas + 5] = 3; //Columns o[bas + 21, bas + 5] = 3; o[bas + 5, bas + 21] = 3; o[bas + 21, bas + 21] = 3; o[bas + 9, bas + 9] = 3; o[bas + 17, bas + 9] = 3; o[bas + 9, bas + 17] = 3; o[bas + 17, bas + 17] = 3; for (int x = 0; x < Size; x++) //Plants for (int y = 0; y < Size; y++) { if (((x > 5 && x < bas) || (x < Size - 5 && x > Size - bas) || (y > 5 && y < bas) || (y < Size - 5 && y > Size - bas)) && o[x, y] == 0 && t[x, y] == 1) { double r = rand.NextDouble(); if (r > 0.6) //0.4 o[x, y] = 4; else if (r > 0.35) //0.25 o[x, y] = 5; else if (r > 0.33) //0.02 o[x, y] = 6; } } int rotation = rand.Next(0, 4); //Rotation for (int i = 0; i < rotation; i++) { t = SetPieces.rotateCW(t); o = SetPieces.rotateCW(o); } Render(this, world, pos, t, o); //Boss & Chest Container container = new Container(0x0501, null, false); int count = rand.Next(3, 8); List<Item> items = new List<Item>(); while (items.Count < count) { Item item = chest.GetRandomLoot(rand); if (item != null) items.Add(item); } for (int i = 0; i < items.Count; i++) container.Inventory[i] = items[i]; container.Move(pos.X + Size / 2, pos.Y + Size / 2); world.EnterWorld(container); Entity snake = Entity.Resolve(0x0dc2); snake.Move(pos.X + Size / 2, pos.Y + Size / 2); world.EnterWorld(snake); }
public void RenderSetPiece(World world, IntPoint pos) { int[,] t = new int[31, 40]; for (int x = 0; x < 13; x++) //Moats for (int y = 0; y < 13; y++) { if ((x == 0 && (y < 3 || y > 9)) || (y == 0 && (x < 3 || x > 9)) || (x == 12 && (y < 3 || y > 9)) || (y == 12 && (x < 3 || x > 9))) continue; t[x + 0, y + 0] = t[x + 18, y + 0] = 2; t[x + 0, y + 27] = t[x + 18, y + 27] = 2; } for (int x = 3; x < 28; x++) for (int y = 3; y < 37; y++) { if (x < 6 || x > 24 || y < 6 || y > 33) t[x, y] = 2; } for (int x = 7; x < 24; x++) //Floor for (int y = 7; y < 33; y++) t[x, y] = rand.Next() % 3 == 0 ? 0 : 1; for (int x = 0; x < 7; x++) //Perimeter for (int y = 0; y < 7; y++) { if ((x == 0 && y != 3) || (y == 0 && x != 3) || (x == 6 && y != 3) || (y == 6 && x != 3)) continue; t[x + 3, y + 3] = t[x + 21, y + 3] = 4; t[x + 3, y + 30] = t[x + 21, y + 30] = 4; } for (int x = 6; x < 25; x++) t[x, 6] = t[x, 33] = 4; for (int y = 6; y < 34; y++) t[6, y] = t[24, y] = 4; for (int x = 13; x < 18; x++) //Bridge for (int y = 3; y < 7; y++) t[x, y] = 6; for (int x = 0; x < 31; x++) //Corruption for (int y = 0; y < 40; y++) { if (t[x, y] == 1 || t[x, y] == 0) continue; double p = rand.NextDouble(); if (t[x, y] == 6) { if (p < 0.4) t[x, y] = 0; continue; } if (p < 0.1) t[x, y] = 1; else if (p < 0.4) t[x, y]++; } //Boss & Chest t[15, 27] = 7; t[15, 20] = 8; int r = rand.Next(0, 4); for (int i = 0; i < r; i++) //Rotation t = SetPieces.rotateCW(t); int w = t.GetLength(0), h = t.GetLength(1); XmlData dat = world.Manager.GameData; for (int x = 0; x < w; x++) //Rendering for (int y = 0; y < h; y++) { if (t[x, y] == 1) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Floor]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; } else if (t[x, y] == 2) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[WaterA]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; } else if (t[x, y] == 3) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[WaterB]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; } else if (t[x, y] == 4) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Floor]; tile.ObjType = dat.IdToObjectType[WallA]; if (tile.ObjId == 0) tile.ObjId = world.GetNextEntityId(); world.Map[x + pos.X, y + pos.Y] = tile; } else if (t[x, y] == 5) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Floor]; world.Map[x + pos.X, y + pos.Y] = tile; Entity wall = Entity.Resolve(world.Manager, dat.IdToObjectType[WallB]); wall.Move(x + pos.X + 0.5f, y + pos.Y + 0.5f); world.EnterWorld(wall); } else if (t[x, y] == 6) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Bridge]; world.Map[x + pos.X, y + pos.Y] = tile; } else if (t[x, y] == 7) { Container container = new Container(world.Manager, 0x0501, null, false); Item[] items = chest.GetLoots(world.Manager, 5, 8).ToArray(); for (int i = 0; i < items.Length; i++) container.Inventory[i] = items[i]; container.Move(pos.X + x + 0.5f, pos.Y + y + 0.5f); world.EnterWorld(container); } else if (t[x, y] == 8) { Entity cyclops = Entity.Resolve(world.Manager, "Cyclops God"); cyclops.Move(pos.X + x, pos.Y + y); world.EnterWorld(cyclops); } } }
public void RenderSetPiece(World world, IntPoint pos) { var t = new int[23, 35]; for (var x = 0; x < 23; x++) //Floor for (var y = 0; y < 35; y++) t[x, y] = rand.Next()%3 == 0 ? 0 : 1; for (var y = 0; y < 35; y++) //Perimeters t[0, y] = t[22, y] = 2; for (var x = 0; x < 23; x++) t[x, 0] = t[x, 34] = 2; var pts = new List<IntPoint>(); for (var y = 0; y < 11; y++) //Crosses for (var x = 0; x < 7; x++) { if (rand.Next()%3 > 0) t[2 + 3*x, 2 + 3*y] = 4; else pts.Add(new IntPoint(2 + 3*x, 2 + 3*y)); } for (var x = 0; x < 23; x++) //Corruption for (var y = 0; y < 35; y++) { if (t[x, y] == 1 || t[x, y] == 0 || t[x, y] == 4) continue; var p = rand.NextDouble(); if (p < 0.1) t[x, y] = 1; else if (p < 0.4) t[x, y]++; } //Boss & Chest var pt = pts[rand.Next(0, pts.Count)]; t[pt.X, pt.Y] = 5; t[pt.X + 1, pt.Y] = 6; var r = rand.Next(0, 4); for (var i = 0; i < r; i++) //Rotation t = SetPieces.rotateCW(t); int w = t.GetLength(0), h = t.GetLength(1); for (var x = 0; x < w; x++) //Rendering for (var y = 0; y < h; y++) { if (t[x, y] == 1) { var tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = Floor; tile.ObjType = 0; world.Obstacles[x + pos.X, y + pos.Y] = 0; world.Map[x + pos.X, y + pos.Y] = tile; } else if (t[x, y] == 2) { var tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = Floor; tile.ObjType = WallA; if (tile.ObjId == 0) tile.ObjId = world.GetNextEntityId(); world.Obstacles[x + pos.X, y + pos.Y] = 2; world.Map[x + pos.X, y + pos.Y] = tile; } else if (t[x, y] == 3) { var tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = Floor; world.Obstacles[x + pos.X, y + pos.Y] = 2; world.Map[x + pos.X, y + pos.Y] = tile; var wall = Entity.Resolve(WallB); wall.Move(x + pos.X + 0.5f, y + pos.Y + 0.5f); world.EnterWorld(wall); } else if (t[x, y] == 4) { var tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = Floor; tile.ObjType = Cross; if (tile.ObjId == 0) tile.ObjId = world.GetNextEntityId(); world.Obstacles[x + pos.X, y + pos.Y] = 2; world.Map[x + pos.X, y + pos.Y] = tile; } else if (t[x, y] == 5) { var container = new Container(0x0501, null, false); var count = rand.Next(3, 8); var items = new List<Item>(); while (items.Count < count) { var item = chest.GetRandomLoot(rand); if (item != null) items.Add(item); } for (var i = 0; i < items.Count; i++) container.Inventory[i] = items[i]; container.Move(pos.X + x + 0.5f, pos.Y + y + 0.5f); world.EnterWorld(container); } else if (t[x, y] == 6) { var mage = Entity.Resolve(0x0925); mage.Move(pos.X + x, pos.Y + y); world.EnterWorld(mage); } } //Boss & Chest }
public void RenderSetPiece(World world, IntPoint pos) { var t = new int[31, 40]; for (var x = 0; x < 13; x++) //Moats for (var y = 0; y < 13; y++) { if ((x == 0 && (y < 3 || y > 9)) || (y == 0 && (x < 3 || x > 9)) || (x == 12 && (y < 3 || y > 9)) || (y == 12 && (x < 3 || x > 9))) continue; t[x + 0, y + 0] = t[x + 18, y + 0] = 2; t[x + 0, y + 27] = t[x + 18, y + 27] = 2; } for (var x = 3; x < 28; x++) for (var y = 3; y < 37; y++) { if (x < 6 || x > 24 || y < 6 || y > 33) t[x, y] = 2; } for (var x = 7; x < 24; x++) //Floor for (var y = 7; y < 33; y++) t[x, y] = rand.Next()%3 == 0 ? 0 : 1; for (var x = 0; x < 7; x++) //Perimeter for (var y = 0; y < 7; y++) { if ((x == 0 && y != 3) || (y == 0 && x != 3) || (x == 6 && y != 3) || (y == 6 && x != 3)) continue; t[x + 3, y + 3] = t[x + 21, y + 3] = 4; t[x + 3, y + 30] = t[x + 21, y + 30] = 4; } for (var x = 6; x < 25; x++) t[x, 6] = t[x, 33] = 4; for (var y = 6; y < 34; y++) t[6, y] = t[24, y] = 4; for (var x = 13; x < 18; x++) //Bridge for (var y = 3; y < 7; y++) t[x, y] = 6; for (var x = 0; x < 31; x++) //Corruption for (var y = 0; y < 40; y++) { if (t[x, y] == 1 || t[x, y] == 0) continue; var p = rand.NextDouble(); if (t[x, y] == 6) { if (p < 0.4) t[x, y] = 0; continue; } if (p < 0.1) t[x, y] = 1; else if (p < 0.4) t[x, y]++; } //Boss & Chest t[15, 27] = 7; t[15, 20] = 8; var r = rand.Next(0, 4); for (var i = 0; i < r; i++) //Rotation t = SetPieces.rotateCW(t); int w = t.GetLength(0), h = t.GetLength(1); for (var x = 0; x < w; x++) //Rendering for (var y = 0; y < h; y++) { if (t[x, y] == 1) { var tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = Floor; tile.ObjType = 0; world.Obstacles[x + pos.X, y + pos.Y] = 0; world.Map[x + pos.X, y + pos.Y] = tile; } else if (t[x, y] == 2) { var tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = WaterA; tile.ObjType = 0; world.Obstacles[x + pos.X, y + pos.Y] = 0; world.Map[x + pos.X, y + pos.Y] = tile; } else if (t[x, y] == 3) { var tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = WaterB; tile.ObjType = 0; world.Obstacles[x + pos.X, y + pos.Y] = 3; world.Map[x + pos.X, y + pos.Y] = tile; } else if (t[x, y] == 4) { var tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = Floor; tile.ObjType = WallA; if (tile.ObjId == 0) tile.ObjId = world.GetNextEntityId(); world.Obstacles[x + pos.X, y + pos.Y] = 2; world.Map[x + pos.X, y + pos.Y] = tile; } else if (t[x, y] == 5) { var tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = Floor; world.Obstacles[x + pos.X, y + pos.Y] = 2; world.Map[x + pos.X, y + pos.Y] = tile; var wall = Entity.Resolve(WallB); wall.Move(x + pos.X + 0.5f, y + pos.Y + 0.5f); world.EnterWorld(wall); } else if (t[x, y] == 6) { var tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = Bridge; world.Obstacles[x + pos.X, y + pos.Y] = 0; world.Map[x + pos.X, y + pos.Y] = tile; } else if (t[x, y] == 7) { var container = new Container(0x0501, null, false); var count = rand.Next(5, 8); var items = new List<Item>(); while (items.Count < count) { var item = chest.GetRandomLoot(rand); if (item != null) items.Add(item); } for (var i = 0; i < items.Count; i++) container.Inventory[i] = items[i]; container.Move(pos.X + x + 0.5f, pos.Y + y + 0.5f); world.EnterWorld(container); } else if (t[x, y] == 8) { var cyclops = Entity.Resolve(0x67d); cyclops.Move(pos.X + x, pos.Y + y); world.EnterWorld(cyclops); } } }
private void ShowBags(Random rand, IEnumerable<Item> loots, Player owner) { var bagType = 0; var items = new Item[8]; var idx = 0; short bag; Container container; foreach (var i in loots) { if (i.BagType > bagType) bagType = i.BagType; items[idx] = i; idx++; if (idx == 8) { bag = 0x0500; switch (bagType) { case 0: bag = 0x0500; break; case 1: bag = 0x0503; break; case 2: bag = 0x0507; break; case 3: bag = 0x0508; break; case 4: bag = 0x0509; break; case 5: bag = 0xffd; break; case 6: bag = 0xffe; break; case 7: bag = 0xfff; break; } container = new Container(bag, 1000*60, true); for (var j = 0; j < 8; j++) container.Inventory[j] = items[j]; container.BagOwner = owner == null ? (int?) null : owner.AccountId; container.Move( Host.Self.X + (float) ((rand.NextDouble()*2 - 1)*0.5), Host.Self.Y + (float) ((rand.NextDouble()*2 - 1)*0.5)); container.Size = 80; Host.Self.Owner.EnterWorld(container); bagType = 0; items = new Item[8]; idx = 0; } } if (idx > 0) { bag = 0x0500; switch (bagType) { case 0: bag = 0x0500; break; case 1: bag = 0x0503; break; case 2: bag = 0x0507; break; case 3: bag = 0x0508; break; case 4: bag = 0x0509; break; case 5: bag = 0xffd; break; case 6: bag = 0xffe; break; case 7: bag = 0xfff; break; } container = new Container(bag, 1000*60, true); for (var j = 0; j < idx; j++) container.Inventory[j] = items[j]; container.BagOwner = owner == null ? (int?) null : owner.AccountId; container.Move( Host.Self.X + (float) ((rand.NextDouble()*2 - 1)*0.5), Host.Self.Y + (float) ((rand.NextDouble()*2 - 1)*0.5)); container.Size = 80; if (Host.Self.Owner != null) //was null sometimes { Host.Self.Owner.EnterWorld(container); } } }
public void RenderSetPiece(World world, IntPoint pos) { var t = new int[11, 11]; for (int x = 0; x < 11; x++) //Moats for (int y = 0; y < 11; y++) if (x == 0 || x == 10 || y == 0 || y == 10) { t[x, y] = t[x, y] = 1; t[x, y] = t[x, y] = 1; } for (int x = 1; x < 10; x++) //Floor for (int y = 1; y < 10; y++) t[x, y] = 2; //Boss & Chest t[5, 5] = 7; t[5, 6] = 8; int r = rand.Next(0, 4); for (int i = 0; i < r; i++) //Rotation t = SetPieces.rotateCW(t); int w = t.GetLength(0), h = t.GetLength(1); XmlData dat = world.Manager.GameData; for (int x = 0; x < w; x++) //Rendering for (int y = 0; y < h; y++) { if (t[x, y] == 1) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Lava]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; } else if (t[x, y] == 2) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Floor]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; } else if (t[x, y] == 7) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Floor]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; var container = new Container(world.Manager, 0x0501, null, false); Item[] items = chest.GetLoots(world.Manager, 5, 8).ToArray(); for (int i = 0; i < items.Length; i++) container.Inventory[i] = items[i]; container.Move(pos.X + x + 0.5f, pos.Y + y + 0.5f); world.EnterWorld(container); } else if (t[x, y] == 8) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Floor]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; Entity mage = Entity.Resolve(world.Manager, "Forgotten Archmage of Flame"); mage.Move(pos.X + x, pos.Y + y); world.EnterWorld(mage); } } }