#W# Initial Commit: Avatars Conquest

This commit is contained in:
WarrentyExpired 2026-07-04 10:35:30 -04:00
commit 5df497787a
7510 changed files with 416048 additions and 0 deletions

View file

@ -0,0 +1,907 @@
/*
Package Name: CEO's Yet Another Arya Addon Generator (YAAAG)
Author: CEO
Version: 1.2
Public Release: 09/25/07
Purpose: Generates AddOns from statics, items, and tiles. Oh my!
*/
/* Modified to work with the new SA & High Seas items by Hammerhand */
// If you're using an SVN that supports List<> methods (remove the //s) to use those instead of arrays or add them for RC1.
#define RC2
//#define DEBUG
#undef DEBUG
using System;
using System.Collections;
using System.IO;
using Server;
using Server.Items;
using Server.Gumps;
using Server.Commands;
using System.Collections.Generic;
using Server.ContextMenus;
using Server.Network;
using Server.Targeting;
namespace Arya.Misc
{
public class AddonGenerator
{
/// <summary>
/// Set this value if you wish the scripts to be output somewhere else rather than in the default RunUO\TheBox
/// directory. This should be a full valid path on your computer
///
/// Example:
///
/// private static string m_CustomOutputDirector = @"C:\Program Files\RunUO\Scripts\Custom\Addons";
/// </summary>
private static string m_CustomOutputDirectory = null;
#region Template
private const string m_SimpleCode = @"
for (int i = 0; i < m_AddOnSimpleComponents.Length / 4; i++)
AddComponent( new AddonComponent( m_AddOnSimpleComponents[i,0] ), m_AddOnSimpleComponents[i,1], m_AddOnSimpleComponents[i,2], m_AddOnSimpleComponents[i,3] );";
private const string m_ComplexCode = @"
for (int i = 0; i < m_AddOnComplexComponents.Length / 6; i++)
AddComplexComponent( (BaseAddon)this, m_AddOnComplexComponents[i,0], m_AddOnComplexComponents[i,1], m_AddOnComplexComponents[i,2], m_AddOnComplexComponents[i,3], m_AddOnComplexComponents[i,4], m_AddOnComplexComponents[i,5] );";
private const string m_ComplexNameCode = @"
private static void AddComplexComponent(BaseAddon addon, int item, int xoffset, int yoffset, int zoffset, int hue, int lightsource)
{
AddComplexComponent(addon, item, xoffset, yoffset, zoffset, hue, lightsource, null, 1);
}
private static void AddComplexComponent(BaseAddon addon, int item, int xoffset, int yoffset, int zoffset, int hue, int lightsource, string name, int amount)
{
AddonComponent ac;
ac = new AddonComponent(item);
if (name != null && name.Length > 0)
ac.Name = name;
if (hue != 0)
ac.Hue = hue;
if (amount > 1)
{
ac.Stackable = true;
ac.Amount = amount;
}
if (lightsource != -1)
ac.Light = (LightType) lightsource;
addon.AddComponent(ac, xoffset, yoffset, zoffset);
}";
private const string m_Template = @"
////////////////////////////////////////
// //
// Generated by CEO's YAAAG - Ver 2 //
// (Yet Another Arya Addon Generator) //
// Modified by Hammerhand for //
// SA & High Seas content //
// //
////////////////////////////////////////
using System;
using Server;
using Server.Items;
namespace {namespace}
{
public class {name}Addon : BaseAddon
{
{simplelist}
{complexlist}
public override BaseAddonDeed Deed
{
get
{
return new {name}AddonDeed();
}
}
[ Constructable ]
public {name}Addon()
{
{simplecomponentscode}
{complexcomponentscode}
{namedcomponentscode}
}
public {name}Addon( Serial serial ) : base( serial )
{
}
{complexnamecomponentscode}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( 0 ); // Version
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
}
}
public class {name}AddonDeed : BaseAddonDeed
{
public override BaseAddon Addon
{
get
{
return new {name}Addon();
}
}
[Constructable]
public {name}AddonDeed()
{
Name = ""{name}"";
}
public {name}AddonDeed( Serial serial ) : base( serial )
{
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( 0 ); // Version
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
}
}
}";
#endregion
public static void Initialize()
{
CommandSystem.Register("AddonGen", AccessLevel.Administrator, new CommandEventHandler(OnAddonGen));
}
#region Command
[Usage("AddonGen [<name> [namespace]]"),
Description("Brings up the addon script generator gump. When used with the name (and eventually namespace) parameter generates an addon script from the targeted region.")]
private static void OnAddonGen(CommandEventArgs e)
{
object[] state = new object[18];
state[0] = "";
state[1] = "Server.Items";
state[2] = true;
state[3] = false;
state[4] = false;
state[5] = true;
state[6] = true;
state[7] = true;
state[8] = true;
state[9] = -128;
state[10] = 127;
state[11] = state[13] = state[15] = 2;
state[12] = state[14] = state[16] = 36653;
if (e.Arguments.Length > 0)
{
state[0] = e.Arguments[0];
if (e.Arguments.Length > 1)
state[1] = e.Arguments[1];
}
e.Mobile.SendGump(new InternalGump(e.Mobile, state));
}
#endregion
private static void PickerCallback(Mobile from, Map map, Point3D start, Point3D end, object state)
{
object[] args = state as object[];
int m_SimpleComponents = 0;
int m_ComplexComponents = 0;
int m_NamedComponents = 0;
int m_TotalComponents = 0;
if (start.X > end.X)
{
int x = start.X;
start.X = end.X;
end.X = x;
}
if (start.Y > end.Y)
{
int y = start.Y;
start.Y = end.Y;
end.Y = y;
}
Rectangle2D bounds = new Rectangle2D(start, end);
string name = args[0] as string;
string ns = args[1] as string;
bool getStatics = (bool)args[2];
bool getItems = (bool)args[3];
bool getTiles = (bool)args[4];
bool includeStaticRange = (bool)args[5];
bool includeItemRange = (bool)args[6];
bool includeTileRange = (bool)args[7];
bool includeZRange = (bool)args[8];
bool generateTest = (bool)args[17];
sbyte min = sbyte.MinValue;
sbyte max = sbyte.MaxValue;
int minStaticID = 2;
int maxStaticID = 36653;
int minItemID = 2;
int maxItemID = 36653;
int minTileID = 2;
int maxTileID = 36653;
try { min = sbyte.Parse(args[9] as string); }
catch { }
try { max = sbyte.Parse(args[10] as string); }
catch { }
try { minStaticID = int.Parse(args[11] as string); }
catch { }
try { maxStaticID = int.Parse(args[12] as string); }
catch { }
try { minItemID = int.Parse(args[13] as string); }
catch { }
try { maxItemID = int.Parse(args[14] as string); }
catch { }
try { minTileID = int.Parse(args[15] as string); }
catch { }
try { maxTileID = int.Parse(args[16] as string); }
catch { }
Hashtable tiles = new Hashtable();
if (getTiles)
{
for (int x = start.X; x <= end.X; x++)
{
for (int y = start.Y; y <= end.Y; y++)
{
#if RC2
StaticTile[] stlist = map.Tiles.GetStaticTiles(x, y, true);
List<Server.StaticTile> list = new List<Server.StaticTile>();
List<Server.StaticTile> remove = new List<Server.StaticTile>();
#else
ArrayList list = map.GetTilesAt(new Point2D(x, y), false, false, true);
ArrayList remove = new ArrayList();
#endif
foreach (StaticTile t in stlist)
{
list.Add(t);
int id = t.ID - 36653;
if (id < 2 || id > 36653)
remove.Add(t);
else if (includeZRange && (t.Z < min || t.Z > max))
remove.Add(t);
else if (!includeZRange && (t.Z >= min && t.Z <= max))
remove.Add(t);
else if (includeTileRange && (id < minTileID || id > maxTileID))
remove.Add(t);
else if (!includeTileRange && (id >= minTileID && id <= maxTileID))
remove.Add(t);
}
foreach (StaticTile t in remove)
{
list.Remove(t);
}
if (list != null && list.Count > 0)
{
tiles[new Point2D(x, y)] = list;
}
}
}
}
IPooledEnumerable en = map.GetItemsInBounds(bounds);
ArrayList target = new ArrayList();
bool fail = false;
try
{
foreach (object o in en)
{
if (getStatics)
{
Static s = o as Static;
if (s == null)
{ }
else if (s.Deleted)
{ }
else if (includeZRange && (s.Z < min || s.Z > max))
continue;
else if (!includeZRange && (s.Z >= min && s.Z <= max))
continue;
else if (includeStaticRange && (s.ItemID < minStaticID || s.ItemID > maxStaticID))
continue;
else if (!includeStaticRange && (s.ItemID >= minStaticID && s.ItemID <= maxStaticID))
continue;
else
{
target.Add(o);
#if DEBUG
Console.WriteLine("Static={0}:{1}", s.GetType().ToString(), s.ItemID);
#endif
continue;
}
}
if (getItems)
{
Static s = o as Static;
if (s != null) // Don't want a static
continue;
Item i = o as Item;
if (i == null)
continue;
else if (i.Deleted)
continue;
else if (i is BaseAddon) // Not a good idea to add a BaseAddOn for obvious reasons
continue;
else if (i.ItemID < 2 || i.ItemID > 36653) // This is not an Item within the normal artwork.. multi... etc.. Toss it
continue;
else if (includeZRange && (i.Z < min || i.Z > max))
continue;
else if (!includeZRange && (i.Z >= min && i.Z <= max))
continue;
else if (includeItemRange && (i.ItemID < minItemID || i.ItemID > maxItemID))
continue;
else if (!includeItemRange && (i.ItemID >= minItemID && i.ItemID <= maxItemID))
continue;
#if DEBUG
Console.WriteLine("item={0}:{1}, {2}-map{3}", i.GetType().ToString(), i.ItemID, i.Deleted, i.Map);
#endif
target.Add(o);
}
}
}
catch (Exception err)
{
Console.WriteLine(err.ToString());
from.SendMessage(0x40, "The targeted components have been modified. Please retry.");
fail = true;
}
finally
{
en.Free();
}
if (fail)
return;
if (target.Count == 0 && tiles.Keys.Count == 0)
{
from.SendMessage(0x40, "No components have been selected.");
from.SendGump(new InternalGump(from, args));
return;
}
// Get center
Point3D center = new Point3D();
center.Z = 127;
int x1 = bounds.End.X;
int y1 = bounds.End.Y;
int x2 = bounds.Start.X;
int y2 = bounds.Start.Y;
// Get correct bounds
foreach (Item item in target)
{
if (item.Z < center.Z)
{
center.Z = item.Z;
}
x1 = Math.Min(x1, item.X);
y1 = Math.Min(y1, item.Y);
x2 = Math.Max(x2, item.X);
y2 = Math.Max(y2, item.Y);
}
CEOIdentifyAddon IdentifyAddon = null;
if (generateTest)
IdentifyAddon = new CEOIdentifyAddon("init");
foreach (Point2D p in tiles.Keys)
{
#if RC2
List<Server.StaticTile> list = tiles[p] as List<Server.StaticTile>;
#else
ArrayList list = tiles[p] as ArrayList;
#endif
if (list == null)
{
Console.WriteLine("The list is null... ");
return;
}
foreach (StaticTile t in list)
{
if (t.Z < center.Z)
{
center.Z = t.Z;
}
}
x1 = Math.Min(x1, p.X);
y1 = Math.Min(y1, p.Y);
x2 = Math.Max(x2, p.X);
y2 = Math.Max(y2, p.Y);
}
center.X = x1 + ((x2 - x1) / 2);
center.Y = y1 + ((y2 - y1) / 2);
// Build items
System.Text.StringBuilder nc = new System.Text.StringBuilder();
nc.Append("\n");
System.Text.StringBuilder sl = new System.Text.StringBuilder();
sl.Append("private static int[,] m_AddOnSimpleComponents = new int[,] {\n\t\t\t ");
System.Text.StringBuilder cl = new System.Text.StringBuilder();
cl.Append("private static int[,] m_AddOnComplexComponents = new int[,] {\n\t\t\t ");
System.Text.StringBuilder sc = new System.Text.StringBuilder();
sc.Append("// ");
System.Text.StringBuilder cc = new System.Text.StringBuilder();
cc.Append("// ");
int simplecount = 0;
int complexcount = 0;
// Tiles
foreach (Point2D p in tiles.Keys)
{
#if RC2
List<Server.StaticTile> list = tiles[p] as List<Server.StaticTile>;
#else
ArrayList list = tiles[p] as ArrayList;
#endif
int xOffset = p.X - center.X;
int yOffset = p.Y - center.Y;
foreach (StaticTile t in list)
{
int zOffset = t.Z - center.Z;
int id = t.ID - 36653;
m_SimpleComponents++;
simplecount++;
m_TotalComponents++;
sc.AppendFormat("{0}\t ", m_TotalComponents);
if (simplecount > 1)
sl.Append(", ");
sl.Append("{");
sl.AppendFormat("{0}, {1}, {2}, {3}", id, xOffset, yOffset, zOffset);
sl.Append("}");
if (simplecount % 3 == 0)
{
sl.AppendFormat("{0}\n\t\t\t", sc.ToString());
sc.Length = 0;
sc.Append("// ");
}
if (generateTest)
AddIdentifyAddOnComponent(IdentifyAddon, id, xOffset, yOffset, zOffset, 0, -1, string.Format("({0}):{1},{2},{3}", m_TotalComponents, xOffset, yOffset, zOffset), 0);
}
}
// Statics & Items
foreach (Item item in target)
{
if (item.Deleted)
continue;
int xOffset = item.X - center.X;
int yOffset = item.Y - center.Y;
int zOffset = item.Z - center.Z;
int id = item.ItemID;
if (((item.ItemData.Flags & TileFlag.LightSource) == TileFlag.LightSource) || (item.Hue != 0) || (item.Name != null) || item.Amount > 1) // Use old method
{
if (item.Name != null || item.Amount != 0) // Have to do this one the old method
{
m_NamedComponents++;
m_TotalComponents++;
int lightsource = -1;
if ((item.ItemData.Flags & TileFlag.LightSource) == TileFlag.LightSource)
lightsource = (int)item.Light;
nc.AppendFormat("\t\t\tAddComplexComponent( (BaseAddon) this, {0}, {1}, {2}, {3}, {4}, {5}, \"{6}\", {7});// {8}\n", id, xOffset, yOffset, zOffset, item.Hue, lightsource, item.Name, item.Amount, m_TotalComponents);
if (generateTest)
AddIdentifyAddOnComponent(IdentifyAddon, id, xOffset, yOffset, zOffset, item.Hue, -1, string.Format("({0},{1}): {2}, {3}, {4}", m_TotalComponents, id, xOffset, yOffset, zOffset), item.Amount);
}
else //if (item.Hue != 0 || (item.ItemData.Flags & TileFlag.LightSource) == TileFlag.LightSource)
{
int lightsource = -1;
if ((item.ItemData.Flags & TileFlag.LightSource) == TileFlag.LightSource)
lightsource = (int)item.Light;
m_ComplexComponents++;
m_TotalComponents++;
cc.AppendFormat("{0}\t", m_TotalComponents);
complexcount++;
if (complexcount > 1)
cl.Append(", ");
cl.Append("{");
cl.AppendFormat("{0}, {1}, {2}, {3}, {4}, {5} ", id, xOffset, yOffset, zOffset, item.Hue, lightsource);
cl.Append("}");
if (complexcount % 3 == 0)
{
cl.AppendFormat("{0}\n\t\t\t", cc.ToString());
cc.Length = 0;
cc.Append("// ");
}
if (generateTest)
AddIdentifyAddOnComponent(IdentifyAddon, id, xOffset, yOffset, zOffset, item.Hue, -1, string.Format("({0},{1}): {2}, {3}, {4}", m_TotalComponents, id, xOffset, yOffset, zOffset), 0);
}
}
else // Add data to static table
{
m_SimpleComponents++;
m_TotalComponents++;
sc.AppendFormat("{0}\t", m_TotalComponents);
simplecount++;
if (simplecount > 1)
sl.Append(", ");
sl.Append("{");
sl.AppendFormat("{0}, {1}, {2}, {3}", id, xOffset, yOffset, zOffset);
sl.Append("}");
if (simplecount % 3 == 0)
{
sl.AppendFormat("{0}\n\t\t\t", sc.ToString());
sc.Length = 0;
sc.Append("// ");
}
if (generateTest)
AddIdentifyAddOnComponent(IdentifyAddon, id, xOffset, yOffset, zOffset, item.Hue, -1, string.Format("({0},{1}): {2}, {3}, {4}", m_TotalComponents, id, xOffset, yOffset, zOffset), 0);
}
}
if (sc.Length > 4)
sl.AppendFormat("{0}\n", sc.ToString());
if (cc.Length > 4)
cl.AppendFormat("{0}\n", cc.ToString());
if (m_SimpleComponents > 0)
sl.Append("\t\t};\n\n");
if (m_ComplexComponents > 0)
cl.Append("\t\t};\n\n");
string output = m_Template.Replace("{name}", name);
output = output.Replace("{simplelist}", m_SimpleComponents > 0 ? sl.ToString() : "");
output = output.Replace("{simplecomponentscode}", m_SimpleComponents > 0 ? m_SimpleCode : "");
output = output.Replace("{complexlist}", m_ComplexComponents > 0 ? cl.ToString() : "");
output = output.Replace("{complexcomponentscode}", m_ComplexComponents > 0 ? m_ComplexCode : "");
output = output.Replace("{namedcomponentscode}", m_NamedComponents > 0 ? nc.ToString() : "");
output = output.Replace("{complexnamecomponentscode}", (m_ComplexComponents > 0 || m_NamedComponents > 0) ? m_ComplexNameCode : "");
output = output.Replace("{namespace}", ns);
StreamWriter writer = null;
string path = null;
if (m_CustomOutputDirectory != null)
path = Path.Combine(m_CustomOutputDirectory, string.Format(@"TheBox\{0}Addon.cs", name));
else
path = Path.Combine(Core.BaseDirectory, string.Format(@"TheBox\{0}Addon.cs", name));
fail = false;
try
{
string folder = Path.GetDirectoryName(path);
if (!Directory.Exists(folder))
{
Directory.CreateDirectory(folder);
}
writer = new StreamWriter(path, false);
writer.Write(output);
}
catch
{
from.SendMessage(0x40, "An error occurred when writing the file.");
fail = true;
}
finally
{
if (writer != null)
writer.Close();
}
if (!fail)
{
from.SendMessage(0x40, "Script saved to {0}", path);
from.SendMessage(0x40, "Total components in AddOn: {0}", m_TotalComponents);
if (generateTest && IdentifyAddon != null)
{
from.SendMessage(0x37, "Now target a land tile to place a your addon.");
from.Target = new InternalTarget(IdentifyAddon);
}
}
}
private static void AddIdentifyAddOnComponent(CEOIdentifyAddon ai, int item, int xoffset, int yoffset, int zoffset, int hue, int lightsource, string name, int amount)
{
if (ai == null)
return;
AddonComponent ac;
ac = new AddonComponent(item);
if (name != null && name.Length > 0)
ac.Name = name;
if (hue != 0)
ac.Hue = hue;
if (amount > 1) // Note: a warning will show on the console regarding a non-stackable item....
{
ac.Stackable = true;
ac.Amount = amount;
}
if (lightsource != -1)
ac.Light = (LightType)lightsource;
ai.AddComponent(ac, xoffset, yoffset, zoffset);
}
private class InternalTarget : Target
{
private CEOIdentifyAddon m_IdentifyAddon;
public InternalTarget(CEOIdentifyAddon IdentifyAddon)
: base(12, false, TargetFlags.None)
{
m_IdentifyAddon = IdentifyAddon;
CheckLOS = true;
AllowGround = true;
DisallowMultis = true;
Range = 15;
}
protected override void OnTargetCancel(Mobile from, TargetCancelType cancelType)
{
if (m_IdentifyAddon != null)
m_IdentifyAddon.Delete();
}
protected override void OnTarget(Mobile from, object o)
{
if (o != null)
{
if (o is LandTarget)
{
LandTarget l = o as LandTarget;
m_IdentifyAddon.MoveToWorld(l.Location, from.Map);
}
else
{
from.SendMessage(37, "Use must target a land tile to place your addon.");
if (m_IdentifyAddon != null)
m_IdentifyAddon.Delete();
}
}
}
}
#region Gump
private class InternalGump : Gump
{
private const int LabelHue = 0x480;
private const int TitleHue = 0x35;
private object[] m_State;
public InternalGump(Mobile m, object[] state)
: base(100, 50)
{
m.CloseGump(typeof(InternalGump));
m_State = state;
MakeGump();
}
private void MakeGump()
{
Closable = true;
Disposable = true;
Dragable = true;
Resizable = false;
AddPage(0);
AddBackground(0, 0, 440, 260, 9260);
//AddAlphaRegion(10, 10, 430, 260); //uncomment this line if you like see-thru menus
AddHtml(0, 15, 440, 20, Center(Color("CEO's Yet Another Arya Addon Generator(YAAAG)", 0x000080)), false, false);
int x = 40;
AddLabel(20, x, LabelHue, @"Name");
AddImageTiled(95, x, 165, 18, 9274);
AddTextEntry(95, x, 165, 20, LabelHue, 0, m_State[0] as string); // Name
x += 20;
AddLabel(20, x, LabelHue, @"Namespace");
AddImageTiled(95, x, 165, 18, 9274);
AddTextEntry(95, x, 165, 20, LabelHue, 1, m_State[1] as string); // Namespace
AddLabel(340, x, TitleHue, @"ID Range");
x += 20;
AddLabel(20, x, TitleHue, @"Export");
AddLabel(170, x, TitleHue, @"ID Range");
AddLabel(320, x, TitleHue, @"Include/Exclude");
x += 25;
// Export Statics, Items, and Tiles
string[] exportString = new string[] { "Statics", "Items", "Tiles" };
for (int i = 0; i < 3; i++)
{
DisplayExportLine(x, i, ((bool)m_State[i + 2]), ((bool)m_State[i + 5]), exportString[i], m_State[11 + (i * 2)].ToString(), m_State[12 + (i * 2)].ToString());
x += (i < 2 ? 25 : 15);
}
AddImageTiled(15, x + 15, 420, 1, 9304);
x += 25;
// Z Range
AddCheck(350, x, 9026, 9027, ((bool)m_State[8]), 6);
AddLabel(20, x, LabelHue, @"Z Range");
AddImageTiled(115, x + 15, 50, 1, 9274);
AddTextEntry(115, x - 5, 50, 20, LabelHue, 2, m_State[9].ToString());
AddLabel(185, x, LabelHue, @"to");
AddImageTiled(225, x + 15, 50, 1, 9274);
AddTextEntry(225, x - 5, 50, 20, LabelHue, 3, m_State[10].ToString());
x += 25;
// Buttons
AddButton(20, x, 4020, 4021, 0, GumpButtonType.Reply, 0);
AddLabel(55, x, LabelHue, @"Cancel");
AddButton(155, x, 4005, 4006, 1, GumpButtonType.Reply, 0);
AddLabel(195, x, LabelHue, @"Generate");
AddButton(300, x, 4005, 4006, 2, GumpButtonType.Reply, 0);
AddLabel(340, x, LabelHue, @"Test & Gen");
}
private void DisplayExportLine(int x, int index, bool state, bool include, string heading, string min, string max)
{
AddCheck(20, x, 9026, 9027, state, index);
AddLabel(40, x, LabelHue, heading);
AddImageTiled(115, x + 15, 50, 1, 9274);
AddTextEntry(115, x - 5, 50, 20, LabelHue, 4 + (index * 2), min);// Tile ID Min
AddLabel(185, x, LabelHue, @"to");
AddImageTiled(225, x + 15, 50, 1, 9274);
AddTextEntry(225, x - 5, 50, 20, LabelHue, 5 + (index * 2), max);// Tile ID Max
AddCheck(350, x, 9026, 9027, include, index + 3); // Include or Exclude compare?
}
private string Center(string text)
{
return String.Format("<CENTER>{0}</CENTER>", text);
}
private string Color(string text, int color)
{
return String.Format("<BASEFONT COLOR=#{0:X6}>{1}</COLOR>", color, text);
}
public override void OnResponse(Server.Network.NetState sender, RelayInfo info)
{
if (info.ButtonID == 0)
return;
else if (info.ButtonID == 1)
m_State[17] = false;
else
m_State[17] = true;
foreach (TextRelay text in info.TextEntries)
m_State[text.EntryID < 2 ? text.EntryID : text.EntryID + 7] = text.Text;
// Reset checks
for (int x = 2; x <= 8; x++)
m_State[x] = false;
foreach (int check in info.Switches)
m_State[check + 2] = true; // Offset by 2 in the state object
if (Verify(sender.Mobile, m_State))
{
BoundingBoxPicker.Begin(sender.Mobile, new BoundingBoxCallback(AddonGenerator.PickerCallback), m_State);
}
else
{
sender.Mobile.SendMessage(0x40, "Please review the generation parameters, some are invalid.");
sender.Mobile.SendGump(new InternalGump(sender.Mobile, m_State));
}
}
private static bool Verify(Mobile from, object[] state)
{
if (state[0] == null || (state[0] as string).Length == 0)
{
from.SendMessage(0x40, "Name field is invalid or missing.");
return false;
}
if (state[1] == null || (state[1] as string).Length == 0)
{
from.SendMessage(0x40, "Namespace field is invalid or missing.");
return false;
}
if (!((bool)state[2] || (bool)state[3] || (bool)state[4]))
{
from.SendMessage(0x40, "You must have least one Export button selected. (Static/Items/Tiles)");
return false;
}
string[] errors = new string[] {"Z Range Min", "Z Range Max","Static Min ID", "Static Max ID",
"Item Min ID", "Item Max ID", "Tile Min ID", "Tile Max ID"};
for (int x = 0; x < 8; x++)
if (!CheckNumber(x < 2 ? 0 : 1, state[x + 9] as string, errors[x], from))
return false;
return true;
}
private static bool CheckNumber(int numType, string number, string error, Mobile from)
{
sbyte sbyteTemp;
int intTemp;
try
{
if (numType == 0)
sbyteTemp = sbyte.Parse(number);
else
intTemp = int.Parse(number);
}
catch
{
from.SendMessage(0x40, "There's a problem with the {0} field.", error);
return false;
}
return true;
}
}
#endregion
}
}
#region CEOIdentifyAddon
namespace Server.Items
{
public class CEOIdentifyAddon : BaseAddon
{
[Constructable]
public CEOIdentifyAddon(string init)
{
// Nothing really here, just prevents adding a null contruct via [add command
}
[Constructable]
public CEOIdentifyAddon()
{
this.Delete();
}
public CEOIdentifyAddon(Serial serial)
: base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write(0); // Version
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
if (this.Map == null || this.Map == Map.Internal)
this.Delete(); // Remove it because it's most
}
public void ReDeed(Mobile m)
{
this.Delete();
}
}
}
#endregion

