private void LoadNpcs() { Database.MySqlCommand command = new Conquer_Online_Server.Database.MySqlCommand(Conquer_Online_Server.Database.MySqlCommandType.SELECT); command.Select("npcs").Where("mapid", ID); Database.MySqlReader reader = new Conquer_Online_Server.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; AddNpc(npc); } reader.Close(); command = new Conquer_Online_Server.Database.MySqlCommand(Conquer_Online_Server.Database.MySqlCommandType.SELECT); command.Select("sobnpcs").Where("mapid", ID); reader = new Conquer_Online_Server.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(); }
private void LoadZones() { Database.MySqlCommand command = new Conquer_Online_Server.Database.MySqlCommand(Conquer_Online_Server.Database.MySqlCommandType.SELECT); command.Select("notavailablepaths").Where("mapid", ID); Database.MySqlReader reader = new Conquer_Online_Server.Database.MySqlReader(command); while (reader.Read()) { Zoning.Zone zone = new Zoning.Zone( new Point() { X = reader.ReadInt32("Point1_X"), Y = reader.ReadInt32("Point1_Y") }, new Point() { X = reader.ReadInt32("Point2_X"), Y = reader.ReadInt32("Point2_Y") }, new Point() { X = reader.ReadInt32("Point3_X"), Y = reader.ReadInt32("Point3_Y") }, new Point() { X = reader.ReadInt32("Point4_X"), Y = reader.ReadInt32("Point4_Y") } ); Zones.Add(zone); } reader.Close(); }
public void LoadMonsters() { Companions = new SafeDictionary<uint, Entity>(1000); Database.MySqlCommand command = new Conquer_Online_Server.Database.MySqlCommand(Conquer_Online_Server.Database.MySqlCommandType.SELECT); command.Select("monsterspawns").Where("mapid", ID); Database.MySqlReader reader = new Conquer_Online_Server.Database.MySqlReader(command); int mycount = 0; try { while (reader.Read()) { uint monsterID = reader.ReadUInt32("npctype"); ushort CircleDiameter = reader.ReadUInt16("maxnpc"); ushort X = reader.ReadUInt16("bound_x"); ushort Y = reader.ReadUInt16("bound_y"); ushort XPlus = reader.ReadUInt16("bound_cx"); ushort YPlus = reader.ReadUInt16("bound_cy"); ushort Amount = reader.ReadUInt16("max_per_gen"); int respawn = reader.ReadInt32("rest_secs"); if (Database.MonsterInformation.MonsterInfos.ContainsKey(monsterID)) { Database.MonsterInformation mt = Database.MonsterInformation.MonsterInfos[monsterID]; mt.RespawnTime = respawn + 5; mt.BoundX = X; mt.BoundY = Y; mt.BoundCX = XPlus; mt.BoundCY = YPlus; bool more = true; for (int count = 0; count < Amount; count++) { if (!more) break; Entity entity = new Entity(EntityFlag.Monster, false); entity.MapObjType = MapObjectType.Monster; entity.MonsterInfo = mt.Copy(); entity.MonsterInfo.Owner = entity; entity.Name = mt.Name; entity.MinAttack = mt.MinAttack; entity.MaxAttack = entity.MagicAttack = mt.MaxAttack; entity.Hitpoints = entity.MaxHitpoints = mt.Hitpoints; entity.Body = mt.Mesh; entity.Level = mt.Level; entity.UID = EntityUIDCounter.Next; entity.MapID = ID; entity.SendUpdates = true; entity.X = (ushort)(X + ServerBase.Kernel.Random.Next(0, XPlus)); entity.Y = (ushort)(Y + ServerBase.Kernel.Random.Next(0, YPlus)); for (int count2 = 0; count2 < 50; count2++) { if (!Floor[entity.X, entity.Y, MapObjectType.Monster, entity]) { entity.X = (ushort)(X + ServerBase.Kernel.Random.Next(0, XPlus)); entity.Y = (ushort)(Y + ServerBase.Kernel.Random.Next(0, YPlus)); if (count2 == 50) more = false; } else break; } if (more) { if (Floor[entity.X, entity.Y, MapObjectType.Monster, entity]) { mycount++; AddEntity(entity); } } } } } } catch (Exception e) { Program.SaveException(e); } reader.Close(); if (mycount != 0) { MyTimer = new System.Timers.Timer(interval); MyTimer.AutoReset = true; MyTimer.Elapsed += new System.Timers.ElapsedEventHandler(_timerCallBack); MyTimer.Start(); // Thread_time = DateTime.Now; //CallBack = new System.Threading.TimerCallback(_timerCallBack); //_timer = new ManagedThreadTimer(5000, 200, CallBack, ThreadPool, this); //CallBack = new TimerCallback(_timerCallBack); //_timer = new Timer(CallBack, this, 10000, 1000); // Console.WriteLine("Loaded and spawned " + mycount + " monsters on " + ID + "."); } }