public void RenderSetPiece(World world, IntPoint pos) { XmlData dat = world.Manager.GameData; IntPoint p = new IntPoint { X = pos.X - (Size / 2), Y = pos.Y - (Size / 2) }; for (int x = 0; x < Size; x++) { for (int y = 0; y < Size; y++) { if (SetPiece[y, x] == 1) { WmapTile tile = world.Map[x + p.X, y + p.Y].Clone(); tile.TileId = dat.IdToTileType["Red Quad"]; tile.ObjType = 0; world.Map[x + p.X, y + p.Y] = tile; } if (SetPiece[y, x] == 2) { WmapTile tile = world.Map[x + p.X, y + p.Y].Clone(); tile.TileId = dat.IdToTileType["Red Quad"]; tile.ObjType = 0; world.Map[x + p.X, y + p.Y] = tile; Entity en = Entity.Resolve(world.Manager, "Realm Portal"); en.Move(x + p.X + 0.5f, y + p.Y + 0.5f); world.EnterWorld(en); } } } }
public void RenderSetPiece(World world, IntPoint pos) { XmlData dat = world.Manager.GameData; for (int x = 0; x < Size; x++) { for (int y = 0; y < Size; y++) { if (SetPiece[y, x] == 1) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[DragonTileBlue]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; Entity dragonwallred = Entity.Resolve(world.Manager, "Dragon Wall Blue"); dragonwallred.Move(x + pos.X + 0.5f, y + pos.Y + 0.5f); world.EnterWorld(dragonwallred); } else if (SetPiece[y, x] == 2) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[DragonTileBlue]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; } else if (SetPiece[y, x] == 3) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[DragonTileCream]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; } } } }
public override void RenderSetPiece(World world, IntPoint pos) { EmbeddedData 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) { 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 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) { XmlData dat = world.Manager.GameData; IntPoint p = new IntPoint { X = pos.X - (Size / 2), Y = pos.Y - (Size / 2) }; for (int x = 0; x < Size; x++) { for (int y = 0; y < Size; y++) { if (SetPiece[y, x] == 1) { WmapTile tile = world.Map[x + p.X, y + p.Y].Clone(); tile.TileId = dat.IdToTileType["Evil Water"]; tile.ObjType = 0; world.Map[x + p.X, y + p.Y] = tile; } } } }
public void CheckGroundOnMove() { WmapTile tile = Owner.Map[(int)X, (int)Y]; TileDesc tileDesc = Manager.GameData.Tiles[tile.TileId]; if (tile.Region == TileRegion.Encounter_1 || tile.Region == TileRegion.Encounter_2 || tile.Region == TileRegion.Encounter_3 || tile.Region == TileRegion.Encounter_4) { string[] pokemons = new string[] { }; switch (tile.Region) { case TileRegion.Encounter_1: pokemons = new string[] { "Caterpie", "Weedle", "Kakuna", "Metapod" }; break; case TileRegion.Encounter_2: pokemons = new string[] { "Pidgey", "Rattata" }; break; case TileRegion.Encounter_3: pokemons = new string[] { "Bulbasaur", "Squirtle", "Charmander" }; break; case TileRegion.Encounter_4: pokemons = new string[] { "Venusaur", "Blastoise", "Charizard" }; break; } wRandom pokerand = new wRandom(); if (pokerand.Next(0, 10) == 0) { Client.SendPacket(new EncounterStartPacket() { Pokemon = pokemons[pokerand.Next(0, pokemons.Length)] }); } } }
public void RenderSetPiece(World world, IntPoint pos) { int[,] t = new int[33, 33]; for (int x = 0; x < 33; x++) //Grassing { for (int y = 0; y < 33; y++) { if (Math.Abs(x - Size / 2) / (Size / 2.0) + rand.NextDouble() * 0.3 < 0.95 && Math.Abs(y - Size / 2) / (Size / 2.0) + rand.NextDouble() * 0.3 < 0.95) { t[x, y] = 1; } } } for (int x = 12; x < 21; x++) //Outer { for (int y = 4; y < 29; y++) { t[x, y] = 2; } } t = SetPieces.rotateCW(t); for (int x = 12; x < 21; x++) { for (int y = 4; y < 29; y++) { t[x, y] = 2; } } for (int x = 13; x < 20; x++) //Inner { for (int y = 5; y < 28; y++) { t[x, y] = 4; } } t = SetPieces.rotateCW(t); for (int x = 13; x < 20; x++) { for (int y = 5; y < 28; y++) { t[x, y] = 4; } } for (int i = 0; i < 4; i++) //Ext { for (int x = 13; x < 20; x++) { for (int y = 5; y < 7; y++) { t[x, y] = 3; } } t = SetPieces.rotateCW(t); } for (int i = 0; i < 4; i++) //Pillars { t[13, 7] = rand.Next() % 3 == 0 ? 6 : 5; t[19, 7] = rand.Next() % 3 == 0 ? 6 : 5; t[13, 10] = rand.Next() % 3 == 0 ? 6 : 5; t[19, 10] = rand.Next() % 3 == 0 ? 6 : 5; t = SetPieces.rotateCW(t); } Noise noise = new Noise(Environment.TickCount); //Perlin noise for (int x = 0; x < 33; x++) { for (int y = 0; y < 33; y++) { if (noise.GetNoise(x / 33f * 8, y / 33f * 8, .5f) < 0.2) { t[x, y] = 0; } } } XmlData dat = world.Manager.GameData; for (int x = 0; x < 33; x++) //Rendering { for (int y = 0; y < 33; y++) { if (t[x, y] == 1) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Grass]; 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[TileDark]; 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[Tile]; 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[Stone]; tile.ObjType = 0; 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[Stone]; tile.ObjType = dat.IdToObjectType[PillarA]; if (tile.ObjId == 0) { tile.ObjId = world.GetNextEntityId(); } world.Map[x + pos.X, y + pos.Y] = tile; } else if (t[x, y] == 6) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Stone]; tile.ObjType = dat.IdToObjectType[PillarB]; if (tile.ObjId == 0) { tile.ObjId = world.GetNextEntityId(); } world.Map[x + pos.X, y + pos.Y] = tile; } } } Entity skull = Entity.Resolve(world.Manager, "Skull Shrine"); //Skulls! skull.Move(pos.X + Size / 2f, pos.Y + Size / 2f); world.EnterWorld(skull); }
public void RenderSetPiece(World world, IntPoint pos) { var t = new int[25, 26]; for (int x = 2; x < 23; x++) //Floor { for (int y = 1; y < 24; y++) { t[x, y] = rand.Next() % 10 == 0 ? 0 : 1; } } for (int y = 1; y < 24; y++) //Perimeters { t[2, y] = t[22, y] = 2; } for (int x = 2; x < 23; x++) { t[x, 23] = 2; } for (int x = 0; x < 3; x++) { for (int y = 0; y < 3; y++) { t[x + 1, y] = t[x + 21, y] = 2; } } for (int x = 0; x < 5; x++) { for (int y = 0; y < 5; y++) { if ((x == 0 && y == 0) || (x == 0 && y == 4) || (x == 4 && y == 0) || (x == 4 && y == 4)) { continue; } t[x, y + 21] = t[x + 20, y + 21] = 2; } } for (int y = 0; y < 6; y++) //Pillars { t[9, 4 + 3 * y] = t[15, 4 + 3 * y] = 4; } for (int x = 0; x < 25; x++) //Corruption { for (int y = 0; y < 26; y++) { if (t[x, y] == 1 || t[x, y] == 0) { continue; } double p = rand.NextDouble(); if (p < 0.1) { t[x, y] = 1; } else if (p < 0.4) { t[x, y]++; } } } 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[PillarA]; 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]; tile.ObjType = dat.IdToObjectType[PillarB]; if (tile.ObjId == 0) { tile.ObjId = world.GetNextEntityId(); } world.Map[x + pos.X, y + pos.Y] = tile; } } } //Boss Entity lich = Entity.Resolve(world.Manager, "Lich"); lich.Move(pos.X + Size / 2, pos.Y + Size / 2); world.EnterWorld(lich); }
protected static void Render(Temple temple, World world, IntPoint pos, int[,] ground, int[,] objs) { EmbeddedData dat = world.Manager.GameData; for (int x = 0; x < temple.Size; x++) //Rendering { for (int y = 0; y < temple.Size; y++) { if (ground[x, y] == 1) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[DarkGrass]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; } else if (ground[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; } if (objs[x, y] == 1) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.ObjType = dat.IdToObjectType[WallA]; if (tile.ObjId == 0) { tile.ObjId = world.GetNextEntityId(); } world.Map[x + pos.X, y + pos.Y] = tile; } else if (objs[x, y] == 2) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.ObjType = dat.IdToObjectType[WallB]; if (tile.ObjId == 0) { tile.ObjId = world.GetNextEntityId(); } world.Map[x + pos.X, y + pos.Y] = tile; } else if (objs[x, y] == 3) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.ObjType = dat.IdToObjectType[WallC]; if (tile.ObjId == 0) { tile.ObjId = world.GetNextEntityId(); } world.Map[x + pos.X, y + pos.Y] = tile; } else if (objs[x, y] == 4) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.ObjType = dat.IdToObjectType[Flower]; if (tile.ObjId == 0) { tile.ObjId = world.GetNextEntityId(); } world.Map[x + pos.X, y + pos.Y] = tile; } else if (objs[x, y] == 5) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.ObjType = dat.IdToObjectType[Grass]; if (tile.ObjId == 0) { tile.ObjId = world.GetNextEntityId(); } world.Map[x + pos.X, y + pos.Y] = tile; } else if (objs[x, y] == 6) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.ObjType = dat.IdToObjectType[Tree]; if (tile.ObjId == 0) { tile.ObjId = world.GetNextEntityId(); } world.Map[x + pos.X, y + pos.Y] = tile; } } } }
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 (IntPoint i in trees) { t[i.X, i.Y] = 3; } XmlData dat = world.Manager.GameData; for (int x = 0; x < Size; x++) { for (int y = 0; y < Size; 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[Water]; 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[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 => { 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 = db.getSerialInfo(t.Items, Manager.GameData); 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); } }); }
public void RenderSetPiece(World world, IntPoint pos) { XmlData dat = world.Manager.GameData; for (int x = 0; x < Size; x++) { for (int y = 0; y < Size; y++) { if (SetPiece[y, x] == 1) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Floor1]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; } else if (SetPiece[y, x] == 2) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Floor2]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; } else if (SetPiece[y, x] == 3) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Floor3]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; } else if (SetPiece[y, x] == 4) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Floor4]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; } else if (SetPiece[y, x] == 5) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Middle]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; } else if (SetPiece[y, x] == 6) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Air]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; } else if (SetPiece[y, x] == 7) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Air2]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; } else if (SetPiece[y, x] == 8) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Air3]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; } else if (SetPiece[y, x] == 9) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Air4]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; } else if (SetPiece[y, x] == 10) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Middle]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; Entity elemental = Entity.Resolve(world.Manager, "Maurth the Succubus Queen"); elemental.Move(pos.X + Size / 2f, pos.Y + Size / 2f); world.EnterWorld(elemental); } } } }
public override void RenderSetPiece(World world, IntPoint pos) { Stopwatch sw = new Stopwatch(); sw.Start(); long time = sw.ElapsedMilliseconds; // Declare cooldown for setpiece transitions int delay = 2000; // 2 seconds // Declare stages bool stage1 = true; bool stage2 = false; bool stage3 = false; bool stage4 = false; bool stage5 = false; bool stage6 = false; bool stage7 = false; bool stage8 = false; bool done = false; // when setpiece is done after all stages EmbeddedData dat = GameServer.Manager.GameData; IntPoint p = new IntPoint { X = pos.X - (Size / 2), Y = pos.Y - (Size / 2) }; do { for (int x = 0; x < Size; x++) { for (int y = 0; y < Size; y++) { // stage 1 if (time >= delay && time < delay * 2 && SetPiece[y, x] == 1 && stage1) { WmapTile tile = world.Map[x + p.X, y + p.Y].Clone(); tile.TileId = dat.IdToTileType["Lava"]; tile.ObjType = 0; world.Map[x + p.X, y + p.Y] = tile; stage1 = false; stage2 = true; } // stage 2 if (time >= delay * 2 && time < delay * 3 && SetPiece[y, x] == 2 && stage2) { WmapTile tile = world.Map[x + p.X, y + p.Y].Clone(); tile.TileId = dat.IdToTileType["Lava"]; tile.ObjType = 0; world.Map[x + p.X, y + p.Y] = tile; stage2 = false; stage3 = true; } // stage 3 if (time >= delay * 3 && time < delay * 4 && SetPiece[y, x] == 3 && stage3) { WmapTile tile = world.Map[x + p.X, y + p.Y].Clone(); tile.TileId = dat.IdToTileType["Lava"]; tile.ObjType = 0; world.Map[x + p.X, y + p.Y] = tile; stage3 = false; stage4 = true; } // stage 4 if (time >= delay * 4 && time < delay * 5 && SetPiece[y, x] == 4 && stage4) { WmapTile tile = world.Map[x + p.X, y + p.Y].Clone(); tile.TileId = dat.IdToTileType["Lava"]; tile.ObjType = 0; world.Map[x + p.X, y + p.Y] = tile; stage4 = false; stage5 = true; } // stage 5 if (time >= delay * 5 && time < delay * 6 && SetPiece[y, x] == 4 && stage5) { WmapTile tile = world.Map[x + p.X, y + p.Y].Clone(); tile.TileId = dat.IdToTileType["Red Quad"]; tile.ObjType = 0; world.Map[x + p.X, y + p.Y] = tile; stage5 = false; stage6 = true; } // stage 6 if (time >= delay * 6 && time < delay * 7 && SetPiece[y, x] == 3 && stage6) { WmapTile tile = world.Map[x + p.X, y + p.Y].Clone(); tile.TileId = dat.IdToTileType["Red Quad"]; tile.ObjType = 0; world.Map[x + p.X, y + p.Y] = tile; stage6 = false; stage7 = true; } // stage 7 if (time >= delay * 7 && time < delay * 8 && SetPiece[y, x] == 2 && stage7) { WmapTile tile = world.Map[x + p.X, y + p.Y].Clone(); tile.TileId = dat.IdToTileType["Red Quad"]; tile.ObjType = 0; world.Map[x + p.X, y + p.Y] = tile; stage7 = false; stage8 = true; } // stage 8 (final) if (time >= delay * 8 && SetPiece[y, x] == 1 && stage8) { WmapTile tile = world.Map[x + p.X, y + p.Y].Clone(); tile.TileId = dat.IdToTileType["Red Quad"]; tile.ObjType = 0; world.Map[x + p.X, y + p.Y] = tile; stage8 = false; done = true; } } } } while (!done); }
public override void Tick(RealmTime time) { base.Tick(time); if (!started && duelist1 != null) { waitingNotif--; if (waitingNotif <= 0) { duelist1.Client.SendPacket(new NotificationPacket { Color = new ARGB(0xFF2222FF), ObjectId = duelist1.Id, Text = "Waiting for duelist..." }); waitingNotif = 2 * 10; } } if (started && QueuedPlayers.ContainsKey(duelist1)) { QueuedPlayers.Remove(duelist1); } if (started && timeLeft > 0) { if (timeLeft % Manager.Logic.TPS == 0) { if (timeLeft / Manager.Logic.TPS == 5) { duelist1.SendInfo("Duel begun with " + duelist2.Name + "."); duelist2.SendInfo("Duel begun with " + duelist1.Name + "."); } foreach (Player i in Players.Values) { i.Client.SendPacket(new NotificationPacket { Color = timeLeft / Manager.Logic.TPS == 5 ? new ARGB(0xFFFF00FF) : new ARGB(0xFFFF0000), ObjectId = i.Id, Text = timeLeft / Manager.Logic.TPS == 5 ? duelist1.Name + " vs. " + duelist2.Name : timeLeft / Manager.Logic.TPS == 4 ? "Duel beginning in..." : (timeLeft / Manager.Logic.TPS).ToString() }); } } timeLeft--; } else if (started && timeLeft == 0) { AllowAbilityTeleport = true; PvP = true; foreach (Player i in Players.Values) { i.Client.SendPacket(new NotificationPacket { Color = new ARGB(0xFF770000), ObjectId = i.Id, Text = "Fight!" }); i.PvP = true; i.UpdateCount++; } foreach (IntPoint point in Map.Regions[TileRegion.Hallway]) { WmapTile tile = Map[point.X, point.Y].Clone(); tile.ObjType = 0; Map[point.X, point.Y] = tile; } timeLeft = -1; } }
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); } } } }
public virtual void TileEvent(Player player, WmapTile tile) { }
public void RenderSetPiece(World world, IntPoint pos) { int[,] t = new int[Size, Size]; for (int x = 0; x < Size; x++) //Bush { for (int y = 0; y < Size; y++) { { if (rand.NextDouble() < 0.02) { t[x, y] = 1; } } } } for (int x = 0; x < Size; x++) //Butterfly { for (int y = 0; y < Size; y++) { { if (rand.NextDouble() < 0.02) { t[x, y] = 2; } } } } for (int x = 0; x < Size; x++) //Corn { for (int y = 0; y < Size; y++) { { if (rand.NextDouble() < 0.02) { t[x, y] = 3; } } } } for (int x = 0; x < Size; x++) //Fir Tree 2 { for (int y = 0; y < Size; y++) { { if (rand.NextDouble() < 0.02) { t[x, y] = 4; } } } } XmlData dat = world.Manager.GameData; for (int x = 0; x < Size; x++) //Rendering { for (int y = 0; y < Size; y++) { if (t[x, y] != 100) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); if (tile.TileId == dat.IdToTileType[Floor]) { tile.ObjType = 0; if (tile.ObjId == 0) { tile.ObjId = world.GetNextEntityId(); } tile.TileId = dat.IdToTileType[ToFloor]; } if (tile.TileId == dat.IdToTileType[Ocean]) { tile.TileId = dat.IdToTileType[ToOcean]; } if (tile.TileId == dat.IdToTileType[Shallow]) { tile.TileId = dat.IdToTileType[ToShallow]; } world.Map[x + pos.X, y + pos.Y] = tile; } if (t[x, y] == 1) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); if (tile.TileId == dat.IdToTileType[ToFloor]) { tile.ObjType = dat.IdToObjectType[F1]; if (tile.ObjId == 0) { tile.ObjId = world.GetNextEntityId(); } } world.Map[x + pos.X, y + pos.Y] = tile; } if (t[x, y] == 2) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); if (tile.TileId == dat.IdToTileType[ToFloor]) { tile.ObjType = dat.IdToObjectType[F2]; if (tile.ObjId == 0) { tile.ObjId = world.GetNextEntityId(); } } world.Map[x + pos.X, y + pos.Y] = tile; } if (t[x, y] == 3) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); if (tile.TileId == dat.IdToTileType[Floor]) { tile.ObjType = dat.IdToObjectType[F3]; if (tile.ObjId == 0) { tile.ObjId = world.GetNextEntityId(); } } world.Map[x + pos.X, y + pos.Y] = tile; } if (t[x, y] == 4) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); if (tile.TileId == dat.IdToTileType[ToFloor]) { tile.ObjType = dat.IdToObjectType[F4]; if (tile.ObjId == 0) { tile.ObjId = world.GetNextEntityId(); } } world.Map[x + pos.X, y + pos.Y] = tile; } } } }
public void EnemyHit(RealmTime time, EnemyHitPacket pkt) { try { var entity = Owner.GetEntity(pkt.TargetId); bool infiniWalling = false; if (Owner.Mining) { if ((entity is Wall)) { infiniWalling = true; Wall w = (entity as Wall); w.HP = 0; GenLogic.GenRandomRoom(Owner, w.X, w.Y, w); for (var tx = -1; tx <= 1; tx++) { for (var ty = -1; ty <= 1; ty++) { if (Owner.Map[(int)w.X + tx, (int)w.Y + ty].TileId == 0xff && Owner.Map[(int)w.X + tx, (int)w.Y + ty].ObjId == 0) { WmapTile tile = Owner.Map[(int)w.X + tx, (int)w.Y + ty]; tile.TileId = Owner.Map[(int)w.X, (int)w.Y].TileId; Owner.Map[(int)w.X + tx, (int)w.Y + ty] = tile; Wall e = new Wall(w.ObjectType, XmlDatas.TypeToElement[w.ObjectType]); e.Move(w.X + tx, w.Y + ty); Owner.EnterWorld(e); } } } } } Projectile prj = (this as IProjectileOwner).Projectiles[pkt.BulletId]; prj.Damage = (int)statsMgr.GetAttackDamage(prj.Descriptor.MinDamage, prj.Descriptor.MaxDamage); prj.ForceHit(entity, time); if (pkt.Killed && !(entity is Wall)) { psr.SendPacket(new UpdatePacket() { Tiles = new UpdatePacket.TileData[0], NewObjects = new ObjectDef[] { entity.ToDefinition() }, RemovedObjectIds = new int[] { pkt.TargetId } }); clientEntities.Remove(entity); } } catch { /*Console.ForegroundColor = ConsoleColor.DarkMagenta; * Console.WriteLine("CAN'T REGISTER HIT by player " + Name); * Console.ForegroundColor = ConsoleColor.White; * * Disabled, this message spams when an enemy dies*/ } /* * if (entity != null && pkt.Killed) //Tolerance * { * Projectile prj = (this as IProjectileOwner).Projectiles[pkt.BulletId]; * Position? entPos = entity.TryGetHistory((time.tickTimes - tickMapping) - pkt.Time); * Position? prjPos = prj == null ? null : (Position?)prj.GetPosition(pkt.Time + tickMapping - prj.BeginTime); * var tol1 = (entPos == null || prjPos == null) ? 10 : (prjPos.Value.X - entPos.Value.X) * (prjPos.Value.X - entPos.Value.X) + (prjPos.Value.Y - entPos.Value.Y) * (prjPos.Value.Y - entPos.Value.Y); * var tol2 = prj == null ? 10 : (prj.X - entity.X) * (prj.X - entity.X) + (prj.Y - entity.Y) * (prj.Y - entity.Y); * if (prj != null && (tol1 < 1 || tol2 < 1)) * { * prj.ForceHit(entity, time); * } * else * { * Console.ForegroundColor = ConsoleColor.DarkMagenta; * Console.WriteLine("CAN'T REGISTER HIT!" + " X: " + tol1 + " Y: " + tol2); * Console.ForegroundColor = ConsoleColor.White; * psr.SendPacket(new UpdatePacket() * { * Tiles = new UpdatePacket.TileData[0], * NewObjects = new ObjectDef[] { entity.ToDefinition() }, * RemovedObjectIds = new int[] { pkt.TargetId } * }); * clientEntities.Remove(entity); * } * } * else if (pkt.Killed) * { * psr.SendPacket(new UpdatePacket() * { * Tiles = new UpdatePacket.TileData[0], * NewObjects = Empty<ObjectDef>.Array, * RemovedObjectIds = new int[] { pkt.TargetId } * }); * }*/ }
public void RenderSetPiece(World world, IntPoint pos) { var t = new int[81, 81]; 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 <= 35) { t[x, y] = 1; } } } for (int x = 0; x < 17; x++) { for (int y = 0; y < 17; y++) { if (Center[x, y] != 0) { t[32 + x, 32 + y] = 2; } } } t[36, 36] = t[44, 36] = t[36, 44] = t[44, 44] = 3; //Pillars (Solo Standing) t[30, 30] = t[50, 30] = t[30, 50] = t[50, 50] = 5; //Pillars (Outer Shape) t[29, 33] = t[47, 29] = t[51, 47] = t[33, 51] = 5; t[32, 29] = t[48, 51] = t[51, 32] = t[29, 48] = 5; // messy t[29, 31] = t[49, 29] = t[51, 49] = t[31, 51] = 5; t[30, 31] = t[49, 30] = t[50, 49] = t[31, 50] = 5; t[33, 29] = t[51, 33] = t[47, 51] = t[29, 47] = 5; t[29, 32] = t[51, 48] = t[48, 29] = t[32, 51] = 5; // messy t[31, 29] = t[51, 31] = t[49, 51] = t[29, 49] = 5; t[31, 30] = t[50, 31] = t[49, 50] = t[30, 49] = 5; t[40, 26] = t[40, 27] = t[39, 27] = t[41, 27] = 4; //Pillars (T Shape) t[40, 54] = t[40, 53] = t[39, 53] = t[41, 53] = 4; t[26, 40] = t[27, 40] = t[27, 39] = t[27, 41] = 4; t[54, 40] = t[53, 40] = t[53, 39] = t[53, 41] = 4; for (int x = 0; x < Size; x++) //Rendering { for (int y = 0; y < Size; y++) { if (t[x, y] == 1) { WmapTile 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) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = Central; 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) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = Central; tile.ObjType = Pillar; tile.Name = ConnectionComputer.GetConnString((_x, _y) => t[x + _x, y + _y] == 3); 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] == 4) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = Floor; tile.ObjType = Pillar; tile.Name = ConnectionComputer.GetConnString((_x, _y) => t[x + _x, y + _y] == 4); 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) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = Floor; tile.ObjType = Pillar; tile.Name = ConnectionComputer.GetConnString((_x, _y) => t[x + _x, y + _y] == 5); 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 unknown = Entity.Resolve(0x0f02); unknown.Move(pos.X + 40.5f, pos.Y + 40.5f); world.EnterWorld(unknown); }
public void RenderSetPiece(World world, IntPoint pos) { var 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; } var 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) { var 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 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) { int outerRadius = 13; int waterRadius = 10; int islandRadius = 3; var border = new List <IntPoint>(); var 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)); } } } } var trees = new HashSet <IntPoint>(); while (trees.Count < border.Count * 0.5) { trees.Add(border[rand.Next(0, border.Count)]); } foreach (IntPoint 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) { WmapTile 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) { WmapTile 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) { WmapTile 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); var container = new Container(0x0501, null, false); int count = rand.Next(5, 8); var 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 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(); using (Database db = new Database()) { for (int i = 0; i < gifts.Count(); i++) { Item newGift = db.getSerialInfo(gifts[i], Manager.GameData); if (c.Items.Count < 8) { c.Items.Add(newGift); wasLastElse = false; } else { giftChests.Add(c); c = new GiftChest(); c.Items = new List <Item>(8); c.Items.Add(newGift); 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; using (Database db = new Database()) { inv = db.getSerialInfo(t.Items, Manager.GameData); }; 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); } }
void SendUpdate(RealmTime time) { int _x = (int)X; int _y = (int)Y; if (Owner == null) { return; } SightTiles = (Owner.IsBlocked() ? Sight.RayCast(this, RADIUS) : Sight.GetSightCircle(this, RADIUS).ToList()); mapWidth = Owner.Map.Width; mapHeight = Owner.Map.Height; var sendEntities = new HashSet <Entity>(GetNewEntities()); var list = new List <UpdatePacket.TileData>(APPOX_AREA_OF_SIGHT); int sent = 0; foreach (var i in SightTiles) { int x = i.X; int y = i.Y; WmapTile tile = Owner.Map[x, y]; if (x < 0 || x >= mapWidth || y < 0 || y >= mapHeight || _tiles[x, y] >= (tile = Owner.Map[x, y]).UpdateCount) { continue; } list.Add(new UpdatePacket.TileData() { X = (short)x, Y = (short)y, Tile = tile.TileId }); _tiles[x, y] = tile.UpdateCount; sent++; } foreach (var i in newSightTiles) { SightTiles.Add(i); } FameCounter.TileSent(sent); var dropEntities = GetRemovedEntities().Distinct().ToArray(); clientEntities.RemoveWhere(_ => Array.IndexOf(dropEntities, _.Id) != -1); foreach (var i in sendEntities) { lastUpdate[i] = i.UpdateCount; } var newStatics = GetNewStatics(_x, _y).ToArray(); var removeStatics = GetRemovedStatics(_x, _y).ToArray(); List <int> removedIds = new List <int>(); foreach (var i in removeStatics) { removedIds.Add(Owner.Map[i.X, i.Y].ObjId); clientStatic.Remove(i); } if (sendEntities.Count > 0 || list.Count > 0 || dropEntities.Length > 0 || newStatics.Length > 0 || removedIds.Count > 0) { Client.SendPacket(new UpdatePacket() { Tiles = list.ToArray(), NewObjects = sendEntities.Select(_ => _.ToDefinition()).Concat(newStatics).ToArray(), RemovedObjectIds = dropEntities.Concat(removedIds).ToArray() }); } SendNewTick(time); }
public void RenderSetPiece(World world, IntPoint pos) { var t = new int[81, 81]; for (int x = 0; x < Size; x++) //Flooring { 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 <= 35) { t[x, y] = 1; } } } for (int x = 0; x < 17; x++) //Center { for (int y = 0; y < 17; y++) { if (Center[x, y] != 0) { t[32 + x, 32 + y] = 2; } } } t[36, 36] = t[44, 36] = t[36, 44] = t[44, 44] = 3; //Pillars t[30, 30] = t[50, 30] = t[30, 50] = t[50, 50] = 4; t[40, 26] = t[40, 27] = t[39, 27] = t[41, 27] = 4; t[40, 54] = t[40, 53] = t[39, 53] = t[41, 53] = 4; t[26, 40] = t[27, 40] = t[27, 39] = t[27, 41] = 4; t[54, 40] = t[53, 40] = t[53, 39] = t[53, 41] = 4; XmlData dat = world.Manager.GameData; for (int x = 0; x < Size; x++) //Rendering { for (int y = 0; y < Size; 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[Central]; 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[Central]; tile.ObjType = dat.IdToObjectType[Pillar]; tile.Name = ConnectionComputer.GetConnString((_x, _y) => t[x + _x, y + _y] == 3); if (tile.ObjId == 0) { tile.ObjId = world.GetNextEntityId(); } 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[Pillar]; tile.Name = ConnectionComputer.GetConnString((_x, _y) => t[x + _x, y + _y] == 4); if (tile.ObjId == 0) { tile.ObjId = world.GetNextEntityId(); } world.Map[x + pos.X, y + pos.Y] = tile; } } } Entity sphinx = Entity.Resolve(world.Manager, "Grand Sphinx"); sphinx.Move(pos.X + 40.5f, pos.Y + 40.5f); world.EnterWorld(sphinx); }
protected override void TickCore(Entity host, RealmTime time, ref object state) { if ((host as Pet)?.PlayerOwner != null) { return; } var map = host.Owner.Map; var x = (int)host.X; var y = (int)host.Y; WmapTile tile = null; if (map.Contains(x, y)) { tile = map[x, y]; } if (tile == null || (tile.Region == TileRegion.None && host.Owner is PetYard)) { host.Move(spawnPoint.X, spawnPoint.Y); return; } if (host.GetNearestEntity(1, null) != null) { return; } WanderStorage storage; if (state == null) { storage = new WanderStorage(); } else { storage = (WanderStorage)state; } Status = CycleStatus.NotStarted; if (host.HasConditionEffect(ConditionEffects.Paralyzed)) { return; } Status = CycleStatus.InProgress; if (storage.RemainingDistance <= 0) { storage.Direction = new Vector2(Random.Next(-2, 2), Random.Next(-2, 2)); storage.Direction.Normalize(); storage.RemainingDistance = coolDown.Next(Random) / 1000f; Status = CycleStatus.Completed; } float dist = host.GetSpeed(speed) * (time.ElaspedMsDelta / 1000f); host.ValidateAndMove(host.X + storage.Direction.X * dist, host.Y + storage.Direction.Y * dist); storage.RemainingDistance -= dist; state = storage; }
public void RenderSetPiece(World world, IntPoint pos) { var 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); var y1_ = (int)Math.Ceiling(y1 * Size); var 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; XmlData dat = world.Manager.GameData; for (int x = 0; x < Size; x++) //Rendering { for (int y = 0; y < Size; y++) { if (p[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 (p[x, y] == 2) { WmapTile 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); 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 + 20.5f, pos.Y + 20.5f); world.EnterWorld(container); }
protected override void TickCore(Entity host, RealmTime time, ref object state) { int cool = (int)state; if (cool <= 0) { if (host.HasConditionEffect(ConditionEffectIndex.Stunned)) { return; } double?tossAngle = randomToss ? Random.Next(0, 360) * Math.PI / 180 : angle; Entity en = null; if (tossAngle == null) { en = host.GetNearestEntity(range, null); } if (tossAngle == null && en == null) { return; } Position target = tossAngle == null ? new Position { X = en.X, Y = en.Y } : new Position { X = host.X + (float)(range * Math.Cos(tossAngle.Value)), Y = host.Y + (float)(range * Math.Sin(tossAngle.Value)), }; Wmap map = host.Owner.Map; WmapTile tile = map[(int)target.X, (int)target.Y]; if (host.Manager.GameData.Tiles[tile.TileId].NoWalk) { return; } if (target.X < 0 || target.Y < 0) { return; } if (!throwProjectileEffect) { host.Owner.BroadcastPacket(new ShowEffectPacket { EffectType = EffectType.Throw, Color = new ARGB(0xffffbf00), TargetObjectId = host.Id, PosA = target }, null); } else { host.Owner.BroadcastPacket(new ShowEffectPacket { EffectType = EffectType.ThrowProjectile, Color = new ARGB(child), PosA = target, PosB = new Position { X = host.X, Y = host.Y } //host pos. }, null); } host.Owner.Timers.Add(new WorldTimer(1500, (world, t) => { Entity entity = Entity.Resolve(world.Manager, child); entity.Move(target.X, target.Y); if (entity is Enemy && host is Enemy) { (entity as Enemy).Terrain = (host as Enemy).Terrain; } world.EnterWorld(entity); })); cool = coolDown.Next(Random); } else { cool -= time.ElaspedMsDelta; } state = cool; }
public override void RenderSetPiece(World world, IntPoint pos) { int w = rand.Next(19, 22), h = rand.Next(19, 22); int[,] t = new int[w, h]; for (int x = 0; x < w; x++) //Perimeter { t[x, 0] = 1; t[x, h - 1] = 1; } for (int y = 0; y < h; y++) { t[0, y] = 1; t[w - 1, y] = 1; } int midPtH = h / 2 + rand.Next(-2, 3); //Mid hori wall int sepH = rand.Next(2, 4); if (rand.Next() % 2 == 0) { for (int x = sepH; x < w; x++) { t[x, midPtH] = 1; } } else { for (int x = 0; x < w - sepH; x++) { t[x, midPtH] = 1; } } int begin, end; if (rand.Next() % 2 == 0) { begin = 0; end = midPtH; } else { begin = midPtH; end = h; } int midPtV = w / 2 + rand.Next(-2, 3); //Mid vert wall int sepW = rand.Next(2, 4); if (rand.Next() % 2 == 0) { for (int y = begin + sepW; y < end; y++) { t[midPtV, y] = 1; } } else { for (int y = begin; y < end - sepW; y++) { t[midPtV, y] = 1; } } for (int x = 0; x < w; x++) //Flooring { for (int y = 0; y < h; y++) { if (t[x, y] == 0) { t[x, y] = 2; } } } for (int x = 0; x < w; x++) //Corruption { for (int y = 0; y < h; y++) { if (rand.Next() % 2 == 0) { t[x, y] = 0; } } } int rotation = rand.Next(0, 4); //Rotation for (int i = 0; i < rotation; i++) { t = SetPieces.rotateCW(t); } w = t.GetLength(0); h = t.GetLength(1); EmbeddedData 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.ObjType = dat.IdToObjectType[Wall]; if (tile.ObjId == 0) { tile.ObjId = world.GetNextEntityId(); } 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; } } } }
protected override void TickCore(Entity host, RealmTime time, ref object state) { if (state == null) { return; } int cool = (int)state; Status = CycleStatus.NotStarted; if (cool <= 0) { if (host.HasConditionEffect(ConditionEffectIndex.Stunned)) { return; } Entity player = host.GetNearestEntity(radius, null); WmapTile tile = host.Owner.Map[(int)host.X + 1, (int)host.Y].Clone(); if (tile.ObjType != 0) { base.fixedAngle = 180 * Math.PI / 180; } else { base.fixedAngle = 0 * Math.PI / 180; } if (player != null || defaultAngle != null || fixedAngle != null) { ProjectileDesc desc = host.ObjectDesc.Projectiles[projectileIndex]; double a = fixedAngle ?? (player == null ? defaultAngle.Value : Math.Atan2(player.Y - host.Y, player.X - host.X)); a += angleOffset; int dmg; if (host is Character) { dmg = (host as Character).Random.Next(desc.MinDamage, desc.MaxDamage); } else { dmg = Random.Next(desc.MinDamage, desc.MaxDamage); } double startAngle = a - shootAngle * (count - 1) / 2; byte prjId = 0; Position prjPos = new Position { X = host.X, Y = host.Y }; for (int i = 0; i < count; i++) { Projectile prj = host.CreateProjectile( desc, host.ObjectType, dmg, time.tickTimes, prjPos, (float)(startAngle + shootAngle * i)); host.Owner.EnterWorld(prj); if (i == 0) { prjId = prj.ProjectileId; } } host.Owner.BroadcastPacket(new ShootPacket { BulletId = prjId, OwnerId = host.Id, Position = prjPos, Angle = (float)startAngle, Damage = (short)dmg, BulletType = (byte)(desc.BulletType), AngleInc = (float)shootAngle, NumShots = (byte)count, }, null); } cool = coolDown.Next(Random); Status = CycleStatus.Completed; } else { cool -= time.thisTickTimes; Status = CycleStatus.InProgress; } state = cool; }
private void Init(Client psr) { if (psr == null) { return; } 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))); if (psr.Account.Gifts != null) { List <GiftChest> giftChests = new List <GiftChest>(); GiftChest c = new GiftChest { 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 (GameServer.Manager.GameData.Items.ContainsKey((ushort)gifts[i])) { if (c.Items.Count < 8) { c.Items.Add(GameServer.Manager.GameData.Items[(ushort)gifts[i]]); wasLastElse = false; } else { giftChests.Add(c); c = new GiftChest { Items = new List <Item>(8) }; c.Items.Add(GameServer.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(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); } } dbVault = new DbVault(psr.Account); for (int i = 0; i < psr.Account.VaultCount; i++) { if (vaultChestPosition.Count == 0) { break; } Container con = new Container(0x0504, null, false); var inv = dbVault[i].Select(_ => _ == -1 ? null : (GameServer.Manager.GameData.Items.ContainsKey((ushort)_) ? GameServer.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[Tuple.Create(con, i)] = con.UpdateCount; } foreach (IntPoint i in giftChestPosition) { GameObject x = new GameObject(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(0x0505); x.Move(i.X + 0.5f, i.Y + 0.5f); EnterWorld(x); } }
public override void RenderSetPiece(World world, IntPoint pos) { int radius = rand.Next(Size - 5, Size + 1) / 2; List <IntPoint> border = new List <IntPoint>(); int[,] t = new int[Size, Size]; for (int y = 0; y < Size; y++) { 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 <= radius) { t[x, y] = 1; if (radius - r < 1.5) { 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 (IntPoint i in trees) { t[i.X, i.Y] = 2; } EmbeddedData dat = world.Manager.GameData; for (int x = 0; x < Size; x++) { for (int y = 0; y < Size; 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[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 ent = Entity.Resolve(world.Manager, "Ent Ancient"); ent.Size = 140; ent.Move(pos.X + Size / 2 + 1, pos.Y + Size / 2 + 1); world.EnterWorld(ent); }