View file

@ -0,0 +1,47 @@
using System;
using Server;
using System.Collections;
using System.Collections.Generic;
using Server.Misc;
using Server.Items;
using Server.Network;
using Server.Commands;
using Server.Commands.Generic;
using Server.Mobiles;
using Server.Accounting;
using Server.Regions;
using System.IO;
using Server.Targeting;
using System.Text;
namespace Server.Scripts.Commands
{
public class AreaLog
{
public static void Initialize()
{
CommandSystem.Register("AreaLog", AccessLevel.Counselor, new CommandEventHandler( AreaLogs ));
}
[Usage("AreaLog")]
[Description("Records the x and y coordinates of an area.")]
public static void AreaLogs( CommandEventArgs e )
{
e.Mobile.SendMessage( "What area do you want to log?" );
BeginArea( e.Mobile );
}
public static void BeginArea( Mobile mob )
{
BoundingBoxPicker.Begin(mob, new BoundingBoxCallback(Area_Callback), new object[]{ "area.txt" } );
}
private static void Area_Callback(Mobile mob, Map map, Point3D start, Point3D end, object state )
{
StreamWriter w = File.AppendText("area.txt");
w.WriteLine( "<rect x=\"" + (start.X - 0) + "\" y=\"" + (start.Y - 0) + "\" width=\"" + ( end.X - start.X + 1 ) + "\" height=\"" + ( end.Y - start.Y + 1 ) + "\" />" );
w.Close();
mob.SendMessage( ( start.X - 1 ) + " " + ( start.Y - 1 ) + " " + ( end.X + 1 ) + " " + ( end.Y + 1 ) );
}
}
}

