This is a script that is based off of GenVendor.cs. It works fine but it uses default spawners and I would like it to use XMLspawners. My question is how can I change the spawner type this generates?
Code:
using System;
using System.Collections;
using Server.Mobiles;
using Server.Commands;
namespace Server
{
public class GenGuards
{
private static int m_Count;
//configuration
private const int NPCCount = 1;//2 npcs per type (so a mage spawner will spawn 2 npcs, a alchemist and herbalist spawner will spawn 4 npcs total)
private const int HomeRange = 5;//How far should they wander?
private const bool TotalRespawn = true;//Should we spawn them up right away?
private static TimeSpan MinTime = TimeSpan.FromMinutes(2.5);//min spawn time
private static TimeSpan MaxTime = TimeSpan.FromMinutes(10.0);//max spawn time
private const int Team = 0;//"team" the npcs are on
public static void Initialize()
{
CommandSystem.Register("GenGuards", AccessLevel.Administrator, new CommandEventHandler(Generate_OnCommand));
}
[Usage("GenGuards")]
[Description("Generates Guards/NPC spawners")]
private static void Generate_OnCommand(CommandEventArgs e)
{
Parse(e.Mobile);
}
public static void Parse(Mobile from)
{
from.SendMessage("Generating All Town Guards & NPCs...");
MakeSpawner(new string[] { "OrderGuard" }, 1400, 1623, 28);//Custom Brit
MakeSpawner(new string[] { "OrderGuard" }, 1400, 1628, 28);
MakeSpawner(new string[] { "OrderGuard" }, 1337, 1622, 50);
MakeSpawner(new string[] { "OrderGuard" }, 1337, 1626, 50);
MakeSpawner(new string[] { "ChaosGuard" }, 1521, 1457, 15);
MakeSpawner(new string[] { "ChaosGuard" }, 1525, 1457, 15);
MakeSpawner(new string[] { "ChaosGuard" }, 1524, 1453, 35);
MakeSpawner(new string[] { "ChaosGuard" }, 1520, 1445, 15);
MakeSpawner(new string[] { "WarriorGuard" }, 1409, 1716, 20);
MakeSpawner(new string[] { "WarriorGuard" }, 1411, 1716, 20);
MakeSpawner(new string[] { "OrderGuard" }, 1371, 1603, 30);//Lord British Castle
MakeSpawner(new string[] { "OrderGuard" }, 1342, 1574, 30);
MakeSpawner(new string[] { "OrderGuard" }, 1306, 1659, 52);
MakeSpawner(new string[] { "WarriorGuard" }, 1315, 1656, 30);
MakeSpawner(new string[] { "OrderGuard" }, 1326, 1681, 52);
MakeSpawner(new string[] { "OrderGuard" }, 1395, 1684, 52);
MakeSpawner(new string[] { "OrderGuard" }, 1353, 1647, 30);
MakeSpawner(new string[] { "OrderGuard" }, 1324, 1676, 30);
MakeSpawner(new string[] { "OrderGuard" }, 1325, 1677, 30);
MakeSpawner(new string[] { "OrderGuard" }, 1337, 1672, 30);
MakeSpawner(new string[] { "OrderGuard" }, 1339, 1672, 30);
MakeSpawner(new string[] { "OrderGuard" }, 1341, 1672, 30);
MakeSpawner(new string[] { "OrderGuard" }, 1337, 1672, 50);
MakeSpawner(new string[] { "OrderGuard" }, 1339, 1672, 50);
MakeSpawner(new string[] { "OrderGuard" }, 1341, 1672, 50);
MakeSpawner(new string[] { "WarriorGuard" }, 1431, 1696, 0);
MakeSpawner(new string[] { "WarriorGuard" }, 1434, 1687, 0);
MakeSpawner(new string[] { "WarriorGuard" }, 3732, 2164, 20);//Magencia
MakeSpawner(new string[] { "WarriorGuard" }, 2506, 554, 0);//Minoc
MakeSpawner(new string[] { "WarriorGuard" }, 2506, 562, 0);
MakeSpawner(new string[] { "WarriorGuard" }, 4459, 1172, 0);//Moonglow
MakeSpawner(new string[] { "WarriorGuard" }, 4471, 1164, 0);
MakeSpawner(new string[] { "WarriorGuard" }, 4476, 1145, 0);
MakeSpawner(new string[] { "WarriorGuard" }, 3578, 1309, 0);//nujelm
MakeSpawner(new string[] { "WarriorGuard" }, 3763, 1323, 0);
MakeSpawner(new string[] { "WarriorGuard" }, 1907, 2687, 0);//Trinsic
MakeSpawner(new string[] { "WarriorGuard" }, 1895, 2689, 10);
MakeSpawner(new string[] { "WarriorGuard" }, 2892, 685, 0);//Vesper
MakeSpawner(new string[] { "WarriorGuard" }, 2878, 683, 0);
MakeSpawner(new string[] { "WarriorGuard" }, 2899, 667, 0);
}
private static Queue m_ToDelete = new Queue();
public static void ClearSpawners(int x, int y, int z)
{
IPooledEnumerable eable = Map.Felucca.GetItemsInRange(new Point3D(x, y, z), 0);
foreach (Item item in eable)
{
if (item is Spawner && item.Z == z)
m_ToDelete.Enqueue(item);
}
eable.Free();
while (m_ToDelete.Count > 0)
((Item)m_ToDelete.Dequeue()).Delete();
}
private static void MakeSpawner(string[] types, int x, int y, int z)
{
if (types.Length == 0)
return;
ClearSpawners(x, y, z);
for (int i = 0; i < types.Length; ++i)
{
Spawner sp = new Spawner(types[i]);
sp.Count = NPCCount;
sp.MinDelay = MinTime;
sp.MaxDelay = MaxTime;
sp.Team = Team;
sp.HomeRange = HomeRange;
sp.MoveToWorld(new Point3D(x, y, z), Map.Felucca);
if (TotalRespawn)
{
sp.Respawn();
sp.BringToHome();
}
++m_Count;
}
}
}
}