Overwrite

Complete Overwrite of the Folder with the free shard. ServUO 57.3 has been added.
This commit is contained in:
Unstable Kitsune
2023-11-28 23:20:26 -05:00
parent 3cd54811de
commit b918192e4e
11608 changed files with 2644205 additions and 47 deletions

View File

@@ -0,0 +1,312 @@
/**************************************
*Script Name: Staff Runebook *
*Author: Joeku *
*For use with RunUO 2.0 RC2 *
*Client Tested with: 6.0.9.2 *
*Version: 1.10 *
*Initial Release: 11/25/07 *
*Revision Date: 02/04/09 *
**************************************/
using System;
using System.Collections.Generic;
using Server;
using Server.Gumps;
using Server.Items;
using Server.Network;
namespace Joeku.SR
{
public class SR_Gump : Gump
{
public SR_RuneAccount RuneAcc { get; set; }
public SR_Gump(Mobile m, SR_RuneAccount runeAcc)
: base(0, 27)
{
RuneAcc = runeAcc;
int count = 0;
if (RuneAcc.ChildRune == null)
count = RuneAcc.Count;
else
count = RuneAcc.ChildRune.Count;
int RunebooksH = 0,
RunebooksW = 0;
int tier = -1;
if (RuneAcc.ChildRune != null)
tier = RuneAcc.ChildRune.Tier;
if (tier > -1)
{
if (tier == 0)
{
RunebooksH = 42;
RunebooksW = 278;
}
else
{
RunebooksH = 37 + 42;
RunebooksW = 278 + (tier * 5);
}
}
int RunesH = 10 * 2;
if (count > 10)
count = 10;
if (count > 0)
RunesH += (count * 22);
if (count > 1)
RunesH += ((count - 1) * 5);
DisplayHeader();
int labelHue = m != null && m.NetState != null && m.NetState.IsEnhancedClient ? 2101 : 2100;
if (tier > -1)
DisplayRunebooks(42, RunebooksH, RunebooksW, tier, labelHue);
DisplayAddNew(42 + RunebooksH + RunesH, labelHue);
DisplayRunes(42 + RunebooksH, RunesH, labelHue);
}
public static void Send(Mobile mob, SR_RuneAccount runeAcc)
{
mob.CloseGump(typeof(SR_Gump));
mob.SendGump(new SR_Gump(mob, runeAcc));
}
public void DisplayHeader()
{
AddPage(0);
AddBackground(0, 0, 210, 42, 9270);
AddImageTiled(10, 10, 190, 22, 2624);
AddAlphaRegion(10, 10, 190, 22);
AddHtml(0, 11, 210, 20, "<CENTER><BASEFONT COLOR=#FFFFFF><BIG>Joeku's Staff Runebook</CENTER>", false, false);
}
public void DisplayRunebooks(int y, int h, int w, int tiers, int labelHue)
{
AddBackground(0, y, w, h, 9270);
AddImageTiled(10, y + 10, w - 20, h - 20, 2624);
AddAlphaRegion(10, y + 10, w - 20, h - 20);
for (int i = tiers, j = 1; i > 0; i--, j++)
{
AddBackground(j * 5, y + 37, ((i - 1) * 5) + 278, 42, 9270);
if (i == 1)
{
AddImageTiled((j * 5) + 10, y + 47, ((i - 1) * 5) + 258, 22, 2624);
AddAlphaRegion((j * 5) + 10, y + 47, ((i - 1) * 5) + 258, 22);
}
}
SR_Rune rune = RuneAcc.Runes[RuneAcc.PageIndex];
AddItem(SR_Utilities.ItemOffsetX(rune), y + SR_Utilities.ItemOffsetY(rune) + 12, SR_Utilities.RunebookID, SR_Utilities.ItemHue(rune));
AddLabelCropped(35, y + 12, w - 108, 20, labelHue, rune.Name);
AddButton(w - 70, y + 10, 4014, 4016, 5, GumpButtonType.Reply, 0);
AddButton(w - 40, y + 10, 4017, 4019, 4, GumpButtonType.Reply, 0);
if (tiers > 0)
{
rune = RuneAcc.ChildRune;
AddItem(SR_Utilities.ItemOffsetX(rune) + tiers * 5, y + SR_Utilities.ItemOffsetY(rune) + 12 + 37, SR_Utilities.RunebookID, SR_Utilities.ItemHue(rune));
AddLabelCropped(35 + tiers * 5, y + 12 + 37, 170, 20, labelHue, rune.Name);
AddButton(w - 70, y + 10 + 37, 4014, 4016, 7, GumpButtonType.Reply, 0);
AddButton(w - 40, y + 10 + 37, 4017, 4019, 6, GumpButtonType.Reply, 0);
}
// AddButton(238, 30 + bgY + 10, 4011, 4013, 0, GumpButtonType.Reply, 0);
}
public void DisplayAddNew(int y, int labelHue)
{
AddBackground(0, y, 278, 42, 9270);
AddImageTiled(10, y + 10, 258, 22, 2624);
AddAlphaRegion(10, y + 10, 258, 22);
AddLabel(15, y + 10, labelHue, @"New Rune");
AddButton(80, y + 10, 4011, 4013, 1, GumpButtonType.Reply, 0);
AddButton(110, y + 10, 4029, 4031, 2, GumpButtonType.Reply, 0);
AddLabel(150, y + 10, labelHue, @"New Runebook");
AddButton(238, y + 10, 4011, 4013, 3, GumpButtonType.Reply, 0);
}
public void DisplayRunes(int y, int h, int labelHue)
{
AddBackground(0, y, 430/*400*/, h, 9270);
AddImageTiled(10, y + 10, 410, h - 20, 2624);
AddAlphaRegion(10, y + 10, 410, h - 20);
List<SR_Rune> runes = null;
int count, runebooks;
if (RuneAcc.ChildRune == null)
{
runes = RuneAcc.Runes;
count = RuneAcc.Count;
runebooks = RuneAcc.RunebookCount;
}
else
{
runes = RuneAcc.ChildRune.Runes;
count = RuneAcc.ChildRune.Count;
runebooks = RuneAcc.ChildRune.RunebookCount;
}
AddPage(1);
int pages = (int)Math.Ceiling((double)count / 9.0), temp = 0;
for (int i = 0, loc = 0, page = 1; i < count; i++, loc++)
{
temp = 10 + y + (22 + 5) * loc;
AddItem(SR_Utilities.ItemOffsetX(runes[i]), 2 + SR_Utilities.ItemOffsetY(runes[i]) + temp, runes[i].IsRunebook ? SR_Utilities.RunebookID : SR_Utilities.RuneID, SR_Utilities.ItemHue(runes[i]));
if (runes[i].IsRunebook)
AddLabelCropped(35, 2 + temp, 175, 20, labelHue, String.Format("{0}. {1}", i + 1, runes[i].Name));
else
{
AddLabelCropped(35, 2 + temp, 175, 20, labelHue, String.Format("{0}. {1} ({2})", i + 1 - runebooks, runes[i].Name, runes[i].TargetMap.ToString()));
AddLabelCropped(215, 2 + temp, 110, 20, labelHue, runes[i].TargetLoc.ToString());
AddButton(360, temp, 4008, 4010, i + 30010, GumpButtonType.Reply, 0);
}
AddButton(330 + (runes[i].IsRunebook ? 30 : 0), temp, 4005, 4007, i + 10, GumpButtonType.Reply, 0);
//AddButton(340, 40 + ((22+5)*i), 4026, 4028, 0, GumpButtonType.Reply, 0);
//AddImage(340, 40 + ((22+5)*i), 4026, 1000);
AddButton(390, temp, 4017, 4019, i + 60010, GumpButtonType.Reply, 0); // delete
if (pages > 1 && ((loc == 8 && i < count - 1) || i == count - 1))
{
temp = 10 + y + (22 + 5) * 9;
// (430(bg) - 20 (buffer) - 70 (txt/buffer) - 60(buttons)) / 2 = 140
if (page > 1)
AddButton(140, temp, 4014, 4016, 0, GumpButtonType.Page, page - 1);
else
AddImage(140, temp, 4014, 1000);
AddHtml(170, 2 + temp, 90, 20, String.Format("<BASEFONT COLOR=#FFFFFF><CENTER>Page {0}/{1}", page, pages), false, false);
if (page < pages)
AddButton(260, temp, 4005, 4007, 0, GumpButtonType.Page, page + 1);
else
AddImage(260, temp, 4005, 1000);
page++;
AddPage(page);
loc = -1;
}
}
}
public override void OnResponse(NetState sender, RelayInfo info)
{
int button = info.ButtonID;
Mobile mob = sender.Mobile;
switch( button )
{
case 0:
break;
case 1:
mob.SendMessage("Enter a description:");
mob.Prompt = new SR_NewRunePrompt(RuneAcc, mob.Location, mob.Map);
Send(mob, SR_Utilities.FetchInfo(mob.Account));
break;
case 2:
mob.SendMessage("Target a location to mark:");
mob.Target = new SR_NewRuneTarget(RuneAcc);
Send(mob, SR_Utilities.FetchInfo(mob.Account));
break;
case 3:
mob.SendMessage("Enter a description:");
mob.Prompt = new SR_NewRunePrompt(RuneAcc);
Send(mob, SR_Utilities.FetchInfo(mob.Account));
break;
case 4:
RuneAcc.RemoveRune(RuneAcc.PageIndex, true);
Send(mob, SR_Utilities.FetchInfo(mob.Account));
break;
case 5:
RuneAcc.ResetPageIndex();
Send(mob, SR_Utilities.FetchInfo(mob.Account));
break;
case 6:
RuneAcc.ChildRune.ParentRune.RemoveRune(RuneAcc.ChildRune.ParentRune.PageIndex, true);
Send(mob, SR_Utilities.FetchInfo(mob.Account));
break;
case 7:
RuneAcc.ChildRune.ParentRune.ResetPageIndex();
Send(mob, SR_Utilities.FetchInfo(mob.Account));
break;
default:
bool moongate = false;
button -= 10;
if (button >= 60000)
{
if (RuneAcc.ChildRune == null)
RuneAcc.RemoveRune(button - 60000);
else
RuneAcc.ChildRune.RemoveRune(button - 60000);
Send(mob, SR_Utilities.FetchInfo(mob.Account));
break;
}
if (button >= 30000)
{
button -= 30000;
moongate = true;
}
SR_Rune rune = null;
if (RuneAcc.ChildRune == null && button >= 0 && button < RuneAcc.Runes.Count)
rune = RuneAcc.Runes[button];
else if (button >= 0 && button < RuneAcc.ChildRune.Runes.Count)
rune = RuneAcc.ChildRune.Runes[button];
if (rune.IsRunebook)
{
if (RuneAcc.ChildRune == null)
RuneAcc.PageIndex = button;
else
RuneAcc.ChildRune.PageIndex = button;
Send(mob, SR_Utilities.FetchInfo(mob.Account));
}
else
{
if (mob.Location == rune.TargetLoc && mob.Map == rune.TargetMap)
mob.SendMessage("You are already there.");
else if (!moongate)
{
mob.PlaySound(0x1FC);
mob.MoveToWorld(rune.TargetLoc, rune.TargetMap);
mob.PlaySound(0x1FC);
}
else
{
if (SR_Utilities.FindItem(typeof(Moongate), mob.Location, mob.Map))
mob.SendMessage("You are standing on top of a moongate, please move.");
else if (SR_Utilities.FindItem(typeof(Moongate), rune.TargetLoc, rune.TargetMap))
mob.SendMessage("There is already a moongate there, sorry.");
else
{
mob.SendLocalizedMessage(501024); // You open a magical gate to another location
Effects.PlaySound(mob.Location, mob.Map, 0x20E);
SR_RuneGate firstGate = new SR_RuneGate(rune.TargetLoc, rune.TargetMap);
firstGate.MoveToWorld(mob.Location, mob.Map);
Effects.PlaySound(rune.TargetLoc, rune.TargetMap, 0x20E);
SR_RuneGate secondGate = new SR_RuneGate(mob.Location, mob.Map);
secondGate.MoveToWorld(rune.TargetLoc, rune.TargetMap);
}
}
}
break;
}
}
}
}