View file

@ -0,0 +1,39 @@
using System;
using Server;
using System.Collections;
using System.Collections.Generic;
using Server.Misc;
using Server.Items;
using Server.Network;
using Server.Commands;
using Server.Commands.Generic;
using Server.Mobiles;
using Server.Accounting;
using Server.Regions;
using System.IO;
using Server.Targeting;
namespace Server.Scripts.Commands
{
public class BodyTypes
{
public static void Initialize()
{
CommandSystem.Register("BodyTypes", AccessLevel.Counselor, new CommandEventHandler( BodyTypess ));
}
[Usage("BodyTypes")]
[Description("Increments a nearby creature's body by 1 point.")]
public static void BodyTypess( CommandEventArgs e )
{
foreach ( Mobile m in (e.Mobile).GetMobilesInRange( 5 ) )
{
if ( m is BaseCreature )
{
m.BodyValue = m.BodyValue + 1;
m.Say( "" + m.BodyValue + "" );
}
}
}
}
}

View file

@ -0,0 +1,43 @@
using Server.Accounting;
using Server.Commands.Generic;
using Server.Commands;
using Server.Items;
using Server.Misc;
using Server.Mobiles;
using Server.Network;
using Server.Regions;
using Server;
using System.Collections.Generic;
using System.Collections;
using System.IO;
using System;
namespace Server.Scripts.Commands
{
public class BuildWorld
{
public static void Initialize()
{
CommandSystem.Register("BuildWorld", AccessLevel.Counselor, new CommandEventHandler( BuildWorlds ));
}
[Usage("BuildWorld")]
[Description("This cleans up the world and rebuilds it, leaving players intact.")]
public static void BuildWorlds( CommandEventArgs e )
{
Server.Commands.Decorate.Decorate_OnCommand( e );
Server.SpawnGenerator.Parse( e.Mobile, "towns.map" );
Server.SpawnGenerator.Parse( e.Mobile, "graveyards.map" );
Server.SpawnGenerator.Parse( e.Mobile, "land.map" );
Server.SpawnGenerator.Parse( e.Mobile, "dungeons.map" );
Server.SpawnGenerator.Parse( e.Mobile, "labyrinths.map" );
Server.SpawnGenerator.Parse( e.Mobile, "mazes.map" );
if ( Server.Misc.Settings.PopulateTowns() ){ Server.SpawnGenerator.Parse( e.Mobile, "citizens.map" ); }
Server.Regions.SpawnEntry.RespawnAllRegions_OnCommand( e );
e.Mobile.SendMessage( "The world has been rebuilt." );
}
}
}

