using System.Drawing; using Server.MirEnvir; namespace Server.MirDatabase { public class RespawnInfo { protected static Envir Envir { get { return Envir.Main; } } public int MonsterIndex; public Point Location; public ushort Count, Spread, Delay, RandomDelay; public byte Direction; public string RoutePath = string.Empty; public int RespawnIndex; public bool SaveRespawnTime = false; public ushort RespawnTicks; //leave 0 if not using this system! public RespawnInfo() { } public RespawnInfo(BinaryReader reader, int Version, int Customversion) { MonsterIndex = reader.ReadInt32(); Location = new Point(reader.ReadInt32(), reader.ReadInt32()); Count = reader.ReadUInt16(); Spread = reader.ReadUInt16(); Delay = reader.ReadUInt16(); Direction = reader.ReadByte(); RoutePath = reader.ReadString(); if (Version > 67) { RandomDelay = reader.ReadUInt16(); RespawnIndex = reader.ReadInt32(); SaveRespawnTime = reader.ReadBoolean(); RespawnTicks = reader.ReadUInt16(); } else { RespawnIndex = ++Envir.RespawnIndex; } } public static RespawnInfo FromText(string text) { string[] data = text.Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries); if (data.Length < 7) return null; RespawnInfo info = new RespawnInfo(); int x,y ; if (!int.TryParse(data[0], out info.MonsterIndex)) return null; if (!int.TryParse(data[1], out x)) return null; if (!int.TryParse(data[2], out y)) return null; info.Location = new Point(x, y); if (!ushort.TryParse(data[3], out info.Count)) return null; if (!ushort.TryParse(data[4], out info.Spread)) return null; if (!ushort.TryParse(data[5], out info.Delay)) return null; if (!byte.TryParse(data[6], out info.Direction)) return null; if (!ushort.TryParse(data[7], out info.RandomDelay)) return null; if (!int.TryParse(data[8], out info.RespawnIndex)) return null; if (!bool.TryParse(data[9], out info.SaveRespawnTime)) return null; if (!ushort.TryParse(data[10], out info.RespawnTicks)) return null; return info; } public void Save(BinaryWriter writer) { writer.Write(MonsterIndex); writer.Write(Location.X); writer.Write(Location.Y); writer.Write(Count); writer.Write(Spread); writer.Write(Delay); writer.Write(Direction); writer.Write(RoutePath); writer.Write(RandomDelay); writer.Write(RespawnIndex); writer.Write(SaveRespawnTime); writer.Write(RespawnTicks); } public override string ToString() { var monsterName = Envir.MonsterInfoList.Find(o => o.Index == MonsterIndex)?.Name ?? "Unknown"; return string.Format("Monster: {0} - {1} - {2} - {3} - {4} - {5} - {6} - {7} - {8} - {9} - {10}", MonsterIndex, monsterName, Functions.PointToString(Location), Count, Spread, Delay, Direction, RandomDelay, RespawnIndex, SaveRespawnTime, RespawnTicks); } } public class RouteInfo { public Point Location; public int Delay; public static RouteInfo FromText(string text) { string[] data = text.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); if (data.Length < 2) return null; RouteInfo info = new RouteInfo(); int x, y; if (!int.TryParse(data[0], out x)) return null; if (!int.TryParse(data[1], out y)) return null; info.Location = new Point(x, y); if (data.Length <= 2) return info; return !int.TryParse(data[2], out info.Delay) ? info : info; } } }