View File

@@ -0,0 +1,121 @@
/**************************************
*Script Name: Staff Runebook *
*Author: Joeku *
*For use with RunUO 2.0 RC2 *
*Client Tested with: 6.0.9.2 *
*Version: 1.10 *
*Initial Release: 11/25/07 *
*Revision Date: 02/04/09 *
**************************************/
using System;
using System.IO;
using System.Xml;
using Server;
namespace Joeku.SR
{
public class SR_Load
{
public static void ReadData(string filePath)
{
if (!File.Exists(filePath))
return;
Console.WriteLine();
Console.WriteLine("Joeku's Staff Runebook: Loading...");
XmlDocument doc = new XmlDocument();
doc.Load(filePath);
XmlElement root = doc["StaffRunebook"];
int version = Utility.ToInt32(root.GetAttribute("Version"));
if (root.HasChildNodes)
{
foreach (XmlElement a in root.GetElementsByTagName("RuneAccount"))
{
try
{
ReadAccountNode(a);
}
catch
{
Console.WriteLine(" Warning: Staff Runebook load failed.");
}
}
}
Console.WriteLine();
}
public static void ReadAccountNode(XmlElement parent)
{
Console.Write(" Account: {0}... ", parent.GetAttribute("Username"));
try
{
SR_RuneAccount acc = new SR_RuneAccount(parent.GetAttribute("Username"));
if (parent.HasChildNodes)
{
XmlElement child = parent.FirstChild as XmlElement;
acc.AddRune(ReadRuneNode(child));
while (child.NextSibling != null)
{
child = child.NextSibling as XmlElement;
acc.AddRune(ReadRuneNode(child));
}
/*foreach( XmlElement child in parent.GetElementsByTagName("Runebook") )
if( child != null )
acc.AddRune(ReadRunebookNode(child));
foreach( XmlElement child in parent.GetElementsByTagName("Rune") )
if( child != null )
acc.AddRune(ReadRuneNode(child));*/
}
}
catch
{
Console.WriteLine("failed.");
}
Console.WriteLine("done.");
}
public static SR_Rune ReadRuneNode(XmlElement parent)
{
if (parent.LocalName == "Runebook")
{
SR_Rune runebook = new SR_Rune(parent.GetAttribute("Name"), true);
if (parent.HasChildNodes)
{
XmlElement child = parent.FirstChild as XmlElement;
runebook.AddRune(ReadRuneNode(child));
while (child.NextSibling != null)
{
child = child.NextSibling as XmlElement;
runebook.AddRune(ReadRuneNode(child));
}
}
return runebook;
}
//else if( parent.LocalName == "Rune" )
return new SR_Rune(parent.GetAttribute("Name"), Map.Parse(parent.GetAttribute("TargetMap")), new Point3D(Utility.ToInt32(parent.GetAttribute("X")),Utility.ToInt32(parent.GetAttribute("Y")),Utility.ToInt32(parent.GetAttribute("Z"))));
}
/*public static SR_Rune ReadRunebookNode( XmlElement parent )
{
SR_Rune rune = new SR_Rune(parent.GetAttribute("Name"), true);
if( parent.HasChildNodes )
{
foreach( XmlElement child in parent.GetElementsByTagName("Runebook") )
if( child != null )
rune.AddRune(ReadRunebookNode(child));
foreach( XmlElement child in parent.GetElementsByTagName("Rune") )
if( child != null )
rune.AddRune(ReadRuneNode(child));
}
return rune;
}
public static SR_Rune ReadRuneNode( XmlElement rune )
{
return new SR_Rune(rune.GetAttribute("Name"), Map.Parse(rune.GetAttribute("TargetMap")), new Point3D(Utility.ToInt32(rune.GetAttribute("X")),Utility.ToInt32(rune.GetAttribute("Y")),Utility.ToInt32(rune.GetAttribute("Z"))) );
}*/
}
}