View file

@ -0,0 +1,57 @@
using System;
using Server;
using System.Collections;
using System.Collections.Generic;
using Server.Misc;
using Server.Items;
using Server.Network;
using Server.Commands;
using Server.Commands.Generic;
using Server.Mobiles;
using Server.Accounting;
using Server.Regions;
using System.IO;
namespace Server.Scripts.Commands
{
public class FaceLog
{
public static void Initialize()
{
CommandSystem.Register("FaceLog", AccessLevel.Counselor, new CommandEventHandler( FaceLogs ));
}
[Usage("FaceLog")]
[Description("Records the x, y, and z coordinates of the caller...along with the map they are in.")]
public static void FaceLogs( CommandEventArgs e )
{
Mobile m = e.Mobile;
string sX = m.X.ToString();
string sY = m.Y.ToString();
string sZ = m.Z.ToString();
string sRegion = m.Region.Name;
string sMap = "Map.Britannia";
if ( m.Map == Map.Underworld ){ sMap = "Map.Underworld"; }
string sDirection = "East";
if ( m.Direction == Direction.North ){ sDirection = "North"; }
else if ( m.Direction == Direction.Right ){ sDirection = "Right"; }
else if ( m.Direction == Direction.East ){ sDirection = "East"; }
else if ( m.Direction == Direction.Down ){ sDirection = "Down"; }
else if ( m.Direction == Direction.South ){ sDirection = "South"; }
else if ( m.Direction == Direction.Left ){ sDirection = "Left"; }
else if ( m.Direction == Direction.West ){ sDirection = "West"; }
else if ( m.Direction == Direction.Up ){ sDirection = "Up"; }
StreamWriter w = File.AppendText("facing.txt");
w.WriteLine( sRegion + "\t" + "(" + sX + ", " + sY + ", " + sZ + ")\t" + sMap + "\t" + sDirection );
w.Close();
m.SendMessage( sRegion + " " + "(" + sX + ", " + sY + ", " + sZ + ") " + sMap + " " + sDirection );
}
}
}

