private void button3_Click(object sender, EventArgs e) { //addnpc Interfaces.INpc npc = new Network.GamePackets.NpcSpawn(); npc.UID = uint.Parse(textBox1.Text); if (!ServerBase.Kernel.Maps[ushort.Parse(textBox6.Text)].Npcs.ContainsKey(npc.UID)) { npc.Kind = (Enums.NpcKind)byte.Parse(textBox2.Text); npc.X = ushort.Parse(textBox4.Text); npc.Y = ushort.Parse(textBox5.Text); npc.MapID = ushort.Parse(textBox6.Text); npc.Model = ushort.Parse(textBox7.Text); npc.Facing = (Enums.ConquerAngle)0; Database.MySqlCommand cmd = new Database.MySqlCommand(Database.MySqlCommandType.INSERT); cmd.Insert("cq_npc").Insert("id", npc.UID).Insert("name", textBox3.Text).Insert("type", (ushort)npc.Kind).Insert("lookface", (int)npc.Model).Insert("cellx", npc.X).Insert("celly", npc.Y).Insert("mapid", npc.MapID); cmd.Execute(); npc.Model = (ushort)(npc.Model / 10); ServerBase.Kernel.Maps[ushort.Parse(textBox6.Text)].AddNpc(npc); WriteLine("Successfully added new npc " + npc.UID); } else { WriteLine("The map " + textBox6.Text + " already contains \n an npc with id " + npc.UID); } }
public static void Load() { if (ServerBase.Kernel.Maps.ContainsKey(1002)) { uint ItemID = 720159; #region CPBag INpc npc = new Network.GamePackets.NpcSpawn(); npc.UID = 1305; npc.Mesh = 13050; npc.Type = Enums.NpcType.Talker; npc.X = (ushort)(X-1); npc.Y = (ushort)(Y-1); npc.MapID = 1002; //ServerBase.Kernel.Maps[1002].AddNpc(npc); // Program.KimoTime16 = Time32.Now; Game.Map Map = ServerBase.Kernel.Maps[1002]; if (Map.SelectCoordonates(ref X, ref Y)) { Network.GamePackets.FloorItem floorItem = new Network.GamePackets.FloorItem(true); floorItem.ValueType = Network.GamePackets.FloorItem.FloorValueType.ConquerPoints; floorItem.Value = Database.rates.PartyDrop; floorItem.ItemID = ItemID; floorItem.MapID = 1002; floorItem.MapObjType = Game.MapObjectType.Item; floorItem.X = X; floorItem.Y = Y; floorItem.Type = Network.GamePackets.FloorItem.Drop; floorItem.OnFloor = Time32.Now; floorItem.UID = Network.GamePackets.FloorItem.FloorUID.Next; while (Map.Npcs.ContainsKey(floorItem.UID)) { floorItem.UID = Network.GamePackets.FloorItem.FloorUID.Next; } Map.AddFloorItem(floorItem); foreach (Client.GameState C in ServerBase.Kernel.GamePool.Values) { if (C.Entity.MapID == 1002) { C.SendScreenSpawn(floorItem, true); npc.SendSpawn(C); //C.Entity.Update(PhoenixProject.Network.GamePackets._String.Effect, "wsmhcxq_att", true); } } } // Network.GamePackets.NpcInitial2.DeleteNPC2(1305); #endregion //Load2(); } }
private void button1_Click(object sender, EventArgs e) { //removenpc Interfaces.INpc npc = new Network.GamePackets.NpcSpawn(); npc.UID = uint.Parse(textBox1.Text); if (ServerBase.Kernel.Maps[ushort.Parse(textBox6.Text)].Npcs.ContainsKey(npc.UID)) { Database.MySqlCommand cmd = new Database.MySqlCommand(Database.MySqlCommandType.DELETE); cmd.Delete("cq_npc", "id", npc.UID); cmd.Execute(); ServerBase.Kernel.Maps[ushort.Parse(textBox6.Text)].Npcs.SafeRemove(npc.UID); WriteLine("Successfully removed npc " + npc.UID); } else { WriteLine("The map " + textBox6.Text + " already doesn't contains \n an npc with id " + npc.UID); } }
public static void Load9() { if (ServerBase.Kernel.Maps.ContainsKey(1002)) { ushort X = 900, Y = 900; INpc npc = new Network.GamePackets.NpcSpawn(); npc.UID = 1305; npc.Mesh = 13050; npc.Type = Enums.NpcType.Talker; npc.X = (ushort)(X - 1); npc.Y = (ushort)(Y - 1); npc.MapID = 1002; foreach (Client.GameState C in ServerBase.Kernel.GamePool.Values) { if (C.Entity.MapID == 1002) { npc.SendSpawn(C); // C.Entity.Update(PhoenixProject.Network.GamePackets._String.Effect, "wsmhcxq_att", true); } } // ServerBase.Kernel.Maps[1002].AddNpc(npc); } }
private void button4_Click(object sender, EventArgs e) { Interfaces.INpc npc = new Network.GamePackets.NpcSpawn(); npc.UID = uint.Parse(textBox8.Text); if (ServerBase.Kernel.Maps[ushort.Parse(textBox6.Text)].Npcs.ContainsKey(npc.UID)) { Database.MySqlCommand cmd = new Database.MySqlCommand(Database.MySqlCommandType.UPDATE); cmd.Update("cq_npc").Set("direction", textBox9.Text).Where("id", npc.UID); cmd.Execute(); ServerBase.Kernel.Maps[ushort.Parse(textBox8.Text)].Npcs[npc.UID].Facing = (Enums.ConquerAngle)ushort.Parse(textBox9.Text); WriteLine("Successfully updated npc " + npc.UID); } else { WriteLine("The map " + textBox6.Text + " doesn't contains \n an npc with id " + npc.UID); } }
private void LoadNpcs() { Database.MySqlCommand command = new PhoenixProject.Database.MySqlCommand(PhoenixProject.Database.MySqlCommandType.SELECT); command.Select("npcs").Where("mapid", ID); PhoenixProject.Database.MySqlReader reader = new PhoenixProject.Database.MySqlReader(command); while (reader.Read()) { INpc npc = new Network.GamePackets.NpcSpawn(); npc.UID = reader.ReadUInt32("id"); npc.Mesh = reader.ReadUInt16("lookface"); npc.Type = (Enums.NpcType)reader.ReadByte("type"); npc.X = reader.ReadUInt16("cellx"); ; npc.Y = reader.ReadUInt16("celly"); npc.MapID = ID; //Network.GamePackets.PokerTable npc2 = new Network.GamePackets.PokerTable(); AddNpc(npc); } reader.Close(); reader.Dispose(); command = new PhoenixProject.Database.MySqlCommand(PhoenixProject.Database.MySqlCommandType.SELECT); command.Select("sobnpcs").Where("mapid", ID); reader = new PhoenixProject.Database.MySqlReader(command); while (reader.Read()) { Network.GamePackets.SobNpcSpawn npc = new Network.GamePackets.SobNpcSpawn(); npc.UID = reader.ReadUInt32("id"); npc.Mesh = reader.ReadUInt16("lookface"); if (ID == 1039) npc.Mesh = (ushort)(npc.Mesh - npc.Mesh % 10 + 7); npc.Type = (Enums.NpcType)reader.ReadByte("type"); npc.X = reader.ReadUInt16("cellx"); ; npc.Y = reader.ReadUInt16("celly"); npc.MapID = reader.ReadUInt16("mapid"); npc.Sort = reader.ReadUInt16("sort"); npc.ShowName = true; npc.Name = reader.ReadString("name"); npc.Hitpoints = reader.ReadUInt32("life"); npc.MaxHitpoints = reader.ReadUInt32("maxlife"); AddNpc(npc); } reader.Close(); reader.Dispose(); }
public Map(ulong id, ulong baseid, string path, bool dynamic) { if (!ServerBase.Kernel.Maps.ContainsKey(id)) ServerBase.Kernel.Maps.Add(id, this); Npcs = new Dictionary<uint, INpc>(); Npcs2 = new Dictionary<uint, table>(); Entities = new List<Entity>(); //Floor = new Floor(0, 0, id); Companions = new List<Entity>(); ID = id; BaseID = baseid; Path = path; Floor = new Floor(0, 0, id); #region Loading floor. if (id != baseid && baseid == 700 && ArenaBaseFloor != null) { Floor = new Game.Floor(ArenaBaseFloor.Bounds.Width, ArenaBaseFloor.Bounds.Height, ID); for (ushort y = 0; y < ArenaBaseFloor.Bounds.Height; y = (ushort)(y + 1)) { for (ushort x = 0; x < ArenaBaseFloor.Bounds.Width; x = (ushort)(x + 1)) { Floor[x, y, MapObjectType.Player, null] = ArenaBaseFloor[x, y, MapObjectType.Player, null]; } } } else { if (File.Exists(ServerBase.Constants.DMapsPath + "\\maps\\" + baseid.ToString() + ".map")) { //Console.WriteLine("kim"); byte[] buff = File.ReadAllBytes(ServerBase.Constants.DMapsPath + "\\maps\\" + baseid.ToString() + ".map"); MemoryStream FS = new MemoryStream(buff); BinaryReader BR = new BinaryReader(FS); int Width = BR.ReadInt32(); int Height = BR.ReadInt32(); Floor = new Game.Floor(Width, Height, ID); for (ushort y = 0; y < Height; y = (ushort)(y + 1)) { for (ushort x = 0; x < Width; x = (ushort)(x + 1)) { Floor[x, y, MapObjectType.InvalidCast, null] = !(BR.ReadByte() == 1 ? true : false); } } BR.Close(); FS.Close(); BR.Dispose(); FS.Flush(); ////BR.Dispose(); //FS.Dispose(); } else { if (File.Exists(ServerBase.Constants.DMapsPath + Path)) { FileStream FS = new FileStream(ServerBase.Constants.DMapsPath + Path, FileMode.Open); BinaryReader BR = new BinaryReader(FS); BR.ReadBytes(268); int Width = BR.ReadInt32(); int Height = BR.ReadInt32(); Floor = new Game.Floor(Width, Height, ID); for (ushort y = 0; y < Height; y = (ushort)(y + 1)) { for (ushort x = 0; x < Width; x = (ushort)(x + 1)) { Floor[x, y, MapObjectType.InvalidCast, null] = !Convert.ToBoolean(BR.ReadUInt16()); BR.BaseStream.Seek(4L, SeekOrigin.Current); } BR.BaseStream.Seek(4L, SeekOrigin.Current); } uint amount = BR.ReadUInt32(); BR.BaseStream.Seek(amount * 12, SeekOrigin.Current); int num = BR.ReadInt32(); List<SceneFile> list = new List<SceneFile>(); for (int i = 0; i < num; i++) { switch (BR.ReadInt32()) { case 10: BR.BaseStream.Seek(0x48L, SeekOrigin.Current); break; case 15: BR.BaseStream.Seek(0x114L, SeekOrigin.Current); break; case 1: list.Add(this.CreateSceneFile(BR)); break; case 4: BR.BaseStream.Seek(0x1a0L, SeekOrigin.Current); break; } } Scenes = list.ToArray(); for (int i = 0; i < Scenes.Length; i++) { foreach (ScenePart part in Scenes[i].Parts) { for (int j = 0; j < part.Size.Width; j++) { for (int k = 0; k < part.Size.Height; k++) { Point point = new Point(); point.X = ((Scenes[i].Location.X + part.StartPosition.X) + j) - part.Size.Width; point.Y = ((Scenes[i].Location.Y + part.StartPosition.Y) + k) - part.Size.Height; Floor[(ushort)point.X, (ushort)point.Y, MapObjectType.InvalidCast, null] = part.NoAccess[j, k]; } } } } BR.Close(); FS.Close(); ////BR.Dispose(); //FS.Dispose(); SaveMap(); } } } #endregion if (baseid == 3024) {//54 46 INpc npc = new Network.GamePackets.NpcSpawn(); npc.UID = 1765; npc.Mesh = 8200; npc.Type = Enums.NpcType.WareHouse; npc.X = 90 ; npc.Y = 67; npc.MapID = id; AddNpc(npc); } LoadNpcs(); // LoadTables(); LoadZones(); LoadMonsters(); //Loadtale(); LoadPortals(); //FloorItemTimerCallBack = new TimerCallback(_timerFloorItemCallBack); //_timerFloorItem = new Timer(FloorItemTimerCallBack, this, 10000, 2000); }
private void TreasureBox() { INpc npc = new Network.GamePackets.NpcSpawn(); npc.UID = 5012; npc.Mesh = 9307; npc.Type = Game.Enums.NpcType.Talker; npc.X = 33 ; npc.Y = 5; npc.MapID = 1225; //Network.GamePackets.PokerTable npc2 = new Network.GamePackets.PokerTable(); AddNpc(npc); }