View File

@@ -0,0 +1,80 @@
/**************************************
*Script Name: Staff Runebook *
*Author: Joeku *
*For use with RunUO 2.0 RC2 *
*Client Tested with: 6.0.9.2 *
*Version: 1.10 *
*Initial Release: 11/25/07 *
*Revision Date: 02/04/09 *
**************************************/
using System;
using System.Collections.Generic;
using System.IO;
using Server;
using Server.Commands;
namespace Joeku.SR
{
public class SR_Main
{
public static int Version = 110;
public static string ReleaseDate = "February 4, 2009";
public static string SavePath = "Saves/Staff Runebook";// "ROOT\..."
public static string FileName = "Rune Accounts.xml";
public static List<SR_RuneAccount> Info = new List<SR_RuneAccount>();
public static int Count
{
get
{
return Info.Count;
}
}
// public SR_Main(){}
[CallPriority(100)]
public static void Initialize()
{
if (Info.Count == 0)
SR_Load.ReadData(Path.Combine(SavePath, FileName));
CommandHandlers.Register("StaffRunebook", AccessLevel.Counselor, new CommandEventHandler(SR_OnCommand));
CommandHandlers.Register("SR", AccessLevel.Counselor, new CommandEventHandler(SR_OnCommand));
CommandHandlers.Register("StaffRunebookReset", AccessLevel.Counselor, new CommandEventHandler(SR_Reset_OnCommand));
EventSink.WorldSave += new WorldSaveEventHandler(EventSink_WorldSave);
}
[Usage("StaffRunebook")]
[Aliases("SR")]
public static void SR_OnCommand(CommandEventArgs e)
{
Mobile mob = e.Mobile;
SR_Gump.Send(mob, SR_Utilities.FetchInfo(mob.Account));
}
[Usage("StaffRunebookReset")]
public static void SR_Reset_OnCommand(CommandEventArgs e)
{
Mobile mob = e.Mobile;
SR_Utilities.NewRuneAcc(SR_Utilities.FetchInfo(mob.Account));
mob.SendMessage("Your staff runebook has been reset to default.");
}
public static void AddInfo(SR_RuneAccount runeAccount)
{
for (int i = 0; i < Info.Count; i++)
if (Info[i].Username == runeAccount.Username)
Info.RemoveAt(i);
Info.Add(runeAccount);
}
private static void EventSink_WorldSave(WorldSaveEventArgs e)
{
// Args: bool e.Message
SR_Save.WriteData();
}
}
}