View file

@ -0,0 +1,331 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using Server;
using Server.Mobiles;
using Server.Items;
using Server.Commands;
using Server.Targeting;
namespace Server.Misc
{
public class Dumps
{
public const int Version = 200; // Script version (do not change)
public static string FilePath = @".\Export\";
public static void Initialize()
{
CommandSystem.Register("FullExport" , AccessLevel.Administrator, new CommandEventHandler(FullExport_OnCommand));
CommandSystem.Register("FullEx" , AccessLevel.Administrator, new CommandEventHandler(FullExport_OnCommand));
}
[Usage( "FullExport [string filename]" )]
[Aliases( "FullEx" )]
[Description( "Exports statics to a cfg decoration file." )]
public static void FullExport_OnCommand(CommandEventArgs e )
{
if( e.Arguments.Length > 0 )
BeginStaEx(e.Mobile, e.ArgString );
else
e.Mobile.SendMessage("Format: FullExport [string filename]" );
}
public static void BeginStaEx(Mobile mob, string file )
{
Export(mob, file, new Rectangle2D(new Point2D(0, 0), new Point2D(7168, 4096)));
}
private static void Export(Mobile mob, string file, Rectangle2D rect)
{
Map map = mob.Map;
if( !Directory.Exists(FilePath) )
Directory.CreateDirectory(FilePath);
using(StreamWriter op = new StreamWriter(String.Format(@".\Export\{0}.cfg", file)))
{
mob.SendMessage("Exporting statics...");
IPooledEnumerable eable = mob.Map.GetItemsInBounds(rect);
int i = 0;
try
{
foreach(Item item in eable)
{
if( item == null || item.Deleted )
continue;
if( item is AddonComponent && !(item is DartBoard) )
continue;
if ( item.Weight >= 0 && !(item is BaseMulti) )
{
string s = Construct(item);
if( !s.Substring(0, s.IndexOf(' ')+1).Contains("+") ) // Make sure this isn't an InternalItem of a class...
{
op.WriteLine(s);
op.WriteLine("{0} {1} {2}", item.X, item.Y, item.Z);
op.WriteLine();
i++;
}
}
}
mob.SendMessage("You exported {0} statics from this facet.", i);
}
catch(Exception e){ mob.SendMessage(e.Message); }
eable.Free();
}
}
public static List<string[]> List = new List<string[]>();
public static void Add(string s){ Add(s, ""); }
public static void Add(string s1, string s2)
{
List.Add(new string[]{s1, s2});
}
public static string Construct(Item item)
{
string s;
int itemID = item.ItemID;
if( item is BaseAddon )
for( int i = 0; i < ((BaseAddon)item).Components.Count; i++ )
if( ((BaseAddon)item).Components[i].Offset == Point3D.Zero )
{
itemID = ((BaseAddon)item).Components[i].ItemID;
break;
}
if( item is LocalizedStatic )
Add("LabelNumber", ((LocalizedStatic)item).Number.ToString());
else if( item is LocalizedSign )
Add("LabelNumber", ((LocalizedSign)item).Number.ToString());
else if( item is AnkhWest )
Add("Bloodied", (item.ItemID == 0x1D98).ToString());
else if( item is AnkhNorth )
Add("Bloodied", (item.ItemID == 0x1E5D).ToString());
else if( item is WarningItem )
{
Add("Range", ((WarningItem)item).Range.ToString());
if( VS(((WarningItem)item).WarningString) )
Add("WarningString", ((WarningItem)item).WarningString);
Add("WarningNumber", ((WarningItem)item).WarningNumber.ToString());
if( item is HintItem )
{
if( VS(((HintItem)item).HintString) )
Add("HintString", ((HintItem)item).HintString);
Add("HintNumber", ((HintItem)item).HintNumber.ToString());
}
Add("Range", ((WarningItem)item).ResetDelay.ToString());
}
else if( item.GetType().IsSubclassOf(typeof(BaseBeverage)) )
Add("Content", ((BaseBeverage)item).Content.ToString());
else if( item.GetType().IsSubclassOf(typeof(BaseDoor)) )
{
if ( ( item.ItemID == 0x3B1 ) )
{
Add("Facing", "WestSS");
}
else if ( ( item.ItemID == 0x3B2 ) )
{
Add("Facing", "SouthSW");
}
else if ( ( item.ItemID == 1663 ) ||
( item.ItemID == 1743 ) ||
( item.ItemID == 1695 ) ||
( item.ItemID == 1711 ) ||
( item.ItemID == 1759 ) ||
( item.ItemID == 1775 ) ||
( item.ItemID == 2115 ) ||
( item.ItemID == 2160 ) ||
( item.ItemID == 1727 ) ||
( item.ItemID == 846 ) ||
( item.ItemID == 830 ) ||
( item.ItemID == 798 ) ||
( item.ItemID == 242 ) ||
( item.ItemID == 814 ) ||
( item.ItemID == 862 ) ||
( item.ItemID == 2134 ) ||
( item.ItemID == 2094 ) ||
( item.ItemID == 1679 ) ||
( item.ItemID == 8183 ) )
{
Add("Facing", "NorthCCW");
}
else if ( ( item.ItemID == 1661 ) ||
( item.ItemID == 1741 ) ||
( item.ItemID == 1693 ) ||
( item.ItemID == 1709 ) ||
( item.ItemID == 1757 ) ||
( item.ItemID == 1773 ) ||
( item.ItemID == 2113 ) ||
( item.ItemID == 2158 ) ||
( item.ItemID == 1725 ) ||
( item.ItemID == 844 ) ||
( item.ItemID == 828 ) ||
( item.ItemID == 796 ) ||
( item.ItemID == 240 ) ||
( item.ItemID == 812 ) ||
( item.ItemID == 860 ) ||
( item.ItemID == 2132 ) ||
( item.ItemID == 2092 ) ||
( item.ItemID == 1677 ) ||
( item.ItemID == 8181 ) )
{
Add("Facing", "SouthCW");
}
else
{
Add("Facing", GetFacing(((BaseDoor)item).Offset).ToString());
}
}
if( item is BaseLight )
{
if( !((BaseLight)item).Burning )
Add("Unlit", String.Empty);
if( !((BaseLight)item).Protected )
Add("Unprotected", String.Empty);
}
else if( item is Spawner )
{
Spawner sp = (Spawner)item;
for(int i = 0; i < sp.SpawnNames.Count; i++)
if( VS(sp.SpawnNames[i]) )
Add("Spawn", sp.SpawnNames[i]);
// if( sp.MinDelay > TimeSpan.Zero )
Add("MinDelay", sp.MinDelay.ToString());
// if( sp.MaxDelay > TimeSpan.Zero )
Add("MaxDelay", sp.MaxDelay.ToString());
// if( sp.NextSpawn > TimeSpan.Zero )
//Add("NextSpawn", sp.NextSpawn.ToString());
// if( sp.Count > 0 )
Add("Count", sp.Count.ToString());
// if( sp.Team > 0 )
//Add("Team", sp.Team.ToString());
// if( sp.HomeRange > 0 )
Add("HomeRange", sp.HomeRange.ToString());
// if( sp.Running )
Add("Running", sp.Running.ToString());
// if( sp.Group )
Add("Group", sp.Group.ToString());
}
else if( item is Teleporter )
{
Teleporter tp = (Teleporter)item;
if( item is SkillTeleporter )
{
SkillTeleporter st = (SkillTeleporter)item;
Add("Skill", st.Skill.ToString());
// "RequiredFixedPoint" == Required * 0.1 ?
Add("Required", st.Required.ToString());
if( VS(st.MessageString) )
Add("MessageString", st.MessageString);
Add("MessageNumber", st.MessageNumber.ToString());
}
else if( item is KeywordTeleporter )
{
KeywordTeleporter kt = (KeywordTeleporter)item;
if( VS(kt.Substring) )
Add("Substring", kt.Substring);
Add("Keyword", kt.Keyword.ToString());
Add("Range", kt.Range.ToString());
}
Add("PointDest", tp.PointDest.ToString());
if( tp.MapDest != null )
Add("MapDest", tp.MapDest.ToString());
Add("Creatures", tp.Creatures.ToString());
Add("SourceEffect", tp.SourceEffect.ToString());
Add("DestEffect", tp.DestEffect.ToString());
Add("SoundID", tp.SoundID.ToString());
Add("Delay", tp.Delay.ToString());
}
if( item.Light != LightType.ArchedWindowEast )
Add("Light", item.Light.ToString());
if( item.Hue > 0 )
Add("Hue", item.Hue.ToString());
if( VS(item.Name) )
Add("Name", item.Name);
if( item.Amount > 1 )
Add("Amount", item.Amount.ToString());
s = String.Format("{0} {1}", ConstructType(item), itemID);
if( List.Count > 0 )
{
s += " (";
for( int i = 0; i < List.Count; i++ )
{
if( List[i][1] == String.Empty )
s += String.Format("{0}{1}", List[i][0], (i < List.Count-1 ? "; " : String.Empty));
else
s += String.Format("{0}={1}{2}", List[i][0], List[i][1], (i < List.Count-1 ? "; " : String.Empty));
}
s += ")";
}
List.Clear();
return s;
}
public static bool VS(string s)
{
if( s == null || s == String.Empty )
return false;
return true;
}
public static string ConstructType(Item item)
{
string s = item.GetType().ToString();
if( s.LastIndexOf('.') > -1 )
s = s.Remove(0, s.LastIndexOf('.')+1);
return s;
}
public static DoorFacing GetFacing(Point3D p)
{
DoorFacing facing = DoorFacing.WestCW;
for(int i = 0; i < m_Offsets.Length; i++)
{
if( p == m_Offsets[i] )
{
facing = (DoorFacing)i;
break;
}
}
return facing;
}
private static Point3D[] m_Offsets = new Point3D[]
{
new Point3D(-1, 1, 0 ),
new Point3D( 1, 1, 0 ),
new Point3D(-1, 0, 0 ),
new Point3D( 1,-1, 0 ),
new Point3D( 1, 1, 0 ),
new Point3D( 1,-1, 0 ),
new Point3D( 0, 0, 0 ),
new Point3D( 0,-1, 0 ),
new Point3D( 0, 0, 0 ),
new Point3D( 0, 0, 0 ),
new Point3D( 0, 0, 0 ),
new Point3D( 0, 0, 0 )
};
}
}

