private void CreateGroup(IConnection connection) { var npcs = Global.VisibleService.FindTargets(connection.Player, connection.Player.Position, 50, TargetingAreaType.Enemy); npcs.Sort((c1, c2) => { Npc npc1 = c1 as Npc; Npc npc2 = c2 as Npc; if (npc1 == null || npc2 == null) { return(0); } return(npc2.NpcTemplate.Size.GetHashCode() .CompareTo(npc1.NpcTemplate.Size.GetHashCode())); }); int counter = 0; int startAngle = RandomUtilities.Random().Next(0, 359); foreach (var creature in npcs) { Npc npc = creature as Npc; if (npc == null) { continue; } int count = int.Parse(GetValue(connection, "Enter count of: [" + npc.NpcTemplate.Name + "]")); if (count > 0) { for (int i = 0; i < count; i++) { SpawnTemplate spawnTemplate = npc.SpawnTemplate.Clone(); spawnTemplate.X += (float)(150f * Math.Cos(startAngle + counter * 30) * counter / 2 / Math.PI + RandomUtilities.Random().Next(-25, 25)); spawnTemplate.Y += (float)(150f * Math.Sin(startAngle + counter * 30) * counter / 2 / Math.PI + RandomUtilities.Random().Next(-25, 25)); Global.MapService.SpawnTeraObject(MapService.CreateNpc(spawnTemplate), npc.Instance); counter++; } Global.MapService.DespawnTeraObject(npc); } } }