View File

@@ -0,0 +1,60 @@
/**************************************
*Script Name: Staff Runebook *
*Author: Joeku *
*For use with RunUO 2.0 RC2 *
*Client Tested with: 6.0.9.2 *
*Version: 1.10 *
*Initial Release: 11/25/07 *
*Revision Date: 02/04/09 *
**************************************/
using System;
using Server;
using Server.Prompts;
namespace Joeku.SR
{
public class SR_NewRunePrompt : Prompt
{
public SR_RuneAccount RuneAcc;
public bool IsRunebook;
public Point3D TargetLoc;
public Map TargetMap;
public SR_NewRunePrompt(SR_RuneAccount runeAcc)
{
this.RuneAcc = runeAcc;
this.IsRunebook = true;
}
public SR_NewRunePrompt(SR_RuneAccount runeAcc, Point3D targetLoc, Map targetMap)
{
this.RuneAcc = runeAcc;
this.TargetLoc = targetLoc;
this.TargetMap = targetMap;
}
public override void OnResponse(Mobile mob, string text)
{
text = text.Trim();
if (text.Length > 40)
text = text.Substring(0, 40);
if (text.Length > 0)
{
SR_Rune rune = null;
if (this.IsRunebook)
rune = new SR_Rune(text, true);
else
rune = new SR_Rune(text, this.TargetMap, this.TargetLoc);
if (this.RuneAcc.ChildRune == null)
this.RuneAcc.AddRune(rune);
else
this.RuneAcc.ChildRune.AddRune(rune);
}
SR_Gump.Send(mob, this.RuneAcc);
}
}
}