View file

@ -0,0 +1,54 @@
using System;
using Server;
using System.Collections;
using System.Collections.Generic;
using Server.Misc;
using Server.Items;
using Server.Network;
using Server.Commands;
using Server.Commands.Generic;
using Server.Mobiles;
using Server.Accounting;
using Server.Regions;
using System.IO;
using Server.Targeting;
namespace Server.Scripts.Commands
{
public class GetLevel
{
public static void Initialize()
{
CommandSystem.Register("GetLevel", AccessLevel.Counselor, new CommandEventHandler( GetLevels ));
}
[Usage("GetLevel")]
[Description("Gets the level of the creature.")]
public static void GetLevels( CommandEventArgs e )
{
e.Mobile.SendMessage( "What target do you want to inspect?" );
e.Mobile.Target = new InternalTarget();
}
private class InternalTarget : Target
{
public InternalTarget() : base ( 8, false, TargetFlags.None )
{
}
protected override void OnTarget( Mobile from, object targeted )
{
if ( targeted is Mobile )
{
Mobile m = (Mobile)targeted;
from.SendMessage( "" + BaseCreature.MyLevel( m ) + "" );
}
else
{
from.SendMessage( "Not a valid creature!" );
}
}
}
}
}

View file

@ -0,0 +1,45 @@
using System;
using Server;
using System.Collections;
using System.Collections.Generic;
using Server.Misc;
using Server.Items;
using Server.Network;
using Server.Commands;
using Server.Commands.Generic;
using Server.Mobiles;
using Server.Accounting;
using Server.Regions;
using System.IO;
namespace Server.Scripts.Commands
{
public class GoLog
{
public static void Initialize()
{
CommandSystem.Register("GoLog", AccessLevel.Counselor, new CommandEventHandler( GoLogs ));
}
[Usage("GoLog")]
[Description("Records the x, y, and z coordinates of the caller...for the go menu.")]
public static void GoLogs( CommandEventArgs e )
{
string sX = e.Mobile.X.ToString();
string sY = e.Mobile.Y.ToString();
string sZ = e.Mobile.Z.ToString();
string sRegion = e.Mobile.Region.Name;
string sMap = "Map.Britannia";
if ( e.Mobile.Map == Map.Underworld ){ sMap = "Map.Underworld"; }
StreamWriter w = File.AppendText("go.txt");
w.WriteLine( "<child name=\"xxxxxxxxx\" x=\"" + sX + "\" y=\"" + sY + "\" z=\"" + sZ + "\" />" );
w.Close();
e.Mobile.SendMessage( sRegion + " " + "(" + sX + ", " + sY + ", " + sZ + ") " + sMap );
}
}
}

