using System.Collections.Generic;
using System.Text.RegularExpressions;
public List<Actor> Actors;
public List<string> Lines;
public Point CalculatePoint(int x, int y, int radii)
var angle = r.NextDouble() * Math.PI * 2;
var radius = Math.Sqrt(r.NextDouble()) * radii;
var x2 = x + radius * Math.Cos(angle);
var y2 = y + radius * Math.Sin(angle);
return new Point((int)x2, (int)y2);
public void GetMonsters()
Actors = new List<Actor>();
Lines = new List<string>();
Lines.Add("coords = new OpenLayers.LonLat(1925, -1525);");
Lines.Add("popupContentHTML = '<div class=\"popups\"><table class=\"popups\"><tr><th colspan=2>Chigoe</th></tr><tr><td class=\"img\"><img src=\"../images/maps/chigoe.png\"></td><td><p class=\"aggro\"><img src=\"../images/maps/1.png\"></p><p>Level: 4-5</p><p>Amount: </p><p>Coords: 38,30<br>(Lower elevation)");
foreach (var line in Lines)
if (line.StartsWith("popupContentHTML"))
var actorGroup = new ActorGroup();
var idx = Lines.IndexOf(line);
var coords = Regex.Matches(Lines[idx - 1], @".+\((\-?\d+).\s(\-?\d+)\)");
var x = Math.Abs(int.Parse(coords[0].Groups[1].Value)) << 1;
var y = Math.Abs(int.Parse(coords[0].Groups[2].Value)) << 1;
var info = Regex.Matches(Lines[idx], @".+<th colspan=\d+>(.+)<\/th>.+Level:\s+(\d*).?(\d*).+Amount:\s+(\d*).?(\d*).+");
var X2 = ((x / mapScale) - mapOffsetX);
var Y2 = ((y / mapScale) - mapOffsetY);
actorGroup.Name = info[0].Groups[1].Value;
actorGroup.MinimumLevel = byte.Parse(info[0].Groups[2].Value);
actorGroup.MaximumLevel = byte.Parse(info[0].Groups[3].Value);
actorGroup.MinimumCount = !string.IsNullOrEmpty(info[0].Groups[4].Value) ? int.Parse(info[0].Groups[4].Value) : 5;
actorGroup.MaximumCount = !string.IsNullOrEmpty(info[0].Groups[5].Value) ? int.Parse(info[0].Groups[5].Value) : 5;
for (var i = 0; i < actorGroup.MaximumCount; i++)
var point = CalculatePoint(X2, Y2, new Random().Next(2, 26));
Console.WriteLine("INSERT INTO `monster_spawn_points` VALUES (X: " + point.X.ToString("0.000") + " Y: " + point.Y.ToString("0.000") + "); -- " + actorGroup.Name);
Console.WriteLine("2D X: " + x);
Console.WriteLine("2D Y: " + y);
Console.WriteLine("3D X: " + X2);
Console.WriteLine("3D Y: " + Y2);
public string Name { get; set; }
public int X { get; set; }
public int Y { get; set; }
public byte MinimumLevel { get; set; }
public byte MaximumLevel { get; set; }
public int MinimumCount { get; set; }
public int MaximumCount { get; set; }
public uint ActorClassId {get ; set; }
public string ActorClassPath {get; set; }
public string Name { get; set; }
public float X { get; set; }
public float Y { get; set; }
public float Z { get; set; }
public float Yaw { get; set; }
public byte Level { get; set; }