View File

@@ -0,0 +1,42 @@
/**************************************
*Script Name: Staff Runebook *
*Author: Joeku *
*For use with RunUO 2.0 RC2 *
*Client Tested with: 6.0.9.2 *
*Version: 1.10 *
*Initial Release: 11/25/07 *
*Revision Date: 02/04/09 *
**************************************/
using System;
using Server;
using Server.Targeting;
namespace Joeku.SR
{
public class SR_NewRuneTarget : Target
{
public SR_RuneAccount RuneAcc;
public SR_NewRuneTarget(SR_RuneAccount runeAcc)
: base(12, true, TargetFlags.None)
{
this.RuneAcc = runeAcc;
}
protected override void OnTarget(Mobile mob, object targ)
{
Point3D loc = new Point3D(0, 0, 0);
if (targ is LandTarget)
loc = (targ as LandTarget).Location;
else if (targ is StaticTarget)
loc = (targ as StaticTarget).Location;
else if (targ is Mobile)
loc = (targ as Mobile).Location;
else if (targ is Item)
loc = (targ as Item).Location;
mob.SendMessage("Enter a description:");
mob.Prompt = new SR_NewRunePrompt(this.RuneAcc, loc, mob.Map);
}
}
}

View File

@@ -0,0 +1,50 @@
/**************************************
*Script Name: Staff Runebook *
*Author: Joeku *
*For use with RunUO 2.0 RC2 *
*Client Tested with: 6.0.9.2 *
*Version: 1.10 *
*Initial Release: 11/25/07 *
*Revision Date: 02/04/09 *
**************************************/
using System;
using Server;
namespace Joeku.SR
{
// Legacy... binary serialization only used in v1.00, deserialization preserved to migrate data.
public class SR_Persistence : Item
{
public SR_Persistence()
{
}
public SR_Persistence(Serial serial)
: base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
Console.WriteLine();
Console.WriteLine();
Console.WriteLine("Joeku's Staff Runebook: Loading...");
Console.WriteLine(" Migrating data from version 1.00... ");
int count = reader.ReadInt();
for (int i = 0; i < count; i++)
SR_RuneAccount.Deserialize(reader, version);
Console.WriteLine();
this.Delete();
}
}
}

View File