View file

@ -0,0 +1,59 @@
using System;
using Server;
using System.Collections;
using System.Collections.Generic;
using Server.Misc;
using Server.Items;
using Server.Network;
using Server.Commands;
using Server.Commands.Generic;
using Server.Mobiles;
using Server.Accounting;
using Server.Regions;
using System.IO;
namespace Server.Scripts.Commands
{
public class PointLog
{
public static void Initialize()
{
CommandSystem.Register("PointLog", AccessLevel.Counselor, new CommandEventHandler( PointLogs ));
}
[Usage("PointLog")]
[Description("Records the x, y, and z coordinates of the caller...along with the map they are in.")]
public static void PointLogs( CommandEventArgs e )
{
string sX = e.Mobile.X.ToString();
string sY = e.Mobile.Y.ToString();
string sZ = e.Mobile.Z.ToString();
string sRegion = e.Mobile.Region.Name;
string sMap = "Map.Britannia";
if ( e.Mobile.Map == Map.Underworld ){ sMap = "Map.Underworld"; }
StreamWriter w = File.AppendText("points.txt");
w.WriteLine( sRegion + "\t" + "(" + sX + ", " + sY + ", " + sZ + ")\t" + sMap );
w.Close();
e.Mobile.SendMessage( sRegion + " " + "(" + sX + ", " + sY + ", " + sZ + ") " + sMap );
}
}
public class ContainerLog
{
public static void ContainerLogs( int x, int y, int item, int gump, Mobile from )
{
StreamWriter w = File.AppendText("containers.txt");
w.WriteLine( "X\tY\tItemID\tGump" );
w.WriteLine( "" + x + "\t" + y + "\t" + item + "\t" + gump + "" );
w.Close();
from.SendMessage( "" + x + " --- " + y + " --- " + item + " --- " + gump + "" );
}
}
}

View file

@ -0,0 +1,339 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using Server;
using Server.Mobiles;
using Server.Items;
using Server.Commands;
using Server.Targeting;
namespace Server.Misc
{
public class Exporters
{
public const int Version = 200; // Script version (do not change)
public static string FilePath = @".\Export\";
public static void Initialize()
{
CommandSystem.Register("StaticExport" , AccessLevel.Administrator, new CommandEventHandler(StaticExport_OnCommand));
CommandSystem.Register("StaEx" , AccessLevel.Administrator, new CommandEventHandler(StaticExport_OnCommand));
}
[Usage( "StaticExport [string filename]" )]
[Aliases( "StaEx" )]
[Description( "Exports statics to a cfg decoration file." )]
public static void StaticExport_OnCommand(CommandEventArgs e )
{
if( e.Arguments.Length > 0 )
BeginStaEx(e.Mobile, e.ArgString );
else
e.Mobile.SendMessage("Format: StaticExport [string filename]" );
}
public static void BeginStaEx(Mobile mob, string file )
{
BoundingBoxPicker.Begin(mob, new BoundingBoxCallback(StaExBox_Callback), new object[]{ file });
}
private static void StaExBox_Callback(Mobile mob, Map map, Point3D start, Point3D end, object state)
{
object[] states = (object[])state;
string file = (string)states[0];
Export(mob, file, new Rectangle2D(new Point2D(start.X, start.Y), new Point2D(end.X+1, end.Y+1)));
}
private static void Export(Mobile mob, string file, Rectangle2D rect)
{
Map map = mob.Map;
if( !Directory.Exists(FilePath) )
Directory.CreateDirectory(FilePath);
using(StreamWriter op = new StreamWriter(String.Format(@".\Export\{0}.cfg", file)))
{
mob.SendMessage("Exporting statics...");
IPooledEnumerable eable = mob.Map.GetItemsInBounds(rect);
int i = 0;
try
{
foreach(Item item in eable)
{
if( item == null || item.Deleted )
continue;
if( item is AddonComponent && !(item is DartBoard) )
continue;
if ( item.Weight >= 0 && !(item is BaseMulti) )
{
string s = Construct(item);
if( !s.Substring(0, s.IndexOf(' ')+1).Contains("+") ) // Make sure this isn't an InternalItem of a class...
{
op.WriteLine(s);
op.WriteLine("{0} {1} {2}", item.X, item.Y, item.Z);
op.WriteLine();
i++;
}
}
}
mob.SendMessage("You exported {0} statics from this facet.", i);
}
catch(Exception e){ mob.SendMessage(e.Message); }
eable.Free();
}
}
public static List<string[]> List = new List<string[]>();
public static void Add(string s){ Add(s, ""); }
public static void Add(string s1, string s2)
{
List.Add(new string[]{s1, s2});
}
public static string Construct(Item item)
{
string s;
int itemID = item.ItemID;
if( item is BaseAddon )
for( int i = 0; i < ((BaseAddon)item).Components.Count; i++ )
if( ((BaseAddon)item).Components[i].Offset == Point3D.Zero )
{
itemID = ((BaseAddon)item).Components[i].ItemID;
break;
}
if( item is LocalizedStatic )
Add("LabelNumber", ((LocalizedStatic)item).Number.ToString());
else if( item is LocalizedSign )
Add("LabelNumber", ((LocalizedSign)item).Number.ToString());
else if( item is AnkhWest )
Add("Bloodied", (item.ItemID == 0x1D98).ToString());
else if( item is AnkhNorth )
Add("Bloodied", (item.ItemID == 0x1E5D).ToString());
else if( item is WarningItem )
{
Add("Range", ((WarningItem)item).Range.ToString());
if( VS(((WarningItem)item).WarningString) )
Add("WarningString", ((WarningItem)item).WarningString);
Add("WarningNumber", ((WarningItem)item).WarningNumber.ToString());
if( item is HintItem )
{
if( VS(((HintItem)item).HintString) )
Add("HintString", ((HintItem)item).HintString);
Add("HintNumber", ((HintItem)item).HintNumber.ToString());
}
Add("Range", ((WarningItem)item).ResetDelay.ToString());
}
else if( item.GetType().IsSubclassOf(typeof(BaseBeverage)) )
Add("Content", ((BaseBeverage)item).Content.ToString());
else if( item.GetType().IsSubclassOf(typeof(BaseDoor)) )
{
if ( ( item.ItemID == 0x3B1 ) )
{
Add("Facing", "WestSS");
}
else if ( ( item.ItemID == 0x3B2 ) )
{
Add("Facing", "SouthSW");
}
else if ( ( item.ItemID == 1663 ) ||
( item.ItemID == 1743 ) ||
( item.ItemID == 1695 ) ||
( item.ItemID == 1711 ) ||
( item.ItemID == 1759 ) ||
( item.ItemID == 1775 ) ||
( item.ItemID == 2115 ) ||
( item.ItemID == 2160 ) ||
( item.ItemID == 1727 ) ||
( item.ItemID == 846 ) ||
( item.ItemID == 830 ) ||
( item.ItemID == 798 ) ||
( item.ItemID == 242 ) ||
( item.ItemID == 814 ) ||
( item.ItemID == 862 ) ||
( item.ItemID == 2134 ) ||
( item.ItemID == 2094 ) ||
( item.ItemID == 1679 ) ||
( item.ItemID == 8183 ) )
{
Add("Facing", "NorthCCW");
}
else if ( ( item.ItemID == 1661 ) ||
( item.ItemID == 1741 ) ||
( item.ItemID == 1693 ) ||
( item.ItemID == 1709 ) ||
( item.ItemID == 1757 ) ||
( item.ItemID == 1773 ) ||
( item.ItemID == 2113 ) ||
( item.ItemID == 2158 ) ||
( item.ItemID == 1725 ) ||
( item.ItemID == 844 ) ||
( item.ItemID == 828 ) ||
( item.ItemID == 796 ) ||
( item.ItemID == 240 ) ||
( item.ItemID == 812 ) ||
( item.ItemID == 860 ) ||
( item.ItemID == 2132 ) ||
( item.ItemID == 2092 ) ||
( item.ItemID == 1677 ) ||
( item.ItemID == 8181 ) )
{
Add("Facing", "SouthCW");
}
else
{
Add("Facing", GetFacing(((BaseDoor)item).Offset).ToString());
}
}
if( item is BaseLight )
{
if( !((BaseLight)item).Burning )
Add("Unlit", String.Empty);
if( !((BaseLight)item).Protected )
Add("Unprotected", String.Empty);
}
else if( item is Spawner )
{
Spawner sp = (Spawner)item;
for(int i = 0; i < sp.SpawnNames.Count; i++)
if( VS(sp.SpawnNames[i]) )
Add("Spawn", sp.SpawnNames[i]);
// if( sp.MinDelay > TimeSpan.Zero )
Add("MinDelay", sp.MinDelay.ToString());
// if( sp.MaxDelay > TimeSpan.Zero )
Add("MaxDelay", sp.MaxDelay.ToString());
// if( sp.NextSpawn > TimeSpan.Zero )
//Add("NextSpawn", sp.NextSpawn.ToString());
// if( sp.Count > 0 )
Add("Count", sp.Count.ToString());
// if( sp.Team > 0 )
//Add("Team", sp.Team.ToString());
// if( sp.HomeRange > 0 )
Add("HomeRange", sp.HomeRange.ToString());
// if( sp.Running )
Add("Running", sp.Running.ToString());
// if( sp.Group )
Add("Group", sp.Group.ToString());
}
else if( item is Teleporter )
{
Teleporter tp = (Teleporter)item;
if( item is SkillTeleporter )
{
SkillTeleporter st = (SkillTeleporter)item;
Add("Skill", st.Skill.ToString());
// "RequiredFixedPoint" == Required * 0.1 ?
Add("Required", st.Required.ToString());
if( VS(st.MessageString) )
Add("MessageString", st.MessageString);
Add("MessageNumber", st.MessageNumber.ToString());
}
else if( item is KeywordTeleporter )
{
KeywordTeleporter kt = (KeywordTeleporter)item;
if( VS(kt.Substring) )
Add("Substring", kt.Substring);
Add("Keyword", kt.Keyword.ToString());
Add("Range", kt.Range.ToString());
}
Add("PointDest", tp.PointDest.ToString());
if( tp.MapDest != null )
Add("MapDest", tp.MapDest.ToString());
Add("Creatures", tp.Creatures.ToString());
Add("SourceEffect", tp.SourceEffect.ToString());
Add("DestEffect", tp.DestEffect.ToString());
Add("SoundID", tp.SoundID.ToString());
Add("Delay", tp.Delay.ToString());
}
if( item.Light != LightType.ArchedWindowEast )
Add("Light", item.Light.ToString());
if( item.Hue > 0 )
Add("Hue", item.Hue.ToString());
if( VS(item.Name) )
Add("Name", item.Name);
if( item.Amount > 1 )
Add("Amount", item.Amount.ToString());
s = String.Format("{0} {1}", ConstructType(item), itemID);
if( List.Count > 0 )
{
s += " (";
for( int i = 0; i < List.Count; i++ )
{
if( List[i][1] == String.Empty )
s += String.Format("{0}{1}", List[i][0], (i < List.Count-1 ? "; " : String.Empty));
else
s += String.Format("{0}={1}{2}", List[i][0], List[i][1], (i < List.Count-1 ? "; " : String.Empty));
}
s += ")";
}
List.Clear();
return s;
}
public static bool VS(string s)
{
if( s == null || s == String.Empty )
return false;
return true;
}
public static string ConstructType(Item item)
{
string s = item.GetType().ToString();
if( s.LastIndexOf('.') > -1 )
s = s.Remove(0, s.LastIndexOf('.')+1);
return s;
}
public static DoorFacing GetFacing(Point3D p)
{
DoorFacing facing = DoorFacing.WestCW;
for(int i = 0; i < m_Offsets.Length; i++)
{
if( p == m_Offsets[i] )
{
facing = (DoorFacing)i;
break;
}
}
return facing;
}
private static Point3D[] m_Offsets = new Point3D[]
{
new Point3D(-1, 1, 0 ),
new Point3D( 1, 1, 0 ),
new Point3D(-1, 0, 0 ),
new Point3D( 1,-1, 0 ),
new Point3D( 1, 1, 0 ),
new Point3D( 1,-1, 0 ),
new Point3D( 0, 0, 0 ),
new Point3D( 0,-1, 0 ),
new Point3D( 0, 0, 0 ),
new Point3D( 0, 0, 0 ),
new Point3D( 0, 0, 0 ),
new Point3D( 0, 0, 0 )
};
}
}

View file

@ -0,0 +1,82 @@
using System;
using Server;
using System.Collections;
using System.Collections.Generic;
using Server.Misc;
using Server.Items;
using Server.Network;
using Server.Commands;
using Server.Commands.Generic;
using Server.Mobiles;
using Server.Accounting;
using Server.Regions;
using System.IO;
using Server.Targeting;
namespace Server.Scripts.Commands
{
public class TargetLog
{
public static void Initialize()
{
CommandSystem.Register("TargetLog", AccessLevel.Counselor, new CommandEventHandler( TargetLogs ));
}
[Usage("TargetLog")]
[Description("Records the x, y, and z coordinates of the caller...along with the map they are in.")]
public static void TargetLogs( CommandEventArgs e )
{
e.Mobile.SendMessage( "What target do you want to log?" );
e.Mobile.Target = new InternalTarget();
}
private class InternalTarget : Target
{
public InternalTarget() : base ( 8, false, TargetFlags.None )
{
}
protected override void OnTarget( Mobile from, object targeted )
{
string sX = "";
string sY = "";
string sZ = "";
string sItem = "";
if ( targeted is Item )
{
sX = ((Item)targeted).X.ToString();
sY = ((Item)targeted).Y.ToString();
sZ = ((Item)targeted).Z.ToString();
sItem = ((Item)targeted).ItemID.ToString();
}
else if ( targeted is StaticTarget )
{
sX = ((StaticTarget)targeted).X.ToString();
sY = ((StaticTarget)targeted).Y.ToString();
sZ = ((StaticTarget)targeted).Z.ToString();
sItem = ((StaticTarget)targeted).ItemID.ToString();
}
string sRegion = from.Region.Name;
string sMap = "Map.Britannia";
if ( from.Map == Map.Underworld ){ sMap = "Map.Underworld"; }
if ( sX != "" )
{
StreamWriter w = File.AppendText("targets.txt");
w.WriteLine( sRegion + "\t" + sItem + "\t" + sX + "\t" + sY + "\t" + sZ + "\t" + sMap );
w.Close();
from.SendMessage( sRegion + " " + sItem + " " + sX + " " + sY + " " + sZ + " " + sMap );
}
else
{
from.SendMessage( "Target failed to log!" );
}
}
}
}
}