@@ -0,0 +1,157 @@
/**************************************
*Script Name: Staff Runebook *
*Author: Joeku *
*For use with RunUO 2.0 RC2 *
*Client Tested with: 6.0.9.2 *
*Version: 1.10 *
*Initial Release: 11/25/07 *
*Revision Date: 02/04/09 *
**************************************/
using System;
using System.Collections.Generic;
using Server;
namespace Joeku.SR
{
public class SR_Rune
{
public string Name;
public bool IsRunebook = false;
public List<SR_Rune> Runes;
public int RunebookCount, RuneCount;
public int PageIndex = -1;
public SR_Rune ParentRune;
public Map TargetMap = Map.Felucca;
public Point3D TargetLoc = new Point3D(0, 0, 0);
public SR_Rune(string name, Map map, Point3D loc)
: this(name, false)
{
this.TargetMap = map;
this.TargetLoc = loc;
}
public SR_Rune(string name, bool isRunebook)
: this(name, isRunebook, new List<SR_Rune>())
{
}
public SR_Rune(string name, bool isRunebook, List<SR_Rune> runes)
{
this.Name = name;
this.IsRunebook = isRunebook;
this.Runes = runes;
this.FindCounts();
}
public int Count
{
get
{
return this.Runes.Count;
}
}
public int Tier
{
get
{
if (this.ParentRune != null)
return this.ParentRune.Tier + 1;
return 0;
}
}
// Legacy... binary serialization only used in v1.00, deserialization preserved to migrate data.
public static SR_Rune Deserialize(GenericReader reader, int version)
{
SR_Rune rune = null;
string name = reader.ReadString();
bool isRunebook = reader.ReadBool();
Map targetMap = reader.ReadMap();
Point3D targetLoc = reader.ReadPoint3D();
if (isRunebook)
rune = new SR_Rune(name, isRunebook);
else
rune = new SR_Rune(name, targetMap, targetLoc);
int count = reader.ReadInt();
for (int i = 0; i < count; i++)
rune.AddRune(SR_Rune.Deserialize(reader, version));
return rune;
}
public void ResetPageIndex()
{
if (!this.IsRunebook || this.PageIndex == -1)
return;
if (this.Runes[this.PageIndex] != null)
this.Runes[this.PageIndex].ResetPageIndex();
this.PageIndex = -1;
}
public void Clear()
{
this.Runes.Clear();
this.RunebookCount = 0;
this.RuneCount = 0;
this.PageIndex = -1;
}
public void AddRune(SR_Rune rune)
{
for (int i = 0; i < this.Count; i++)
if (this.Runes[i] == rune)
this.Runes.RemoveAt(i);
if (rune.IsRunebook)
{
this.Runes.Insert(this.RunebookCount, rune);
this.RunebookCount++;
}
else
{
this.Runes.Add(rune);
this.RuneCount++;
}
rune.ParentRune = this;
}
public void RemoveRune(int index)
{
this.RemoveRune(index, false);
}
public void RemoveRune(int index, bool pageIndex)
{
if (this.Runes[index].IsRunebook)
this.RunebookCount--;
else
this.RuneCount--;
if (pageIndex && this.PageIndex == index)
this.PageIndex = -1;
this.Runes.RemoveAt(index);
}
public void FindCounts()
{
int runebookCount = 0, runeCount = 0;
for (int i = 0; i < this.Runes.Count; i++)
if (this.Runes[i].IsRunebook)
runebookCount++;
else
runeCount++;
this.RunebookCount = runebookCount;
this.RuneCount = runeCount;
}
}
}

View File

@@ -0,0 +1,139 @@
/**************************************
*Script Name: Staff Runebook *
*Author: Joeku *
*For use with RunUO 2.0 RC2 *
*Client Tested with: 6.0.9.2 *
*Version: 1.10 *
*Initial Release: 11/25/07 *
*Revision Date: 02/04/09 *
**************************************/
using System;
using System.Collections.Generic;
using Server;
namespace Joeku.SR
{
public class SR_RuneAccount
{
public string Username;
public List<SR_Rune> Runes;
public int RunebookCount, RuneCount;
public int PageIndex = -1;
public SR_RuneAccount(string username)
: this(username, new List<SR_Rune>())
{
}
public SR_RuneAccount(string username, List<SR_Rune> runes)
{
this.Username = username;
this.Runes = runes;
this.FindCounts();
SR_Main.AddInfo(this);
}
public int Count
{
get
{
return this.Runes.Count;
}
}
public SR_Rune ChildRune
{
get
{
SR_Rune rune = null;
if (this.PageIndex > -1)
rune = this.Runes[this.PageIndex];
if (rune != null)
{
while (rune.PageIndex > -1)
rune = rune.Runes[rune.PageIndex];
}
return rune;
}
}
// Legacy... binary serialization only used in v1.00, deserialization preserved to migrate data.
public static void Deserialize(GenericReader reader, int version)
{
List<SR_Rune> runes = new List<SR_Rune>();
string username = reader.ReadString();
Console.Write(" Account: {0}... ", username);
int count = reader.ReadInt();
for (int i = 0; i < count; i++)
runes.Add(SR_Rune.Deserialize(reader, version));
new SR_RuneAccount(username, runes);
Console.WriteLine("done.");
}
public void ResetPageIndex()
{
this.Runes[this.PageIndex].ResetPageIndex();
this.PageIndex = -1;
}
public void Clear()
{
this.Runes.Clear();
this.RunebookCount = 0;
this.RuneCount = 0;
this.PageIndex = -1;
}
public void AddRune(SR_Rune rune)
{
for (int i = 0; i < this.Count; i++)
if (this.Runes[i] == rune)
this.Runes.RemoveAt(i);
if (rune.IsRunebook)
{
this.Runes.Insert(this.RunebookCount, rune);
this.RunebookCount++;
}
else
{
this.Runes.Add(rune);
this.RuneCount++;
}
}
public void RemoveRune(int index)
{
this.RemoveRune(index, false);
}
public void RemoveRune(int index, bool pageIndex)
{
if (this.Runes[index].IsRunebook)
this.RunebookCount--;
else
this.RuneCount--;
if (pageIndex && this.PageIndex == index)
this.PageIndex = -1;
this.Runes.RemoveAt(index);
}
public void FindCounts()
{
int runebookCount = 0, runeCount = 0;
for (int i = 0; i < this.Runes.Count; i++)
if (this.Runes[i].IsRunebook)
runebookCount++;
else
runeCount++;
this.RunebookCount = runebookCount;
this.RuneCount = runeCount;
}
}
}

View File

@@ -0,0 +1,73 @@
/**************************************
*Script Name: Staff Runebook *
*Author: Joeku *
*For use with RunUO 2.0 RC2 *
*Client Tested with: 6.0.9.2 *
*Version: 1.10 *
*Initial Release: 11/25/07 *
*Revision Date: 02/04/09 *
**************************************/
using System;
using Server;
using Server.Items;
namespace Joeku.SR
{
public class SR_RuneGate : Moongate
{
public SR_RuneGate(Point3D target, Map map)
: base(target, map)
{
this.Map = map;
if (this.ShowFeluccaWarning && map == Map.Felucca)
this.ItemID = 0xDDA;
this.Dispellable = false;
InternalTimer t = new InternalTimer(this);
t.Start();
}
public SR_RuneGate(Serial serial)
: base(serial)
{
}
public override bool ShowFeluccaWarning
{
get
{
return false/*Core.AOS*/;
}
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
this.Delete();
}
private class InternalTimer : Timer
{
private readonly Item m_Item;
public InternalTimer(Item item)
: base(TimeSpan.FromSeconds(30.0))
{
this.Priority = TimerPriority.OneSecond;
this.m_Item = item;
}
protected override void OnTick()
{
this.m_Item.Delete();
}
}
}
}

View File

@@ -0,0 +1,79 @@
/**************************************
*Script Name: Staff Runebook *
*Author: Joeku *
*For use with RunUO 2.0 RC2 *
*Client Tested with: 6.0.9.2 *
*Version: 1.10 *
*Initial Release: 11/25/07 *
*Revision Date: 02/04/09 *
**************************************/
using System;
using System.IO;
using System.Xml;
namespace Joeku.SR
{
public class SR_Save
{
public static void WriteData()
{
if (!Directory.Exists(SR_Main.SavePath))
Directory.CreateDirectory(SR_Main.SavePath);
string filePath = Path.Combine(SR_Main.SavePath, SR_Main.FileName);
using (StreamWriter op = new StreamWriter(filePath))
{
XmlTextWriter xml = new XmlTextWriter(op);
xml.Formatting = Formatting.Indented;
xml.IndentChar = '\t';
xml.Indentation = 1;
xml.WriteStartDocument(true);
xml.WriteStartElement("StaffRunebook");
xml.WriteAttributeString("Version", SR_Main.Version.ToString());
for (int i = 0; i < SR_Main.Count; i++)
WriteAccountNode(SR_Main.Info[i], xml);
xml.WriteEndElement();
xml.Close();
}
}
public static void WriteAccountNode(SR_RuneAccount a, XmlTextWriter xml)
{
xml.WriteStartElement("RuneAccount");
xml.WriteAttributeString("Username", a.Username);
for (int i = 0; i < a.Count; i++)
WriteRuneNode(a.Runes[i], xml);
xml.WriteEndElement();
}
public static void WriteRuneNode(SR_Rune r, XmlTextWriter xml)
{
xml.WriteStartElement(r.IsRunebook ? "Runebook" : "Rune");
xml.WriteAttributeString("Name", r.Name);
if (!r.IsRunebook)
{
xml.WriteAttributeString("TargetMap", r.TargetMap.ToString());
xml.WriteAttributeString("X", r.TargetLoc.X.ToString());
xml.WriteAttributeString("Y", r.TargetLoc.Y.ToString());
xml.WriteAttributeString("Z", r.TargetLoc.Z.ToString());
}
else
for (int i = 0; i < r.Count; i++)
WriteRuneNode(r.Runes[i], xml);
xml.WriteEndElement();
}
}
}

View File

@@ -0,0 +1,207 @@
/**************************************
*Script Name: Staff Runebook *
*Author: Joeku *
*For use with RunUO 2.0 RC2 *
*Client Tested with: 6.0.9.2 *
*Version: 1.10 *
*Initial Release: 11/25/07 *
*Revision Date: 02/04/09 *
**************************************/
using System;
using Server;
using Server.Accounting;
using Server.Gumps;
namespace Joeku.SR
{
public class SR_Utilities
{
public static bool FindItem(Type type, Point3D p, Map map)
{
return FindEntity(type, p, map, false);
}
public static bool FindMobile(Type type, Point3D p, Map map)
{
return FindEntity(type, p, map, true);
}
public static bool FindEntity(Type type, Point3D p, Map map, bool mob)
{
IPooledEnumerable loc;
Rectangle2D rect = new Rectangle2D(p.X, p.Y, 1, 1);
if (mob)
loc = map.GetMobilesInBounds(rect);
else
loc = map.GetItemsInBounds(rect);
bool found = false;
try
{
foreach (object o in loc)
if (o != null && o.GetType() == type || o.GetType().IsSubclassOf(type))
{
found = true;
break;
}
}
catch
{
}
loc.Free();
return found;
}
public static SR_RuneAccount FetchInfo(IAccount acc)
{
return FetchInfo(acc as Account);
}
public static SR_RuneAccount FetchInfo(Account acc)
{
return FetchInfo(acc.Username);
}
public static SR_RuneAccount FetchInfo(string username)
{
SR_RuneAccount runeAcc = null;
for (int i = 0; i < SR_Main.Count; i++)
if (SR_Main.Info[i].Username == username)
{
runeAcc = SR_Main.Info[i];
break;
}
if (runeAcc == null)
{
runeAcc = new SR_RuneAccount(username);
NewRuneAcc(runeAcc);
}
return runeAcc;
}
public static int RunebookID = 8901;
public static int RuneID = 7956;
public static int ItemOffsetY(SR_Rune rune)
{
if (rune.IsRunebook)
return -1;
return 3;
}
public static int ItemOffsetX(SR_Rune rune)
{
if (rune.IsRunebook)
return -1;
return -2;
}
public static int ItemHue(SR_Rune rune)
{
int hue = 0;
if (rune.IsRunebook)
hue = 1121;
else
hue = RuneHues[MapInt(rune.TargetMap) /*+ (rune.House != null) ? 5 : 0*/];
return hue;
}
private static readonly int[] RuneHues = new int[] { 0, 50, 1102, 1102, 1154, 0x66D, 0x47F, 0x55F, 0x55F, 0x47F };
// To do: check for valid Z (?)
public static bool CheckValid(Point3D loc, Map map)
{
Point2D dim = MapDimensions[MapInt(map)];
if (loc.X < 0 || loc.Y < 0 || loc.X > dim.X || loc.Y > dim.Y)
return false;
return true;
}
private static readonly Point2D[] MapDimensions = new Point2D[]
{
new Point2D(7168, 4096), // Felucca
new Point2D(7168, 4096), // Trammel
new Point2D(2304, 1600), // Ilshenar
new Point2D(2560, 2048), // Malas
new Point2D(1448, 1448), // Tokuno
#region SA
new Point2D(1280, 4096)// TerMur
#endregion
};
public static int MapInt(Map map)
{
int i = 0;
if (map == Map.Felucca)
i = 0;
else if (map == Map.Trammel)
i = 1;
else if (map == Map.Ilshenar)
i = 2;
else if (map == Map.Malas)
i = 3;
else if (map == Map.Tokuno)
i = 4;
#region SA
else if (map == Map.TerMur)
i = 5;
#endregion
return i;
}
public static void NewRuneAcc(SR_RuneAccount acc)
{
acc.Clear();
acc.AddRune(AddTree(GoGump.Felucca, Map.Felucca));
acc.AddRune(AddTree(GoGump.Trammel, Map.Trammel));
acc.AddRune(AddTree(GoGump.Ilshenar, Map.Ilshenar));
acc.AddRune(AddTree(GoGump.Malas, Map.Malas));
acc.AddRune(AddTree(GoGump.Tokuno, Map.Tokuno));
#region SA
acc.AddRune(AddTree(GoGump.TerMur, Map.TerMur));
#endregion
}
private static SR_Rune AddTree(LocationTree tree, Map map)
{
SR_Rune runeBook = new SR_Rune(map.ToString(), true);
for (int i = 0; i < tree.Root.Children.Length; i++)
runeBook.AddRune(AddNode(tree.Root.Children[i], map));
return runeBook;
}
private static SR_Rune AddNode(object o, Map map)
{
if (o is ParentNode)
{
ParentNode parentNode = o as ParentNode;
SR_Rune runeBook = new SR_Rune(parentNode.Name, true);
for (int i = 0; i < parentNode.Children.Length; i++)
runeBook.AddRune(AddNode(parentNode.Children[i], map));
return runeBook;
}
ChildNode childNode = o as ChildNode;
return new SR_Rune(childNode.Name, map, childNode.Location);
}
}
}